From 3e3e2c0d0c4cfd8ce01ca81ce754edc2a79682d0 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 26 Oct 2026 16:46:28 +0900 Subject: [PATCH 01/51] feat(stiffeners): model tapered bend stiffeners on finite-EI lines (#50) feat(stiffeners): model tapered bend stiffeners on finite-EI lines A STIFFENERS table describes a polyurethane bend stiffener over End A or End B of a finite-EI line as conical segments from the root outward (length, outer diameter at each side, bore, modulus, density). The sleeve bends with the cable: every element it covers takes the compliance average of EI_cable + E pi/64 (OD^4 - ID^4) over its length (an element of an EI = 0 section only when the sleeve covers it completely), the sleeve's mean mass, and one diameter, that of the displaced area of cable and solid sleeve, for its buoyancy, added mass and drag, as a line type has. Elements it does not reach keep their line type's values exactly, so decks without stiffeners are unchanged. The overlay sits in the two routines every finite-EI route builds its element properties from, so it applies standalone, on the OpenFAST aggregate, through the C API and in Python. Under a stiffener BendMomN (and the BendMoment columns) report the cable's own moment, the line type's EI times the curvature; the new StfMomN reports the sleeve's share. FairDefl/AnchDefl give the angle between the end force and the direction a held END CONNECTIONS row declares, the stiffener's load case with the end tension. Initialisation notes name a stiffener spanning fewer than 10 elements and one at a pinned end. The Python reader and builder mirror the native table and channel rules. On a hang-off clamped through a 5 m stiffener (16 times the cable's EI at the root), the curvature follows OrcaFlex 11.6d with its stiffener as a line attachment within 0.74 % of the root value, and an independent collocation solution of the planar extensible elastica within 0.74 % (cable moment), 0.18 % (section moment) and 0.003 deg (deflection). Example lazy_wave_bend_stiffener.dat. --- CHANGELOG.md | 20 + CMakeLists.txt | 19 +- VALIDATION.md | 13 + doc/capabilities.rst | 6 + doc/concepts.rst | 4 +- doc/driver_format.md | 81 +++- doc/examples.rst | 6 + doc/migrating.rst | 4 +- doc/modeling.rst | 38 +- doc/outputs.rst | 23 +- doc/references.rst | 6 + doc/theory.rst | 56 +++ examples/README.md | 2 +- examples/lazy_wave_bend_stiffener.dat | 72 ++++ python/cabledyn/builder.py | 93 +++- python/cabledyn/deck_file.py | 133 +++++- python/tests/test_builder.py | 21 + python/tests/test_deck_native_parity.py | 57 +++ src/CableDyn_DeckDriver.f90 | 402 +++++++++++++++++- src/CableDyn_HermiteCableDynamic.f90 | 48 ++- tests/check_bend_stiffener.py | 264 ++++++++++++ .../orcaflex_bend_stiffener_curvature.csv | 163 +++++++ tests/test_bend_stiffener.f90 | 334 +++++++++++++++ validation/scripts/orcaflex_bend_stiffener.py | 101 +++++ 24 files changed, 1909 insertions(+), 57 deletions(-) create mode 100644 examples/lazy_wave_bend_stiffener.dat create mode 100644 tests/check_bend_stiffener.py create mode 100644 tests/data/orcaflex_bend_stiffener_curvature.csv create mode 100644 tests/test_bend_stiffener.f90 create mode 100644 validation/scripts/orcaflex_bend_stiffener.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 37ef50c3..41a39e8e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,26 @@ All notable changes to CableDyn are recorded in this file. The format follows ## [Unreleased] +### Added + +- Bend stiffeners (`STIFFENERS` table): a tapered polyurethane sleeve over an end of a finite-EI + line, given as conical segments from the root outward (outer diameters, bore, modulus, + density). Each element it covers takes the compliance average of the cable-plus-sleeve + bending stiffness and the sleeve's mass, buoyancy and drag; standalone and coupled, with the + Python reader and builder. A hang-off clamped through a 5 m stiffener follows an independent + solution of the planar elastica within 0.2 % of the root moment, and its curvature follows + OrcaFlex 11.6d within 0.8 %. Initialisation notes name a stiffener spanning fewer than 10 + elements and one at a pinned end. Example `lazy_wave_bend_stiffener.dat`. +- Output channels `StfMomN`, the share of the section moment a bend stiffener carries, + and `FairDefl`/`AnchDefl`, the deflection of the end force from the direction a held + END CONNECTIONS row declares (with the end tension, a stiffener's load case). + +### Changed + +- Under a bend stiffener, `BendMomN` (and the `BendMoment` columns of the static profile, + range graphs and element file) report the cable's own moment, the line type's EI times the + curvature; lines without stiffeners are unchanged. + ## [0.3.0] - 2026-10-23 ### Added diff --git a/CMakeLists.txt b/CMakeLists.txt index 27126a4c..6c664032 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1087,6 +1087,14 @@ file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/line_attachments) add_test(NAME line_attachments COMMAND test_line_attachments WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/line_attachments) set_tests_properties(line_attachments PROPERTIES LABELS "fortran;static;dynamic;validation") +# Bend stiffeners (STIFFENERS): element properties against closed forms and a fine integration, +# the deck grammar, and the stiffener's end on a stock-order LINES row. +add_executable(test_bend_stiffener tests/test_bend_stiffener.f90) +target_link_libraries(test_bend_stiffener PRIVATE cabledyn_core) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bend_stiffener) +add_test(NAME bend_stiffener COMMAND test_bend_stiffener WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bend_stiffener) +set_tests_properties(bend_stiffener PROPERTIES LABELS "fortran;driver;static") + # OpenFAST CompMooring=5 aggregate: one deck carrying BOTH EI=0 mooring lines AND finite-EI # Hermite cables composed behind the same FMF moving-point facade. Proves pure-mooring # equivalence to CD_FMF (bit-for-bit), mixed-deck composition + column routing, pure-cable @@ -2293,6 +2301,15 @@ if(Python3_Interpreter_FOUND) set_tests_properties(driver_touchdown_recovery PROPERTIES LABELS "python;driver;integration;static" ENVIRONMENT "${_cabledyn_python_test_environment}") + # A hang-off through a tapered bend stiffener follows the planar elastica (scipy solve_bvp) + # within 2 % of the root moment and 1 cm; skipped where scipy is not installed. + add_test(NAME driver_bend_stiffener + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_bend_stiffener.py + $) + set_tests_properties(driver_bend_stiffener PROPERTIES + LABELS "python;driver;integration;static;validation" + SKIP_RETURN_CODE 77 + ENVIRONMENT "${_cabledyn_python_test_environment}") endif() # A clamped finite-EI cable with a buoyant section on a Rigid6 body: the body static solve # holds the objects at their deck poses, warns once, and reports no balanced clamped end loads. @@ -2772,7 +2789,7 @@ endforeach() # spectra, stream waves, anisotropic friction, modal analysis, clamped ends on bodies, MoorDyn-C # kinematics files, bodies and rods, line failure): every shipped deck must run to completion. foreach(_feature_example IN ITEMS - lazy_wave_vessel_motion lazy_wave_vessel_rao lazy_wave_buoyancy_modules lazy_wave_buoyancy_smeared + lazy_wave_vessel_motion lazy_wave_vessel_rao lazy_wave_bend_stiffener lazy_wave_buoyancy_modules lazy_wave_buoyancy_smeared chain_range_tdp chain_torsethaugen_spread chain_two_train_sea stream_wave_shallow_chain airy_wave_shallow_chain laid_cable_cross_current chain_modes lazy_wave_modes buoy_clamped_cable moordynC_wavekin/chain_wavekin7_currents1 spar_pinned_rods mixed_body_rods_points diff --git a/VALIDATION.md b/VALIDATION.md index 99243cd2..db4eb82b 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -75,6 +75,7 @@ article's methods, are compared in | **L3-6d** | Moving-touchdown dynamic contact | OrcaFlex 11.6d installed | curv 0.48/0.58%, tension 0.74/0.90/0.80%, TDP 0.08 m, migration 2–3 m/cycle | curv <3–5%, tension <2–3%, TDP excursion bounds <1.5 m | Pass | | **L3-6e** | Out-of-plane / 3D whirl response | OrcaFlex 11.6d | 3D curv 0.52%, interior Y env ≤1.0 mm, sag ≤22 mm, tension 0.14/0.17/0.12% | curv <3%, env <5 cm, tension <2–3% | Pass | | **L3-7** | 1-hour VolturnUS-S mooring dynamic | OrcaFlex 11.6d | `FairTen` mean 0.27%, std 0.26%, min/max 0.50/0.43%, Fourier 0.27/1.14% | ≤5% | Pass | +| **L3-8** | Bend stiffener at a clamped hang-off (5 m tapered polyurethane) | OrcaFlex 11.6d (stiffener attachment) / planar elastica | curvature 0.74% of root; cable moment 0.74%, section moment 0.18%, deflection angle 0.003° | <1.5% / <2%, 0.05° | Pass | | **L3-H** | Holcombe static lazy-wave experiment | measured marker geometry | position RMSE 1.07–1.89% of suspended length; peak marker-curvature error 0.34–5.54% | end-restraint bracket | Pass | | **L3-B** | Bergdahl chain experiment, 30 orbit conditions | measured upper-end force | RMSE 1.58 N; MAPE 3.13%; Pearson 0.993; Lin concordance 0.989 | full published matrix | Pass | | **L-fig** | Along-arc curvature overlay (CableDyn / OrcaFlex / MoorDyn-F ±4×) | 3-code committed record | CableDyn peak 0.11% from OrcaFlex | <0.5% | Pass | @@ -261,6 +262,18 @@ initialisation. offset of L2-V in its mean and extremes. The force-blended `EI = 0` step moved the minimum by +7 kN (0.15% before) and the other statistics by at most 0.01%; no step of this drive needs the rotation- and snap-resolved sub-steps, so they leave it unchanged bit for bit. +- **L3-8 bend stiffener at a clamped hang-off** (`driver_bend_stiffener`): a 60 m power + cable (EI 20 kN·m²) clamped horizontal and pulled 30° off by its weight through a 5 m + polyurethane stiffener (0.5 m cylinder of 0.60 m, cone to 0.22 m, bore 0.20 m, E 50 MPa; + 16 times the cable's EI at the root), on 0.05 m elements. The static curvature over the + stiffener and 3 m beyond follows OrcaFlex 11.6d with the stiffener given as a line attachment + within **0.74% of the root curvature** (root 0.4523 against 0.4522 1/m; + [`orcaflex_bend_stiffener.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/orcaflex_bend_stiffener.py)). + Against an independent collocation solution of the planar extensible elastica with + `EI(s)` and the sleeve's weight, the cable's own moment follows within **0.74%** of its root + value, cable and sleeve moments add up to the section moment within **0.18%**, the node + positions within **0.6 mm**, and the end force's deflection from the clamp axis within + **0.003°** (32.37°). - **L-fig curvature overlay**: `l3_lazywave_dynamic` writes each site's along-arc curvature profile. [`validation/scripts/curvature_profile_overlay.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/curvature_profile_overlay.py) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index e6fcac78..2225ca7d 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -102,6 +102,12 @@ Line and constitutive capability - Supported - lumped at nodes of a finite-EI cable, standalone and coupled; rejected on the two-moving-end compatibility solver + * - 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 * - Modal analysis (``nModes``) - Standalone only - natural frequencies and mode shapes of each line about its static equilibrium (all diff --git a/doc/concepts.rst b/doc/concepts.rst index a44f0b43..e6277908 100644 --- a/doc/concepts.rst +++ b/doc/concepts.rst @@ -61,8 +61,8 @@ line type and its own mesh density: 1 buoy 50.0 16 1 bare 55.0 18 <- End B (anchor) side -A bare cable + a buoyancy stretch + a bend stiffener is **three sections of one line**, not -three lines. A single-material chain is **one section**. The unstretched length is the sum of +A bare cable + a buoyancy stretch + more bare cable is **three sections of one line**, not +three lines; a bend stiffener over its end is a ``STIFFENERS`` row on that line. A single-material chain is **one section**. The unstretched length is the sum of the section lengths; the mesh is refined per section. .. admonition:: Porting from MoorDyn diff --git a/doc/driver_format.md b/doc/driver_format.md index 7e336172..14bf2e29 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -133,16 +133,17 @@ except that `SYROPE IC` must come **after** `LINES`, because its rows name lines exist. A conventional layout is: LINE TYPES → BODIES → EXTERNAL LOADS → ROD TYPES → RODS → POINTS → TURBINES → LINES → SYROPE IC → -SECTIONS → END CONNECTIONS / EQUIVALENT BUOYANCY / ATTACHMENTS / FAILURE / CONTROL → OPTIONS → -OUTPUTS +SECTIONS → END CONNECTIONS / EQUIVALENT BUOYANCY / ATTACHMENTS / STIFFENERS / FAILURE / CONTROL → +OPTIONS → OUTPUTS Within LINE TYPES, the header row must precede the data rows because it selects their column order. A **line is one object spanning two end points** (End A = `NodeA`, End B = `NodeB`), built from an ordered list of **sections**, each with its own line type and mesh density (the same -line-and-section arrangement OrcaFlex uses): a bare cable, a bend stiffener, and a buoyancy -stretch are sections of one line. A single-material line is one section. MoorDyn composites written +line-and-section arrangement OrcaFlex uses): a bare cable and a buoyancy stretch are sections of +one line, and a bend stiffener over its end is a [STIFFENERS](#stiffeners-optional-finite-ei-lines) +row. A single-material line is one section. MoorDyn composites written as separate lines joined at a `Connect` point are also valid. @@ -208,6 +209,7 @@ are collapsed. It must match one of the spellings below; any other name fails wi | END CONNECTIONS | `END CONNECTIONS`, `END CONNECTION` | | EQUIVALENT BUOYANCY | `EQUIVALENT BUOYANCY`, `EQUIVALENT SECTIONS`, `BUOYANCY SECTIONS` | | ATTACHMENTS | `ATTACHMENTS`, `LINE ATTACHMENTS`, `CLUMPS` | +| STIFFENERS | `STIFFENERS`, `STIFFENER`, `BEND STIFFENERS`, `BEND STIFFENER` | | FAILURE | `FAILURE`, `FAILURES` | | CONTROL | `CONTROL`, `CONTROLS` | | TURBINES | `TURBINES`, `TURBINE` | @@ -687,8 +689,9 @@ as written. | `Length` | section unstretched length [m]; > 0 and at most 1e6, with `Length/NumSegs` at least 1e-6 | | `NumSegs` | section element count, 1 to 1 000 000. A finite-EI line needs far fewer: its static solve is verified up to 20 480 elements on the 80 m reference cable (elements of about 8 mm) and does not converge at 40 960 (about 4 mm). Keep finite-EI elements longer than about `sqrt(EI/EA)`, and refine only where the curvature needs it | -A single-material line is one `SECTIONS` row; a bare cable with a buoyancy stretch and a bend -stiffener is three sections of one line. +A single-material line is one `SECTIONS` row; a bare cable with a buoyancy stretch is three sections +of one line (bare, buoyant, bare). A bend stiffener over a line end is a +[STIFFENERS](#stiffeners-optional-finite-ei-lines) row, not a section. - A standalone deck with a finite-EI section needs `dtM`/`TMax`, unless it is a mixed `EI = 0` + finite-EI deck, which may be static-only. @@ -760,7 +763,8 @@ Behaviour: with `vesselMotion` or `vesselRAO` it is stored in vessel axes (equal to global axes at the reference pose) and turns with the vessel. - The connection moment equals the bending moment of the line at its end node, so - `BendMomN1` (End A) and `BendMomN` (End B) report it. + `BendMomN1` (End A) and `BendMomN` (End B) report it; under a bend stiffener + it is `BendMom` plus `StfMom` at that node. - On a `Body` point the direction is given in the body frame, like the point offset, and turns with the body. On a rod end it must be parallel to the rod axis (either sense, in the frame of the rod's deck coordinates); another direction is rejected by name. The connection @@ -931,6 +935,65 @@ Behaviour: attachments at theirs; a checkpoint restart is bit-identical. They are rejected on the two-moving-end compatibility route. +### STIFFENERS (optional, finite-EI lines) + +A bend stiffener: a tapered polyurethane sleeve over a line end, usually at a hang-off, that +spreads the bending of the cable over its length. The sleeve is not a separate object; it adds +its bending stiffness, mass, buoyancy and drag to the elements it covers. Each row is one +conical segment, and the rows of one line end follow each other outward from the stiffener +root, each starting where the previous one ends. A cylindrical root, a cone and a tip are three +rows. + +```text +--------------------- STIFFENERS ------------------------------------ +LineID End Length RootOD TipOD InnerD E Density +(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3) +1 A 0.4 0.45 0.45 0.17 5.0e7 1150 +1 A 3.6 0.45 0.18 0.17 5.0e7 1150 +``` + +| Column | Meaning | +|--------|---------| +| `LineID` | existing `LINES` id of a finite-EI line | +| `End` | the end the stiffener sleeves: `A` or `B` (also `EndA`, `EndB`) | +| `Length` | length of the segment along the line [m] | +| `RootOD` | outer diameter at the segment's root side [m] | +| `TipOD` | outer diameter at the segment's tip side [m]; the diameter varies linearly in between | +| `InnerD` | inner (bore) diameter [m], smaller than both outer diameters | +| `E` | Young's modulus of the sleeve material [Pa] | +| `Density` | density of the sleeve material [kg/m³] | + +Behaviour: + +- Over the stiffener the section bends as cable and sleeve together: + `EI(s) = EI_cable + E π/64 (OD(s)⁴ − InnerD⁴)`. The sleeve carries no axial load and no + torque, so `EA` and `GJ` are the cable's. Each element takes the compliance average of + `EI(s)` over its length, `L / ∫ ds/EI(s)`, the cable mass plus the mean sleeve mass, a + diameter of the displaced area of cable plus solid sleeve, `√(d² + OD² − InnerD²)`, for its + buoyancy, added mass and drag alike, as a line type has one diameter (the sleeve's outer + diameter when `InnerD` is the cable diameter; see [theory](theory.rst), *Bend stiffeners*). Elements the stiffener does not reach keep + their line type's values exactly. +- The element properties are piecewise constant, one value per deck element, so the deck mesh + must resolve the taper: an initialisation note names a stiffener that spans fewer than 10 + elements and the element length that resolves it. Split the section at the stiffener tip and + mesh the part under it finely (about 0.1–0.2 m elements for a typical 3–8 m stiffener). +- The stiffener root takes the moment only where the end is held in rotation: declare the end + `Rigid`, or a rotational spring, in [END CONNECTIONS](#end-connections-optional-finite-ei-lines). + A stiffener at a pinned end prints a note. +- Outputs: `CurvN` is the curvature cable and sleeve share; `BendMomN` the cable's + own moment (the line type's `EI` × curvature, the value to check against the cable's limits); + `StfMomN` the sleeve's share, so that the two add up to the section moment the root + connection carries. `FairDefl`/`AnchDefl` give the angle between the end force and the + held direction, which with `FairTen`/`AnchTen` is the stiffener's load case. Keep the fine + mesh a couple of metres past the stiffener tip, where the cable's curvature can peak. +- The material is linear elastic. A row fails if the line is not finite-EI, a value is + non-finite, above 1e15 or out of range (`Length`, `RootOD`, `TipOD` and `E` must be positive, + `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. + ### FAILURE (optional, EI = 0 decks) A FAILURE row detaches line ends from a point during a dynamic run, with MoorDyn's trigger rules. @@ -1295,13 +1358,15 @@ bending moment. None of these channels is mandatory. | `FairDecl` | line L fairlead (End A) declination from +GZ (0 = up, 90 = horizontal, 180 = down) | deg | | `AnchDecl` | line L anchor (End B) declination from +GZ (0 = up, 90 = horizontal, 180 = down) | deg | | `FairAngle` / `AnchAngle` | aliases of `FairDecl` / `AnchDecl` | deg | +| `FairDefl` / `AnchDefl` | line L deflection of the End-A / End-B end force from the direction a `Rigid` or rotational-spring END CONNECTIONS row holds there (0 when the line leaves along it); only at such an end | deg | | `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 | | `TenN` | line L effective tension at node J. EI = 0 lines: the mean of the two adjacent segment tensions. Finite-EI lines: the axial component of the section force recovered from nodal equilibrium (`OutputRecovery element`: the length-weighted mean of the adjacent element-mean axial forces). End nodes report the line-end force of `FairTen`/`AnchTen` | N | | `CurvN` | line L curvature at node J. `EI = 0` lines: geometric curvature of the circle through the node and its two neighbours (end nodes take the adjacent interior value). Cubic-Hermite lines: `BendMomN` / EI, the larger of the two sides at a section junction (`OutputRecovery element`: exact curvature of the continuous centreline, the larger one-sided element value at an interior node) | 1/m | -| `BendMomN` | line L bend moment = EI × curvature **relative to the stress-free reference shape** (≈ 0 at the reference; the finite-EI reference is straight). Finite-EI lines: recovered from nodal equilibrium, the moment the neighbouring elements carry (`OutputRecovery element`: EI × the larger one-sided exact curvature); 0 on EI = 0 lines | N·m | +| `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 | +| `StfMomN` | line L share of the section moment a bend stiffener carries at node J (the section moment less `BendMomN`; 0 outside the stiffener); only on a line with STIFFENERS | N·m | | `LNp{x,y,z}` | line L node J position component | m | | `LNv{x,y,z}` | line L node J velocity component (0 in static-only runs) | m/s | | `LNa{x,y,z}` | line L node J acceleration component (0 in static-only runs) | m/s² | diff --git a/doc/examples.rst b/doc/examples.rst index b3a6f5d4..342e0d79 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -335,6 +335,12 @@ touchdown and lazy-wave shape from the geometry alone; there is no initial-shape cable — :doc:`tutorial_motion` - Hermite, dynamic - ~9 s + * - ``lazy_wave_bend_stiffener.dat`` + - the RAO-driven cable with a 4 m polyurethane bend stiffener (a cylindrical root and a cone, + ``STIFFENERS``) at its clamped hang-off; ``BendMom1N1`` is the stiffener root moment and the + curvature channels sample the stiffener and the cable past its tip — :doc:`modeling` + - Hermite, dynamic + - ~9 s * - ``lazy_wave_buoyancy_modules.dat`` - the 80 m cable in a 0.5 m/s current with its buoyant stretch built from ten discrete buoyancy modules (``ATTACHMENTS`` series ``first:pitch:last``) — :doc:`tutorial_lazywave` diff --git a/doc/migrating.rst b/doc/migrating.rst index 04748725..de3e5fc7 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -62,8 +62,8 @@ When to use SECTIONS instead ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 7-column row can describe only a single-type line. A composite (chain–polyester–chain, or a -power cable with bare, buoyancy, and bend-stiffener zones) is, in MoorDyn, several lines joined at -``Connect`` points; in CableDyn it is **one line with several ordered sections**: +power cable with bare and buoyancy zones) is, in MoorDyn, several lines joined at ``Connect`` +points; in CableDyn it is **one line with several ordered sections**: .. code-block:: text diff --git a/doc/modeling.rst b/doc/modeling.rst index 25eb2eb9..46d7e51a 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -78,6 +78,37 @@ viscoelastic model is a four-parameter series-Kelvin solid that reduces to a sta solid only when ``BA_D = 0``). Preserve the units shown in the ``LINE TYPES`` table; the parser does not infer or convert vendor units. +.. _modeling-bend-stiffeners: + +**Bend stiffeners.** Give a bend stiffener as a ``STIFFENERS`` table on the cable, not as a +section of its own: one row per conical segment from the root outward (outer diameter at each +side, bore, modulus and density of the polyurethane), at End A or End B. The driver adds the +sleeve's bending stiffness, mass, buoyancy and drag to the elements it covers +(:ref:`theory-bend-stiffeners`). Three choices decide the result: + +- **the root connection.** The stiffener root is clamped to the hang-off or I-tube: declare that + end ``Rigid`` (or a rotational spring for a compliant connection) in ``END CONNECTIONS``, along + the hang-off direction. A pinned end carries no moment, so the stiffener then takes none; +- **the mesh under the stiffener.** One stiffness per element: split the section at the + stiffener tip and mesh the part under it with elements of about 0.1–0.2 m, at least ten over + the stiffener (the driver notes fewer); +- **the material.** The sleeve is linear elastic. Polyurethane stiffness depends on temperature + and strain rate; use the modulus for the design temperature and check the result at the + ends of its range. + +The design checks are the curvature of the cable against its minimum bend radius along the +stiffener and just past its tip (``CurvN`` channels and the range graphs; keep the fine +mesh a couple of metres beyond the tip), the cable's own moment (``BendMomN``), and the +stiffener's load case, the end force with its deflection from the hang-off direction +(``FairTen`` with ``FairDefl``). ``StfMomN`` is the sleeve's share of the moment; +at the root, ``BendMomN1`` plus ``StfMomN1`` is the moment the hang-off takes. + +A sleeve that can slide or rattle on the cable, a steel root section and friction between +sleeve and cable are not modelled: the sleeve is bonded to the cable in bending. + +``lazy_wave_bend_stiffener.dat`` shows a 4 m stiffener at a clamped hang-off on a vessel in +waves. + 5. Choose and converge the mesh ------------------------------- @@ -125,9 +156,10 @@ two- or four-fold local refinement. When end curvature matters: - report the curvature 1–2 m from a pinned end, never the value at the pinned node: a pinned end carries no moment, so the exact curvature there is zero, and the computed nodal value is a discretisation residue (at ``dtM = 0.05 s`` up to 37 times the converged value 1 m away); -- for bend-stiffener or hang-off design, model the stiffener as a section and the end as a - clamped or rotational-spring ``END CONNECTIONS`` row (see :doc:`driver_format`); a pinned end - does not represent the moment a stiffener carries. +- for bend-stiffener or hang-off design, give the stiffener as a ``STIFFENERS`` table (see + :ref:`bend stiffeners `) and the end as a clamped or rotational-spring + ``END CONNECTIONS`` row (see :doc:`driver_format`); a pinned end does not represent the moment + a stiffener carries. **Snap loads on slack lines.** When a slack line snaps taut it excites axial waves up to the segment scale, near :math:`2c/l` with :math:`c = \sqrt{EA/m}` and :math:`l` the segment length. diff --git a/doc/outputs.rst b/doc/outputs.rst index fc24a612..cfe4e6f2 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -223,8 +223,8 @@ finite-EI line of the run: - nodal curvature (same definition as ``CurvN``) * - ``BendMoment`` - ``(N.m)`` - - bend moment (same definition as ``BendMomN``); written as 0 by the ``EI = 0`` - static route + - bend moment (same definition as ``BendMomN``: the cable's own share under a bend + stiffener); written as 0 by the ``EI = 0`` static route * - ``Declination`` - ``(deg)`` - axial-tangent angle from +Z (0 = up, 90 = horizontal, 180 = down) @@ -301,7 +301,8 @@ B)``, header row, units row, data (12 columns): - maximum curvature over the element * - ``BendMomentAtPeak`` - ``(N.m)`` - - ``EI × PeakCurvature`` + - ``EI × PeakCurvature``, with the line type's ``EI`` (the cable's share under a bend + stiffener) * - ``MinimumAxialResultant`` - ``(N)`` - minimum axial force resultant over the element (negative = compression) @@ -558,6 +559,13 @@ Line-end channels * - ``FairAngle`` / ``AnchAngle`` - aliases of ``FairDecl`` / ``AnchDecl`` - deg + * - ``FairDefl`` / ``AnchDefl`` + - deflection of the End-A / End-B end force (``FairTen`` / ``AnchTen``) from the direction + a ``Rigid`` or rotational-spring ``END CONNECTIONS`` row holds at that end, turning with + the body or vessel it is on: 0 when the line leaves the connection along that direction. + With the end force, the load case of a bend stiffener or hang-off design. Only at an end + with such a row + - deg A grounded anchor segment reads ``AnchIncl ≈ 0``; the small non-zero value reports the actual orientation of the last element, which CableDyn does not force to horizontal. @@ -648,7 +656,14 @@ Line-node channels of the moment recovered from nodal equilibrium, the mean of the two neighbouring elements (one-sided at a line end, where it is the end connection moment); ``OutputRecovery element``: ``EI`` times the larger one-sided exact curvature. 0 on - ``EI = 0`` lines + ``EI = 0`` lines. Under a bend stiffener (``STIFFENERS``) it is the cable's own share, + the line type's ``EI`` times the curvature; the stiffener's share is ``StfMomN`` + and the two add up to the section moment + - N·m + * - ``StfMomN`` + - the share of the section moment a bend stiffener carries at node ``J``, the section + moment less ``BendMomN``; 0 where no stiffener covers the node. Only on a line with + ``STIFFENERS`` - N·m * - ``LNpx`` / ``py`` / ``pz`` - node position component diff --git a/doc/references.rst b/doc/references.rst index 0fc43e6a..371c264b 100644 --- a/doc/references.rst +++ b/doc/references.rst @@ -28,6 +28,12 @@ Element formulation element formulation for geometrically exact curved Kirchhoff rods. *Computer Methods in Applied Mechanics and Engineering* **278**, 445–478. https://doi.org/10.1016/j.cma.2014.05.017 +.. _ref-boef1990: + +- **Boef, W. J. C. & Out, J. M. M. (1990).** Analysis of a flexible-riser top connection with + bend restrictor. *Offshore Technology Conference*, Houston, OTC-6436-MS. + https://doi.org/10.4043/6436-MS + .. _ref-bergou2008: - **Bergou, M., Wardetzky, M., Robinson, S., Audoly, B. & Grinspun, E. (2008).** Discrete diff --git a/doc/theory.rst b/doc/theory.rst index 312d462c..046aea2e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -140,6 +140,62 @@ The element follows the geometrically exact Kirchhoff-rod formulation of interpolation of :ref:`Meier, Popp & Wall (2015) `, reduced to a torsion-free cable. Torsion enters only through the condensed line term below. +.. _theory-bend-stiffeners: + +Bend stiffeners +~~~~~~~~~~~~~~~ + +A bend stiffener (``STIFFENERS``) is a sleeve of outer diameter :math:`D(s)`, bore :math:`d_i`, +modulus :math:`E_s` and density :math:`\rho_s` over a line end, made of conical segments in +which :math:`D` varies linearly with the arc length. Cable and sleeve bend together, as in the +stiffener design model of :ref:`Boef & Out (1990) `, so over the stiffener + +.. math:: + + EI(s) = EI_c + E_s \frac{\pi}{64}\left(D(s)^4 - d_i^4\right), + +with :math:`EI_c` the cable's bending stiffness. The sleeve carries no axial load and no torque +(:math:`EA` and :math:`GJ` are the cable's), and its material is linear elastic. The element +energy above takes one :math:`EI` per element, so an element over the arc :math:`[a, b]` of +length :math:`L` takes the compliance average + +.. math:: + + EI_e = L \left( \int_a^b \frac{\mathrm{d}s}{EI(s)} \right)^{-1}, + +which gives the exact relative end rotation of the element under a uniform moment: the stiff +root of a tapered sleeve is not allowed to stiffen a whole element that only partly lies on it. +On an ``EI = 0`` section of the line the bare part of an element has an infinite compliance, +so only an element the sleeve covers completely gains bending stiffness. +The element mass per length is the cable's plus :math:`\rho_s \tfrac{\pi}{4}\, +\overline{D^2 - d_i^2}`, where the bar is the mean over the element. Like a line type, the +element has one diameter, that of the displaced area of cable and solid sleeve, +:math:`\sqrt{d^2 + \overline{D^2 - d_i^2}}` with :math:`d` the cable diameter, for its +buoyancy (the dry part above the surface included), added mass, Froude–Krylov force and drag; +with the bore equal to the cable diameter it is the sleeve's outer diameter. The integrals use six-point Gauss–Legendre quadrature on each +part of the element a segment covers. With these one-per-element values the taper is resolved +by the mesh, as in a segmented line model; the driver notes a stiffener that spans fewer than +ten elements. + +The recovered section moment :math:`M` (:ref:`theory-output-recovery`) is shared in proportion +to the stiffnesses, since cable and sleeve take the same curvature :math:`\kappa = M/EI_e`: the +cable carries :math:`EI_c\,\kappa`, reported as ``BendMom``, and the sleeve +:math:`(EI_e - EI_c)\,\kappa`, reported as ``StfMom``. At a node between a covered and a bare +element the side of the larger curvature, the bare one, gives the values. The deflection angle +``FairDefl``/``AnchDefl`` is :math:`\arccos(\hat{\mathbf F}\cdot\hat{\mathbf d})` between the +end force :math:`\mathbf F` and the direction :math:`\mathbf d` the end connection holds (into +the line), the angle through which the stiffener turns the cable. + +The planar check ``driver_bend_stiffener`` compares a hang-off clamped through a 5 m stiffener +(a cylindrical root and a cone, 16 times the cable's stiffness at the root) with an independent +collocation solution of the extensible elastica +:math:`\theta' = M/EI(s)`, :math:`M' = -(1 + \varepsilon)(\cos\theta\,n_z - \sin\theta\,n_x)`, +:math:`\mathbf n' = (0, w(s))`: on 0.05 m elements the cable's moment over the stiffener and +3 m beyond follows the elastica within 0.8 % of its root value, cable and sleeve moments add up +to the section moment within 0.2 % at the root, the deflection angle agrees within 0.003°, and +the node positions within 1 mm. On the same hang-off, the curvature along the stiffener follows +OrcaFlex 11.6d with its stiffener given as a line attachment within 0.8 % of the root curvature. + .. _theory-output-recovery: Node tension, curvature and bend moment diff --git a/examples/README.md b/examples/README.md index cacac9a7..416de1b3 100644 --- a/examples/README.md +++ b/examples/README.md @@ -45,7 +45,7 @@ Copy a deck under a new name and keep every file it references at the same relat | `openfast/` | IEA-15MW VolturnUS-S `.fst` pair (`CompMooring = 5` and `3`) with their mooring decks; see [openfast/README.md](openfast/README.md). | | `data/syrope/` | Syrope settings and original working-curve table used by `syrope_polyester_mooring.dat`. | | `data/lozon/` | Prescribed hang-off heave history for `lozon_gomex80_power_cable_motion.dat` and the script that generates it. | -| `data/vessel/` | 6-DOF vessel-motion record for `lazy_wave_vessel_motion.dat`, the script that generates it, and the illustrative RAO table for `lazy_wave_vessel_rao.dat`. | +| `data/vessel/` | 6-DOF vessel-motion record for `lazy_wave_vessel_motion.dat`, the script that generates it, and the illustrative RAO table for `lazy_wave_vessel_rao.dat` and `lazy_wave_bend_stiffener.dat`. | | `data/torsion/` | Hang-off roll history (motionFile roll column) for `torsion_lazy_wave_hangoff_twist.dat` and the script that generates it. | | `data/range_tdp/` | Fairlead surge history for `chain_range_tdp.dat` and the script that generates it. | | `moordynC_wavekin/` | A deck with the MoorDyn-C `wave_frequencies.txt` and `current_profile.txt` files it reads from its own folder. | diff --git a/examples/lazy_wave_bend_stiffener.dat b/examples/lazy_wave_bend_stiffener.dat new file mode 100644 index 00000000..86e9c999 --- /dev/null +++ b/examples/lazy_wave_bend_stiffener.dat @@ -0,0 +1,72 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable through a bend stiffener at a clamped hang-off on a vessel in a JONSWAP sea +-- The cable, vessel motion and sea of lazy_wave_vessel_rao.dat, with a 4 m polyurethane bend +-- stiffener at the hang-off: a 0.4 m cylindrical root of 0.45 m outer diameter and a 3.6 m cone +-- to 0.18 m, bored to 0.17 m (E = 50 MPa, 1150 kg/m^3). At the root the sleeve is about five +-- times as stiff in bending as the cable (EI 9.9e4 against 1.99e4 N m^2). The root is clamped +-- (Rigid) along the static hang-off tangent; BendMom1N1 is the root moment, the curvature +-- channels sample the stiffener (nodes 14 and 27, 2 m and 4 m from the root) and the bare cable +-- just past its tip (node 34). The 0.152 m elements give 27 elements over the stiffener. +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (N-m2) (-) (-) (-) (-) +bare 0.160 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0 +buoy 0.290 59.53 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------ +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 5.0 0.0 -14.0 +2 Fixed 125.0 0.0 -80.0 +--------------------- LINES ------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 r +--------------------- SECTIONS ---------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 bare 68.114 448 +1 buoy 50.000 320 +1 bare 52.101 256 +--------------------- STIFFENERS -------------------------------------------- +-- Rows run outward from the root at End A: the cylindrical root, then the cone. +LineID End Length RootOD TipOD InnerD E Density +(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3) +1 A 0.4 0.45 0.45 0.17 5.0e7 1150 +1 A 3.6 0.45 0.18 0.17 5.0e7 1150 +--------------------- END CONNECTIONS --------------------------------------- +-- End A is clamped along the static hang-off tangent (81.6 deg below horizontal, toward End B). +LineID End Stiffness EzX EzY EzZ +(-) (-) (N-m/rad) (-) (-) (-) +1 A Rigid 0.1461 0.0 -0.9893 +--------------------- OPTIONS ----------------------------------------------- +9.80665 g - Gravitational acceleration (m/s^2) [default: 9.80665] +1025.0 rhoW - Water density (kg/m^3) [default: 1025] +80.0 WtrDpth - Water depth for the flat seabed (m) [default: absent standalone; host-owned OpenFAST] +1.0e5 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] +1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] +0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] +False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] +40.0 TMax - Standalone simulation duration (s), including the 10 s wave ramp +data/vessel/sample_rao.txt vesselRAO - Displacement RAO table: vessel motion from the deck waves +0.0|0.0|0.0 vesselRef - Vessel reference point, rotation centre and RAO origin (m) [default: 0|0|0] +10.0 RangeStart - First output time in the range graphs (s) [default: 0] +False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] +True tensile_safety - Refine and reject local axial compression in this tensile cable +dynamic_solver 1.0e-4 1.0e-14 100 12 - Relative tolerance, absolute tolerance, max iterations, backtracks +none frictionMu - Seabed friction coefficient {none; value>=0} [default: none] +none current - Current model and velocity (m/s) {none; uniform; profile} [default: none] +jonswap 4.0 10.0 3.3 0.0 waves - Wave model, JONSWAP Hs, Tp, gamma, and direction (m, s, deg) {none; airy; jonswap} +1 WaveSeed - Seed of the random sea [default: 1] +10.0 rampTime - Half-cosine start-up ramp of the wave amplitudes (s) [default: 0] +0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy] +-- Complete option/default reference: cabledyn_options_reference.dat and doc/options.rst. +--------------------- OUTPUTS ----------------------------------------------- +"FairTen1" +"AnchTen1" +"BendMom1N1" +"Curv1N14" +"Curv1N27" +"Curv1N34" +"TDP1s" +--------------------- need this line ---------------------------------------- diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index d7a7463f..8bf7c1a6 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -84,6 +84,7 @@ "RodEnd", "RodType", "Section", + "Stiffener", "SyropeEA", "SyropeIC", "Turbine", @@ -104,13 +105,14 @@ ( "line", re.compile( - r"(fairten|anchten|anchfz|anchfh|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl)" + r"(fairten|anchten|anchfz|anchfh|fairangle|anchangle|fairdecl|anchdecl|fairincl|anchincl" + r"|fairdefl|anchdefl)" r"([0-9]+)()", re.IGNORECASE, ), ), ("line", re.compile(r"(tdp)([0-9]+)(s|x|y|z|lay|exc|grd)", re.IGNORECASE)), - ("line", re.compile(r"(ten|curv|bendmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE)), + ("line", re.compile(r"(ten|curv|bendmom|stfmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE)), ("line", re.compile(r"(twist)([0-9]+)(n[0-9]+|)", re.IGNORECASE)), ("line", re.compile(r"(l)([0-9]+)(n[0-9]+(?:[pva][xyz]|dec|azi))", re.IGNORECASE)), ("point", re.compile(r"(point|con)([0-9]+)(p[xyz])", re.IGNORECASE)), @@ -615,6 +617,43 @@ class Attachment: cdax: float | None = None +@dataclass(eq=False) +class Stiffener: + """One ``STIFFENERS`` row: a conical segment of a bend stiffener on a finite-EI line. + + The rows of one line end follow each other outward from the stiffener root, each starting + where the previous one ends; a cylindrical root, a cone and a tip are three rows. + + Attributes + ---------- + line : Line + The finite-EI line. + end : str + The end the stiffener sleeves, ``A`` or ``B``. + length : float + Length of the segment, in m. + root_od : float + Outer diameter at the segment's root side, in m. + tip_od : float + Outer diameter at the segment's tip side, in m. + inner_d : float + Inner diameter, in m. + modulus : float + Young's modulus of the stiffener material, in Pa. + density : float + Density of the stiffener material, in kg/m^3. + """ + + line: Line + end: str + length: float + root_od: float + tip_od: float + inner_d: float + modulus: float + density: float + + @dataclass(eq=False) class SyropeIC: """One ``SYROPE IC`` row: the prior load history of Syrope lines. @@ -1257,6 +1296,7 @@ def __init__( self._end_connections: list[EndConnection] = [] self._equivalent_buoyancy: list[EquivalentBuoyancy] = [] self._attachments: list[Attachment] = [] + self._stiffeners: list[Stiffener] = [] self._syrope_ic: list[SyropeIC] = [] self._failures: list[Failure] = [] self._controls: list[Control] = [] @@ -1426,6 +1466,11 @@ def attachments(self) -> tuple[Attachment, ...]: """``ATTACHMENTS`` rows.""" return tuple(self._attachments) + @property + def stiffeners(self) -> tuple[Stiffener, ...]: + """``STIFFENERS`` rows.""" + return tuple(self._stiffeners) + @property def syrope_ic(self) -> tuple[SyropeIC, ...]: """``SYROPE IC`` rows.""" @@ -2005,6 +2050,28 @@ def add_attachment( self._attachments.append(item) return item + def add_stiffener( + self, + line: Line | int, + end: str, + length: float, + root_od: float, + tip_od: float, + inner_d: float, + modulus: float, + density: float, + ) -> Stiffener: + """Add a ``STIFFENERS`` row (one conical segment); see :class:`Stiffener`. + + Returns + ------- + Stiffener + The new row. + """ + item = Stiffener(self._line(line), end, length, root_od, tip_od, inner_d, modulus, density) + self._stiffeners.append(item) + return item + def add_syrope_ic( self, lines: Line | int | Iterable[Line | int], tmax0: float, tmean0: float ) -> SyropeIC: @@ -2151,6 +2218,7 @@ def _registry(self, obj: object) -> list[Any] | None: (EndConnection, self._end_connections), (EquivalentBuoyancy, self._equivalent_buoyancy), (Attachment, self._attachments), + (Stiffener, self._stiffeners), (SyropeIC, self._syrope_ic), (Failure, self._failures), (Control, self._controls), @@ -2234,6 +2302,7 @@ def references(self, obj: object) -> tuple[object, ...]: elif isinstance(obj, Line): found.extend(row for row in self._end_connections if row.line is obj) found.extend(row for row in self._attachments if row.line is obj) + found.extend(row for row in self._stiffeners if row.line is obj) for rows in (self._syrope_ic, self._failures, self._controls): found.extend(row for row in rows if any(line is obj for line in row.lines)) found.extend(self._line_options(obj.id)) @@ -2397,7 +2466,11 @@ def _check_references(self) -> None: self._member(point.body, self._bodies, "body") if point.rod_end is not None: self._member(point.rod_end.rod, self._rods, "rod") - owners: list[EndConnection | Attachment] = [*self._end_connections, *self._attachments] + owners: list[EndConnection | Attachment | Stiffener] = [ + *self._end_connections, + *self._attachments, + *self._stiffeners, + ] for owned in owners: self._member(owned.line, self._lines, "line") for eq in self._equivalent_buoyancy: @@ -2453,6 +2526,7 @@ def to_text(self, *, validate: bool = True) -> str: _emit(out, "END CONNECTIONS", *self._end_connection_table()) _emit(out, "EQUIVALENT BUOYANCY", *self._equivalent_table()) _emit(out, "ATTACHMENTS", *self._attachment_table()) + _emit(out, "STIFFENERS", *self._stiffener_table()) _emit(out, "FAILURE", *self._failure_table()) _emit(out, "CONTROL", *self._control_table()) _emit(out, "EXTERNAL LOADS", *self._external_load_table()) @@ -2785,6 +2859,16 @@ def _attachment_table(self) -> tuple[str, str, list[list[str]]]: header = "LineID ArcLength Mass Volume CdA Ca CdAx" return header, "(-) (m) (kg) (m^3) (m^2) (-) (m^2)", rows + def _stiffener_table(self) -> tuple[str, str, list[list[str]]]: + rows: list[list[str]] = [] + for row in self._stiffeners: + what = f"line {row.line.id} stiffener" + values = (row.length, row.root_od, row.tip_od, row.inner_d, row.modulus, row.density) + cells = [_int(row.line.id, what), _end_letter(row.end)] + rows.append([*cells, *(_num(value, what) for value in values)]) + header = "LineID End Length RootOD TipOD InnerD E Density" + return header, "(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3)", rows + def _syrope_table(self) -> tuple[str, str, list[list[str]]]: rows = [ [_line_list(row.lines), _num(row.tmax0, "SYROPE IC"), _num(row.tmean0, "SYROPE IC")] @@ -2980,6 +3064,9 @@ def load(self) -> None: for row in self.rows("EQUIVALENT BUOYANCY"): t = row.tokens model.add_equivalent_buoyancy(t[0], _f(t[1]), _f(t[2])) + for row in self.rows("STIFFENERS"): + t = row.tokens + model.add_stiffener(_native_int(t[0]), t[1][-1], *(_f(token) for token in t[2:8])) for row in self.rows("ATTACHMENTS"): t = row.tokens arc: float | tuple[float, float, float] diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 3ff8dd6f..9f7f1ea7 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -70,6 +70,10 @@ "ATTACHMENTS": "ATTACHMENTS", "LINE ATTACHMENTS": "ATTACHMENTS", "CLUMPS": "ATTACHMENTS", + "STIFFENERS": "STIFFENERS", + "STIFFENER": "STIFFENERS", + "BEND STIFFENERS": "STIFFENERS", + "BEND STIFFENER": "STIFFENERS", } # Table sections whose rows the native reader takes through a Fortran # list-directed READ. Their descriptive and units rows are recognized by the @@ -91,7 +95,9 @@ ) # Table sections the native reader splits on whitespace and parses column by # column (their comma-separated line lists are valid there). -_WHITESPACE_TABLE_SECTIONS = frozenset({"FAILURE", "CONTROL", "SYROPE IC", "ATTACHMENTS"}) +_WHITESPACE_TABLE_SECTIONS = frozenset( + {"FAILURE", "CONTROL", "SYROPE IC", "ATTACHMENTS", "STIFFENERS"} +) _TABLE_SECTIONS = _LIST_DIRECTED_SECTIONS | _WHITESPACE_TABLE_SECTIONS _NATIVE_RECORD_LENGTH = 512 _INT32_MAX = 2**31 - 1 @@ -691,7 +697,14 @@ def _parse_line_node_channel(lowered: str) -> tuple[int, int, int, int]: # Twist: the line's total twist (node 1) line_id = _native_positive_int(lowered, 6, last) return (line_id, 1, 11, 0) if line_id > 0 else (line_id, 0, 0, 0) - for keyword, code in (("torq", 9), ("twist", 10), ("ten", 3), ("curv", 5), ("bendmom", 6)): + for keyword, code in ( + ("torq", 9), + ("twist", 10), + ("ten", 3), + ("curv", 5), + ("bendmom", 6), + ("stfmom", 12), + ): if lowered.startswith(keyword): prefix = len(keyword) separator = lowered.find("n", prefix) @@ -745,6 +758,9 @@ def _channel_identity_key(channel: str) -> str: if lowered.startswith(("fairincl", "anchincl")): return f"{lowered[:8]}:{line_id}" return f"{lowered[:4]}decl:{line_id}" + if lowered.startswith(("fairdefl", "anchdefl")): + line_id = _native_id_suffix(lowered[8:]) + return f"{lowered[:8]}:{line_id}" if line_id > 0 else lowered if lowered.startswith("point") or ( lowered.startswith("con") and lowered[3:4].isascii() and lowered[3:4].isdigit() ): @@ -761,7 +777,7 @@ def _channel_identity_key(channel: str) -> str: if touchdown is not None and int(touchdown.group(1)) > 0: component = ("s", "x", "y", "z", "lay", "exc", "grd").index(touchdown.group(2)) + 1 return f"tdp:{int(touchdown.group(1))}:{component}" - if lowered.startswith(("ten", "curv", "bendmom", "l", "torq", "twist")): + if lowered.startswith(("ten", "curv", "bendmom", "stfmom", "l", "torq", "twist")): line_id, node_id, kind, component = _parse_line_node_channel(lowered) if line_id > 0 and node_id > 0 and kind > 0: return f"node:{line_id}:{node_id}:{kind}:{component}" @@ -2034,6 +2050,83 @@ def _check_attachments( f"(unstretched length {line_lengths[line_id]:.10g} m)" ) + def _check_stiffeners( + self, + line_ids: set[str], + section_types_by_line: dict[str, list[str]], + line_type_meta: dict[str, tuple[float, float, float, float]], + line_lengths: dict[str, float], + ) -> None: + """Native ``append_line_stiffener`` and its finalize checks for STIFFENERS rows. + + A row ``LineID End Length RootOD TipOD InnerD E Density`` is one conical segment of the + bend stiffener sleeving End A or End B; the rows of one line end follow each other + outward from the root. The stiffeners of both ends together must fit on the line. + """ + extent: dict[tuple[str, str], float] = {} + for row in self._rows("STIFFENERS"): + where = self._at(row) + if len(row.tokens) != 8: + raise DeckFormatError( + f"{where}: STIFFENERS rows must be: " + "LineID End Length RootOD TipOD InnerD E Density" + ) + try: + line_id = str(_native_int(row.tokens[0])) + except ValueError as exc: + raise DeckFormatError(f"{where}: STIFFENERS LineID must be an integer") from exc + if line_id not in line_ids: + raise DeckFormatError( + f"{where}: STIFFENERS row references undefined LINE id {line_id}" + ) + end = {"a": "a", "enda": "a", "b": "b", "endb": "b"}.get(row.tokens[1].lower()) + if end is None: + raise DeckFormatError(f"{where}: STIFFENERS End must be A or B") + try: + length, root_od, tip_od, inner_d, modulus, density = ( + _native_float(token) for token in row.tokens[2:] + ) + except ValueError as exc: + raise DeckFormatError( + f"{where}: STIFFENERS Length, RootOD, TipOD, InnerD, E and Density must be " + "plain numbers" + ) from exc + values = (length, root_od, tip_od, inner_d, modulus, density) + if not all( + math.isfinite(value) and value <= _NATIVE_MAX_COEFFICIENT for value in values + ): + raise DeckFormatError( + f"{where}: STIFFENERS Length, RootOD, TipOD, InnerD, E and Density must be " + "finite and at most 1e15" + ) + if not (length > 0.0 and root_od > 0.0 and tip_od > 0.0 and modulus > 0.0): + raise DeckFormatError( + f"{where}: STIFFENERS Length, RootOD, TipOD and E must be > 0" + ) + if inner_d < 0.0 or density < 0.0: + raise DeckFormatError(f"{where}: STIFFENERS InnerD and Density must be >= 0") + if not inner_d < min(root_od, tip_od): + raise DeckFormatError( + f"{where}: STIFFENERS InnerD must be smaller than RootOD and TipOD" + ) + extent[(line_id, end)] = extent.get((line_id, end), 0.0) + length + for line_id in sorted({key[0] for key in extent}, key=int): + if not any( + line_type_meta[name][3] > 0.0 + for name in section_types_by_line.get(line_id, []) + if name in line_type_meta + ): + raise DeckFormatError( + f"{self._label}: STIFFENERS name line {line_id}, which is not a finite-EI " + "line: a stiffener adds bending stiffness, which an EI = 0 line does not have" + ) + total = extent.get((line_id, "a"), 0.0) + extent.get((line_id, "b"), 0.0) + if total > line_lengths[line_id] * (1.0 + 1.0e-12): + raise DeckFormatError( + f"{self._label}: the STIFFENERS of line {line_id} are longer than the line " + "(End A and End B stiffeners together)" + ) + def _legacy_rod_type_columns(self, record: DeckRecord) -> bool: """Return whether ``record`` sits under a legacy CableDyn ROD TYPES header. @@ -2763,6 +2856,8 @@ def end_key(token: str) -> str: line_nelems: dict[str, int] = dict.fromkeys(line_ids, 0) line_lengths: dict[str, float] = dict.fromkeys(line_ids, 0.0) normalized_line_endpoints: dict[str, tuple[str, str]] = {} + # lines whose stock anchor-first row the native reader turns around (its ends swap) + swapped_lines: set[str] = set() range_lines = 0 series_lines = 0 # lines with per-line time-series files (flags p, t) for row in self.lines: @@ -2845,6 +2940,7 @@ def end_key(token: str) -> str: if type_a == "fixed" and upper_b: node_a, node_b = node_b, node_a type_a, type_b = type_b, type_a + swapped_lines.add(str(_native_int(row.tokens[0]))) normalized_line_endpoints[str(_native_int(row.tokens[0]))] = (node_a, node_b) if not has_dynamic_points: type_a_is_coupled = type_a in {"coupled", "vessel"} or _is_turbine_point_type( @@ -2978,9 +3074,12 @@ def end_key(token: str) -> str: "to run the dynamic working-curve path" ) + self._check_stiffeners(line_ids, section_types_by_line, line_type_meta, line_lengths) self._check_attachments(line_ids, section_types_by_line, line_type_meta, line_lengths) assigned_end_connections: set[tuple[str, str]] = set() + # (line, end) held by a Rigid or rotational-spring row, in native End A/B order + held_ends: set[tuple[str, str]] = set() # line id -> {end: torsionally restrained} from the optional torsion columns torsion_ends: dict[str, dict[str, bool]] = {} torsion_pretwist: dict[str, dict[str, float]] = {} @@ -3076,6 +3175,8 @@ def end_key(token: str) -> str: self._check_torsion_normal(where, row, normal, direction, norm) torsion_ends.setdefault(line_id, {})[end] = restrained if non_pinned: + swapped = line_id in swapped_lines + held_ends.add((line_id, {"a": "b", "b": "a"}[end] if swapped else end)) has_finite_ei = any( line_type_meta[line_type][3] > 0.0 for line_type in section_types_by_line[line_id] @@ -3762,6 +3863,7 @@ def is_body_kind(kind: str, pinned: bool) -> bool: # Native check_channel: ids are digit strings compared by value, so leading zeros # are accepted (FairTen01 is FairTen1). + stiffened_lines = {str(_native_int(row.tokens[0])) for row in self._rows("STIFFENERS")} for channel in channels: lowered = channel.lower() endpoint_channel = re.fullmatch( @@ -3818,6 +3920,22 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._label}: OUTPUT {channel!r} references an unknown line" ) continue + # FairDefl/AnchDefl: deflection of the end force from a held end's direction + deflection_channel = re.fullmatch(r"(fair|anch)defl([0-9]+)", lowered) + if deflection_channel: + line_id = _channel_id(deflection_channel.group(2)) + if line_id not in line_ids: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r} references an unknown line" + ) + end = "a" if deflection_channel.group(1) == "fair" else "b" + if (line_id, end) not in held_ends: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: the deflection angle needs a Rigid or " + "rotational-spring END CONNECTIONS row at End " + f"{end.upper()} of line {line_id}" + ) + continue if point_channel: # (a POINT row merged into a zero-length rod's connector no longer exists) point_id = _channel_id(point_channel.group(1)) @@ -3864,8 +3982,8 @@ def is_body_kind(kind: str, pinned: bool) -> bool: "no torque" ) continue - if lowered.startswith(("ten", "curv", "bendmom", "l")): - # native parse_line_node_channel: Ten/Curv/BendMomN, LN... + if lowered.startswith(("ten", "curv", "bendmom", "stfmom", "l")): + # native parse_line_node_channel: Ten/Curv/BendMom/StfMomN, LN... line_number, node_id, kind, _ = _parse_line_node_channel(lowered) if ( node_id == 0 @@ -3886,6 +4004,11 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r} node exceeds the line node count" ) + if kind == 12 and line_id not in stiffened_lines: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: line {line_id} has no STIFFENERS, " + "so no stiffener moment" + ) continue raise DeckFormatError(f"{self._label}: unsupported OUTPUT channel {channel!r}") diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index c24acc98..c45b3f43 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -107,6 +107,7 @@ def _semantic(deck: DeckFile) -> dict[str, object]: "TURBINES", "EQUIVALENT BUOYANCY", "ATTACHMENTS", + "STIFFENERS", "CONTROL", "EXTERNAL LOADS", ) @@ -425,6 +426,26 @@ def test_end_connections_attachments_and_equivalent_buoyancy() -> None: round_trip = DeckModel.from_deck_file(deck) assert round_trip.attachments[0].arc_length == (42.5, 5.0, 87.5) assert round_trip.end_connections[1].stiffness == "Rigid" + # a bend stiffener: a cylindrical root and a cone at End A + model.add_stiffener(1, "a", 0.4, 0.45, 0.45, 0.17, 5.0e7, 1150.0) + model.add_stiffener(model.lines[1], "EndA", 3.6, 0.45, 0.18, 0.17, 5.0e7, 1150.0) + deck = model.to_deck_file() + assert [row.tokens[:3] for row in deck._rows("STIFFENERS")] == [ + ("1", "A", "0.4"), + ("1", "A", "3.6"), + ] + round_trip = DeckModel.from_deck_file(deck) + assert [(row.end, row.length, row.tip_od) for row in round_trip.stiffeners] == [ + ("A", 0.4, 0.45), + ("A", 3.6, 0.18), + ] + refs = round_trip.references(round_trip.lines[1]) + assert all(any(ref is row for ref in refs) for row in round_trip.stiffeners) + with pytest.raises(ValueError, match="end must be A or B"): + model.add_stiffener(1, "C", 1.0, 0.4, 0.4, 0.2, 5.0e7, 1150.0) + model.to_text(validate=False) + model.remove(model.stiffeners[-1]) + assert len(model.stiffeners) == 2 # an end connection on an EI = 0 line is a native error model.line_types["cable"].ei = 0.0 with pytest.raises(DeckFormatError): diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index bc1f2d4c..21d15d46 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -202,6 +202,63 @@ def test_attachment_arc_length_lies_on_the_line(arc, accepted): _rejects(text, "ATTACHMENTS ArcLength lies beyond the end of line 1") +_STIFFENER_ROOT = "1 A 0.4 0.45 0.45 0.17 5.0e7 1150" + + +@pytest.mark.parametrize( + ("row", "message"), + [ + ("1 A 0.4 0.45 0.45 0.17 5.0e7", "STIFFENERS rows must be: LineID End Length"), + ("x A 0.4 0.45 0.45 0.17 5.0e7 1150", "STIFFENERS LineID must be an integer"), + ("2 A 0.4 0.45 0.45 0.17 5.0e7 1150", "STIFFENERS row references undefined LINE id 2"), + ("1 C 0.4 0.45 0.45 0.17 5.0e7 1150", "STIFFENERS End must be A or B"), + ("1 A 0.4 0.45 0.45 0.17 5.0e7 dense", "must be plain numbers"), + ("1 A 0.4 0.45 0.45 0.17 2.0e15 1150", "must be finite and at most 1e15"), + ("1 A 0.0 0.45 0.45 0.17 5.0e7 1150", "Length, RootOD, TipOD and E must be > 0"), + ("1 A 0.4 0.45 0.45 -0.1 5.0e7 1150", "InnerD and Density must be >= 0"), + ("1 A 0.4 0.45 0.15 0.17 5.0e7 1150", "InnerD must be smaller than RootOD and TipOD"), + ("1 B 167.0 0.45 0.45 0.17 5.0e7 1150", "are longer than the line"), + ], +) +def test_stiffener_rows_are_native(row, message): + _rejects(_example("lazy_wave_bend_stiffener.dat", (_STIFFENER_ROOT, row)), message) + + +def test_stiffener_needs_a_finite_ei_line(): + text = _section(_HELD, "STIFFENERS", "1 A 1.0 0.5 0.5 0.3 5.0e7 1150") + _rejects(text, "STIFFENERS name line 1, which is not a finite-EI line") + + +@pytest.mark.parametrize( + ("channel", "message"), + [ + ("StfMom1N3", None), + ("FairDefl1", None), + ("AnchDefl1", "needs a Rigid or rotational-spring END CONNECTIONS row at End B of line 1"), + ], +) +def test_stiffener_and_deflection_channels_are_native(channel, message): + text = _example("lazy_wave_bend_stiffener.dat", ('"TDP1s"', f'"TDP1s"\n"{channel}"')) + if message is None: + DeckFile.from_text(text) + else: + _rejects(text, message) + + +def test_stiffener_moment_needs_a_stiffener(): + text = _example("lazy_wave_vessel_rao.dat", ('"TDP1s"', '"TDP1s"\n"StfMom1N3"')) + _rejects(text, "line 1 has no STIFFENERS, so no stiffener moment") + + +def test_stiffener_aliases_and_end_spellings_are_native(): + text = _example( + "lazy_wave_bend_stiffener.dat", + ("STIFFENERS ---", "BEND STIFFENERS ---"), + (_STIFFENER_ROOT, "1 enda 0.4 0.45 0.45 0.17 5.0e7 1150"), + ) + DeckFile.from_text(text) + + # --------------------------------------------------------------------------- output channels diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index c43aef6f..5e2b639f 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -77,7 +77,8 @@ MODULE CableDyn_DeckDriver 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, & - CD_HermiteCable_Axial_Resultant_Range, CD_HermiteCable_Element, CD_HCABLE_OK + CD_HermiteCable_Axial_Resultant_Range, CD_HermiteCable_Element, CD_HCABLE_OK, & + CD_HermiteCable_Gauss_Rule USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve_AutoMesh, CD_HermiteCable_Static_Solve, & CD_HermiteCable_Prolong_Arc, & CD_HC_OSCILLATION_REL_TOL, & @@ -184,6 +185,7 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Init_Deck_Models PUBLIC :: CD_Init_Deck_System PUBLIC :: CD_Init_Deck_HermiteCable + PUBLIC :: CD_Stiffener_Overlay PUBLIC :: CD_Init_Deck_Aggregate PUBLIC :: CD_Deck_Query_dtM PUBLIC :: CD_End_Deck_Aggregate @@ -475,6 +477,11 @@ MODULE CableDyn_DeckDriver ! End A [m], mass [kg], displaced volume [m^3], drag area CdA [m^2], added-mass Ca [-], ! axial drag area CdAx [m^2] (rows 1-6). REAL(wp), ALLOCATABLE :: att(:, :) + ! STIFFENERS (finite-EI lines): one column per conical segment of a bend stiffener -- the end + ! it sleeves (1 = End A, 2 = End B), the segment's arc from that end to its root side and to + ! its tip side [m], outer diameter at the root side and at the tip side [m], inner diameter + ! [m], Young's modulus [Pa] and density [kg/m^3] (rows 1-8). + REAL(wp), ALLOCATABLE :: stf(:, :) END TYPE TYPE :: DeckEndConnection @@ -1504,6 +1511,10 @@ SUBROUTINE init_one_finite_model(ln, sections, types, points, opts, deck_model, 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') @@ -1725,6 +1736,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, LOGICAL :: has_att REAL(wp), ALLOCATABLE :: w_bare_deck(:), l0_deck_att(:), w_bare(:) INTEGER, ALLOCATABLE :: att_node(:) + ! STIFFENERS: the cable's own bending stiffness per element (internal order), without the + ! sleeve, for the cable's share of the bend moment (allocated only on a stiffened line) + REAL(wp), ALLOCATABLE :: ei_cable(:) REAL(wp) :: att_offset ! Condensed torsion (both END CONNECTIONS rows torsionally restrained): solved as the last ! static load stage on the final mesh, then installed in the cable. @@ -1891,6 +1905,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 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) IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (ALLOCATED(ln%stf)) THEN + ALLOCATE (ei_cable(SIZE(l0))) + CALL finite_line_type_ei(ln, sections, types, ei_cable) + END IF ! A seabed sloping across that plane under the as-laid run pushes the grounded nodes out ! of it against their friction: solved in 3D as well, so the march starts at rest. IF (.NOT. require_3d_static) require_3d_static = as_laid_cross_slope() @@ -2837,6 +2855,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 'dynamic tolerance ', static_tol_target, '; equilibrium accepted at the relative residual ', res CALL report_note(note_text) END IF + IF (ALLOCATED(ln%stf)) CALL stiffener_notes() IF (saddle_kept) THEN WRITE (note_text, '(A,I0,A)') 'line ', ln%id, ': the equilibrium in the current is held in the '// & 'vertical plane of the line; it is unstable out of that plane and no out-of-plane equilibrium was '// & @@ -2900,6 +2919,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL remap_elem_by_reference_arc(can, l0, l0_am) CALL remap_elem_by_reference_arc(cat, l0, l0_am) CALL remap_elem_by_reference_arc(ba_raw, l0, l0_am) + IF (ALLOCATED(ei_cable)) CALL remap_elem_by_reference_arc(ei_cable, l0, l0_am) END IF ! The node output channels read deck nodes: map each onto the final mesh (set on the cable ! once it is built below). @@ -3003,6 +3023,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable coupled-shell init failed: '//TRIM(em)); RETURN END IF IF (ALLOCATED(deck_map)) CALL MOVE_ALLOC(deck_map, cable%deck_node) + ! a stiffened line: the outputs report the cable's own share of the bend moment + IF (ALLOCATED(ei_cable)) cable%line%EI_line = ei_cable IF (ANY(ba > CD_ZERO)) THEN CALL CD_HFMF_Set_Axial_Damping(cable, ba, es, em) IF (es /= CD_HFMF_OK) THEN @@ -4375,6 +4397,50 @@ SUBROUTINE report_note(text) IF (PRESENT(init_note)) CALL append_note_line(init_note, text) END SUBROUTINE report_note + SUBROUTINE stiffener_notes() + !! Notes on each bend stiffener of the line, nothing changed: a stiffener spanning fewer than + !! STIFFENER_MIN_ELEMENTS deck elements, whose taper the element properties (one value per + !! deck element) cannot follow, with the element length that resolves it; and a stiffener at + !! a pinned end, where the root moment it is built to carry cannot develop. + INTEGER, PARAMETER :: STIFFENER_MIN_ELEMENTS = 10 + CHARACTER(1), PARAMETER :: END_NAME(2) = ['A', 'B'] + REAL(wp) :: s_end, len_stf, lo, hi + INTEGER :: iend, n_cov, e + CHARACTER(32) :: b1, b2 + CHARACTER(512) :: text + DO iend = 1, 2 + IF (.NOT. ANY(NINT(ln%stf(1, :)) == iend)) CYCLE + len_stf = MAXVAL(ln%stf(3, :), MASK=NINT(ln%stf(1, :)) == iend) + ! deck elements in internal order run from End B; count those the stiffener reaches + n_cov = 0 + s_end = CD_ZERO + DO e = 1, SIZE(l0) + IF (iend == 2) THEN + lo = s_end; hi = s_end + l0(e) + ELSE + lo = SUM(l0) - s_end - l0(e); hi = SUM(l0) - s_end + END IF + IF (lo < len_stf*(CD_ONE - 1.0e-12_wp)) n_cov = n_cov + 1 + s_end = s_end + l0(e) + END DO + WRITE (b1, '(F12.2)') len_stf + IF (n_cov < STIFFENER_MIN_ELEMENTS) THEN + WRITE (b2, '(F12.3)') len_stf/REAL(STIFFENER_MIN_ELEMENTS, wp) + text = 'line '//TRIM(int_to_str(ln%id))//': the '//TRIM(ADJUSTL(b1))//' m stiffener at End '// & + END_NAME(iend)//' spans '//TRIM(int_to_str(n_cov))//' elements, too few to follow its taper '// & + '(one stiffness per element): give the section there elements of at most '// & + TRIM(ADJUSTL(b2))//' m over the stiffener' + CALL report_note(text) + END IF + IF (ln%endconn_mode(iend) == CD_ENDCONN_PINNED) THEN + text = 'line '//TRIM(int_to_str(ln%id))//': the stiffener at End '//END_NAME(iend)//' sleeves a '// & + 'pinned end, which carries no moment, so the stiffener root takes none; declare that end '// & + 'Rigid or a rotational spring in END CONNECTIONS to model a stiffener clamped at its root' + CALL report_note(text) + END IF + END DO + END SUBROUTINE stiffener_notes + SUBROUTINE friction_resolution_note() !! Seabed friction acts at the nodes: as the line lands and lifts at touchdown, a grounded !! element locks or releases up to mu w L of friction (mu the axial friction coefficient, @@ -9082,6 +9148,7 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia i_rn(e) = types(tidx)%i_rn END DO END DO + IF (ALLOCATED(ln%stf)) CALL CD_Stiffener_Overlay(ln%stf, l0, diam, ei=ei, mpl=mpl) l0 = l0(n_elem:1:-1) ea = ea(n_elem:1:-1) mpl = mpl(n_elem:1:-1) @@ -9115,12 +9182,33 @@ SUBROUTINE finite_raw_ba_array(ln, sections, types, ba_raw) ba_raw = ba_raw(SIZE(ba_raw):1:-1) END SUBROUTINE finite_raw_ba_array + SUBROUTINE finite_line_type_ei(ln, sections, types, ei) + !! The line types' own bending stiffness on the deck elements (internal order), without + !! any STIFFENERS sleeve. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: ei(:) + INTEGER :: i, j, e + + e = 0 + DO i = 1, SIZE(sections) + IF (sections(i)%line_id /= ln%id) CYCLE + DO j = 1, sections(i)%nsegs + e = e + 1 + ei(e) = types(sections(i)%ltype)%ei + END DO + END DO + ei = ei(SIZE(ei):1:-1) + END SUBROUTINE finite_line_type_ei + SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) !! Expand section hydro coefficients to finite-EI element arrays. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckLineType), INTENT(IN) :: types(:) REAL(wp), INTENT(OUT) :: diam(:), cdn(:), cdt(:), can(:), cat(:) + REAL(wp) :: l0(SIZE(diam)) INTEGER :: i, j, e, tidx e = 0 @@ -9129,6 +9217,7 @@ SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) tidx = sections(i)%ltype DO j = 1, sections(i)%nsegs e = e + 1 + l0(e) = sections(i)%length/REAL(sections(i)%nsegs, wp) diam(e) = types(tidx)%diam cdn(e) = types(tidx)%cdn cdt(e) = types(tidx)%cdt @@ -9136,6 +9225,8 @@ SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) cat(e) = types(tidx)%cat END DO END DO + ! a stiffener widens the line: the same displaced-area diameter as its weight and buoyancy + IF (ALLOCATED(ln%stf)) CALL CD_Stiffener_Overlay(ln%stf, l0, diam) diam = diam(SIZE(diam):1:-1) cdn = cdn(SIZE(cdn):1:-1) cdt = cdt(SIZE(cdt):1:-1) @@ -9143,6 +9234,84 @@ SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) cat = cat(SIZE(cat):1:-1) END SUBROUTINE finite_hydro_arrays + SUBROUTINE CD_Stiffener_Overlay(stf, l0, diam, ei, mpl) + !! Add the bend stiffeners of a finite-EI line (ln%stf columns) to its element properties, + !! in public element order (End A first). A stiffener is a polyurethane sleeve bonded to the + !! cable in bending: over its length the section has the bending stiffness of the cable plus + !! that of the sleeve, EI_c + E pi/64 (OD^4 - ID^4), with the outer diameter OD varying + !! linearly along each conical segment; it carries no axial load and no torque. An element it + !! covers, wholly or in part, takes + !! ei the compliance average l / int ds/EI(s), exact for the element's rotation under a + !! uniform moment, so a stiff root next to a soft tip is not over-stiffened; + !! mpl the cable mass plus the mean sleeve mass, rho pi/4 (OD^2 - ID^2); + !! diam the diameter of the mean displaced area, cable plus solid sleeve, sqrt(d^2 + mean + !! (OD^2 - ID^2)): one diameter, like a line type's, for the weight and buoyancy (dry + !! part above the surface included), the added mass, Froude-Krylov force and drag. With + !! the bore equal to the cable diameter it is the sleeve's outer diameter. + !! The integrals use 6-point Gauss-Legendre on each part of the element a segment covers. + !! An element no stiffener reaches is left untouched. + REAL(wp), INTENT(IN) :: stf(:, :), l0(:) + REAL(wp), INTENT(INOUT) :: diam(:) + REAL(wp), INTENT(INOUT), OPTIONAL :: ei(:), mpl(:) + REAL(wp), PARAMETER :: PI_64 = 0.0490873852123405193_wp ! pi/64 + REAL(wp) :: gp(6), gw(6), s_end(0:SIZE(l0)), line_len, a, b, lo, hi, x, t, od, d_line + REAL(wp) :: compliance, sleeve_mass, sleeve_area, covered, ei_line + INTEGER :: e, k, g + + CALL CD_HermiteCable_Gauss_Rule(6, gp, gw) + s_end(0) = CD_ZERO + DO e = 1, SIZE(l0) + s_end(e) = s_end(e - 1) + l0(e) + END DO + line_len = s_end(SIZE(l0)) + DO e = 1, SIZE(l0) + a = s_end(e - 1) + b = s_end(e) + d_line = diam(e) + ei_line = CD_ZERO + IF (PRESENT(ei)) ei_line = ei(e) + compliance = CD_ZERO; sleeve_mass = CD_ZERO; sleeve_area = CD_ZERO; covered = CD_ZERO + DO k = 1, SIZE(stf, 2) + ! the segment's span on the public arc + IF (NINT(stf(1, k)) == 1) THEN + lo = stf(2, k); hi = stf(3, k) + ELSE + lo = line_len - stf(3, k); hi = line_len - stf(2, k) + END IF + lo = MAX(lo, a); hi = MIN(hi, b) + IF (.NOT. (hi > lo)) CYCLE + covered = covered + (hi - lo) + DO g = 1, 6 + x = lo + gp(g)*(hi - lo) + ! fraction of the way from the segment's root side to its tip side + IF (NINT(stf(1, k)) == 1) THEN + t = (x - stf(2, k))/(stf(3, k) - stf(2, k)) + ELSE + t = (line_len - x - stf(2, k))/(stf(3, k) - stf(2, k)) + END IF + t = MIN(CD_ONE, MAX(CD_ZERO, t)) + od = stf(4, k) + t*(stf(5, k) - stf(4, k)) + compliance = compliance + gw(g)*(hi - lo)/(ei_line + stf(7, k)*PI_64*(od**4 - stf(6, k)**4)) + sleeve_mass = sleeve_mass + gw(g)*(hi - lo)*stf(8, k)*QUARTER_PI*(od**2 - stf(6, k)**2) + sleeve_area = sleeve_area + gw(g)*(hi - lo)*(od**2 - stf(6, k)**2) + END DO + END DO + IF (.NOT. (covered > CD_ZERO)) CYCLE + IF (PRESENT(ei)) THEN + IF (ei_line > CD_ZERO) THEN + compliance = compliance + (l0(e) - covered)/ei_line + ei(e) = l0(e)/compliance + ELSE IF (covered >= l0(e)*(CD_ONE - 1.0e-12_wp)) THEN + ! an EI = 0 element bends only where the sleeve covers all of it; a bare part has an + ! infinite compliance and leaves the element without bending stiffness + ei(e) = l0(e)/compliance + END IF + END IF + IF (PRESENT(mpl)) mpl(e) = mpl(e) + sleeve_mass/l0(e) + diam(e) = SQRT(d_line**2 + sleeve_area/l0(e)) + END DO + END SUBROUTINE CD_Stiffener_Overlay + SUBROUTINE remap_elem_by_reference_arc(a, l0_parent, l0_child) !! Map a piecewise-constant per-element field from a parent reference mesh to !! any nested child mesh. Child midpoints select the parent, so interfaces are @@ -10871,6 +11040,9 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CHARACTER(DECK_RECLEN), ALLOCATABLE :: att_rows(:) INTEGER, ALLOCATABLE :: att_lines(:) INTEGER :: n_att + CHARACTER(DECK_RECLEN), ALLOCATABLE :: stf_rows(:) + INTEGER, ALLOCATABLE :: stf_lines(:) + INTEGER :: n_stf CHARACTER(2*NAMELEN), ALLOCATABLE :: channel_keys(:) LOGICAL :: ext_march, types_stock_cols, rodtypes_legacy_cols, turb_ok, static_finite_ok INTEGER :: unit, ios, section, nt, nb, nrt, nr, np, nlin, nsec, neq, nch, nfl, nct, nec, lineno @@ -10887,7 +11059,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti INTEGER, PARAMETER :: SEC_NONE = 0, SEC_TYPES = 1, SEC_BODIES = 2, SEC_POINTS = 3, SEC_LINES = 4, & SEC_SECTIONS = 5, SEC_OPTIONS = 6, SEC_OUTPUTS = 7, SEC_RODTYPES = 8, SEC_RODS = 9, & SEC_EQUIV = 10, SEC_FAILURE = 11, SEC_CONTROL = 12, SEC_SYROPE_IC = 13, & - SEC_ENDCONN = 14, SEC_TURBINES = 15, SEC_EXTLOADS = 16, SEC_ATTACH = 17 + SEC_ENDCONN = 14, SEC_TURBINES = 15, SEC_EXTLOADS = 16, SEC_ATTACH = 17, & + SEC_STIFF = 18 ErrStat = 0; ErrMsg = '' ext_march = .FALSE. @@ -10907,6 +11080,8 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti next_ext = 0 ALLOCATE (att_rows(0), att_lines(0)) n_att = 0 + ALLOCATE (stf_rows(0), stf_lines(0)) + n_stf = 0 nt = 0; nb = 0; nrt = 0; nr = 0; np = 0; nlin = 0; nsec = 0; neq = 0; nch = 0; nfl = 0; nct = 0; nec = 0 section = SEC_NONE ALLOCATE (channel_lines(0)) @@ -11023,6 +11198,15 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti END IF att_rows(n_att) = line(1:MIN(LEN(line), DECK_RECLEN)) att_lines(n_att) = lineno + CASE (SEC_STIFF) + IF (.NOT. has_numeric_token(line)) CYCLE + n_stf = n_stf + 1 + IF (n_stf > SIZE(stf_rows)) THEN + stf_rows = [stf_rows, [(REPEAT(' ', DECK_RECLEN), i_ch=1, 8)]] + stf_lines = [stf_lines, [(0, i_ch=1, 8)]] + END IF + stf_rows(n_stf) = line(1:MIN(LEN(line), DECK_RECLEN)) + stf_lines(n_stf) = lineno CASE (SEC_OPTIONS) CALL apply_option(line, opts, ErrStat, ErrMsg) CASE (SEC_OUTPUTS) @@ -11113,6 +11297,13 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO + DO i_ch = 1, n_stf + CALL append_line_stiffener(stf_rows(i_ch), lines, ErrStat, ErrMsg) + IF (ErrStat /= 0) THEN + CALL add_row_context('deck', stf_lines(i_ch), stf_rows(i_ch), ErrMsg) + RETURN + END IF + END DO ! Caller-supplied environment overrides land HERE -- before equivalent-buoyancy ! conversion and validation -- so both run under the environment the model is @@ -12302,6 +12493,8 @@ SUBROUTINE set_section(secname, section, ErrStat, ErrMsg) section = 16 CASE ('ATTACHMENTS', 'LINE ATTACHMENTS', 'CLUMPS') section = 17 + CASE ('STIFFENERS', 'STIFFENER', 'BEND STIFFENERS', 'BEND STIFFENER') + section = 18 CASE DEFAULT IF (LEN_TRIM(secname) > NAMELEN) THEN CALL fail(ErrStat, ErrMsg, 'unknown deck section "'//secname(1:NAMELEN)//'..."') @@ -13637,6 +13830,81 @@ SUBROUTINE append_line_attachment(row, lines, ErrStat, ErrMsg) CALL MOVE_ALLOC(grown, lines(li)%att) END SUBROUTINE append_line_attachment + SUBROUTINE append_line_stiffener(row, lines, ErrStat, ErrMsg) + !! One STIFFENERS row: LineID End Length RootOD TipOD InnerD E Density -- a conical segment of + !! the bend stiffener sleeving End A or End B of a finite-EI line. The rows of one line end + !! follow each other outward from the root, each starting where the previous one ends, so a + !! cylindrical root, a cone and a tip are three rows. RootOD and TipOD are the outer diameters + !! of the segment at its root side and at its tip side. Stored columns: end (1 = A, 2 = B), + !! arc of the root side and of the tip side from that end, RootOD, TipOD, InnerD, E, Density. + CHARACTER(*), INTENT(IN) :: row + TYPE(DeckLine), INTENT(INOUT) :: lines(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + CHARACTER(DECK_RECLEN) :: tok + INTEGER :: li, lid, k, iend, nold + REAL(wp) :: vals(6), s0 + REAL(wp), ALLOCATABLE :: grown(:, :) + LOGICAL :: found, ok + + ErrStat = 0; ErrMsg = '' + IF (count_tokens(row) /= 8) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS rows must be: LineID End Length RootOD TipOD InnerD E Density'); RETURN + END IF + CALL get_token(row, 1, tok, found) + CALL parse_int_token(tok, lid, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS LineID must be an integer'); RETURN + END IF + li = find_line(lines, lid) + IF (li == 0) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS row references undefined LINE id '//TRIM(int_to_str(lid))); RETURN + END IF + CALL get_token(row, 2, tok, found) + SELECT CASE (to_lower(TRIM(tok))) + CASE ('a', 'enda') + iend = 1 + CASE ('b', 'endb') + iend = 2 + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'STIFFENERS End must be A or B'); RETURN + END SELECT + DO k = 1, 6 + CALL get_token(row, k + 2, tok, found) + CALL parse_real_token(tok, vals(k), ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS Length, RootOD, TipOD, InnerD, E and Density must be plain numbers') + RETURN + END IF + END DO + IF (.NOT. ALL(IEEE_IS_FINITE(vals)) .OR. ANY(vals > MAX_COEFFICIENT)) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS Length, RootOD, TipOD, InnerD, E and Density must be finite '// & + 'and at most 1e15'); RETURN + END IF + IF (.NOT. (vals(1) > CD_ZERO .AND. vals(2) > CD_ZERO .AND. vals(3) > CD_ZERO .AND. vals(5) > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS Length, RootOD, TipOD and E must be > 0'); RETURN + END IF + IF (vals(4) < CD_ZERO .OR. vals(6) < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS InnerD and Density must be >= 0'); RETURN + END IF + IF (.NOT. (vals(4) < MIN(vals(2), vals(3)))) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS InnerD must be smaller than RootOD and TipOD'); RETURN + END IF + ! a segment starts where the previous segment of the same line end stops + s0 = CD_ZERO + nold = 0 + IF (ALLOCATED(lines(li)%stf)) THEN + nold = SIZE(lines(li)%stf, 2) + DO k = 1, nold + IF (NINT(lines(li)%stf(1, k)) == iend) s0 = MAX(s0, lines(li)%stf(3, k)) + END DO + END IF + ALLOCATE (grown(8, nold + 1)) + IF (nold > 0) grown(:, 1:nold) = lines(li)%stf + grown(:, nold + 1) = [REAL(iend, wp), s0, s0 + vals(1), vals(2:6)] + CALL MOVE_ALLOC(grown, lines(li)%stf) + END SUBROUTINE append_line_stiffener + SUBROUTINE trim_end_connections(endconns, nec) TYPE(DeckEndConnection), ALLOCATABLE, INTENT(INOUT) :: endconns(:) INTEGER, INTENT(IN) :: nec @@ -14804,6 +15072,9 @@ FUNCTION channel_identity_key(ch) RESULT(key) ELSE key = lo(1:4)//'decl:'//TRIM(int_to_str(a)) END IF + ELSE IF (is_end_deflection_channel(lo)) THEN + a = int_suffix(ch, 9) + IF (a > 0) key = lo(1:8)//':'//TRIM(int_to_str(a)) ELSE IF (is_point_force_channel(lo)) THEN CALL parse_point_force_channel(ch, a, b) IF (a > 0 .AND. b > 0) key = 'pointf:'//TRIM(int_to_str(a))//':'//TRIM(int_to_str(b)) @@ -14814,7 +15085,8 @@ FUNCTION channel_identity_key(ch) RESULT(key) CALL parse_point_channel(ch, a, b) IF (a > 0 .AND. b > 0) key = 'point:'//TRIM(int_to_str(a))//':'//TRIM(int_to_str(b)) ELSE IF (starts_with(lo, 'ten') .OR. starts_with(lo, 'curv') .OR. starts_with(lo, 'bendmom') .OR. & - starts_with(lo, 'l') .OR. starts_with(lo, 'torq') .OR. starts_with(lo, 'twist')) THEN + starts_with(lo, 'stfmom') .OR. starts_with(lo, 'l') .OR. starts_with(lo, 'torq') .OR. & + starts_with(lo, 'twist')) THEN CALL parse_line_node_channel(ch, a, b, c, d) IF (a > 0 .AND. b > 0 .AND. c > 0) key = 'node:'//TRIM(int_to_str(a))//':'//TRIM(int_to_str(b))// & ':'//TRIM(int_to_str(c))//':'//TRIM(int_to_str(d)) @@ -14935,6 +15207,8 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) ! attachment arcs are measured from End A, which is now the other end IF (ALLOCATED(lines(i)%att)) & lines(i)%att(1, :) = SUM(sections%length, MASK=sections%line_id == lines(i)%id) - lines(i)%att(1, :) + ! a stiffener sleeves the same physical end, which is now the other end index + IF (ALLOCATED(lines(i)%stf)) lines(i)%stf(1, :) = 3.0_wp - lines(i)%stf(1, :) CALL reverse_line_sections(sections, lines(i)%id) END IF END DO @@ -15919,6 +16193,23 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END IF END DO + ! STIFFENERS: bend stiffeners sleeving the ends of a finite-EI line + DO j = 1, SIZE(lines) + IF (.NOT. ALLOCATED(lines(j)%stf)) CYCLE + at_line = lines(j)%deck_line + IF (.NOT. line_is_finite_ei(lines(j), types, sections)) THEN + CALL fail(ErrStat, ErrMsg, 'STIFFENERS name line '//TRIM(int_to_str(lines(j)%id))// & + ', which is not a finite-EI line: a stiffener adds bending stiffness, which an EI = 0 line '// & + 'does not have'); RETURN + END IF + IF (MAX(CD_ZERO, MAXVAL(lines(j)%stf(3, :), MASK=NINT(lines(j)%stf(1, :)) == 1)) + & + MAX(CD_ZERO, MAXVAL(lines(j)%stf(3, :), MASK=NINT(lines(j)%stf(1, :)) == 2)) > & + SUM(sections%length, MASK=sections%line_id == lines(j)%id)*(CD_ONE + 1.0e-12_wp)) THEN + CALL fail(ErrStat, ErrMsg, 'the STIFFENERS of line '//TRIM(int_to_str(lines(j)%id))// & + ' are longer than the line (End A and End B stiffeners together)'); RETURN + END IF + END DO + ! ATTACHMENTS: discrete clumps/buoyancy modules on a finite-EI line DO j = 1, SIZE(lines) IF (.NOT. ALLOCATED(lines(j)%att)) CYCLE @@ -27602,7 +27893,7 @@ SUBROUTINE write_hermite_static_element_profile(out_root, lines, cables, ErrStat minimum_u_public = CD_ONE - minimum_u_internal maximum_u_public = CD_ONE - maximum_u_internal arc_peak = arc_start + u_curvature_public*l0 - moment_peak = cables(li)%line%EI(internal_element)*curvature_peak + moment_peak = cables(li)%line%EI_line(internal_element)*curvature_peak WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') lines(li)%id, tab, public_element, & tab, arc_start, tab, arc_end, tab, u_curvature_public, tab, arc_peak, tab, curvature_peak, & tab, moment_peak, tab, minimum_resultant, tab, minimum_u_public, tab, maximum_resultant, & @@ -27787,6 +28078,8 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, line_id = anchor_force_line_id(channels(i)) ELSE IF (is_endpoint_angle_channel(lo)) THEN line_id = endpoint_angle_line_id(channels(i)) + ELSE IF (is_end_deflection_channel(lo)) THEN + line_id = int_suffix(channels(i), 9) ELSE CALL parse_line_node_channel(channels(i), line_id, pidx, pp, comp) END IF @@ -31647,6 +31940,13 @@ LOGICAL FUNCTION is_endpoint_angle_channel(lo) RESULT(is_angle) starts_with(lo, 'fairincl') .OR. starts_with(lo, 'anchincl') END FUNCTION is_endpoint_angle_channel + LOGICAL FUNCTION is_end_deflection_channel(lo) RESULT(is_defl) + !! FairDefl/AnchDefl: the angle between the end force and the direction a Rigid or + !! rotational-spring END CONNECTIONS row holds at End A / End B [deg]. + CHARACTER(*), INTENT(IN) :: lo + is_defl = starts_with(lo, 'fairdefl') .OR. starts_with(lo, 'anchdefl') + END FUNCTION is_end_deflection_channel + LOGICAL FUNCTION is_fair_endpoint_angle(lo) RESULT(is_fair) CHARACTER(*), INTENT(IN) :: lo is_fair = starts_with(lo, 'fairangle') .OR. starts_with(lo, 'fairdecl') .OR. & @@ -31814,6 +32114,17 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r IF (find_line(lines, endpoint_angle_line_id(ch)) == 0) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN END IF + ELSE IF (is_end_deflection_channel(lo)) THEN + li = find_line(lines, int_suffix(ch, 9)) + IF (li == 0) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": unknown line id'); RETURN + END IF + ! the angle is measured from the direction a held end connection declares + IF (lines(li)%endconn_mode(MERGE(1, 2, starts_with(lo, 'fairdefl'))) == CD_ENDCONN_PINNED) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": the deflection angle needs a Rigid or '// & + 'rotational-spring END CONNECTIONS row at End '//MERGE('A', 'B', starts_with(lo, 'fairdefl'))// & + ' of line '//TRIM(int_to_str(lines(li)%id))); RETURN + END IF ELSE IF (is_point_force_channel(lo)) THEN CALL parse_point_force_channel(ch, pidx, comp) IF (comp < 1 .OR. point_index(points, pidx) == 0) THEN @@ -31854,7 +32165,7 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r 'torque'); RETURN END IF ELSE IF (starts_with(lo, 'ten') .OR. starts_with(lo, 'curv') .OR. & - starts_with(lo, 'bendmom') .OR. starts_with(lo, 'l')) THEN + starts_with(lo, 'bendmom') .OR. starts_with(lo, 'stfmom') .OR. starts_with(lo, 'l')) THEN CALL parse_line_node_channel(ch, line_id, node, kind, comp) li = find_line(lines, line_id) IF (li /= 0 .AND. node == 0 .AND. names_node_zero(lo)) THEN @@ -31868,12 +32179,16 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r IF (node > nelem + 1) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index exceeds line node count'); RETURN END IF + IF (kind == 12 .AND. .NOT. ALLOCATED(lines(li)%stf)) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' has no '// & + 'STIFFENERS, so no stiffener moment'); RETURN + END IF ELSE CALL fail(ErrStat, ErrMsg, 'OUTPUT channel "'//TRIM(ch)// & '" not supported (use FairTen, AnchTen, AnchFz, AnchFH, FairIncl, AnchIncl, '// & - 'FairDecl, AnchDecl (FairAngle/AnchAngle aliases), '// & + 'FairDecl, AnchDecl (FairAngle/AnchAngle aliases), FairDefl, AnchDefl, '// & 'Point

p{x,y,z} (alias Con

p{x,y,z}), Point

F{x,y,z,H}, '// & - 'TenN, CurvN, BendMomN, TorqN, TwistN, Twist, '// & + 'TenN, CurvN, BendMomN, StfMomN, TorqN, TwistN, Twist, '// & 'LNp{x,y,z}, LNv{x,y,z}, LNa{x,y,z}, LNDec, LNAzi, '// & 'TDP{s,x,y,z,Lay,Exc,Grd}, or the Body/Rod channels)'); RETURN END IF @@ -32107,7 +32422,8 @@ SUBROUTINE parse_line_node_channel(ch, line_id, node_id, kind, comp) !! Parse supported line-node output channels (kind codes shared with the writers): !! TenN -> kind=3, comp=0 nodal tension [N] !! CurvN -> kind=5, comp=0 curvature [1/m] - !! BendMomN -> kind=6, comp=0 bend moment [N.m] + !! BendMomN -> kind=6, comp=0 cable bend moment [N.m] + !! StfMomN -> kind=12, comp=0 stiffener moment [N.m] !! LNp{x,y,z} -> kind=1, comp=1..3 position [m] !! LNv{x,y,z} -> kind=2, comp=1..3 velocity [m/s] !! LNa{x,y,z} -> kind=4, comp=1..3 acceleration [m/s^2] @@ -32160,6 +32476,10 @@ SUBROUTINE parse_line_node_channel(ch, line_id, node_id, kind, comp) CALL parse_keyword_line_node(lo, 7, last, line_id, node_id) IF (line_id > 0 .AND. node_id > 0) kind = 6 RETURN + ELSE IF (starts_with(lo, 'stfmom')) THEN + CALL parse_keyword_line_node(lo, 6, last, line_id, node_id) + IF (line_id > 0 .AND. node_id > 0) kind = 12 + RETURN END IF ! LN... channels: p/v/a{x,y,z} (component) or Dec/Azi (scalar). IF (.NOT. starts_with(lo, 'l')) RETURN @@ -33099,11 +33419,11 @@ SUBROUTINE range_sample_cable_element(ErrStat, ErrMsg) bend = CD_ZERO IF (inode > 1) THEN curv = MAX(curv, rl%as(inode - 1)) - bend = MAX(bend, cable%line%EI(inode - 1)*rl%as(inode - 1)) + bend = MAX(bend, cable%line%EI_line(inode - 1)*rl%as(inode - 1)) END IF IF (inode <= ne) THEN curv = MAX(curv, rl%vs(inode)) - bend = MAX(bend, cable%line%EI(inode)*rl%vs(inode)) + bend = MAX(bend, cable%line%EI_line(inode)*rl%vs(inode)) END IF rl%val(CD_RQ_CURVATURE, j) = curv rl%val(CD_RQ_BEND, j) = bend @@ -33465,6 +33785,8 @@ SUBROUTINE CD_Eval_Aggregate_Channel(ch, has_sys, system, cables, line_is_cable, line_id = anchor_force_line_id(ch) ELSE IF (is_endpoint_angle_channel(lo)) THEN line_id = endpoint_angle_line_id(ch) + ELSE IF (is_end_deflection_channel(lo)) THEN + line_id = int_suffix(ch, 9) ELSE CALL parse_line_node_channel(ch, line_id, node, kind, comp) END IF @@ -33632,6 +33954,8 @@ LOGICAL FUNCTION CD_Channel_Token_Parses(ch) RESULT(ok) ok = anchor_force_line_id(ch) > 0 ELSE IF (is_endpoint_angle_channel(lo)) THEN ok = endpoint_angle_line_id(ch) > 0 + ELSE IF (is_end_deflection_channel(lo)) THEN + ok = int_suffix(ch, 9) > 0 ELSE CALL parse_line_node_channel(ch, line_id, node, kind, comp) ok = line_id > 0 .AND. node > 0 .AND. kind > 0 @@ -33844,6 +34168,27 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) END IF val = endpoint_angle_from_declination(lo, val) RETURN + ELSE IF (is_end_deflection_channel(lo)) THEN + ! the angle between the force on the end's support and the held direction: internally End + ! A is node nn and End B node 1, and the held direction follows the internal tangent (out + ! of the line at End A, into it at End B), while the end force points into the line + BLOCK + REAL(wp) :: force(3), axis(3), cosine + INTEGER :: inode_end + inode_end = MERGE(nnode, 1, starts_with(lo, 'fairdefl')) + CALL CD_HermiteCable_Dyn_End_Force(cable%line, inode_end, force, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": finite-EI end-force recovery failed: '// & + TRIM(em)); RETURN + END IF + axis = MERGE(-cable%line%endconn_d0(:, 2), cable%line%endconn_d0(:, 1), inode_end == nnode) + val = CD_ZERO + IF (NORM2(force) > CD_ZERO .AND. NORM2(axis) > CD_ZERO) THEN + cosine = DOT_PRODUCT(force, axis)/(NORM2(force)*NORM2(axis)) + val = ACOS(MAX(-CD_ONE, MIN(CD_ONE, cosine)))*CD_RAD2DEG + END IF + END BLOCK + RETURN END IF CALL parse_line_node_channel(ch, line_id, node, kind, comp) deck_numbering = ALLOCATED(cable%deck_node) @@ -33905,6 +34250,15 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) IF (es /= CD_HCABLE_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF + CASE (12) ! the bend stiffener's share of the section moment (zero outside a stiffener) + IF (.NOT. cable%line%output_element_recovery) THEN + CALL cable_node_values(cable, inode, sec_ten, sec_curv, sec_bend, ErrStat, ErrMsg, sleeve_moment=val) + RETURN + END IF + CALL cable_nodal_bend_moment(cable, inode, sec_bend, es, em, sleeve_moment=val) + IF (es /= CD_HCABLE_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN + END IF CASE (9, 10, 11) ! condensed torsion: torque [N m], twist from End A to node J, total twist [deg] BLOCK REAL(wp) :: th, mt @@ -34080,18 +34434,20 @@ SUBROUTINE cable_end_tension(cable, inode, tension, ErrStat, ErrMsg) tension = NORM2(force) END SUBROUTINE cable_end_tension - SUBROUTINE cable_node_values(cable, inode, tension, curvature, bend_moment, ErrStat, ErrMsg) + SUBROUTINE cable_node_values(cable, inode, tension, curvature, bend_moment, ErrStat, ErrMsg, sleeve_moment) !! Equilibrium node values of a finite-EI cable at internal node inode - !! (CD_HermiteCable_Dyn_Node_Values): effective tension, curvature and bend moment. + !! (CD_HermiteCable_Dyn_Node_Values): effective tension, curvature, the cable's bend moment and + !! (optional) the share a bend stiffener carries. TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable INTEGER, INTENT(IN) :: inode REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment INTEGER :: es CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' - CALL CD_HermiteCable_Dyn_Node_Values(cable%line, inode, tension, curvature, bend_moment, es, em) + CALL CD_HermiteCable_Dyn_Node_Values(cable%line, inode, tension, curvature, bend_moment, es, em, sleeve_moment) IF (es /= CD_HCDYN_OK) CALL fail_solve(ErrStat, ErrMsg, 'finite-EI node-value recovery failed: '//TRIM(em)) END SUBROUTINE cable_node_values @@ -34147,31 +34503,39 @@ SUBROUTINE cable_nodal_curvature(cable, inode, curvature, ErrStat, ErrMsg) END IF END SUBROUTINE cable_nodal_curvature - SUBROUTINE cable_nodal_bend_moment(cable, inode, bend_moment, ErrStat, ErrMsg) + SUBROUTINE cable_nodal_bend_moment(cable, inode, bend_moment, ErrStat, ErrMsg, sleeve_moment) !! Magnitudes of the two one-sided EI*kappa traces at a node. Taking their - !! maximum avoids inventing an averaged EI at a stepped section interface. + !! maximum avoids inventing an averaged EI at a stepped section interface. bend_moment is the + !! cable's own share EI_line kappa; sleeve_moment (optional) the share of a bend stiffener, + !! (EI - EI_line) kappa. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cable INTEGER, INTENT(IN) :: inode REAL(wp), INTENT(OUT) :: bend_moment INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment REAL(wp) :: curvature ErrStat = CD_HCABLE_OK ErrMsg = '' bend_moment = CD_ZERO + IF (PRESENT(sleeve_moment)) sleeve_moment = CD_ZERO IF (inode < 1 .OR. inode > cable%line%nn) THEN ErrStat = 1; ErrMsg = 'cable_nodal_bend_moment: node index out of range'; RETURN END IF IF (inode > 1) THEN CALL cable_element_curvature(cable, inode - 1, CD_ONE, curvature, ErrStat, ErrMsg) IF (ErrStat /= CD_HCABLE_OK) RETURN - bend_moment = MAX(bend_moment, cable%line%EI(inode - 1)*curvature) + bend_moment = MAX(bend_moment, cable%line%EI_line(inode - 1)*curvature) + IF (PRESENT(sleeve_moment)) sleeve_moment = MAX(sleeve_moment, & + (cable%line%EI(inode - 1) - cable%line%EI_line(inode - 1))*curvature) END IF IF (inode <= cable%line%ne) THEN CALL cable_element_curvature(cable, inode, CD_ZERO, curvature, ErrStat, ErrMsg) IF (ErrStat /= CD_HCABLE_OK) RETURN - bend_moment = MAX(bend_moment, cable%line%EI(inode)*curvature) + bend_moment = MAX(bend_moment, cable%line%EI_line(inode)*curvature) + IF (PRESENT(sleeve_moment)) sleeve_moment = MAX(sleeve_moment, & + (cable%line%EI(inode) - cable%line%EI_line(inode))*curvature) END IF END SUBROUTINE cable_nodal_bend_moment @@ -34219,7 +34583,7 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) END SELECT ELSE IF (starts_with(lo, 'fairten') .OR. starts_with(lo, 'anchten') .OR. is_anchor_force_channel(lo)) THEN unit = '(N)' - ELSE IF (is_endpoint_angle_channel(lo)) THEN + ELSE IF (is_endpoint_angle_channel(lo) .OR. is_end_deflection_channel(lo)) THEN unit = '(deg)' ELSE IF (is_point_force_channel(lo)) THEN unit = '(N)' @@ -34230,7 +34594,7 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) SELECT CASE (kind) CASE (3); unit = '(N)' CASE (5); unit = '(1/m)' - CASE (6); unit = '(N.m)' + CASE (6, 12); unit = '(N.m)' CASE (7, 8); unit = '(deg)' CASE (9); unit = '(N.m)' CASE (10, 11); unit = '(deg)' diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index edf6b65b..05df1ccb 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -216,6 +216,10 @@ MODULE CableDyn_HermiteCableDynamic INTEGER :: ne = 0, nn = 0, ndof = 0 INTEGER :: axial_quadrature_order = 4, bending_quadrature_order = 4 REAL(wp), ALLOCATABLE :: l0(:), EA(:), EI(:), rho_a(:), w(:) ! per element + ! The cable's own bending stiffness per element, for the outputs: EI less the sleeve of a + ! bend stiffener (STIFFENERS), and equal to EI on every element without one. The bend + ! moment outputs report the cable's share EI_line kappa and the sleeve's the rest. + REAL(wp), ALLOCATABLE :: EI_line(:) ! Optional axial Kelvin-Voigt damping. BA is the axial constitutive dashpot ! coefficient [N s] after resolving the deck's direct-BA / negative-zeta convention. ! It is integrated over reference arc length with the same Hermite kinematics and @@ -671,8 +675,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Init(model, l0, EA, EI, rho_a, w, seed, fixed_dof model%ne = ne; model%nn = nn; model%ndof = ndof model%seabed_z = seabed_z; model%kn = kn - ALLOCATE (model%l0(ne), model%EA(ne), model%EI(ne), model%rho_a(ne), model%w(ne)) + ALLOCATE (model%l0(ne), model%EA(ne), model%EI(ne), model%EI_line(ne), model%rho_a(ne), model%w(ne)) model%l0 = l0; model%EA = EA; model%EI = EI; model%rho_a = rho_a; model%w = w + model%EI_line = EI model%ei_resolve = MAXVAL(ABS(w)*l0*l0)/12.0_wp ! gen-alpha constants @@ -5464,7 +5469,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery(model, element_recovery) model%output_element_recovery = element_recovery END SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery - SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend_moment, ErrStat, ErrMsg) + SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend_moment, ErrStat, ErrMsg, & + sleeve_moment) !! Equilibrium node values at one node (internal order), from the two adjacent elements; !! the same values as CD_HermiteCable_Dyn_Node_Recovery returns for that node. The element end !! residuals are kept in the model for the element state they were evaluated at (see the rc_ @@ -5477,10 +5483,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3) ErrStat = CD_HCDYN_OK; ErrMsg = '' tension = CD_ZERO; curvature = CD_ZERO; bend_moment = CD_ZERO + IF (PRESENT(sleeve_moment)) sleeve_moment = CD_ZERO IF (.NOT. model%initialized) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Node_Values: model not initialised'; RETURN END IF @@ -5505,7 +5513,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Values(model, node, tension, curvature, bend IF (ErrStat /= CD_HCDYN_OK) RETURN fp = -g(1:3); mp = -g(4:6) END IF - CALL node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + CALL node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg, & + sleeve_moment) CONTAINS @@ -5561,8 +5570,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! oscillation of the stiff-EA axial strain. !! !! tension(j) = t_j . F_j (t_j the unit nodal tangent; a line end reports the end force - !! magnitude of CD_HermiteCable_Dyn_End_Force), bend_moment(j) = |m_j - (m_j . t_j) t_j|, - !! curvature(j) = bend_moment(j)/EI, the larger of the two sides at a section junction (the + !! magnitude of CD_HermiteCable_Dyn_End_Force), the section moment M_j = |m_j - (m_j . t_j) t_j|, + !! curvature(j) = M_j/EI, the larger of the two sides at a section junction, and + !! bend_moment(j) the cable's own share EI_line curvature (M_j itself where no bend stiffener + !! sleeves the element; see node_values) (the !! exact geometric trace on an element without bending stiffness, or with EI below ei_resolve, !! where the recovered moment error w L0^2/12 exceeds the elastic moment of a 1 m bend radius). !! segment_tension(e) is the @@ -5629,16 +5640,21 @@ PURE LOGICAL FUNCTION size_ok(x, n) RESULT(ok) END FUNCTION size_ok END SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery - SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg) + SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg, & + sleeve_moment) !! Node values from the one-sided section force and moment before (fm, mm) and after !! (fp, mp) the node; a line end uses its only side (see CD_HermiteCable_Dyn_Node_Recovery). + !! bend_moment is the cable's own share of the section moment, EI_line kappa on the side of + !! the larger value (the whole section moment on a side without a bend stiffener), and + !! sleeve_moment the rest, the share a stiffener sleeve carries. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: node REAL(wp), INTENT(IN) :: fm(3), mm(3), fp(3), mp(3) REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace + REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment + REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace, section_moment, cable_moment INTEGER :: e, side CHARACTER(200) :: em2 @@ -5658,13 +5674,19 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom ELSE tension = DOT_PRODUCT(t, f) END IF - bend_moment = NORM2(m - DOT_PRODUCT(m, t)*t) + section_moment = NORM2(m - DOT_PRODUCT(m, t)*t) curvature = CD_ZERO + cable_moment = CD_ZERO DO side = 0, 1 e = node - 1 + side IF (e < 1 .OR. e > model%ne) CYCLE IF (model%EI(e) > CD_ZERO .AND. model%EI(e) >= model%ei_resolve) THEN - curvature = MAX(curvature, bend_moment/model%EI(e)) + curvature = MAX(curvature, section_moment/model%EI(e)) + IF (model%EI_line(e) == model%EI(e)) THEN + cable_moment = MAX(cable_moment, section_moment) + ELSE + cable_moment = MAX(cable_moment, model%EI_line(e)*(section_moment/model%EI(e))) + END IF ELSE CALL gather_elem(model, e, qe) CALL CD_HermiteCable_Curvature(qe, model%l0(e), REAL(1 - side, wp), trace, ErrStat, em2) @@ -5672,8 +5694,15 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: '//TRIM(em2); RETURN END IF curvature = MAX(curvature, trace) + IF (model%EI_line(e) == model%EI(e)) THEN + cable_moment = MAX(cable_moment, section_moment) + ELSE + cable_moment = MAX(cable_moment, model%EI_line(e)*trace) + END IF END IF END DO + bend_moment = cable_moment + IF (PRESENT(sleeve_moment)) sleeve_moment = MAX(CD_ZERO, section_moment - cable_moment) END SUBROUTINE node_values PURE FUNCTION unit_tangent(model, node) RESULT(t) @@ -6569,6 +6598,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) IF (ALLOCATED(model%l0)) DEALLOCATE (model%l0) IF (ALLOCATED(model%EA)) DEALLOCATE (model%EA) IF (ALLOCATED(model%EI)) DEALLOCATE (model%EI) + IF (ALLOCATED(model%EI_line)) DEALLOCATE (model%EI_line) IF (ALLOCATED(model%rho_a)) DEALLOCATE (model%rho_a) IF (ALLOCATED(model%w)) DEALLOCATE (model%w) IF (ALLOCATED(model%BA)) DEALLOCATE (model%BA) diff --git a/tests/check_bend_stiffener.py b/tests/check_bend_stiffener.py new file mode 100644 index 00000000..c1e077a1 --- /dev/null +++ b/tests/check_bend_stiffener.py @@ -0,0 +1,264 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Bend stiffener against the planar elastica (driver_bend_stiffener in CMakeLists.txt). + +A power cable leaves a hang-off clamped horizontal at End A through a 5 m polyurethane bend +stiffener (a 0.5 m cylindrical root and a 4.5 m cone) and hangs to a fixed End B 52 m away and +30 m lower. The driver solves the static equilibrium with the stiffener given as a STIFFENERS +table. The reference is an independent solution of the planar extensible elastica, + + x' = (1 + e) cos(theta), z' = (1 + e) sin(theta), theta' = M / EI(s), + M' = -(1 + e) (cos(theta) n_z - sin(theta) n_x), n' = (0, w(s)), + e = (n_x cos(theta) + n_z sin(theta)) / EA, + +with EI(s) the cable's EI plus E pi/64 (OD(s)^4 - ID^4) of the sleeve and w(s) the submerged +weight of cable and sleeve per unstretched length, solved by collocation (scipy solve_bvp) +with the clamped direction and position at End A, and the position and zero moment of the +pinned End B. Over the stiffener and the 3 m beyond it the cable's own bend moment (the +static profile's BendMoment, EI_cable kappa) must follow the reference within 2 % of its root +value, and the node positions within 1 cm; at the root and 2 m along, the cable's and the +stiffener's moments (BendMom1N + StfMom1N) must add up to the reference section moment +within 2 % of the root moment; and FairDefl1, the angle between the end force and the clamp +axis, must follow the reference within 0.05 deg. + +The curvature over the same 8 m must also follow OrcaFlex 11.6d, with the stiffener given as a +line attachment (tests/data/orcaflex_bend_stiffener_curvature.csv), within 1.5 % of the root +curvature; this part needs no scipy. + +The initialisation notes are checked too: none on this deck; the resolution note when the 5 m +stiffener spans 3 elements (2 m elements); the pinned-end note when End A has no END +CONNECTIONS row. + +Usage: check_bend_stiffener.py +Exit 77 (skipped) when scipy is not installed and the notes pass. +""" + +import math +import pathlib +import subprocess +import sys +import tempfile + +import numpy as np + +try: + from scipy.integrate import solve_bvp +except ImportError: # pragma: no cover - environment dependent + solve_bvp = None + +MOMENT_TOLERANCE = 0.02 +POSITION_TOLERANCE = 0.01 +ANGLE_TOLERANCE = 0.05 +ORCAFLEX_TOLERANCE = 0.015 +ORCAFLEX_CSV = pathlib.Path(__file__).resolve().parent / "data" / "orcaflex_bend_stiffener_curvature.csv" +WINDOW = 8.0 + +G = 9.80665 +RHO_W = 1025.0 +D_CABLE = 0.20 +M_CABLE = 60.0 +EA = 5.0e8 +EI_CABLE = 2.0e4 +LENGTH = 60.0 +END_B = (51.90, -30.0) +# root side arc, tip side arc, root OD, tip OD (outward from End A) +SEGMENTS = [(0.0, 0.5, 0.60, 0.60), (0.5, 5.0, 0.60, 0.22)] +ID_STF = 0.20 +E_STF = 5.0e7 +RHO_STF = 1150.0 + +DECK = f"""--------------------- CableDyn Input File ------------------------------------ +Bend stiffener check: hang-off clamped horizontal, static +--------------------- 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) (-) (-) (-) (-) +cable {D_CABLE} {M_CABLE} {EA} -1.0 {EI_CABLE} 1.2 0.0 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Coupled 0.0 0.0 -20.0 0 0 0 0 +2 Fixed {END_B[0]} 0.0 {-20.0 + END_B[1]} 0 0 0 0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 cable 8.0 160 +1 cable 52.0 52 +--------------------- STIFFENERS --------------------------------------------- +LineID End Length RootOD TipOD InnerD E Density +(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3) +""" + "".join( + f"1 A {s1 - s0} {od0} {od1} {ID_STF} {E_STF} {RHO_STF}\n" for s0, s1, od0, od1 in SEGMENTS +) + """--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ +(-) (-) (N-m/rad) (-) (-) (-) +1 A Rigid 1.0 0.0 0.0 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +0.05 dtM +0.05 TMax +--------------------- OUTPUTS ------------------------------------------------ +"FairTen1" +"FairDefl1" +"BendMom1N1" +"StfMom1N1" +"BendMom1N41" +"StfMom1N41" +END +""" + + +def outer_diameter(s: np.ndarray) -> np.ndarray: + od = np.full_like(s, np.nan) + for s0, s1, od0, od1 in SEGMENTS: + inside = (s >= s0) & (s <= s1) + od[inside] = od0 + (s[inside] - s0) / (s1 - s0) * (od1 - od0) + return od + + +def section(s: np.ndarray) -> tuple[np.ndarray, np.ndarray]: + """Bending stiffness and submerged weight per unstretched length at arc s from End A.""" + od = outer_diameter(s) + sleeve = ~np.isnan(od) + ei = np.full_like(s, EI_CABLE) + w = np.full_like(s, (M_CABLE - RHO_W * math.pi / 4.0 * D_CABLE**2) * G) + area = math.pi / 4.0 * (od[sleeve] ** 2 - ID_STF**2) + ei[sleeve] += E_STF * math.pi / 64.0 * (od[sleeve] ** 4 - ID_STF**4) + w[sleeve] += (RHO_STF - RHO_W) * area * G + return ei, w + + +FORCE_SCALE = 1.0e5 +MOMENT_SCALE = 1.0e4 + + +def reference(s_nodes: np.ndarray, x_seed: np.ndarray, z_seed: np.ndarray): + """Planar extensible elastica along the unstretched arc, y = (x, z, theta, M, n_x, n_z), with + the moment and the force scaled by MOMENT_SCALE and FORCE_SCALE. The seed is the shape only: + the driver's node positions; moment zero and a tension of FORCE_SCALE along the line.""" + + def rhs(s, y): + x, z, th, m, nx, nz = y + ei, w = section(s) + c, sn = np.cos(th), np.sin(th) + stretch = 1.0 + FORCE_SCALE * (nx * c + nz * sn) / EA + return np.vstack([stretch * c, stretch * sn, MOMENT_SCALE * m / ei, + -stretch * FORCE_SCALE / MOMENT_SCALE * (c * nz - sn * nx), + np.zeros_like(s), w / FORCE_SCALE]) + + def bc(ya, yb): + return np.array([ya[0], ya[1], ya[2], yb[0] - END_B[0], yb[1] - END_B[1], yb[3]]) + + # a dense start mesh: the collocation residual is met at 1e-4 without refinement, which + # would split the mesh at the steps of the sleeve's weight and stiffness at its tip + mesh = np.unique(np.round(np.concatenate([s_nodes, np.linspace(0.0, WINDOW, 1601), + np.linspace(0.0, LENGTH, 1201)]), 9)) + xs = np.interp(mesh, s_nodes, x_seed) + zs = np.interp(mesh, s_nodes, z_seed) + th = np.unwrap(np.arctan2(np.gradient(zs, mesh), np.gradient(xs, mesh))) + y0 = np.vstack([xs, zs, th, np.zeros_like(mesh), np.cos(th[-1]) * np.ones_like(mesh), np.sin(th)]) + sol = solve_bvp(rhs, bc, mesh, y0, tol=1.0e-4, max_nodes=50000) + if not sol.success: + raise RuntimeError(f"reference elastica did not converge: {sol.message}") + return sol + + +RESOLUTION_NOTE = "stiffener at End A spans" +PINNED_NOTE = "the stiffener at End A sleeves a pinned end" + + +def solve(exe: str, tmp: str, name: str, deck_text: str): + """Run the driver on a deck; return (exit code, stdout + stderr, static profile rows, the + output channels at t = 0 by name).""" + deck = pathlib.Path(tmp) / f"{name}.dat" + deck.write_text(deck_text) + root = str(pathlib.Path(tmp) / name) + run = subprocess.run([exe, str(deck), root], capture_output=True, text=True) + static = pathlib.Path(root + ".static.out") + rows = static.read_text().splitlines()[3:] if static.exists() else [] + channels = {} + series = pathlib.Path(root + ".out") + if series.exists(): + lines = series.read_text().splitlines() + channels = dict(zip(lines[1].split(), (float(v) for v in lines[2].split()))) + return run.returncode, run.stdout + run.stderr, rows, channels + + +def check_notes(exe: str, tmp: str, log: str) -> bool: + ok = RESOLUTION_NOTE not in log and PINNED_NOTE not in log + print(f"{'ok ' if ok else 'FAIL'} no stiffener note on the resolved, clamped deck") + coarse = DECK.replace("1 cable 8.0 160", "1 cable 8.0 4") + rc, out, _, _ = solve(exe, tmp, "coarse", coarse) + good = rc == 0 and RESOLUTION_NOTE in out and "spans 3 elements" in out + print(f"{'ok ' if good else 'FAIL'} resolution note with 2 m elements") + ok = ok and good + start = DECK.index("--------------------- END CONNECTIONS") + pinned = DECK[:start] + DECK[DECK.index("--------------------- OPTIONS"):] + # (the deflection angle needs a held end) + rc, out, _, _ = solve(exe, tmp, "pinned", pinned.replace('"FairDefl1"\n', "")) + good = rc == 0 and PINNED_NOTE in out + print(f"{'ok ' if good else 'FAIL'} pinned-end note without END CONNECTIONS") + return ok and good + + +def check_orcaflex(arc: np.ndarray, curvature: np.ndarray) -> bool: + """The curvature over the first WINDOW m against OrcaFlex 11.6d with its stiffener given as a + line attachment (tests/data/orcaflex_bend_stiffener_curvature.csv, from + validation/scripts/orcaflex_bend_stiffener.py), within ORCAFLEX_TOLERANCE of the root value.""" + table = np.loadtxt(ORCAFLEX_CSV, delimiter=",", comments="#", skiprows=2) + window = arc <= WINDOW + reference = np.interp(arc[window], table[:, 0], table[:, 1]) + error = np.max(np.abs(curvature[window] - reference)) / table[0, 1] + ok = error <= ORCAFLEX_TOLERANCE + print(f"{'ok ' if ok else 'FAIL'} curvature against OrcaFlex 11.6d: largest difference " + f"{100 * error:.2f} % of the root curvature {table[0, 1]:.4f} 1/m") + return ok + + +def main() -> int: + exe = sys.argv[1] + with tempfile.TemporaryDirectory() as tmp: + rc, log, rows, out = solve(exe, tmp, "stiffener", DECK) + if rc != 0: + print(log[-3000:]) + print("FAIL: the driver did not solve the stiffener deck") + return 1 + notes_ok = check_notes(exe, tmp, log) + data = np.array([[float(v) for v in r.split()[2:9]] for r in rows if r.strip()]) + orcaflex_ok = check_orcaflex(data[:, 0], data[:, 5]) + if solve_bvp is None: + print("SKIP: scipy is not installed (the elastica comparison needs solve_bvp)") + return 77 if notes_ok and orcaflex_ok else 1 + arc, x, z, moment = data[:, 0], data[:, 1], data[:, 3] + 20.0, data[:, 6] + s_nodes = np.cumsum(np.r_[0.0, np.full(160, 8.0 / 160), np.full(52, 1.0)]) + sol = reference(s_nodes, x, z) + ref = sol.sol(s_nodes) + ref[3] *= MOMENT_SCALE + section_moment = np.abs(ref[3]) + cable_moment = EI_CABLE * section_moment / section(s_nodes)[0] + window = s_nodes <= WINDOW + cable_error = np.max(np.abs(np.abs(moment[window]) - cable_moment[window])) / cable_moment[0] + position_error = np.max(np.hypot(x - ref[0], z - ref[1])) + print(f"root cable moment: driver {moment[0]:.1f} N m, elastica {cable_moment[0]:.1f} N m") + print(f"largest cable-moment difference over the first {WINDOW} m: {100 * cable_error:.2f} % of the root value") + print(f"largest node position difference: {1000 * position_error:.2f} mm") + total_error = 0.0 + for node in (1, 41): + total = out[f"BendMom1N{node}"] + out[f"StfMom1N{node}"] + total_error = max(total_error, abs(total - section_moment[node - 1]) / section_moment[0]) + print(f"node {node}: cable + stiffener {total:.1f} N m, elastica section moment {section_moment[node - 1]:.1f} N m") + end_force = sol.sol(np.array([0.0]))[4:6, 0] + deflection = math.degrees(math.atan2(abs(end_force[1]), end_force[0])) + angle_error = abs(out["FairDefl1"] - deflection) + print(f"FairDefl1: driver {out['FairDefl1']:.4f} deg, elastica {deflection:.4f} deg") + ok = (cable_error <= MOMENT_TOLERANCE and position_error <= POSITION_TOLERANCE and notes_ok + and total_error <= MOMENT_TOLERANCE and angle_error <= ANGLE_TOLERANCE and orcaflex_ok) + print("PASS" if ok else "FAIL") + return 0 if ok else 1 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/data/orcaflex_bend_stiffener_curvature.csv b/tests/data/orcaflex_bend_stiffener_curvature.csv new file mode 100644 index 00000000..82041792 --- /dev/null +++ b/tests/data/orcaflex_bend_stiffener_curvature.csv @@ -0,0 +1,163 @@ +# OrcFxAPI 11.6d static curvature along the hang-off (validation/scripts/orcaflex_bend_stiffener.py) +arc_m,curvature_per_m +0.000000,4.52202935e-01 +0.025000,4.42374765e-01 +0.075000,4.23063500e-01 +0.125000,4.04431762e-01 +0.175000,3.86458130e-01 +0.225000,3.69120886e-01 +0.275000,3.52398148e-01 +0.325000,3.36267975e-01 +0.375000,3.20708463e-01 +0.425000,3.05697832e-01 +0.475000,2.91214188e-01 +0.525000,2.80981913e-01 +0.575000,2.74616508e-01 +0.625000,2.68251090e-01 +0.675000,2.61890066e-01 +0.725000,2.55537806e-01 +0.775000,2.49198641e-01 +0.825000,2.42876863e-01 +0.875000,2.36576718e-01 +0.925000,2.30302408e-01 +0.975000,2.24058084e-01 +1.025000,2.17847846e-01 +1.075000,2.11675739e-01 +1.125000,2.05545752e-01 +1.175000,1.99461812e-01 +1.225000,1.93427784e-01 +1.275000,1.87447466e-01 +1.325000,1.81524586e-01 +1.375000,1.75662800e-01 +1.425000,1.69865690e-01 +1.475000,1.64136755e-01 +1.525000,1.58479413e-01 +1.575000,1.52896996e-01 +1.625000,1.47392744e-01 +1.675000,1.41969803e-01 +1.725000,1.36631219e-01 +1.775000,1.31379938e-01 +1.825000,1.26218795e-01 +1.875000,1.21150517e-01 +1.925000,1.16177711e-01 +1.975000,1.11302864e-01 +2.025000,1.06528339e-01 +2.075000,1.01856364e-01 +2.125000,9.72890354e-02 +2.175000,9.28283055e-02 +2.225000,8.84759825e-02 +2.275000,8.42337235e-02 +2.325000,8.01030302e-02 +2.375000,7.60852439e-02 +2.425000,7.21815410e-02 +2.475000,6.83929286e-02 +2.525000,6.47202403e-02 +2.575000,6.11641320e-02 +2.625000,5.77250786e-02 +2.675000,5.44033709e-02 +2.725000,5.11991123e-02 +2.775000,4.81122169e-02 +2.825000,4.51424075e-02 +2.875000,4.22892147e-02 +2.925000,3.95519762e-02 +2.975000,3.69298370e-02 +3.025000,3.44217505e-02 +3.075000,3.20264801e-02 +3.125000,2.97426016e-02 +3.175000,2.75685072e-02 +3.225000,2.55024093e-02 +3.275000,2.35423460e-02 +3.325000,2.16861872e-02 +3.375000,1.99316415e-02 +3.425000,1.82762645e-02 +3.475000,1.67174676e-02 +3.525000,1.52525274e-02 +3.575000,1.38785968e-02 +3.625000,1.25927159e-02 +3.675000,1.13918242e-02 +3.725000,1.02727733e-02 +3.775000,9.23234047e-03 +3.825000,8.26724185e-03 +3.875000,7.37414703e-03 +3.925000,6.54969332e-03 +3.975000,5.79050032e-03 +4.025000,5.09318450e-03 +4.075000,4.45437373e-03 +4.125000,3.87072148e-03 +4.175000,3.33892068e-03 +4.225000,2.85571710e-03 +4.275000,2.41792197e-03 +4.325000,2.02242392e-03 +4.375000,1.66619989e-03 +4.425000,1.34632515e-03 +4.475000,1.05998206e-03 +4.525000,8.04467736e-04 +4.575000,5.77200370e-04 +4.625000,3.75724273e-04 +4.675000,1.97713570e-04 +4.725000,4.09745402e-05 +4.775000,9.65533700e-05 +4.825000,2.16797819e-04 +4.875000,3.21555530e-04 +4.925000,4.12480920e-04 +4.975000,4.91672140e-04 +5.025000,6.05407857e-04 +5.075000,6.57380692e-04 +5.125000,7.00952817e-04 +5.175000,7.37483590e-04 +5.225000,7.68112385e-04 +5.275000,7.93794202e-04 +5.325000,8.15329500e-04 +5.375000,8.33389211e-04 +5.425000,8.48535698e-04 +5.475000,8.61240324e-04 +5.525000,8.71898179e-04 +5.575000,8.80840429e-04 +5.625000,8.88344649e-04 +5.675000,8.94643502e-04 +5.725000,8.99932005e-04 +5.775000,9.04373624e-04 +5.825000,9.08105373e-04 +5.875000,9.11242098e-04 +5.925000,9.13880065e-04 +5.975000,9.16099965e-04 +6.025000,9.17969431e-04 +6.075000,9.19545159e-04 +6.125000,9.20874668e-04 +6.175000,9.21997791e-04 +6.225000,9.22947919e-04 +6.275000,9.23753040e-04 +6.325000,9.24436612e-04 +6.375000,9.25018304e-04 +6.425000,9.25514600e-04 +6.475000,9.25939319e-04 +6.525000,9.26304046e-04 +6.575000,9.26618494e-04 +6.625000,9.26890805e-04 +6.675000,9.27127807e-04 +6.725000,9.27335224e-04 +6.775000,9.27517858e-04 +6.825000,9.27679737e-04 +6.875000,9.27824243e-04 +6.925000,9.27954213e-04 +6.975000,9.28072031e-04 +7.025000,9.28179701e-04 +7.075000,9.28278914e-04 +7.125000,9.28371095e-04 +7.175000,9.28457446e-04 +7.225000,9.28538991e-04 +7.275000,9.28616604e-04 +7.325000,9.28691036e-04 +7.375000,9.28762937e-04 +7.425000,9.28832879e-04 +7.475000,9.28901374e-04 +7.525000,9.28968886e-04 +7.575000,9.29035852e-04 +7.625000,9.29102688e-04 +7.675000,9.29169809e-04 +7.725000,9.29237639e-04 +7.775000,9.29306619e-04 +7.825000,9.29377234e-04 +7.875000,9.29450012e-04 +7.925000,9.29525554e-04 +7.975000,9.29604543e-04 diff --git a/tests/test_bend_stiffener.f90 b/tests/test_bend_stiffener.f90 new file mode 100644 index 00000000..f4fcc374 --- /dev/null +++ b/tests/test_bend_stiffener.f90 @@ -0,0 +1,334 @@ +! File: tests/test_bend_stiffener.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_bend_stiffener + !! Gates for bend stiffeners (STIFFENERS) on a finite-EI line: + !! 1. Element properties (CD_Stiffener_Overlay) against closed forms: a cylindrical sleeve + !! over half an element gives the compliance average of the bending stiffness, the mean + !! sleeve mass and the displaced-area diameter (the outer one when the bore is the + !! cable's); the same sleeve + !! at End B lands on the mirrored element; elements it does not reach are unchanged bit + !! for bit. + !! 2. A cone: the element values follow a 20 000-interval midpoint integration of the same + !! averages to 1e-10. + !! 3. Deck grammar: malformed rows, a stiffener on an EI = 0 line and stiffeners longer than + !! the line fail closed by name; on a stock-order LINES row the stiffener sleeves the same + !! physical end, and the static profile is the native deck's; StfMom on a line without a + !! stiffener and AnchDefl at a pinned end fail closed, FairDefl at the clamped end runs. + !! 4. Coupled route (the OpenFAST aggregate): the cable carries the stiffened root element, + !! and its initial fairlead load is the standalone static solve's. + !! The static equilibrium against the planar elastica is tests/check_bend_stiffener.py. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Stiffener_Overlay + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_End, CD_AGG_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + INTEGER :: nfail + nfail = 0 + + CALL case_cylinder() + CALL case_cone() + CALL case_grammar() + CALL case_coupled() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'test_bend_stiffener: ', nfail, ' check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'test_bend_stiffener: all checks passed' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(msg) + END IF + END SUBROUTINE require + + LOGICAL FUNCTION close_rel(a, b, tol) + REAL(wp), INTENT(IN) :: a, b, tol + close_rel = ABS(a - b) <= tol*MAX(ABS(a), ABS(b)) + END FUNCTION close_rel + + SUBROUTINE case_cylinder() + !! Four 1 m elements; a 1.5 m cylindrical sleeve (OD 0.5 m, ID 0.2 m) covers element 1 and + !! half of element 2 from End A (or from End B: elements 4 and 3). + REAL(wp), PARAMETER :: EI_C = 2.0e4_wp, M_C = 60.0_wp, D_C = 0.2_wp + REAL(wp), PARAMETER :: OD = 0.5_wp, ID = 0.2_wp, EMOD = 5.0e7_wp, RHO = 1150.0_wp + REAL(wp) :: stf(8, 1), l0(4), ei(4), mpl(4), dv(4), ei_s, ei_half, m_s + INTEGER :: iend, e_full, e_half, e_far(2) + l0 = 1.0_wp + ei_s = EMOD*PI/64.0_wp*(OD**4 - ID**4) + m_s = RHO*PI/4.0_wp*(OD**2 - ID**2) + ei_half = 1.0_wp/(0.5_wp/EI_C + 0.5_wp/(EI_C + ei_s)) + DO iend = 1, 2 + stf(:, 1) = [REAL(iend, wp), 0.0_wp, 1.5_wp, OD, OD, ID, EMOD, RHO] + ei = EI_C; mpl = M_C; dv = D_C + CALL CD_Stiffener_Overlay(stf, l0, dv, ei=ei, mpl=mpl) + IF (iend == 1) THEN + e_full = 1; e_half = 2; e_far = [3, 4] + ELSE + e_full = 4; e_half = 3; e_far = [1, 2] + END IF + CALL require(close_rel(ei(e_full), EI_C + ei_s, 1.0e-13_wp), 'cylinder: covered element EI') + CALL require(close_rel(ei(e_half), ei_half, 1.0e-13_wp), 'cylinder: half-covered element takes the '// & + 'compliance average') + CALL require(close_rel(mpl(e_full), M_C + m_s, 1.0e-13_wp), 'cylinder: covered element mass') + CALL require(close_rel(mpl(e_half), M_C + 0.5_wp*m_s, 1.0e-13_wp), 'cylinder: half-covered mass') + CALL require(close_rel(dv(e_full), SQRT(D_C**2 + OD**2 - ID**2), 1.0e-13_wp), & + 'cylinder: displaced-area diameter of cable plus solid sleeve') + CALL require(close_rel(dv(e_half), SQRT(D_C**2 + 0.5_wp*(OD**2 - ID**2)), 1.0e-13_wp), & + 'cylinder: half-covered displaced-area diameter') + CALL require(close_rel(dv(e_full), OD, 1.0e-13_wp), & + 'cylinder: with the bore equal to the cable diameter the diameter is the outer one') + CALL require(ALL(ei(e_far) == EI_C) .AND. ALL(mpl(e_far) == M_C) .AND. ALL(dv(e_far) == D_C), & + 'cylinder: elements the sleeve does not reach are unchanged') + ! an EI = 0 section: the covered element bends with the sleeve alone; the half-covered one + ! keeps EI = 0, its bare half having an infinite compliance + ei = 0.0_wp; mpl = M_C; dv = D_C + CALL CD_Stiffener_Overlay(stf, l0, dv, ei=ei, mpl=mpl) + CALL require(close_rel(ei(e_full), ei_s, 1.0e-13_wp), 'cylinder: covered EI = 0 element takes the sleeve') + CALL require(ei(e_half) == 0.0_wp, 'cylinder: half-covered EI = 0 element keeps EI = 0') + END DO + END SUBROUTINE case_cylinder + + SUBROUTINE case_cone() + !! A 2.5 m cone (OD 0.6 -> 0.22 m) from End A over five 0.7 m elements: the fourth element + !! (2.1 - 2.8 m) holds the cone's tip; the fifth is bare. + REAL(wp), PARAMETER :: EI_C = 2.0e4_wp, M_C = 60.0_wp, D_C = 0.2_wp + REAL(wp), PARAMETER :: OD0 = 0.6_wp, OD1 = 0.22_wp, ID = 0.2_wp, EMOD = 5.0e7_wp, RHO = 1150.0_wp + INTEGER, PARAMETER :: NQ = 20000 + REAL(wp) :: stf(8, 1), l0(5), ei(5), mpl(5), dv(5), a, s, od, comp, mass, area, h, tol + INTEGER :: e, k + l0 = 0.7_wp + stf(:, 1) = [1.0_wp, 0.0_wp, 2.5_wp, OD0, OD1, ID, EMOD, RHO] + ei = EI_C; mpl = M_C; dv = D_C + CALL CD_Stiffener_Overlay(stf, l0, dv, ei=ei, mpl=mpl) + DO e = 1, 4 + a = 0.7_wp*REAL(e - 1, wp) + h = 0.7_wp/REAL(NQ, wp) + comp = 0.0_wp; mass = 0.0_wp; area = 0.0_wp + DO k = 1, NQ + s = a + (REAL(k, wp) - 0.5_wp)*h + IF (s < 2.5_wp) THEN + od = OD0 + s/2.5_wp*(OD1 - OD0) + comp = comp + h/(EI_C + EMOD*PI/64.0_wp*(od**4 - ID**4)) + mass = mass + h*RHO*PI/4.0_wp*(od**2 - ID**2) + area = area + h*(od**2 - ID**2) + ELSE + comp = comp + h/EI_C + END IF + END DO + ! the cone tip inside element 4 limits the midpoint rule there to O(h/l) = 5e-5 + tol = MERGE(2.0e-4_wp, 1.0e-6_wp, e == 4) + CALL require(close_rel(ei(e), 0.7_wp/comp, tol), 'cone: compliance-average EI of element') + CALL require(close_rel(mpl(e), M_C + mass/0.7_wp, tol), 'cone: mean mass of element') + CALL require(close_rel(dv(e), SQRT(D_C**2 + area/0.7_wp), tol), 'cone: displaced-area diameter') + IF (e < 4) CALL require(close_rel(ei(e), 0.7_wp/comp, 1.0e-10_wp), & + 'cone: Gauss average matches the fine integration inside the cone') + END DO + CALL require(ei(5) == EI_C .AND. mpl(5) == M_C .AND. dv(5) == D_C, & + 'cone: bare elements unchanged') + END SUBROUTINE case_cone + + SUBROUTINE write_deck(path, stiffener_rows, ei, stock, channel) + !! A 60 m cable clamped horizontal at a 20 m deep hang-off and fixed 30 m lower; stock: the + !! 7-column LINES row written anchor first, so the parser swaps the ends. + CHARACTER(*), INTENT(IN) :: path + CHARACTER(*), INTENT(IN) :: stiffener_rows(:) + REAL(wp), INTENT(IN) :: ei + LOGICAL, INTENT(IN) :: stock + CHARACTER(*), INTENT(IN), OPTIONAL :: channel + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'Bend stiffener test deck' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-)' + WRITE (u, '(A,ES12.4,A)') 'cable 0.20 60.0 5.0e8 -1.0 ', ei, ' 1.2 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) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 51.90 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--------------------- LINES --------------------------------------------------' + IF (stock) THEN + WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-) (m) (-) (-)' + WRITE (u, '(A)') '1 cable 2 1 60.0 120 -' + ELSE + 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 cable 60.0 120' + END IF + IF (SIZE(stiffener_rows) > 0) THEN + WRITE (u, '(A)') '--------------------- STIFFENERS ---------------------------------------------' + WRITE (u, '(A)') 'LineID End Length RootOD TipOD InnerD E Density' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (m) (Pa) (kg/m^3)' + DO k = 1, SIZE(stiffener_rows) + WRITE (u, '(A)') TRIM(stiffener_rows(k)) + END DO + END IF + IF (ei > 0.0_wp) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + IF (stock) THEN + WRITE (u, '(A)') '1 B Rigid -1.0 0.0 0.0' + ELSE + WRITE (u, '(A)') '1 A Rigid 1.0 0.0 0.0' + END IF + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') '"FairTen1"' + IF (PRESENT(channel)) WRITE (u, '(A)') '"'//channel//'"' + WRITE (u, '(A)') 'END' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run(deck, root, ok, msg) + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: msg + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(deck, root, conv, es, msg) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run + + SUBROUTINE read_static(path, prof, n) + !! Columns 3-9 of a .static.out (arc, X, Y, Z, tension, curvature, moment), node by node. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: prof(:, :) + INTEGER, INTENT(OUT) :: n + CHARACTER(1024) :: rec + INTEGER :: u, ios, idum(2) + ALLOCATE (prof(7, 2000)) + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)') rec + READ (u, '(A)') rec + READ (u, '(A)') rec + DO + READ (u, '(A)', IOSTAT=ios) rec + IF (ios /= 0) EXIT + IF (LEN_TRIM(rec) == 0) CYCLE + n = n + 1 + READ (rec, *) idum, prof(:, n) + END DO + CLOSE (u) + END SUBROUTINE read_static + + SUBROUTINE case_grammar() + CHARACTER(80) :: rows(2), none(0) + CHARACTER(512) :: msg + LOGICAL :: ok + REAL(wp), ALLOCATABLE :: pa(:, :), pb(:, :) + INTEGER :: na, nb + rows(1) = '1 A 0.5 0.60 0.60 0.20 5.0e7 1150' + rows(2) = '1 A 4.5 0.60 0.22 0.20 5.0e7 1150' + CALL write_deck('stf_native.dat', rows, 2.0e4_wp, .FALSE.) + CALL run('stf_native.dat', 'stf_native', ok, msg) + CALL require(ok, 'grammar: native deck solves: '//TRIM(msg)) + ! stock order: the deck's End B is the hang-off; the stiffener sleeves the same physical end + rows(1) = '1 B 0.5 0.60 0.60 0.20 5.0e7 1150' + rows(2) = '1 B 4.5 0.60 0.22 0.20 5.0e7 1150' + CALL write_deck('stf_stock.dat', rows, 2.0e4_wp, .TRUE.) + CALL run('stf_stock.dat', 'stf_stock', ok, msg) + CALL require(ok, 'grammar: stock-order deck solves: '//TRIM(msg)) + CALL read_static('stf_native.static.out', pa, na) + CALL read_static('stf_stock.static.out', pb, nb) + CALL require(na == nb .AND. na > 0, 'grammar: both decks write a static profile') + IF (na == nb .AND. na > 0) THEN + CALL require(MAXVAL(ABS(pa(2:4, :na) - pb(2:4, :nb))) < 1.0e-6_wp .AND. & + MAXVAL(ABS(pa(7, :na) - pb(7, :nb))) < 1.0e-6_wp*MAXVAL(ABS(pa(7, :na))), & + 'grammar: on a stock-order row the stiffener sleeves the same physical end') + END IF + rows(1) = '1 A 0.5 0.60 0.60 0.20 5.0e7' + CALL write_deck('stf_bad0.dat', rows(1:1), 2.0e4_wp, .FALSE.) + CALL run('stf_bad0.dat', 'stf_bad0', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'LineID End Length') > 0, 'grammar: a seven-column row: '//TRIM(msg)) + rows(1) = '1 C 0.5 0.60 0.60 0.20 5.0e7 1150' + CALL write_deck('stf_bad1.dat', rows(1:1), 2.0e4_wp, .FALSE.) + CALL run('stf_bad1.dat', 'stf_bad1', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'End must be A or B') > 0, 'grammar: an unknown end: '//TRIM(msg)) + rows(1) = '1 A 0.5 0.60 0.60 0.70 5.0e7 1150' + CALL write_deck('stf_bad2.dat', rows(1:1), 2.0e4_wp, .FALSE.) + CALL run('stf_bad2.dat', 'stf_bad2', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'InnerD must be smaller') > 0, 'grammar: InnerD above OD: '//TRIM(msg)) + rows(1) = '1 A 0.5 0.60 0.60 0.20 0.0 1150' + CALL write_deck('stf_bad3.dat', rows(1:1), 2.0e4_wp, .FALSE.) + CALL run('stf_bad3.dat', 'stf_bad3', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'must be > 0') > 0, 'grammar: a zero modulus: '//TRIM(msg)) + rows(1) = '2 A 0.5 0.60 0.60 0.20 5.0e7 1150' + CALL write_deck('stf_bad4.dat', rows(1:1), 2.0e4_wp, .FALSE.) + CALL run('stf_bad4.dat', 'stf_bad4', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'undefined LINE') > 0, 'grammar: an unknown line: '//TRIM(msg)) + rows(1) = '1 A 40.0 0.60 0.60 0.20 5.0e7 1150' + rows(2) = '1 B 25.0 0.60 0.60 0.20 5.0e7 1150' + CALL write_deck('stf_bad5.dat', rows, 2.0e4_wp, .FALSE.) + CALL run('stf_bad5.dat', 'stf_bad5', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'longer than the line') > 0, 'grammar: stiffeners overlap: '//TRIM(msg)) + rows(1) = '1 A 0.5 0.60 0.60 0.20 5.0e7 1150' + CALL write_deck('stf_bad6.dat', rows(1:1), 0.0_wp, .FALSE.) + CALL run('stf_bad6.dat', 'stf_bad6', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'not a finite-EI line') > 0, 'grammar: an EI = 0 line: '//TRIM(msg)) + ! no STIFFENERS table: the same deck still solves (the table is optional) + CALL write_deck('stf_none.dat', none, 2.0e4_wp, .FALSE.) + CALL run('stf_none.dat', 'stf_none', ok, msg) + CALL require(ok, 'grammar: the deck without stiffeners solves: '//TRIM(msg)) + ! the stiffener moment needs a stiffener; the deflection angle a held end + CALL write_deck('stf_ch1.dat', none, 2.0e4_wp, .FALSE., channel='StfMom1N3') + CALL run('stf_ch1.dat', 'stf_ch1', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'has no STIFFENERS') > 0, 'grammar: StfMom without a stiffener: '//TRIM(msg)) + rows(1) = '1 A 0.5 0.60 0.60 0.20 5.0e7 1150' + CALL write_deck('stf_ch2.dat', rows(1:1), 2.0e4_wp, .FALSE., channel='AnchDefl1') + CALL run('stf_ch2.dat', 'stf_ch2', ok, msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'END CONNECTIONS row at End B') > 0, & + 'grammar: AnchDefl at a pinned End B: '//TRIM(msg)) + CALL write_deck('stf_ch3.dat', rows(1:1), 2.0e4_wp, .FALSE., channel='FairDefl1') + CALL run('stf_ch3.dat', 'stf_ch3', ok, msg) + CALL require(ok, 'grammar: FairDefl at the clamped End A: '//TRIM(msg)) + END SUBROUTINE case_grammar + + SUBROUTINE case_coupled() + !! The native deck of case_grammar on the coupled route: its root element, wholly inside the + !! 0.5 m cylindrical root (OD 0.6 m, ID 0.2 m), has EI_c + E pi/64 (OD^4 - ID^4), and the + !! initial fairlead load matches the standalone static fairlead tension. + TYPE(CD_AGG_ModuleType), SAVE :: agg + REAL(wp), PARAMETER :: EI_ROOT = 2.0e4_wp + 5.0e7_wp*PI/64.0_wp*(0.6_wp**4 - 0.2_wp**4) + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), load(3, 1) + REAL(wp), ALLOCATABLE :: prof(:, :) + CHARACTER(512) :: em + INTEGER :: es, ne, n + CALL CD_AGG_Init_From_Deck(agg, 'stf_native.dat', 0.05_wp, es, em) + CALL require(es == CD_AGG_OK, 'coupled: the stiffener deck initializes: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ! internal element order runs from End B: the root element at End A is the last + ne = SIZE(agg%cables(1)%line%EI) + CALL require(close_rel(agg%cables(1)%line%EI(ne), EI_ROOT, 1.0e-12_wp), & + 'coupled: the root element carries the stiffener') + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, load, es, em) + CALL read_static('stf_native.static.out', prof, n) + IF (n > 0) CALL require(close_rel(NORM2(load(:, 1)), prof(5, 1), 1.0e-6_wp), & + 'coupled: the initial fairlead load is the standalone static tension') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_coupled + +END PROGRAM test_bend_stiffener diff --git a/validation/scripts/orcaflex_bend_stiffener.py b/validation/scripts/orcaflex_bend_stiffener.py new file mode 100644 index 00000000..99d9fa3a --- /dev/null +++ b/validation/scripts/orcaflex_bend_stiffener.py @@ -0,0 +1,101 @@ +# File: validation/scripts/orcaflex_bend_stiffener.py +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""OrcaFlex static reference for a hang-off clamped through a tapered bend stiffener. + +Provenance tool (NOT built by CMake): regenerates +`tests/data/orcaflex_bend_stiffener_curvature.csv`, the OrcaFlex column of the +`driver_bend_stiffener` check (tests/check_bend_stiffener.py) and of the L3-7 row of +VALIDATION.md. The problem is the check's deck: a 60 m power cable (OD 0.20 m, 60 kg/m, +EA 500 MN, EI 20 kN.m^2) clamped horizontal at (0, 0, -20) m and fixed (pinned) at +(51.9, 0, -50) m, in still water 100 m deep, through a 5 m polyurethane stiffener at End A: a +0.5 m cylinder of 0.60 m outer diameter and a 4.5 m cone to 0.22 m, bored to 0.20 m +(E 50 MPa, 1150 kg/m^3). + +In OrcaFlex the stiffener is a line attachment (Stiffener type) whose line type is a +homogeneous pipe of that material, with its outer diameter given as a line-type-diameter +profile; the attachment and the cable bend together. The cable is meshed at 0.05 m over its +first 8 m and 1 m beyond, as in the check. The CSV holds the static curvature of the cable +along its first 8 m (arc from End A, curvature in 1/m). + +Result (OrcFxAPI 11.6d): root curvature 0.4522 /m (CableDyn 0.4523), cable bend moment at the +root 9.04 kN.m; CableDyn's curvature follows the profile within 0.8 % of the root curvature. +OrcaFlex SI (m, te, kN). + +Usage: python validation/scripts/orcaflex_bend_stiffener.py [output.csv] +""" + +import pathlib +import sys + +import OrcFxAPI as ofx + +ROOT = pathlib.Path(__file__).resolve().parents[2] +OUTPUT = ROOT / "tests" / "data" / "orcaflex_bend_stiffener_curvature.csv" +WINDOW = 8.0 + + +def build() -> tuple[ofx.Model, ofx.OrcaFlexObject]: + m = ofx.Model() + m.environment.WaterDepth = 100.0 + m.environment.Density = 1.025 + profile = m.CreateObject(ofx.otLineTypeDiameter, "StiffenerOD") + profile.SetDataRowCount("IndependentValue", 3) + for i, (arc, od) in enumerate([(0.0, 0.60), (0.5, 0.60), (5.0, 0.22)]): + profile.SetData("IndependentValue", i, arc) + profile.SetData("DependentValue", i, od) + cable = m.CreateObject(ofx.otLineType, "cable") + cable.OD, cable.ID = 0.20, 0.0 + cable.MassPerUnitLength = 0.060 + cable.EIx = 20.0 + cable.EA = 5.0e5 + sleeve = m.CreateObject(ofx.otLineType, "stiffener material") + sleeve.Category = "Homogeneous pipe" + sleeve.OD = "StiffenerOD" + sleeve.ID = 0.20 + sleeve.E = 5.0e4 # kPa + sleeve.MaterialDensity = 1.15 + stiffener = m.CreateObject(ofx.otStiffenerType, "stiffener") + stiffener.LineType = "stiffener material" # its length (5 m) follows the diameter profile + line = m.CreateObject(ofx.otLine, "hangoff") + line.EndAConnection, line.EndBConnection = "Fixed", "Fixed" + line.EndAX, line.EndAY, line.EndAZ = 0.0, 0.0, -20.0 + line.EndBX, line.EndBY, line.EndBZ = 51.90, 0.0, -50.0 + line.EndAAzimuth, line.EndADeclination = 0.0, 90.0 + line.EndAxBendingStiffness = ofx.OrcinaInfinity() + line.EndBxBendingStiffness = 0.0 + line.NumberOfSections = 2 + line.LineType = ("cable", "cable") + line.Length = (8.0, 52.0) + line.TargetSegmentLength = (0.05, 1.0) + line.NumberOfAttachments = 1 + line.AttachmentType = ("stiffener",) + line.Attachmentz = (0.0,) + line.AttachmentzRelativeTo = ("End A",) + return m, line + + +def main() -> int: + output = pathlib.Path(sys.argv[1]) if len(sys.argv) > 1 else OUTPUT + m, line = build() + m.CalculateStatics() + curvature = line.RangeGraph("Curvature", ofx.pnStaticState) + moment = line.RangeGraph("Bend moment", ofx.pnStaticState) + rows = [ + (arc, k) + for arc, k in zip(curvature.X, curvature.Mean) + if arc <= WINDOW + 1.0e-9 + ] + with output.open("w", encoding="utf-8", newline="\n") as handle: + handle.write("# OrcFxAPI 11.6d static curvature along the hang-off (validation/scripts/" + "orcaflex_bend_stiffener.py)\n") + handle.write("arc_m,curvature_per_m\n") + for arc, k in rows: + handle.write(f"{arc:.6f},{k:.8e}\n") + print(f"root curvature {curvature.Mean[0]:.5f} /m, cable bend moment {moment.Mean[0]:.3f} kN.m") + print(f"wrote {len(rows)} rows to {output}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) From d855f9e001481cfc07fd191ec47bf61fa24b0f6e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 26 Oct 2026 19:01:51 +0900 Subject: [PATCH 02/51] fix(statics): converge weightless taut finite-EI lines (#51) * fix(statics): converge weightless taut finite-EI lines The Hermite static solve judges convergence by the residual relative to a force scale: the line's total submerged weight, with a 1 N floor. A weightless or near-neutral taut line (a neutrally buoyant cable, a tendon) carries tension far above its weight, and the round-off of its axial forces EA (|r'| - 1) then lies far above tol x scale: a neutrally buoyant 60 m cable at 61 kN stopped at ||R|| 1e-4 N against a 1e-6 N test and failed every static route, even lying straight along its chord. A taut line, its ends farther apart than its length L, carries at least (chord/L - 1) times its series axial stiffness whatever its weight; the force scale now includes that tension. A slack line (chord <= L) keeps its weight scale, so every such solve is unchanged: all 99 example output files are identical to dev. The weightless cable clamped 30 deg off its chord now converges and follows an independent solution of the planar elastica within 0.14 % (root moment) and 0.07 % (end tension). Signed-off-by: Jae Hoon Seo * fix(statics): use the chord tension only with both ends held The taut-chord tension is a lower bound on the line's tension only while the solve holds both end positions. With an end free to move (a cantilever) the seed's chord implies no tension at equilibrium, and an overstretched seed set a force scale that the solve never revised: a cantilever with EA 1e12 N seeded 1 % long took a 1e10 N scale and read its 1000 N weight as converged before bending. The bound now applies only when the end positions are both fixed; such a cantilever reaches the beam deflection w L^4/(8 EI) from either seed. Signed-off-by: Jae Hoon Seo * fix(statics): skip the chord tension with an EA = 0 element EA = 0 is a valid element input, and the series compliance sum(l0/EA) divided by zero on a held taut seed. An element without axial stiffness leaves the series stiffness, and so the tension bound, at zero: the bound is skipped. The static test checks that no division by zero is raised. Signed-off-by: Jae Hoon Seo --------- Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 7 +++ src/CableDyn_HermiteCableStatic.f90 | 17 ++++++- tests/test_hermite_cable_static.f90 | 75 ++++++++++++++++++++++++++++- 3 files changed, 97 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 41a39e8e..7a298876 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,13 @@ All notable changes to CableDyn are recorded in this file. The format follows range graphs and element file) report the cable's own moment, the line type's EI times the curvature; lines without stiffeners are unchanged. +### Fixed + +- A weightless or near-neutral taut finite-EI line (a neutrally buoyant cable, a tendon) failed + its static solve, even straight along its chord: the convergence test scaled the residual by + the line's weight alone, far below the round-off of its axial forces. A taut line's scale now + includes the tension its stretched chord implies; slack lines are unchanged. + ## [0.3.0] - 2026-10-23 ### Added diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 687b3541..ee3a8387 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -467,7 +467,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ TYPE(CD_HermiteTorsionType), INTENT(INOUT), OPTIONAL :: torsion INTEGER :: ne, nn, ndof, c, it, es, i, b, nci, n_buoy, omp_threads, axial_order, bending_order - REAL(wp) :: eifac, rnorm, fscale, bfac, rmerit, ptc_tau, ptc_rprev, pi_total, pi_abs, lm_mu + REAL(wp) :: eifac, rnorm, fscale, bfac, rmerit, ptc_tau, ptc_rprev, pi_total, pi_abs, lm_mu, chord REAL(wp), ALLOCATABLE :: q(:), trib(:), w_cur(:), q_base(:) REAL(wp) :: endconn_k(2), endconn_d0(3, 2), direction_norm REAL(wp) :: rigid_basis(3, 3, 2), projected_tangent(3) @@ -892,6 +892,21 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ fscale = MAX(fscale, MAXVAL(ABS(f_nodal(6*(i - 1) + 4:6*(i - 1) + 6)))/trib(i)) END DO END IF + ! The tension a taut line must carry: with its ends farther apart than its length L, a line + ! is stretched by at least chord/L - 1 over its series axial stiffness, so it carries at + ! least that force whatever its weight. A line that carries little weight for its tension + ! -- a weightless or near-neutral taut line, a tendon -- otherwise had a weight scale far + ! below the round-off of its axial forces (EA (|r'| - 1) is formed from coordinate + ! differences), and Newton stagnated at the round-off floor of an equilibrium it had + ! reached: a neutrally buoyant 60 m cable at 61 kN stopped at ||R|| 1e-4 N against tol x + ! 1 N. A slack line (chord <= L) keeps its weight scale. The bound holds only while the + ! solve holds both end positions, which keeps the chord; with an end free to move (a + ! cantilever) the seed's chord implies no tension at equilibrium. An element without axial + ! stiffness (EA = 0) leaves the series stiffness, and so the bound, at zero. + IF (.NOT. (ANY(freemask(1:3)) .OR. ANY(freemask(6*(nn - 1) + 1:6*(nn - 1) + 3))) .AND. ALL(EA > CD_ZERO)) THEN + chord = NORM2(q(6*(nn - 1) + 1:6*(nn - 1) + 3) - q(1:3)) + IF (chord > SUM(l0)) fscale = MAX(fscale, (chord/SUM(l0) - CD_ONE)*SUM(l0)/SUM(l0/EA)) + END IF ! Buoyancy load continuation. A net-buoyant section (w < 0, e.g. a lazy-wave buoyancy ! module) makes the equilibrium non-unique: alongside the smooth buoyant arch there are diff --git a/tests/test_hermite_cable_static.f90 b/tests/test_hermite_cable_static.f90 index 0dd1b2a5..d3d4aae8 100644 --- a/tests/test_hermite_cable_static.f90 +++ b/tests/test_hermite_cable_static.f90 @@ -25,7 +25,8 @@ PROGRAM test_hermite_cable_static USE CableDyn_Line, ONLY: CD_Nodal_Seabed_Stiffness, CD_LINE_OK USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE - USE, INTRINSIC :: IEEE_EXCEPTIONS, ONLY: IEEE_USUAL, IEEE_GET_HALTING_MODE, IEEE_SET_HALTING_MODE, IEEE_SET_FLAG + USE, INTRINSIC :: IEEE_EXCEPTIONS, ONLY: IEEE_USUAL, IEEE_GET_HALTING_MODE, IEEE_SET_HALTING_MODE, IEEE_SET_FLAG, & + IEEE_GET_FLAG, IEEE_DIVIDE_BY_ZERO IMPLICIT NONE LOGICAL :: fp_halt(3) ! saved IEEE halting modes around deliberately non-finite inputs @@ -42,6 +43,7 @@ PROGRAM test_hermite_cable_static CALL check_seabed_mesh_jump() CALL check_scalar_contact_on_slope() CALL check_taut_line_anchored_on_floor() + CALL check_weightless_taut_line() CALL check_laid_line_node_recovery() CALL check_end_support_energy_gradient() CALL check_frictionless_slope_run() @@ -314,6 +316,77 @@ SUBROUTINE check_seabed_mesh_jump() CALL require(dev < 0.1_wp*pen0, 'mesh-jump penetration stays near w/(kBot d)') END SUBROUTINE check_seabed_mesh_jump + SUBROUTINE check_weightless_taut_line() + !! A weightless taut line converges. The relative residual took its force scale from the + !! line's weight alone (1 N floor), far below the round-off of the 61 kN axial force of a + !! stiff line (EA 5e8 N), and Newton stagnated at ||R|| ~ 1e-4 N of an equilibrium it had + !! reached. A 60 m line stretched over a 60.0073 m chord on 212 elements (0.05 m over its + !! first 8 m) must converge straight, with the axial strain of the chord, C/L - 1. + INTEGER, PARAMETER :: NA = 160, NB = 52, NE = NA + NB, NN = NE + 1 + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), q(6*NN), curv(NN), res, chord(3), s, stretch + LOGICAL :: divided + INTEGER :: fixed(6), i, es, it + CHARACTER(512) :: em + l0(1:NA) = 8.0_wp/NA; l0(NA + 1:) = 1.0_wp + EA = 5.0e8_wp; EI = 2.0e4_wp; w = 0.0_wp + chord = [51.97_wp, 0.0_wp, -30.0_wp] + ! a straight seed along the chord, unit tangents + s = 0.0_wp + DO i = 1, NN + IF (i > 1) s = s + l0(i - 1) + seed(6*(i - 1) + 1:6*(i - 1) + 3) = chord*s/60.0_wp + seed(6*(i - 1) + 4:6*(i - 1) + 6) = chord/NORM2(chord) + END DO + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed, -1.0e4_wp, 0.0_wp, 4, 200, 1.0e-6_wp, & + 1.0_wp, q, curv, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'weightless taut line converges: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) RETURN + stretch = NORM2(q(6*(NE/2) + 4:6*(NE/2) + 6)) + CALL require(ABS(stretch - NORM2(chord)/60.0_wp) <= 1.0e-9_wp, 'weightless taut line takes the chord strain') + CALL require(MAXVAL(ABS(curv)) <= 1.0e-8_wp, 'weightless taut line stays straight') + CALL check_free_end_preload() + ! An element with EA = 0 (a valid input) leaves the series stiffness at zero: the bound is + ! skipped, not computed as l0/EA (no division by zero on a held taut seed). + EA(NA + 1) = 0.0_wp + CALL IEEE_SET_FLAG(IEEE_DIVIDE_BY_ZERO, .FALSE.) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed, -1.0e4_wp, 0.0_wp, 1, 1, 1.0e-6_wp, & + 1.0_wp, q, curv, res, it, es, em) + CALL IEEE_GET_FLAG(IEEE_DIVIDE_BY_ZERO, divided) + CALL require(.NOT. divided, 'a held taut line with an EA = 0 element raises no division by zero') + END SUBROUTINE check_weightless_taut_line + + SUBROUTINE check_free_end_preload() + !! The taut-chord tension enters the force scale only while both end positions are held. A + !! cantilever (clamped End A, free End B; EA 1e12 N, EI 1e8 N m^2, 100 N/m over 10 m) seeded + !! 1 % overstretched would otherwise take a 1e10 N scale from its seed, and its 1000 N weight + !! would read as converged before the line bent; it must reach the beam deflection + !! w L^4/(8 EI) = 1.25 mm, as from an unstretched seed. + INTEGER, PARAMETER :: NE = 10, NN = NE + 1 + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed_a(6*NN), seed_b(6*NN), qa(6*NN), qb(6*NN), curv(NN), res + REAL(wp) :: tip + INTEGER :: i, es, it + CHARACTER(512) :: em + l0 = 1.0_wp; EA = 1.0e12_wp; EI = 1.0e8_wp; w = 100.0_wp + tip = 100.0_wp*10.0_wp**4/(8.0_wp*1.0e8_wp) + seed_a = 0.0_wp; seed_b = 0.0_wp + DO i = 1, NN + seed_a(6*(i - 1) + 1) = REAL(i - 1, wp) + seed_b(6*(i - 1) + 1) = 1.01_wp*REAL(i - 1, wp) + seed_a(6*(i - 1) + 4) = 1.0_wp + seed_b(6*(i - 1) + 4) = 1.0_wp + END DO + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed_a, [1, 2, 3, 4, 5, 6], -1.0e4_wp, 0.0_wp, 4, 200, & + 1.0e-6_wp, 1.0_wp, qa, curv, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'cantilever from an unstretched seed converges: '//TRIM(em)) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed_b, [1, 2, 3, 4, 5, 6], -1.0e4_wp, 0.0_wp, 4, 200, & + 1.0e-6_wp, 1.0_wp, qb, curv, res, it, es, em) + CALL require(es == CD_HCSTAT_OK, 'cantilever from an overstretched seed converges: '//TRIM(em)) + CALL require(ABS(-qa(6*NE + 3) - tip) <= 1.0e-3_wp*tip, 'cantilever from an unstretched seed: w L^4/(8 EI)') + CALL require(ABS(-qb(6*NE + 3) - tip) <= 1.0e-3_wp*tip, & + 'cantilever from an overstretched seed: w L^4/(8 EI) (no seed preload in the force scale)') + END SUBROUTINE check_free_end_preload + SUBROUTINE check_taut_line_anchored_on_floor() !! The floor carries the end element's weight moment only where the element lies on it. !! A taut line anchored on the floor rises into the water from its anchor: its end element From 6b9fac443ee0f571e08db2669fde2fdc5da39516 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 26 Oct 2026 21:32:11 +0900 Subject: [PATCH 03/51] fix(outputs): keep the down-slope pull in a grounded finite-EI end force (#52) A finite-EI end resting on the seabed left the downward part of its end force to the floor (force(3) = MAX(force(3), 0)), a rule from before bathymetry: on a flat floor that part is the end node's weight, but on a slope it also holds the line's own pull. A cable laid down a 10 deg slope from its anchor reported AnchTen 1.5 % low (cos 10 deg of the tension) and AnchFz = Point

Fz = 0 instead of -1.5 kN. The floor now takes the part of the end force pressing into it along its upward normal, the old rule on a flat floor, so the anchor keeps the line's along-floor pull. On a frictional seabed it also holds the along-floor part of the end node's own weight, up to mu times that normal load. On the 10 deg slope the anchor force runs 10.00 deg below horizontal and AnchTen continues the line tension to 0.1 N. Flat seabeds are unchanged: all 52 example decks write identical outputs. The cross-slope as-laid friction test now bounds the lateral anchor force in the plane of the floor (203 N, below the 415 N of a reference without the sink offset): the pull of the run sunk into the penalty seabed, along the slope's normal, goes to the floor instead of adding its lateral part. Found by the statics robustness campaign (sloped-seabed lazy wave, BALANCE 6 %). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 +++ doc/outputs.rst | 11 +++-- src/CableDyn_HermiteCableDynamic.f90 | 29 +++++++++---- tests/test_anchor_uplift.py | 59 +++++++++++++++++++++++++++ tests/test_static_friction_as_laid.py | 32 ++++++++++----- 5 files changed, 116 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a298876..f78f9db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,12 @@ All notable changes to CableDyn are recorded in this file. The format follows its static solve, even straight along its chord: the convergence test scaled the residual by the line's weight alone, far below the round-off of its axial forces. A taut line's scale now includes the tension its stretched chord implies; slack lines are unchanged. +- The anchor force of a finite-EI line resting on a sloped seabed (`bathymetryFile`). The floor + took the whole downward part of the end force, so a cable laid down the slope from its anchor + lost the down-slope pull: on a 10° slope `AnchTen` read 1.5 % low and `AnchFz`/`Point

Fz` + read 0. The floor now takes only the part pressing into it along its normal, and on a + frictional seabed the along-floor part of the end node's weight up to the friction it can + hold; flat seabeds are unchanged. ## [0.3.0] - 2026-10-23 diff --git a/doc/outputs.rst b/doc/outputs.rst index cfe4e6f2..2bc94bca 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -610,9 +610,14 @@ In :doc:`tutorial_catenary` (:math:`w` = 3.18 kN/m, :math:`\Delta L` = 10 m, :math:`\delta` = 0.13 m) this estimate is −18.4 kN, and the run reports ``AnchFz1`` = −18.2 kN beside ``AnchFH1`` = 191.5 kN (the horizontal tension) and ``AnchTen1`` = 192.4 kN. The share belongs to the lumped anchor node: it scales with the anchor segment length, vanishes as the mesh -is refined, and is not uplift. A finite-EI (cubic-Hermite) end resting on the seabed leaves its -end node's weight to the floor and reads ``AnchFz`` = 0 there. Read the vertical anchor load from -``AnchFz``, not from the difference between ``AnchTen`` and ``AnchFH``. +is refined, and is not uplift. A finite-EI (cubic-Hermite) end resting on the seabed leaves the +part of its end force pressing into the floor (along the floor normal) to the floor: on a flat +seabed that is the end node's weight, and ``AnchFz`` reads 0 there. On a sloped seabed +(``bathymetryFile``) the anchor keeps the line's along-floor pull, so a line laid down the slope +from its anchor reads a negative ``AnchFz``, the down-slope component of its tension; on a +frictional seabed (``frictionMu``) the floor also holds the along-floor part of the end node's +own weight, up to the friction coefficient times that normal load. Read the vertical anchor load +from ``AnchFz``, not from the difference between ``AnchTen`` and ``AnchFH``. Line-node channels ~~~~~~~~~~~~~~~~~~ diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 05df1ccb..60bcb3ad 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -5297,13 +5297,13 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) REAL(wp), PARAMETER :: PI_L = 3.14159265358979323846_wp REAL(wp) :: qe(12), ve(12), fe(12), fdrag(12), fdamp(12), energy, fdry(4), kdry(4, 4), r3(3), gate, gate_gap REAL(wp) :: dry_wl, dry_b, dry_r, gap, normal, normal_gap, z_floor, xg, yg, gxg, gyg - REAL(wp) :: gx, gy, sfac, nvec(3), vn, rk(3), jrel(3, 3), jtan(3, 3) + REAL(wp) :: gx, gy, sfac, nvec(3), vn, rk(3), jrel(3, 3), jtan(3, 3), fn, wt(3) REAL(wp) :: curv_e(3), fcrease_e(3), kcrease_e(3, 3) INTEGER :: e, i0, iz, zslot, es, k LOGICAL :: dry, has_jac CHARACTER(1024) :: em2 - ErrStat = CD_HCDYN_OK; ErrMsg = ''; force = CD_ZERO; gap = -HUGE(CD_ONE) + ErrStat = CD_HCDYN_OK; ErrMsg = ''; force = CD_ZERO; gap = -HUGE(CD_ONE); nvec = [CD_ZERO, CD_ZERO, CD_ONE] IF (.NOT. model%initialized) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: model not initialised'; RETURN END IF @@ -5451,12 +5451,25 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) force = force + mt*gend(:, MERGE(1, 2, node == 1)) END BLOCK END IF - ! An end resting on the seabed (at or inside the contact blend) does not carry the end - ! node's weight: the floor does, as it does for the grounded nodes beside it. The - ! downward part of the end force is left to the seabed, so a grounded end reports the - ! horizontal (grounded-run) tension. - IF ((model%has_contact .OR. model%kn > CD_ZERO) .AND. .NOT. (gap <= -CD_SEABED_CONTACT_BLEND)) & - force(3) = MAX(force(3), CD_ZERO) + ! An end resting on the seabed (at or inside the contact blend) leaves to the floor the part + ! of its end force pressing into it along the upward normal nvec (the end node's weight on a + ! flat floor), as the floor carries the grounded nodes beside it: a grounded end on a flat + ! floor reports the horizontal (grounded-run) tension, and one on a slope keeps the line's + ! along-floor pull, down-slope component included. On a frictional seabed the floor also + ! holds the along-floor part of the end node's own weight, up to mu times that normal load + ! (the line's pull stays with the anchor); without friction it stays with the line, as in + ! the floor's end-element support (held_end_floor_support). + IF ((model%has_contact .OR. model%kn > CD_ZERO) .AND. .NOT. (gap <= -CD_SEABED_CONTACT_BLEND)) THEN + fn = DOT_PRODUCT(force, nvec) + IF (fn < CD_ZERO) THEN + force = force - fn*nvec + IF (model%fr_active .AND. model%w(e) > CD_ZERO) THEN + wt = -model%w(e)*0.5_wp*model%l0(e)*([CD_ZERO, CD_ZERO, CD_ONE] - nvec(3)*nvec) + IF (NORM2(wt) > CD_ZERO) & + force = force - MIN(CD_ONE, MIN(model%contact_mu, model%contact_mu_axial)*(-fn)/NORM2(wt))*wt + END IF + END IF + END IF END SUBROUTINE CD_HermiteCable_Dyn_End_Force SUBROUTINE CD_HermiteCable_Dyn_Set_Output_Recovery(model, element_recovery) diff --git a/tests/test_anchor_uplift.py b/tests/test_anchor_uplift.py index 66fd076b..61648c2c 100644 --- a/tests/test_anchor_uplift.py +++ b/tests/test_anchor_uplift.py @@ -19,6 +19,8 @@ * dynamics: a fairlead surge lifts the anchor of a catenary; at every output time the channels are finite and consistent, ``TDPGrd > 0`` implies ``AnchFz < 0`` and ``AnchFz > 0`` implies ``TDPGrd = 0``, and the held end state is the suspended elastic catenary; +* 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. usage: test_anchor_uplift.py --exe --examples --output

@@ -472,6 +474,63 @@ def main() -> int: check_anchor_point("multibody march, line 1", out / "rigid6", 1, 4) check_anchor_point("multibody march, line 2", out / "rigid6", 2, 5) + # --- (d) sloped seabed: a finite-EI cable laid down a 10 deg slope from its anchor. The floor + # takes only the part of the end force pressing into it, so the anchor keeps the down-slope pull: + # the anchor force lies along the floor and AnchTen continues the line tension, where dropping + # the whole downward part read cos(10 deg) of it. Up the end element the tension grows by its + # along-slope weight w l0 sin(10 deg): on this frictionless floor the along-floor part of the + # end node's weight stays with the line. + slope = math.radians(10.0) + bathy = "".join(f"{x:.1f} {y:.1f} {200.0 + (300.0 - x) * math.tan(slope)!r}\n" + for x in range(-200, 701, 100) for y in (-300.0, 300.0)) + (out / "slope_bathy.txt").write_text(bathy, encoding="utf-8", newline="\n") + d_pc, m_pc, l0_pc = 0.16, 36.7, 2.0 + w_pc = (m_pc - RHO * math.pi / 4.0 * d_pc**2) * G + deck = f"""finite-EI cable laid down a 10 deg slope from its anchor +--- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +pc {d_pc} {m_pc} 4.69e8 -1 19900 1.2 0.1 1 0 +--- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -20 0 0 0 0 +2 Fixed 300 0 -200 0 0 0 0 +--- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 pc 410 {int(410 / l0_pc)} +--- OPTIONS --- +9.80665 g +1025.0 rhoW +slope_bathy.txt bathymetryFile +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--- OUTPUTS --- +{" ".join(anchor_channels(1, 2))} +--- need this line --- +""" + (out / "slope.dat").write_text(deck, encoding="utf-8", newline="\n") + run(args.exe, out / "slope.dat", out / "slope", env) + check_anchor_point("finite-EI cable on a sloped seabed", out / "slope", 1, 2) + hist = read_output(out / "slope.out") + ten, fz, fh = (float(hist.column(c)[0]) for c in ("AnchTen1", "AnchFz1", "AnchFH1")) + rows = [row.split() for row in (out / "slope.static.out").read_text(encoding="utf-8").splitlines()[3:]] + t_next = float(rows[-2][6]) + angle = math.degrees(math.atan2(-fz, fh)) + check(abs(angle - 10.0) < 0.2, f"sloped seabed: the anchor force runs {angle:.2f} deg below horizontal, along " + "the 10 deg floor (AnchFz < 0: the down-slope pull)") + expect = t_next + w_pc * l0_pc * math.sin(slope) + check(abs(ten - expect) < 0.05 * w_pc * l0_pc, + f"sloped seabed: AnchTen1 {ten:.1f} N continues the next node's tension {t_next:.1f} N plus the end " + f"element's along-slope weight (expected {expect:.1f} N)") + # --- fail-closed contracts bad = set_outputs(chain_deck(R3, 550.0, 55, 500.0, 100.0, 0.0, "1.0e5"), ["AnchFz2"]) (out / "bad_line.dat").write_text(bad, encoding="utf-8", newline="\n") diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index aacf39be..6482c12d 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -29,8 +29,8 @@ plane of the chord (45 degrees) is solved in 3D from the start, so the state is consistent (friction within mu N, a march from it stays at rest), while 180 degrees keeps the planar solve and flips the reference (the anchor tension falls below the default one); -* ``fei_cross`` (a cable on a cross slope, EI = 0 and finite EI): the lateral anchor force stays a - small fraction of the one a reference without the sink offset of the laid nodes would give, and +* ``fei_cross`` (a cable on a cross slope, EI = 0 and finite EI): the lateral anchor force stays + below the one a reference without the sink offset of the laid nodes would give, and the finite-EI line, solved in 3D because the seabed slopes across its chord, stays at rest when marched; * ``att_cross`` (a finite-EI line with discrete buoyancy modules on a cross slope): the reference @@ -413,9 +413,11 @@ def main() -> int: # the friction reference keeps that offset. A reference without it would leave the run shifted # down the slope by the sink, about w tan(slope)/(kBot d) = 1 cm, which the anchor would carry # as a lateral force of AnchTen times that shift over an element (about +0.4 kN, down the slope). - # With it the lateral anchor force is a small fraction of that, up the slope, for the EI = 0 - # line and for the finite-EI one (whose end force follows the cable's end tangent where the - # EI = 0 line's follows the chord of its first element). The seabed slope across the chord + # With it the lateral anchor force stays below that: up the slope for the EI = 0 line, whose end + # force follows the chord of its first element, and in the plane of the floor for the finite-EI + # one, whose end force follows the cable's end tangent less the part pressing into the floor and + # the along-floor part of its end node's weight, which the friction holds. + # The seabed slope across the chord # pushes the run out of its vertical plane against its friction, so the finite-EI line is solved # in 3D and a march from its static state stays at rest. cdir = root / "fei_cross" @@ -428,12 +430,22 @@ def main() -> int: check(rc == 0, "fei_cross %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) if rc == 0: r0 = table(cdir / (tag + ".out"))[0] - # the anchor force of a run shifted down the slope by its sink, half of it - bound = 0.5 * r0["AnchTen1"] * w / (1.0e5 * d) * math.tan(math.radians(5.0)) / 5.0 + # the anchor force of a run shifted down the slope by its sink + ref = r0["AnchTen1"] * w / (1.0e5 * d) * math.tan(math.radians(5.0)) / 5.0 fy[tag] = r0["Point2Fy"] - check(-bound < fy[tag] < 0.0, - "fei_cross %s: lateral anchor force %.4g N up the slope, within half the %.4g N of a reference " - "without the sink" % (tag, fy[tag], 2.0 * bound)) + if tag == "ei0": + check(-0.5 * ref < fy[tag] < 0.0, + "fei_cross ei0: lateral anchor force %.4g N up the slope, within half the %.4g N of a " + "reference without the sink" % (fy[tag], ref)) + else: + # A finite-EI end resting on the floor leaves the part of its end force pressing into + # the floor to it, here the pull of the run sunk into the penalty seabed along the + # slope's normal (about AnchTen delta / l0, whose lateral part the EI = 0 line keeps), + # and the friction holds its end node's weight across the slope: what is left is the + # run's pull in the plane of the floor, below the reference. + check(abs(fy[tag]) < ref, + "fei_cross fei: lateral anchor force %.4g N in the plane of the floor, below the %.4g N of a " + "reference without the sink" % (fy[tag], ref)) if rc == 0 and tag == "fei": rc, _ = run(a.exe, cdir, "fei_rest", deck("fei cross rest", **cd, tmax=1.0)) check(rc == 0, "fei_cross fei at-rest march runs (rc %d)" % rc) From 8abfec7666b1f477d499e415d0e010a1df8d157d Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 26 Oct 2026 23:02:40 +0900 Subject: [PATCH 04/51] fix(outputs): write every channel value with a three-digit exponent (#53) OpenFAST's native .CD.out wrote channel values as ES15.6E2. A value that needs a three-digit exponent, below 1e-99 or from 1e100 on, then fills the field with asterisks, and the round-off noise of a zero component reaches that range: on the IEA-15 mixed deck the y position and tangent azimuth channels of the finite-EI cable, which lies in the x-z plane, printed 30 such fields in 10 s (e.g. 2.9e-113, 2.9e-104), and a coupled campaign with the 0.3.0 release counted 28,818 in 31 runs. Every reader of the file failed or misread it. Channel values are now written with a three-digit exponent at the same field width, ES15.6E3, through two shared formats in CableDyn_Conventions: CD_NATIVE_CHANNEL_FMT for .CD.out and the OpenFAST module driver, CD_CHANNEL_FMT (ES15.7E3, as every other standalone writer) for the mixed EI = 0 + finite-EI .out. That writer, the module driver, the modal results and the static driver's mesh file stated no exponent width, so a three-digit exponent dropped its letter (1.0000000-120), which Python's float() rejects; they get E3 too. test_output_formats writes zero, 1e-120, -3e150, the 1e+-100 edges, a subnormal, HUGE and ordinary values through both formats: each field is TAB plus a fixed width with no asterisks, a mantissa, E, a sign and three digits, and reads back to its printed precision (zero exactly). With the old formats it fails on exactly the reported fields. On the mixed deck the .CD.out now has no asterisk field and numpy reads it whole. The outputs reference and the OpenFAST tutorial show the format. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 +++ CMakeLists.txt | 5 ++ app/cabledyn.f90 | 3 +- doc/outputs.rst | 8 +-- doc/tutorial_openfast.rst | 8 +-- src/CableDyn_Conventions.f90 | 11 ++++ src/CableDyn_Driver.f90 | 4 +- src/CableDyn_Modal.f90 | 4 +- src/openfast/CableDyn_OF.f90 | 5 +- src/openfast/CableDyn_OF_Driver.f90 | 3 +- tests/test_output_formats.f90 | 84 +++++++++++++++++++++++++++++ 11 files changed, 125 insertions(+), 16 deletions(-) create mode 100644 tests/test_output_formats.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index f78f9db1..a2735045 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,12 @@ All notable changes to CableDyn are recorded in this file. The format follows read 0. The floor now takes only the part pressing into it along its normal, and on a frictional seabed the along-floor part of the end node's weight up to the friction it can hold; flat seabeds are unchanged. +- OpenFAST's native `.CD.out` wrote a channel value below 1e-99 or from 1e100 on as a + field of asterisks (`ES15.6E2`): the round-off noise of a zero component, such as the y + position or tangent azimuth of a line in the x-z plane, broke every reader. Channel values now + have a three-digit exponent (`ES15.6E3`, same width). The mixed `EI = 0` + finite-EI `.out`, + the modal results, the static driver's mesh file and the OpenFAST module driver, which wrote + such values without the exponent letter, do too. ## [0.3.0] - 2026-10-23 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c664032..a67f6b8c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1174,6 +1174,11 @@ target_link_libraries(test_hfmf_mirror PRIVATE cabledyn_core) add_test(NAME hfmf_mirror COMMAND test_hfmf_mirror WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(hfmf_mirror PROPERTIES LABELS "fortran;unit;dynamic;openfast") +add_executable(test_output_formats tests/test_output_formats.f90) +target_link_libraries(test_output_formats PRIVATE cabledyn_core) +add_test(NAME output_formats COMMAND test_output_formats) +set_tests_properties(output_formats PROPERTIES LABELS "fortran;unit;output") + add_executable(test_c_api tests/test_c_api.f90) target_link_libraries(test_c_api PRIVATE cabledyn_core) add_test(NAME c_api COMMAND test_c_api) diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 3e2b9fb5..bac2d593 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -19,6 +19,7 @@ PROGRAM cabledyn !! exit code " (stop_run); an interrupt or a fatal fault is reported by !! CableDyn_FatalReport with the simulated time reached. USE CableDyn_Precision, ONLY: wp, CD_ZERO + USE CableDyn_Conventions, ONLY: CD_CHANNEL_FMT USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_Deck_Query_dtM, & CD_Classify_Dynamic_Completion, CD_DECKDRV_OK, & CD_DECKDRV_BADINPUT, CD_DECKDRV_SOLVEFAIL, CD_DECK_PATHLEN @@ -803,7 +804,7 @@ SUBROUTINE write_mixed_row(unit, time, aggregate, stat, msg) DO i = 1, CD_AGG_NumChannels(aggregate) CALL CD_AGG_EvalChannel(aggregate, i, value, stat, msg) IF (stat /= CD_AGG_OK) RETURN - WRITE (unit, '(A,ES15.7)', ADVANCE='NO', IOSTAT=ios) CHAR(9), value + WRITE (unit, CD_CHANNEL_FMT, ADVANCE='NO', IOSTAT=ios) CHAR(9), value IF (ios /= 0) THEN stat = CD_AGG_BADINPUT; msg = 'cannot write mixed output row'; RETURN END IF diff --git a/doc/outputs.rst b/doc/outputs.rst index 2bc94bca..3eac9688 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -97,9 +97,8 @@ All standalone files are plain ASCII tables: three-digit exponent, e.g. `` 1.2500000000000000E+001``) so that time stamps survive long runs with small ``dtM`` without rounding; * every other real value is Fortran ``ES15.7E3`` (15 characters, 8 significant digits, e.g. - `` 5.0988032E+005``, three-digit exponent). The one exception is the channel columns of the - mixed ``EI = 0`` + finite-EI route's ``.out``, written as ``ES15.7`` (the same 8 significant - digits with a two-digit exponent, e.g. `` 5.0988032E+05``); + `` 5.0988032E+005``, three-digit exponent, so round-off noise below 1e-99 in a component that + is zero still prints as a number); * integer key columns (``LineID``, ``Node``, ``Element``, ``Segment``) are written without padding (``I0``); * a non-finite channel value is never written: a dynamic row that would contain ``NaN`` or @@ -946,7 +945,8 @@ output root: ``(deg)`` angles, ``(m)`` positions, ``(m/s)`` velocities, ``(m/s2)`` accelerations, ``(deg/s)`` / ``(deg/s2)`` body and rod angular rates, ``(1/m)`` curvature, ``(N.m)`` bend moment and body/rod moments, ``(-)`` ``RodSub``; -* data rows: time as ``ES25.16E3`` (full double precision), values as ``ES15.6E2``, TAB-separated. +* data rows: time as ``ES25.16E3`` (full double precision), values as ``ES15.6E3`` (7 significant + digits, three-digit exponent), TAB-separated. The first data row is the static initialisation at ``t = 0``; every further row is written after each committed CableDyn step, at every ``dtM`` boundary. It is independent of OpenFAST's ``DT_Out`` diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index 5345b99f..50c2e217 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -238,10 +238,10 @@ Check, in order: .. code-block:: text - Time FairTen1 AnchTen1 FairIncl1 AnchIncl1 FairTen2 ... - (s) (N) (N) (deg) (deg) (N) ... - 0.0000000E+00 2.437520E+06 1.351636E+06 5.568478E+01 -1.961023E-02 2.436576E+06 ... - 2.5000000E-02 2.438082E+06 1.351645E+06 5.568463E+01 -1.961023E-02 2.435530E+06 ... + Time FairTen1 AnchTen1 FairIncl1 AnchIncl1 FairTen2 ... + (s) (N) (N) (deg) (deg) (N) ... + 0.0000000000000000E+000 2.437520E+006 1.351636E+006 5.568478E+001 -1.961023E-002 2.436576E+006 ... + 2.5000000000000001E-002 2.438082E+006 1.351645E+006 5.568463E+001 -1.961023E-002 2.435530E+006 ... CableDyn channels are chosen in the deck's ``OUTPUTS`` section (keep its closing ``END``), not in the ``.fst`` ``OutList``. Channel names and units: :doc:`outputs`; sign and angle conventions: diff --git a/src/CableDyn_Conventions.f90 b/src/CableDyn_Conventions.f90 index 96102790..84778a80 100644 --- a/src/CableDyn_Conventions.f90 +++ b/src/CableDyn_Conventions.f90 @@ -12,6 +12,8 @@ MODULE CableDyn_Conventions !! (azimuth / declination / gamma) [deg] -> R in SO(3). !! - CD_Body_Rotation : 6D-body attitude, intrinsic x-y'-z'' !! (rotation1 / 2 / 3) [deg] -> R in SO(3). + !! - CD_CHANNEL_FMT, CD_NATIVE_CHANNEL_FMT : the channel-value formats of the + !! time-series files (three-digit exponent). !! !! These are the OrcaFlex 11.5 conventions (frames right-handed, GZ up; azimuth !! +GX->+GY; declination from +GZ). The two Euler sequences are deliberately @@ -24,6 +26,15 @@ MODULE CableDyn_Conventions PRIVATE PUBLIC :: CD_Direction_Vector, CD_LineEnd_Rotation, CD_Body_Rotation PUBLIC :: CD_Deg2Rad, CD_Rad2Deg + PUBLIC :: CD_CHANNEL_FMT, CD_NATIVE_CHANNEL_FMT + + ! One TAB-separated channel value of a time-series row: the standalone .out files (8 + ! significant digits) and OpenFAST's native .CD.out (7). The exponent field has three + ! digits: with two, a magnitude below 1e-99 or at 1e100 and above (the round-off noise of a + ! component that is zero, such as the y position of a line in the x-z plane) fills the field + ! with asterisks, and without a stated width the exponent letter is dropped. + CHARACTER(*), PARAMETER :: CD_CHANNEL_FMT = '(A,ES15.7E3)' + CHARACTER(*), PARAMETER :: CD_NATIVE_CHANNEL_FMT = '(A,ES15.6E3)' REAL(wp), PARAMETER :: CD_PI = 3.14159265358979323846_wp REAL(wp), PARAMETER :: CD_RAD_PER_DEG = CD_PI/180.0_wp diff --git a/src/CableDyn_Driver.f90 b/src/CableDyn_Driver.f90 index 000c6fa8..a68c39a8 100644 --- a/src/CableDyn_Driver.f90 +++ b/src/CableDyn_Driver.f90 @@ -756,11 +756,11 @@ SUBROUTINE write_csv(path, q, conn, tension, converged, stalled, at_floor, n_ite ' stalled=', stalled, ' at_floor=', at_floor WRITE (unit, '(A)') 'section,node,x,y,z' DO i = 1, n_nodes - WRITE (unit, '(A,I0,3(A,ES23.15))') 'node,', i, ',', q(3*i - 2), ',', q(3*i - 1), ',', q(3*i) + WRITE (unit, '(A,I0,3(A,ES23.15E3))') 'node,', i, ',', q(3*i - 2), ',', q(3*i - 1), ',', q(3*i) END DO WRITE (unit, '(A)') 'section,elem,node_a,node_b,tension_N' DO i = 1, n_elem - WRITE (unit, '(A,I0,2(A,I0),A,ES23.15)') 'elem,', i, ',', conn(1, i), ',', conn(2, i), & + WRITE (unit, '(A,I0,2(A,I0),A,ES23.15E3)') 'elem,', i, ',', conn(1, i), ',', conn(2, i), & ',', tension(i) END DO CLOSE (unit) diff --git a/src/CableDyn_Modal.f90 b/src/CableDyn_Modal.f90 index 358870f3..2f1f0ac8 100644 --- a/src/CableDyn_Modal.f90 +++ b/src/CableDyn_Modal.f90 @@ -759,7 +759,7 @@ SUBROUTINE CD_Modal_Write_Line(unit, line_id, q, dof_per_node, omega2, shapes, n fr = om/TWO_PI per = CD_ZERO IF (om > CD_ZERO) per = CD_ONE/fr - WRITE (unit, '(I0,A,I0,3(A,ES16.8))') line_id, TB, j, TB, fr, TB, per, TB, om + WRITE (unit, '(I0,A,I0,3(A,ES16.8E3))') line_id, TB, j, TB, fr, TB, per, TB, om ELSE dmax = CD_ZERO DO i = 1, nn @@ -770,7 +770,7 @@ SUBROUTINE CD_Modal_Write_Line(unit, line_id, q, dof_per_node, omega2, shapes, n IF (dmax > CD_ZERO) scl = CD_ONE/dmax DO i = 1, nn i0 = dof_per_node*(i - 1) - WRITE (unit, '(I0,A,I0,A,I0,6(A,ES16.8))') line_id, TB, j, TB, i, TB, q(i0 + 1), TB, q(i0 + 2), TB, & + WRITE (unit, '(I0,A,I0,A,I0,6(A,ES16.8E3))') line_id, TB, j, TB, i, TB, q(i0 + 1), TB, q(i0 + 2), TB, & q(i0 + 3), TB, scl*shapes(i0 + 1, j), TB, scl*shapes(i0 + 2, j), TB, scl*shapes(i0 + 3, j) END DO END IF diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index c963a00b..e9a89d60 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -70,6 +70,7 @@ MODULE CableDyn USE CableDyn_Types USE NWTC_Library USE CableDyn_Precision, ONLY: wp + USE CableDyn_Conventions, ONLY: CD_NATIVE_CHANNEL_FMT USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_SeaState_Steady_Current, CD_HYDRO_OK USE CableDyn_DeckDriver, ONLY: CD_Deck_Query_dtM, CD_DECKDRV_OK USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_UpdateStates_Moving, & @@ -362,7 +363,7 @@ SUBROUTINE open_native_outputs( id, root, t_start, ErrStat, ErrMsg, write_profil ErrStat, ErrMsg, RoutineName ) RETURN END IF - WRITE (un, '(A,ES15.6E2)', ADVANCE='NO') CHAR(9), value + WRITE (un, CD_NATIVE_CHANNEL_FMT, ADVANCE='NO') CHAR(9), value END DO WRITE (un, '(A)') '' FLUSH (un) @@ -2425,7 +2426,7 @@ SUBROUTINE CD_CalcOutput( t, u, p, x, xd, z, other, y, m, ErrStat, ErrMsg ) CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: committed-step channel record: '//TRIM(em), & ErrStat, ErrMsg, RoutineName ); RETURN END IF - WRITE (Inst(id)%native_un, '(A,ES15.6E2)', ADVANCE='NO') CHAR(9), cval + WRITE (Inst(id)%native_un, CD_NATIVE_CHANNEL_FMT, ADVANCE='NO') CHAR(9), cval END DO WRITE (Inst(id)%native_un, '(A)') '' ! keep the record readable during the run (and intact after a crash) diff --git a/src/openfast/CableDyn_OF_Driver.f90 b/src/openfast/CableDyn_OF_Driver.f90 index 9574b743..97ee9a91 100644 --- a/src/openfast/CableDyn_OF_Driver.f90 +++ b/src/openfast/CableDyn_OF_Driver.f90 @@ -44,6 +44,7 @@ PROGRAM CableDyn_OF_Driver USE NWTC_Library USE CableDyn_Types USE CableDyn, ONLY: CD_Init, CD_UpdateStates, CD_CalcOutput, CD_End + USE CableDyn_Conventions, ONLY: CD_NATIVE_CHANNEL_FMT USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE IMPLICIT NONE @@ -165,7 +166,7 @@ PROGRAM CableDyn_OF_Driver IF (.NOT. ALL(IEEE_IS_FINITE(y%CoupledLoads(1)%Moment))) CALL fail_out('non-finite coupled moment') WRITE (un_out, '(F12.4)', ADVANCE='NO') t + dtc DO ic = 1, nch - WRITE (un_out, '(A,ES15.6)', ADVANCE='NO') TAB, y%WriteOutput(ic) + WRITE (un_out, CD_NATIVE_CHANNEL_FMT, ADVANCE='NO') TAB, y%WriteOutput(ic) END DO WRITE (un_out, '()') END DO diff --git a/tests/test_output_formats.f90 b/tests/test_output_formats.f90 new file mode 100644 index 00000000..d3466008 --- /dev/null +++ b/tests/test_output_formats.f90 @@ -0,0 +1,84 @@ +! File: tests/test_output_formats.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_output_formats + !! Gate for the channel-value formats of the time-series files (CD_CHANNEL_FMT, the + !! standalone .out files; CD_NATIVE_CHANNEL_FMT, OpenFAST's native .CD.out). Every + !! value a channel can carry must print as a number any reader parses: no field of + !! asterisks (a two-digit exponent overflows below 1e-99 and from 1e100, the round-off + !! noise of a zero component such as the y position of a line in the x-z plane), and the + !! exponent letter kept (an unstated exponent width drops it at three digits, which + !! Python's float() rejects). Each field is TAB plus mantissa, 'E', sign and three + !! digits, and reads back to its printed precision (zero exactly). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_Conventions, ONLY: CD_CHANNEL_FMT, CD_NATIVE_CHANNEL_FMT + IMPLICIT NONE + REAL(wp), PARAMETER :: VALUES(13) = [0.0_wp, 1.0e-120_wp, -3.0e150_wp, 9.99999949e-100_wp, -1.0e-99_wp, & + 1.0e100_wp, -9.9999999e99_wp, 1.0e-310_wp, 5.0988032e5_wp, & + -1.961023e-2_wp, 1.0_wp, HUGE(1.0_wp), -TINY(1.0_wp)] + INTEGER :: nfail, i + + nfail = 0 + DO i = 1, SIZE(VALUES) + CALL check(CD_CHANNEL_FMT, 'standalone', VALUES(i), 15, 5.0e-8_wp) + CALL check(CD_NATIVE_CHANNEL_FMT, 'native', VALUES(i), 15, 5.0e-7_wp) + END DO + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: channel-value formats print every magnitude as a parseable number' + +CONTAINS + + SUBROUTINE check(fmt, label, x, width, rel) + !! Write TAB + x with fmt, then check the field's shape and its read-back value. + CHARACTER(*), INTENT(IN) :: fmt, label + REAL(wp), INTENT(IN) :: x, rel + INTEGER, INTENT(IN) :: width + CHARACTER(64) :: buf + CHARACTER(:), ALLOCATABLE :: field + REAL(wp) :: y + INTEGER :: ios, ie, n + CHARACTER(32) :: shown + + WRITE (shown, '(ES24.16E3)') x + WRITE (buf, fmt, IOSTAT=ios) CHAR(9), x + IF (ios /= 0) THEN + CALL fail(label//' write failed for '//TRIM(shown)); RETURN + END IF + n = LEN_TRIM(buf) + IF (buf(1:1) /= CHAR(9) .OR. n /= width + 1) THEN + CALL fail(label//' field is not TAB plus a fixed width for '//TRIM(shown)//': "'//TRIM(buf)//'"'); RETURN + END IF + field = TRIM(ADJUSTL(buf(2:n))) + IF (INDEX(field, '*') > 0) THEN + CALL fail(label//' field overflows for '//TRIM(shown)//': "'//field//'"'); RETURN + END IF + ! mantissa, then E, a sign and exactly three exponent digits at the end of the field + ie = INDEX(field, 'E', BACK=.TRUE.) + IF (ie == 0 .OR. ie /= LEN(field) - 4) THEN + CALL fail(label//' field lacks a three-digit E exponent for '//TRIM(shown)//': "'//field//'"'); RETURN + END IF + IF (VERIFY(field(ie + 1:ie + 1), '+-') /= 0 .OR. VERIFY(field(ie + 2:), '0123456789') /= 0) THEN + CALL fail(label//' exponent is not a sign and three digits for '//TRIM(shown)//': "'//field//'"'); RETURN + END IF + READ (field, *, IOSTAT=ios) y + IF (ios /= 0) THEN + CALL fail(label//' field does not read back for '//TRIM(shown)//': "'//field//'"'); RETURN + END IF + ! ABS(.) >= 0, so "not > 0" tests an exact zero without a REAL equality compare + IF (.NOT. (ABS(x) > 0.0_wp)) THEN + IF (ABS(y) > 0.0_wp) CALL fail(label//' zero does not read back as zero: "'//field//'"') + ELSE IF (ABS(y - x) > rel*ABS(x)) THEN + CALL fail(label//' value does not round-trip for '//TRIM(shown)//': "'//field//'"') + END IF + END SUBROUTINE check + + SUBROUTINE fail(msg) + CHARACTER(*), INTENT(IN) :: msg + WRITE (*, '(A)') 'MISMATCH: '//msg + nfail = nfail + 1 + END SUBROUTINE fail + +END PROGRAM test_output_formats From f267527acb1807abaf75140a89555dd760077eeb Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 27 Oct 2026 00:38:24 +0900 Subject: [PATCH 05/51] fix(openfast): restart a finite-EI cable from its committed boundary (#54) openfast -restart did not continue a run with a finite-EI cable bit for bit. The checkpoint rebuild moves each coupled end to the restored input mesh, the glue's input at the restart time, and the cable's mirror held only its free DOFs: its fairlead kept the restored mesh's bits instead of the boundary the uninterrupted run committed (with NumCrctn = 0 that run stepped with the extrapolated input). The EI=0 lines already reload their committed coupled motion. On the IEA-15 mixed deck restarted at 6 s, the lazy-wave cable's .CD.out channels drifted by up to 9.4e-7 (relative) within 4 s, while the chain-only deck stayed exact. The cable mirror gains a boundary block, reloaded after the move: [q; v; a] of the held DOFs (the held accelerations move here from the force-blend block, so the configuration blend restores them too), the end-connection directions and the parent frame (orientation, angular velocity and acceleration). Unpacking checks the orientation before it writes anything. The parent frame of a torsion cable now reloads as committed instead of being re-derived from its end frames. With the fix every .CD.out and OpenFAST row from 6 s to 10 s matches the uninterrupted run bit for bit at dtM = DT and 2 DT, NumCrctn 0 and 1, and with a rigid fairlead END CONNECTIONS row (before: 3 to 6 rows of the cable's channels differed in each). The mirror test covers the new layout, its round trip and the orientation check. Signed-off-by: Jae Hoon Seo --- ARCHITECTURE.md | 9 +- CHANGELOG.md | 4 + VALIDATION.md | 2 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 125 +++++++++++++++++---------- src/openfast/CableDyn_OF.f90 | 23 ++--- tests/test_hfmf_mirror.f90 | 35 +++++--- 6 files changed, 123 insertions(+), 75 deletions(-) diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 082923e3..c1acf3b6 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -360,10 +360,11 @@ the exchange buildable and testable without OpenFAST. committed positions and holds them for the step. - **State mirror.** The authoritative state lives in the module instance, and `x%states` carries a mirror of it: line node velocities and positions, finite-EI - cable DOFs, constitutive states (`dl_1`, Syrope), friction anchors, and body and - rod states. Checkpoint/restart, correction iterations, and the framework - metadata use the mirror; a restart rebuilds the model from the packed deck and - the mirror. + cable DOFs, constitutive states (`dl_1`, Syrope), friction anchors, the committed + boundary kinematics of the coupled ends, and body and rod states. + Checkpoint/restart, correction iterations, and the framework metadata use the + mirror; a restart rebuilds the model from the packed deck and the mirror, which + then overrides the restored input mesh at the coupled ends. - **Scope.** Correction iterations, quasi-static linearisation, FAST.Farm shared moorings (`MooringMod = 5`), line failures, and active line-length control are supported. Combinations that are not supported coupled stop with a named error; diff --git a/CHANGELOG.md b/CHANGELOG.md index a2735045..134915c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,10 @@ All notable changes to CableDyn are recorded in this file. The format follows have a three-digit exponent (`ES15.6E3`, same width). The mixed `EI = 0` + finite-EI `.out`, the modal results, the static driver's mesh file and the OpenFAST module driver, which wrote such values without the exponent letter, do too. +- `openfast -restart` with a finite-EI cable continues the run bit for bit. The rebuild moved the + cable's fairlead to the restored input mesh, whose last bits differ from the boundary the + uninterrupted run committed, and the cable's `.CD.out` channels drifted by up to 1e-6 + (relative) within seconds. The checkpoint now carries the cable's committed boundary. ## [0.3.0] - 2026-10-23 diff --git a/VALIDATION.md b/VALIDATION.md index db4eb82b..a0f24c89 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -776,7 +776,7 @@ stop with a named error. | Nonzero `PtfmInit` | Pass verified | 6-DOF displaced free decay ≤0.51% | | Correction iterations (`NumCrctn > 0`) | Pass verified | bit-identical to own `NumCrctn = 0` run | | SeaState wave/current kinematics | Pass verified | wave A/B ≤0.16% of range | -| Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0; also with supercycling (`dtM` > `DT`, the held SeaState fields and the predictor loads checkpointed): IEA-15 VolturnUS-S, turbulent wind and JONSWAP sea, `openfast -restart` at 50 s reproduces every later OpenFAST and `.CD.out` row of the chain mooring at `dtM` = 4 `DT` (extrapolated and held loads) and `DT`, and of the chain + 248-element power-cable mooring at `dtM` = 2 `DT` | +| Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0; also with supercycling (`dtM` > `DT`, the held SeaState fields and the predictor loads checkpointed): IEA-15 VolturnUS-S, turbulent wind and JONSWAP sea, `openfast -restart` at 50 s reproduces every later OpenFAST and `.CD.out` row of the chain mooring at `dtM` = 4 `DT` (extrapolated and held loads) and `DT`, and of the chain + 248-element power-cable mooring at `dtM` = 2 `DT`. A finite-EI cable also checkpoints its committed boundary (held DOFs, end-connection directions, vessel frame): before, the rebuild took its fairlead from the restored input mesh, which differs in the last bits, and on the IEA-15 mixed deck restarted at 6 s the lazy-wave cable's `.CD.out` channels drifted by up to 9.4e-7 (relative) within 4 s; now all rows to 10 s match bit for bit at `dtM` = `DT` and 2 `DT`, `NumCrctn` 0 and 1, and with a rigid fairlead END CONNECTIONS row | | Linearisation | Pass verified (quasi-static stiffness) | quasi-static `dYdu` compared entry by entry with stock MoorDyn's zero-frequency reduction `D − C A⁻¹ B` (full-precision `.lin` output): fairlead stiffness 0.07–0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; standalone static FD 1.5e-5; transverse term equals `H/X`. Velocity/acceleration columns are zero by design ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)) | | FAST.Farm shared moorings + clumps + channel record | Pass verified | 600 s A/B of the r-test `MD_Shared` farm against stock MoorDyn (same deck, analysis from 100 s; [`fastfarm_shared_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/fastfarm_shared_ab.py)): tension means ≤0.02%, minima and maxima ≤0.25%, platform motions within millimetres and 0.001°; shared-line tension std 2.2–2.7% lower, 1.0% at half the mooring step (CableDyn's implicit step at the 0.05 s coupling step against MoorDyn's 1e-4 s explicit step). On the shared lines, which have no Fixed end, `FairTen`/`AnchTen` name the opposite ends from MoorDyn's (see the migration guide). MoorDyn's initial settling does not converge for the anchor legs 6 and 7 (2.4 m excess length at t = 0), a start-up transient over by 100 s that most likely set the 3% end of the earlier 60 s record | | Slack-line tension convention | Pass verified | tension-only dynamics; BA on slack lines matches `MoorDyn_Line.f90` | diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index ee0a94fd..c7533c28 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -84,6 +84,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_MinSpanZ PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize + PUBLIC :: CD_HFMF_BoundaryMirrorSize PUBLIC :: CD_HFMF_ForceMirrorSize PUBLIC :: CD_HFMF_TorsionMirrorSize PUBLIC :: CD_HFMF_PackMirror @@ -1527,16 +1528,31 @@ INTEGER FUNCTION CD_HFMF_MirrorSize(self) RESULT(n) !! carries the committed acceleration, and unlike the EI=0 side (whose acceleration !! is re-derived by CD_Recompute_System_Acceleration) the cable reloads it exactly. !! A cable on a frictional seabed appends its stick-slip friction anchors, (x, y) per - !! node (CD_HFMF_FrictionMirrorSize slots): they are committed state like q. Zero if - !! uninitialised. + !! node (CD_HFMF_FrictionMirrorSize slots): they are committed state like q. Then come + !! the committed boundary (CD_HFMF_BoundaryMirrorSize), the force-blend state and the + !! torsion state. Zero if uninitialised. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN IF (ALLOCATED(self%line%freemask)) n = 3*COUNT(self%line%freemask) - n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + & - CD_HFMF_TorsionMirrorSize(self) + n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_BoundaryMirrorSize(self) + & + CD_HFMF_ForceMirrorSize(self) + CD_HFMF_TorsionMirrorSize(self) END FUNCTION CD_HFMF_MirrorSize + INTEGER FUNCTION CD_HFMF_BoundaryMirrorSize(self) RESULT(n) + !! Mirror slots of the committed boundary: [q; v; a] of the held (prescribed or fixed) + !! DOFs, the end-connection directions (6) and the parent frame the coupled end was + !! committed with (orientation 9, angular velocity 3, angular acceleration 3). A restart + !! 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. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + n = 0 + IF (.NOT. self%initialized) RETURN + n = 3*(self%line%ndof - COUNT(self%line%freemask)) + 21 + END FUNCTION CD_HFMF_BoundaryMirrorSize + INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) !! Mirror slots of the condensed torsion, last: the accepted (unwrapped) Theta, Phi and the !! four end-frame vectors (14 values); zero without torsion. @@ -1547,15 +1563,14 @@ INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) END FUNCTION CD_HFMF_TorsionMirrorSize INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) - !! Mirror slots of the force-blended generalised-alpha integrator state beyond [v; q; a] of - !! the free DOFs: a validity flag and the committed force F_n (ndof values), then the - !! committed accelerations of the held DOFs; zero with the configuration blend. The - !! force blend carries F_n and a_n of the prescribed end into the next step, so a restart - !! reloads them instead of re-evaluating F_n and taking a_n from the host input mesh. + !! Mirror slots of the force-blended generalised-alpha integrator state beyond the free + !! and boundary blocks: a validity flag and the committed force F_n (ndof values); zero + !! with the configuration blend. The force blend carries F_n into the next step, so a + !! restart reloads it instead of re-evaluating it. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN - IF (self%line%force_blend) n = 1 + self%line%ndof + (self%line%ndof - COUNT(self%line%freemask)) + IF (self%line%force_blend) n = 1 + self%line%ndof END FUNCTION CD_HFMF_ForceMirrorSize INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) @@ -1567,21 +1582,23 @@ INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) END FUNCTION CD_HFMF_FrictionMirrorSize SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) - !! Write the cable's continuous state into buf as [v_free; q_free; a_free] -- the - !! layout CD_HFMF_MirrorSize sizes. The mirror is written every mooring step and - !! reloaded ONLY by a checkpoint-restart rebuild (CD_HFMF_UnpackMirror); the module - !! stays self-authoritative in normal marching. + !! Write the cable's continuous state into buf as [v_free; q_free; a_free], then the + !! friction, boundary, force-blend and torsion blocks -- the layout CD_HFMF_MirrorSize + !! sizes. The mirror is written every mooring step and reloaded ONLY by a + !! checkpoint-restart rebuild or the state-const CalcOutput restore + !! (CD_HFMF_UnpackMirror); the module stays self-authoritative in normal marching. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self REAL(wp), INTENT(OUT) :: buf(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, nf, k + INTEGER :: i, nf, nh, k ErrStat = CD_HFMF_OK; ErrMsg = '' buf = CD_ZERO IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_PackMirror: module not initialised'; RETURN END IF nf = COUNT(self%line%freemask) + nh = self%line%ndof - nf IF (SIZE(buf) /= CD_HFMF_MirrorSize(self)) THEN ErrStat = CD_HFMF_BADINPUT ErrMsg = 'CD_HFMF_PackMirror: buffer must be sized CD_HFMF_MirrorSize' @@ -1602,6 +1619,20 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 1:k + 2*self%line%nn) = RESHAPE(self%line%fr_anchor, [2*self%line%nn]) k = k + 2*self%line%nn END IF + ! committed boundary: [q; v; a] of the held DOFs, end-connection directions, parent frame + DO i = 1, self%line%ndof + IF (self%line%freemask(i)) CYCLE + k = k + 1 + buf(k) = self%line%q(i) + buf(nh + k) = self%line%v(i) + buf(2*nh + k) = self%line%a(i) + END DO + k = k + 2*nh + buf(k + 1:k + 6) = RESHAPE(self%line%endconn_d0, [6]) + buf(k + 7:k + 15) = RESHAPE(self%parent_dcm, [9]) + buf(k + 16:k + 18) = self%parent_omega + buf(k + 19:k + 21) = self%parent_alpha + k = k + 21 ! 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 @@ -1609,11 +1640,6 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 2:k + 1 + self%line%ndof) = self%line%fc_R END IF k = k + 1 + self%line%ndof - DO i = 1, self%line%ndof - IF (self%line%freemask(i)) CYCLE - k = k + 1 - buf(k) = self%line%a(i) - END DO END IF IF (self%line%torsion%active) THEN buf(k + 1) = self%line%torsion%theta @@ -1623,18 +1649,19 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) END SUBROUTINE CD_HFMF_PackMirror SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) - !! CHECKPOINT-RESTART reload: overwrite the cable's free-DOF state from a mirror - !! written by CD_HFMF_PackMirror ([v_free; q_free; a_free]) and set the line clock - !! to the restart time. The prescribed (coupled) and fixed DOFs are untouched -- the - !! caller re-prescribes the coupled endpoint from the host mesh - !! (CD_HFMF_SetCoupledKinematics) around this call. The module must already be - !! initialised from the SAME deck (the rebuild re-runs the static build first). + !! CHECKPOINT-RESTART reload: overwrite the cable's committed state from a mirror + !! written by CD_HFMF_PackMirror and set the line clock to the restart time. The held + !! DOFs, end-connection directions and parent frame reload from the boundary block, so + !! a caller that first moved the coupled endpoint to the host's restored input mesh + !! (CD_HFMF_SetCoupledKinematics) continues from the committed boundary bit for bit. The + !! module must already be initialised from the SAME deck (the rebuild re-runs the + !! static build first). TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: buf(:) REAL(wp), INTENT(IN) :: t INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, nf, k + INTEGER :: i, nf, nh, k, kb ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_UnpackMirror: module not initialised'; RETURN @@ -1666,6 +1693,14 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) END ASSOCIATE END DO END IF + ! the boundary block's parent orientation, checked before anything is written as well + nh = self%line%ndof - nf + kb = 3*nf + CD_HFMF_FrictionMirrorSize(self) + 3*nh + IF (.NOT. valid_parent_dcm(RESHAPE(buf(kb + 7:kb + 15), [3, 3]))) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_UnpackMirror: the parent orientation must be a proper orthogonal DCM' + RETURN + END IF k = 0 DO i = 1, self%line%ndof IF (self%line%freemask(i)) THEN @@ -1681,6 +1716,19 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%ws_recovery_fr = self%line%fr_anchor k = k + 2*self%line%nn END IF + DO i = 1, self%line%ndof + IF (self%line%freemask(i)) CYCLE + k = k + 1 + self%line%q(i) = buf(k) + self%line%v(i) = buf(nh + k) + self%line%a(i) = buf(2*nh + k) + END DO + k = k + 2*nh + self%line%endconn_d0 = RESHAPE(buf(k + 1:k + 6), [3, 2]) + self%parent_dcm = RESHAPE(buf(k + 7:k + 15), [3, 3]) + self%parent_omega = buf(k + 16:k + 18) + self%parent_alpha = buf(k + 19:k + 21) + k = k + 21 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. @@ -1705,11 +1753,6 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%fc_valid = .TRUE. END IF k = k + 1 + self%line%ndof - DO i = 1, self%line%ndof - IF (self%line%freemask(i)) CYCLE - k = k + 1 - self%line%a(i) = buf(k) - END DO END IF IF (self%line%torsion%active) THEN self%line%torsion%theta = buf(k + 1) @@ -1718,22 +1761,8 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%torsion%torque = (self%line%torsion%phi - self%line%torsion%theta)/ & CD_HermiteTorsion_Compliance(self%line%torsion, self%line%l0) self%line%tors_drive_set = .FALSE. - ! A parent-attached torsion frame without a parent end connection: the parent orientation - ! is not in the mirror but follows from the restored end frame (its director and normal - ! in parent axes, tors_frame_parent, and in global axes), so a later step without - ! u_orientation holds it instead of turning the frame back to the static orientation. - IF (self%tors_parent .AND. .NOT. self%has_parent_endconn) THEN - BLOCK - REAL(wp) :: fp(3, 3), gg(3, 3) - fp(:, 1) = self%tors_frame_parent(:, 1) - fp(:, 2) = self%tors_frame_parent(:, 2) - fp(:, 3) = cross3(fp(:, 1), fp(:, 2)) - gg(:, 1) = frame_to_global(self, self%line%torsion%ends(:, 2*self%tors_index - 1)) - gg(:, 2) = frame_to_global(self, self%line%torsion%ends(:, 2*self%tors_index)) - gg(:, 3) = cross3(gg(:, 1), gg(:, 2)) - self%parent_dcm = MATMUL(fp, TRANSPOSE(gg)) - END BLOCK - END IF + ! (a parent-attached torsion frame turns with the parent orientation, which the boundary + ! block restored as committed, so a later step without u_orientation holds it) END IF END SUBROUTINE CD_HFMF_UnpackMirror diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index e9a89d60..2e13f9c0 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -91,8 +91,8 @@ MODULE CableDyn CD_AGG_GetInitMetadata, CD_AGG_GetInitLine, & CD_AGG_WriteStaticProfile USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & - CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & - CD_HFMF_TorsionMirrorSize, CD_HFMF_OK + CD_HFMF_FrictionMirrorSize, CD_HFMF_BoundaryMirrorSize, & + CD_HFMF_ForceMirrorSize, CD_HFMF_TorsionMirrorSize, CD_HFMF_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -1102,14 +1102,14 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! (1e-10) if any bound ends ever disagree. The same gather runs inside every ! normal step, so a state violating the invariant cannot even advance, let alone ! be packed. The vector's real payload is the COMMITTED boundary kinematics: the - ! vessel-end accelerations the last advance committed differ at round-off from the - ! restored input mesh, and on a point deck that round-off is amplified through the - ! explicit-point window. Pure coupled decks keep the interiors-only mirror (their - ! restart is exact from the host-restored boundary alone at output precision). + ! vessel-end kinematics the last advance committed differ in the last bits from the + ! restored input mesh (the glue's input at the restart time, not the extrapolated one + ! the advance used), and on a point deck that round-off is amplified through the + ! explicit-point window. A finite-EI cable carries its committed boundary in its own + ! mirror block (CD_HFMF_BoundaryMirrorSize). IF (Inst(id)%agg%has_sys) THEN - ! the committed boundary kinematics of the EI=0 lines: a restart takes the coupled - ! endpoints' q/v from the restored input mesh, but their committed accelerations - ! (the generalised-alpha a_n) only from here + ! the committed boundary kinematics [q; v; a] of the EI=0 lines' coupled endpoints: + ! the rebuild moves them to the restored input mesh, then reloads them from here nstates = nstates + 3*CD_System_NSystemCoupledDOF( Inst(id)%agg%sys%fast%system ) END IF IF (CD_AGG_NDynamicPoints( Inst(id)%agg ) > 0 .AND. Inst(id)%agg%has_sys) THEN @@ -3332,8 +3332,9 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) IF (csz <= 0) CYCLE ! uninitialised cable contributes no states ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors, the - ! force-blend state and the torsion state (if any) + ! committed boundary, the force-blend state and the torsion state (if any) nf = (csz - CD_HFMF_FrictionMirrorSize( inst_%agg%cables(ic) ) - & + CD_HFMF_BoundaryMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_TorsionMirrorSize( inst_%agg%cables(ic) ))/3 LinStr = 'Cable '//TRIM(Num2LStr(ic)) @@ -3789,7 +3790,7 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) npd = 9*CD_AGG_NDynamicPoints( inst_%agg ) IF (npd == 0 .AND. inst_%agg%has_sys) THEN ! no dynamic points: restore the committed boundary kinematics (the restored input - ! mesh carries the coupled positions and velocities, not the committed accelerations) + ! mesh carries the glue's input at the restart time, not the committed kinematics) ncd = CD_System_NSystemCoupledDOF( inst_%agg%sys%fast%system ) IF (koff + 3*ncd > SIZE(states)) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: the coupled-motion mirror extends '// & diff --git a/tests/test_hfmf_mirror.f90 b/tests/test_hfmf_mirror.f90 index d735f4c0..b6c67360 100644 --- a/tests/test_hfmf_mirror.f90 +++ b/tests/test_hfmf_mirror.f90 @@ -8,25 +8,28 @@ PROGRAM test_hfmf_mirror !! checkpoint-restart rebuild reloads. Builds a real lazy-wave coupled cable from a !! deck and checks: !! 1) MirrorSize is the free-DOF [v; q; a] layout (three blocks strictly below ndof - !! each: the coupled fairlead is prescribed) plus the force-blend block (validity - !! flag, committed force, held-DOF accelerations) of the default force blend; + !! each: the coupled fairlead is prescribed) plus the committed-boundary block ([q; v; a] + !! of the held DOFs, end-connection directions, parent frame) and the force-blend block + !! (validity flag, committed force) of the default force blend; !! 2) PackMirror fills a correctly sized buffer with finite values whose velocity !! AND acceleration blocks are zero at the static IC (rest), confirming the !! [v_free; q_free; a_free] order; !! 3) UnpackMirror ROUND-TRIPS: perturb the packed state, unpack into a second !! identically built cable, re-pack -- bit-identical buffers, and the line clock !! carries the restart time; - !! 4) wrong-sized / non-finite buffers and a non-finite time fail closed. + !! 4) wrong-sized / non-finite buffers, a non-orthogonal parent orientation and a + !! non-finite time fail closed. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_DECKDRV_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_MirrorSize, CD_HFMF_PackMirror, & CD_HFMF_UnpackMirror, CD_HFMF_FrictionMirrorSize, CD_HFMF_ForceMirrorSize, & + CD_HFMF_BoundaryMirrorSize, & CD_HFMF_End, CD_HFMF_OK, CD_HFMF_BADINPUT USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE, IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE INTEGER :: nfail TYPE(CD_HFMF_ModuleType) :: cable, twin - INTEGER :: es, cn, n, nf, i, nx + INTEGER :: es, cn, n, nf, i, nx, kb CHARACTER(512) :: em REAL(wp), ALLOCATABLE :: buf(:), buf2(:), badbuf(:) @@ -39,15 +42,16 @@ PROGRAM test_hfmf_mirror END IF ! (1) size: [v; q; a] of the free DOFs (strictly below 3*ndof: the coupled node is - ! prescribed) plus the force-blend block of the default force blend + ! prescribed) plus the committed-boundary and force-blend blocks of the default force blend n = CD_HFMF_MirrorSize(cable) - nx = CD_HFMF_FrictionMirrorSize(cable) + CD_HFMF_ForceMirrorSize(cable) + nx = CD_HFMF_FrictionMirrorSize(cable) + CD_HFMF_BoundaryMirrorSize(cable) + CD_HFMF_ForceMirrorSize(cable) nf = (n - nx)/3 CALL require(n > 0, 'mirror size positive') CALL require(MOD(n - nx, 3) == 0, 'free-DOF part a multiple of three ([v; q; a])') CALL require(3*nf < 3*cable%line%ndof, 'free-DOF part below 3*ndof (some DOFs prescribed/fixed)') - CALL require(CD_HFMF_ForceMirrorSize(cable) == 1 + cable%line%ndof + (cable%line%ndof - nf), & - 'force-blend block: flag, committed force, held-DOF accelerations') + CALL require(CD_HFMF_BoundaryMirrorSize(cable) == 3*(cable%line%ndof - nf) + 21, & + 'boundary block: held-DOF [q; v; a], end-connection directions, parent frame') + CALL require(CD_HFMF_ForceMirrorSize(cable) == 1 + cable%line%ndof, 'force-blend block: flag, committed force') ! (2) pack a correctly sized buffer: finite, velocity + acceleration blocks zero at rest ALLOCATE (buf(n), buf2(n)) @@ -65,20 +69,25 @@ PROGRAM test_hfmf_mirror END IF ! (3) unpack round-trip into an identically built twin: perturbed [v; q; a] survives - ! bit-for-bit and the clock carries the restart time + ! bit-for-bit (held DOFs and parent frame included) and the clock carries the restart time CALL CD_Init_Deck_HermiteCable('hfmf_mirror.dat', 0.05_wp, twin, cn, es, em) CALL require(es == CD_DECKDRV_OK, 'init twin: '//TRIM(em)) DO i = 1, n buf(i) = buf(i) + 1.0e-3_wp*REAL(i, wp) ! a deterministic mid-flight-like state END DO - ! the force-blend validity flag is 0 or 1 (a committed force at the restored state) - IF (CD_HFMF_ForceMirrorSize(cable) > 0) buf(3*nf + CD_HFMF_FrictionMirrorSize(cable) + 1) = 1.0_wp + ! the parent orientation stays a rotation (a quarter turn about z), the force-blend validity + ! flag is 0 or 1 (a committed force at the restored state) + kb = 3*nf + CD_HFMF_FrictionMirrorSize(cable) + 3*(cable%line%ndof - nf) + buf(kb + 7:kb + 15) = [0.0_wp, 1.0_wp, 0.0_wp, -1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp] + IF (CD_HFMF_ForceMirrorSize(cable) > 0) buf(kb + 22) = 1.0_wp CALL CD_HFMF_UnpackMirror(twin, buf, 12.5_wp, es, em) CALL require(es == CD_HFMF_OK, 'unpack ok: '//TRIM(em)) CALL require(ABS(twin%line%t - 12.5_wp) <= 0.0_wp, 'restart time set on the line clock') CALL CD_HFMF_PackMirror(twin, buf2, es, em) CALL require(es == CD_HFMF_OK, 're-pack ok') CALL require(nan_max_abs(buf2 - buf) <= 0.0_wp, 'unpack -> pack round-trips bit-identically') + CALL require(nan_max_abs(twin%parent_dcm(:, 1) - [0.0_wp, 1.0_wp, 0.0_wp]) <= 0.0_wp, & + 'the parent orientation reloads from the boundary block') ! (4) fail-closed edges ALLOCATE (badbuf(n + 1)) @@ -90,6 +99,10 @@ PROGRAM test_hfmf_mirror CALL CD_HFMF_UnpackMirror(twin, buf, 1.0_wp, es, em) CALL require(es == CD_HFMF_BADINPUT, 'non-finite mirror fails closed') buf(1) = 0.0_wp + buf(kb + 7) = 2.0_wp + CALL CD_HFMF_UnpackMirror(twin, buf, 1.0_wp, es, em) + CALL require(es == CD_HFMF_BADINPUT, 'a non-orthogonal parent orientation fails closed') + buf(kb + 7) = 0.0_wp CALL CD_HFMF_UnpackMirror(twin, buf, IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN), es, em) CALL require(es == CD_HFMF_BADINPUT, 'non-finite restart time fails closed') From 155441177ebc6a3eadf317d6bfa1e0aad6d52662 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 27 Oct 2026 02:57:59 +0900 Subject: [PATCH 06/51] feat(viv): cross-flow vortex-induced vibration of EI = 0 lines (#55) MoorDyn v2's optional LINE TYPES columns `Cl` or `Cl dF cF` now switch on cross-flow vortex-induced vibration of `EI = 0` lines in the standalone driver: the synchronisation model of Thorsen et al. (2014, 2016) in the form MoorDyn implements it. Model. Each interior node carries a shedding phase phi and the lift 1/4 rho d Cl (l_i + l_i+1) U cos(phi) q x v_n (wetted fraction included). The phase rate is 2 pi (cF + dF sin(phi_y - phi)) U/d, with phi_y the phase of the node's cross-flow motion from its running-RMS velocity and acceleration. The RMS window is `VIVrmsWindow` seconds, by default 500 steps of `dtM` as in MoorDyn, and the phases start at 2 pi i/N from End A. The static equilibrium carries no lift. In the implicit step the phase is explicit. The step's lift takes the phase predicted at t_n+1 from the step-start rate (the generalised-alpha level under the configuration blend), and the commit is the Heun update with the rate at the converged end state. The lift's position and velocity derivatives enter the tangent. The phase sample and the lift use the node kinematics averaged with the neighbours, (x_i-1 + 2 x_i + x_i+1)/4. With the node's own kinematics, a step that resolves the mesh zig-zag mode (dtM 2e-3 s or less on the benchmark) let the synchronisation loop pump that mode until the line lost lock-in; the average removes the zig-zag mode exactly and keeps a resolved mode of wavenumber k to cos^2(k l0/2). Validation against MoorDyn-F (OpenFAST v5 `moordyn_driver`, dtM 5e-4 s) on a taut 100 m line in a uniform cross current, U = 0.06-0.42 m/s: - mode-1 and mode-3 lock-in (U <= 0.18 and >= 0.36 m/s): mid-span A/D within 1.2 % and the response frequency within one spectral bin, e.g. U 0.15 m/s: 0.662 against 0.663 at 0.293 Hz; - the same response at every dtM from 5e-4 to 1e-2 s; - at U 0.21-0.33 m/s the two codes settle on different modes (MoorDyn-F mode 1, CableDyn mode 2). Each is robust to the initial state, the step and the phase origin in its own code. VALIDATION.md records this as a scoped result. Scope. The coupled OpenFAST and FAST.Farm routes and mixed `EI = 0` / finite-EI decks refuse `Cl > 0` by name (they neither checkpoint the phase nor feed it the host's fluid field yet), as do finite-EI and Syrope line types, and an EI = 0 deck without water (the lift acts with the line's Morison drag). In-line VIV is not modelled. State. The phases and running mean squares are part of the committed line state (commit_state_copy): the rotation-resolved sub-steps, the recovery rungs, the line-system rollback and the snapshots save and restore them with the kinematics. Python. `DeckFile` reads the 11- and 13-column rows with MoorDyn's checks and `DeckModel` keeps `cl`, `df` and `cf` through load and save. `DeckFile` refuses `Cl > 0` where the native code does, and the builder refuses VIV columns on a 14-column finite-EI row. Tests: `viv_kernels` (lift, phase rate, RMS update, Jacobians against central differences), `viv_lockin` (the benchmark at dtM 0.01 and 0.002 s against the MoorDyn-F reference), a `test_model` case that forces sub-steps on a VIV line (a repeated sub-stepped pass and the fallback to the plain step stay bit-identical), and the deck-file and builder tests. Full suite on this branch: 304/304 ctest, 2081 pytest; the examples are unchanged. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 7 + CMakeLists.txt | 21 ++ VALIDATION.md | 1 + doc/capabilities.rst | 8 +- doc/cli.rst | 3 +- doc/concepts.rst | 4 +- doc/coupling.rst | 2 +- doc/migrating.rst | 4 + doc/options.rst | 9 + doc/references.rst | 12 + doc/theory.rst | 45 +++ doc/troubleshooting.rst | 5 +- python/cabledyn/builder.py | 33 ++- python/cabledyn/deck_file.py | 76 ++++- python/tests/test_builder.py | 18 ++ python/tests/test_deck_file.py | 77 ++++- src/CableDyn_DeckDriver.f90 | 117 +++++++- src/CableDyn_Hydro.f90 | 9 + src/CableDyn_Model.f90 | 524 ++++++++++++++++++++++++++++++++- src/CableDyn_System.f90 | 54 +++- src/CableDyn_VIV.f90 | 208 +++++++++++++ tests/test_model.f90 | 95 +++++- tests/test_viv_kernels.f90 | 135 +++++++++ tests/test_viv_lockin.py | 158 ++++++++++ 24 files changed, 1587 insertions(+), 38 deletions(-) create mode 100644 src/CableDyn_VIV.f90 create mode 100644 tests/test_viv_kernels.f90 create mode 100644 tests/test_viv_lockin.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 134915c6..fbe1f1b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,13 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- Cross-flow vortex-induced vibration of `EI = 0` lines in the standalone driver: MoorDyn v2's + LINE TYPES columns `Cl` or `Cl dF cF` switch on the synchronisation model of Thorsen et al., + with the same phase start and running-RMS window (`VIVrmsWindow`, default 500 steps of + `dtM`). On a taut 100 m line in a uniform current it follows MoorDyn-F's lock-in amplitude + and frequency to two to three digits through mode-1 and mode-3 lock-in, at any `dtM` from + 5e-4 to 1e-2 s. The Python deck tools read and keep the columns. The coupled and mixed + routes refuse `Cl > 0` by name. - Bend stiffeners (`STIFFENERS` table): a tapered polyurethane sleeve over an end of a finite-EI line, given as conical segments from the root outward (outer diameters, bore, modulus, density). Each element it covers takes the compliance average of the cable-plus-sleeve diff --git a/CMakeLists.txt b/CMakeLists.txt index a67f6b8c..22d27f5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -413,6 +413,7 @@ add_library(cabledyn_obj OBJECT src/CableDyn_Damping.f90 src/CableDyn_Viscoelastic.f90 src/CableDyn_Syrope.f90 + src/CableDyn_VIV.f90 src/CableDyn_Dynamic.f90 src/CableDyn_Model.f90 src/CableDyn_Modal.f90 @@ -1169,6 +1170,11 @@ add_test(NAME flagship_compression_note COMMAND test_flagship_compression_note ${CMAKE_SOURCE_DIR}/examples/iea15mw_umaine_mixed_cabledyn.dat) set_tests_properties(flagship_compression_note PROPERTIES LABELS "fortran;integration;static;contact") +add_executable(test_viv_kernels tests/test_viv_kernels.f90) +target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) +add_test(NAME viv_kernels COMMAND test_viv_kernels) +set_tests_properties(viv_kernels PROPERTIES LABELS "fortran;unit;dynamic;viv") + add_executable(test_hfmf_mirror tests/test_hfmf_mirror.f90) target_link_libraries(test_hfmf_mirror PRIVATE cabledyn_core) add_test(NAME hfmf_mirror COMMAND test_hfmf_mirror WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -1614,6 +1620,21 @@ if(Python3_Interpreter_FOUND) message(STATUS "anchor_uplift_channels: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() + # Cross-flow VIV lock-in of a taut line against MoorDyn-F, at a coarse and a zig-zag-resolving + # dtM (needs numpy). + if(_range_tdp_numpy_rc EQUAL 0) + add_test(NAME viv_lockin + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_viv_lockin.py + --exe $ + --output ${CMAKE_BINARY_DIR}/viv_lockin) + set_tests_properties(viv_lockin PROPERTIES + LABELS "python;integration;dynamic;viv;validation" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + else() + message(STATUS "viv_lockin: skipped (numpy not importable in ${Python3_EXECUTABLE})") + endif() + # Node channels on a refined finite-EI line name deck nodes: the static profile's DeckNode # column, the standalone static and dynamic cubic-Hermite routes, the mixed route (the OpenFAST # aggregate evaluator) and the C API on the coarse lazy-wave deck the static solve refines diff --git a/VALIDATION.md b/VALIDATION.md index a0f24c89..fe21a1f6 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -62,6 +62,7 @@ article's methods, are compared in | **L2-V** | VolturnUS-S anchor tension | closed-form catenary | 0.77% | <3% | Pass | | **L2-80** | Lozon 80 m all-chain mooring | catenary (H) / MoorDyn-F (fairlead) | 0.03% / 1.8% | <2% / <5% | Pass | | **L2-arb** | Closed-form catenary reference check | OrcaFlex VolturnUS-S ref | 0.69% | <2% | Pass | +| **L2-VIV** | Cross-flow VIV lock-in of a taut 100 m line, U = 0.06–0.42 m/s | MoorDyn-F (OpenFAST v5 `moordyn_driver`, `dtM` 5e-4 s) | mode-1 and mode-3 lock-in (U ≤ 0.18 and ≥ 0.36 m/s): mid-span A/D within 1.2%, frequency within one spectral bin; same response at `dtM` 5e-4 to 1e-2 s; at 0.21–0.33 m/s the codes settle on different modes (MoorDyn-F mode 1, CableDyn mode 2) | A/D <3%, frequency within one spectral bin (`viv_lockin`) | Pass scoped | | **L3-1** | WD0050 static | OrcaFlex | 0.15 / 0.85% | <2% | Pass | | **L3-2** | Regular-wave dynamic | OrcaFlex (pinned, dt-converged) | mean 0.30%, swing 8.4% | <2% / <15% | Pass | | **L3-3** | Current-deflected static | OrcaFlex | 0.07–0.67% | <2% | Pass | diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 2225ca7d..450b8b01 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -113,9 +113,11 @@ Line and constitutive capability - natural frequencies and mode shapes of each line about its static equilibrium (all ``EI = 0`` lines, or all finite-EI lines on the Hermite route; flat seabed); a deck with torsion is rejected - * - VIV (``compVIV``) - - Not implemented - - use another validated model; CableDyn rejects the request + * - Cross-flow VIV (LINE TYPES ``Cl``, ``dF``, ``cF``) + - Standalone only + - MoorDyn v2's synchronisation model on ``EI = 0`` lines (:ref:`theory-viv`); in-line VIV + and finite-EI cables are not provided; the coupled OpenFAST and FAST.Farm routes and + mixed ``EI = 0`` / finite-EI decks refuse ``Cl > 0`` by name Loads and environment --------------------- diff --git a/doc/cli.rst b/doc/cli.rst index affb914c..5036ac73 100644 --- a/doc/cli.rst +++ b/doc/cli.rst @@ -1016,7 +1016,8 @@ native reader's rules. - ``LINE TYPES`` row ``NAME``; fields ``name``, ``diam``, ``mass``, ``ea``, ``ba``, ``ei`` followed by ``cdn``, ``cdt``, ``can``, ``cat`` (CableDyn columns), ``cd``, ``ca``, ``cdax``, ``caax`` (MoorDyn-style columns), or ``gas``, ``gj``, ``irt``, - ``irn``, ``cdn``, ``cdt``, ``can``, ``cat`` (14-column rows). + ``irn``, ``cdn``, ``cdt``, ``can``, ``cat`` (14-column rows); an 11- or 13-column row + adds ``cl`` or ``cl``, ``df``, ``cf`` (VIV). * - ``section.LINE.OCCURRENCE.FIELD`` - The ``OCCURRENCE``-th section (1-based, End A to End B) of line ``LINE``; fields ``lineid``, ``linetype``, ``length``, ``numsegs``. A 7-column ``LINES`` row counts as a diff --git a/doc/concepts.rst b/doc/concepts.rst index e6277908..0f9e57c4 100644 --- a/doc/concepts.rst +++ b/doc/concepts.rst @@ -80,7 +80,9 @@ A ``LINE TYPES`` row is the reusable material a section refers to by name: diame metre, axial stiffness ``EA``, axial damping ``BA``, bending stiffness ``EI``, and the four Morison coefficients (``Cd_n``, ``Cd_t``, ``Ca_n``, ``Ca_t``). ``EI`` is the switch between the two solver paths (next section). Axial response can be linear ``EA`` or a stateful constitutive model -(viscoelastic, Syrope) — see :doc:`theory`. +(viscoelastic, Syrope) — see :doc:`theory`. An ``EI = 0`` row may end with MoorDyn's cross-flow +VIV columns ``Cl`` or ``Cl dF cF`` (lift coefficient and synchronisation band; see +:ref:`theory-viv`). Two solver paths, selected by ``EI`` ------------------------------------ diff --git a/doc/coupling.rst b/doc/coupling.rst index d66c8d64..8ec85665 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -57,7 +57,7 @@ solve is mathematically incorrect; changing ``NumCrctn`` does not change that de ``current`` except as a steady current on a single-turbine, pure ``EI = 0`` deck without Rigid6 bodies or rods in a SeaState without waves or current (a WaterKin ``CurrentMod 1`` table remains available), - - VIV (``compVIV``), and + - cross-flow VIV (a LINE TYPES ``Cl > 0``), which runs in the standalone driver only, and - fluid-source combinations that the nodewise SeaState field cannot separate without double counting. diff --git a/doc/migrating.rst b/doc/migrating.rst index de3e5fc7..9a851f77 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -92,6 +92,10 @@ Keyword map * - ``LINE TYPES`` ``Name Diam MassDen EA BA/-zeta EI Cd Ca CdAx CaAx`` - same row; the native order is ``Cd_n Cd_t Ca_n Ca_t`` and the header decides which is meant. ``EI > 0`` switches the line to the bending element. + * - ``LINE TYPES`` VIV columns ``Cl`` or ``Cl dF cF`` + - same columns and the same synchronisation model on ``EI = 0`` types in the standalone + driver (:ref:`theory-viv`); the running-RMS window is ``VIVrmsWindow`` seconds, by default + 500 steps of ``dtM`` as MoorDyn's * - ``ElasticMod 2/3`` viscoelastic ``EA``/``BA`` - ``Es|Ed`` / ``Es|alphaMBL|vbeta`` in ``EA`` and ``BA_s|BA_d`` in ``BA`` * - Syrope line type and ``SYROPE IC`` diff --git a/doc/options.rst b/doc/options.rst index 3d6090de..e5accfcf 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -676,6 +676,15 @@ Ambient fluid and prescribed motion shape; one to two peak periods is typical - standalone ``waves``, ``wavetrain``, and WaterKin ``WaveKinMod 1`` waves - ``20.0 rampTime`` + * - ``VIVrmsWindow`` / ``viv_rms_window`` + - real, s + - ``0`` + - finite, ≥ 0; the averaging time of the running RMS cross-flow velocity and acceleration + of the VIV synchronisation model (:ref:`theory-viv`). ``0`` takes MoorDyn's 500 steps of + ``dtM`` (of the first step when the deck has no ``dtM``); set it to compare runs at + different ``dtM`` with the same averaging time + - standalone ``EI = 0`` lines with a LINE TYPES ``Cl > 0`` + - ``0.25 VIVrmsWindow`` * - ``motionFile`` - path, or ``0``/``none`` - absent diff --git a/doc/references.rst b/doc/references.rst index 371c264b..9498856b 100644 --- a/doc/references.rst +++ b/doc/references.rst @@ -77,6 +77,18 @@ Time integration and nonlinear solution Hydrodynamics and ocean environment ----------------------------------- +.. _ref-thorsen2014: + +- **Thorsen, M. J., Sævik, S. & Larsen, C. M. (2014).** A simplified method for time domain + simulation of cross-flow vortex-induced vibrations. *Journal of Fluids and Structures* + **49**, 135–148. https://doi.org/10.1016/j.jfluidstructs.2014.04.006 + +.. _ref-thorsen2016: + +- **Thorsen, M. J., Sævik, S. & Larsen, C. M. (2016).** Time domain simulation of + vortex-induced vibrations in stationary and oscillating flows. *Journal of Fluids and + Structures* **61**, 1–19. https://doi.org/10.1016/j.jfluidstructs.2015.11.006 + .. _ref-morison1950: - **Morison, J. R., O'Brien, M. P., Johnson, J. W. & Schaaf, S. A. (1950).** The force diff --git a/doc/theory.rst b/doc/theory.rst index 046aea2e..9b96cc7e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -715,6 +715,51 @@ fluid acceleration :math:`\dot{\mathbf{u}}_f = \dot{\mathbf{u}}_{f,n} + \dot{\ma The fluid acceleration is the local (Eulerian) acceleration of the wave field. +.. _theory-viv: + +Cross-flow vortex-induced vibration +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``EI = 0`` lines can carry the cross-flow lift of the synchronisation model of +:ref:`Thorsen et al. (2014) ` and :ref:`(2016) ` in the form +MoorDyn v2 implements it: a LINE TYPES row with a lift coefficient :math:`C_L > 0` (see +:doc:`file_formats`). At an interior node with unit tangent :math:`\mathbf{q}` (the chord of its +neighbours) and normal relative flow :math:`\mathbf{v}_n` of speed :math:`U = \lvert\mathbf{v}_n\rvert`, +each node carries a vortex-shedding phase :math:`\phi` and the lift + +.. math:: + + \mathbf{F}_L = \tfrac{1}{4}\rho\,d\,C_L\,(l_{i} + l_{i+1})\,U\cos\phi\;\mathbf{q}\times\mathbf{v}_n , + +the per-length :math:`\tfrac{1}{2}\rho d C_L U^2\cos\phi` over the node's half elements (wetted +fraction included). The phase follows the cross-flow motion +:math:`\dot y = \dot{\mathbf{r}}\cdot\mathbf{e}`, :math:`\ddot y = \ddot{\mathbf{r}}\cdot\mathbf{e}` +along :math:`\mathbf{e} = \mathbf{q}\times\mathbf{v}_n/U`: + +.. math:: + + \dot\phi = 2\pi\,\hat f\,\frac{U}{d}, \qquad + \hat f = c_F + d_F \sin(\phi_{\dot y} - \phi), \qquad + \phi_{\dot y} = \operatorname{atan2}\!\left(-\frac{\ddot y}{\ddot y_\text{rms}},\, + \frac{\dot y}{\dot y_\text{rms}}\right), + +so the shedding frequency locks onto the cross-flow motion inside the band +:math:`c_F \pm d_F` (MoorDyn's defaults 0.18 and 0.08). The running RMS values average over +``VIVrmsWindow`` seconds, by default 500 steps of ``dtM`` as in MoorDyn, and the phases start at +:math:`2\pi i/N` along the line from End A. The static equilibrium carries no lift. + +In the implicit step the phase is explicit: the step's lift takes the phase predicted at +:math:`t_{n+1}` from the step-start rate (the generalised-α level under the configuration blend), +and the committed phase is the trapezoidal (Heun) update with the rate at the converged end +state. The lift's position and velocity derivatives enter the tangent. The cross-flow motion of +the phase and the velocity in the lift are the node values averaged with the neighbours, +:math:`(\mathbf{x}_{i-1} + 2\mathbf{x}_i + \mathbf{x}_{i+1})/4`. That keeps a resolved mode of +wavenumber :math:`k` to :math:`\cos^2(k l_0/2)` and removes the mesh-scale zig-zag mode exactly. +With the node's own kinematics, a step that resolves the zig-zag mode lets the synchronisation +loop pump it until the line loses lock-in; a coarse step only hides this behind the +integrator's numerical damping. VIV runs in the standalone driver; the coupled and mixed +aggregate routes refuse a deck with :math:`C_L > 0`. + Buoyancy and wetting ~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index ab6092ed..5d80a286 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -838,8 +838,9 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com - linearise a pinned-hang-off, uncontrolled variant of the deck; time-domain runs support both * - a ``Rigid`` end-connection direction reversed by exactly 180 degrees in one host update - drive the platform through intermediate orientations - * - VIV (``compVIV``) - - use a solver with a separately validated VIV model + * - VIV on the coupled or mixed route (``VIV (LINE TYPES Cl > 0) runs in the standalone driver + of an EI = 0 deck``) + - run the VIV study on a standalone ``EI = 0`` deck, or set ``Cl = 0`` for the coupled run * - 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/builder.py b/python/cabledyn/builder.py index 8bf7c1a6..1aa415b3 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -193,6 +193,11 @@ class LineType: 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. + cl, df, cf : float | None + Optional cross-flow VIV columns of an ``EI = 0`` type (MoorDyn's lift + coefficient and the half-range and centre of the synchronisation band + in non-dimensional frequency). ``cl`` set writes the 13-column row, with + MoorDyn's ``df = 0.08`` and ``cf = 0.18`` where they are ``None``. """ name: str @@ -209,6 +214,9 @@ class LineType: gj: float | None = None irt: float | None = None irn: float | None = None + cl: float | None = None + df: float | None = None + cf: float | None = None @dataclass(eq=False) @@ -1622,6 +1630,9 @@ def add_line_type( gj: float | None = None, irt: float | None = None, irn: float | None = None, + cl: float | None = None, + df: float | None = None, + cf: float | None = None, ) -> LineType: """Add a ``LINE TYPES`` row; see :class:`LineType` for the fields. @@ -1637,7 +1648,9 @@ def add_line_type( """ _text(name, "line-type name") self._check_new_key(self.line_types, name) - item = LineType(name, diam, mass, ea, ba, ei, cdn, cdt, can, cat, gas, gj, irt, irn) + item = LineType( + name, diam, mass, ea, ba, ei, cdn, cdt, can, cat, gas, gj, irt, irn, cl, df, cf + ) self._line_types.append(item) return item @@ -2631,7 +2644,7 @@ def save( def _line_type_table(self) -> tuple[str, str, list[list[str]]]: rows: list[list[str]] = [] - wide = False + wide = viv = False for item in self._line_types: what = f"line type {item.name!r}" row = [_text(item.name, what), _num(item.diam, what), _num(item.mass, what)] @@ -2649,10 +2662,23 @@ def _line_type_table(self) -> tuple[str, str, list[list[str]]]: 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)] + if item.cl is not None: + if all(value is not None for value in extra): + # a LINE TYPES row has 10, 11, 13 or 14 columns: no VIV on the wide row + raise ValueError(f"{what}: cl, df and cf do not combine with gas, gj, irt, irn") + viv = True + df = 0.08 if item.df is None else item.df + cf = 0.18 if item.cf is None else item.cf + row += [_num(v, what) for v in (item.cl, df, cf)] + elif item.df is not None or item.cf is not None: + raise ValueError(f"{what}: df and cf need the VIV lift coefficient cl") rows.append(row) if wide: header = "Name Diam Mass EA BA EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t" units = "(-) (m) (kg/m) (N) (N-s) (N-m^2) (N) (N-m^2) (kg-m) (kg-m) (-) (-) (-) (-)" + elif viv: + header = "Name Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t Cl dF cF" + units = "(-) (m) (kg/m) (N) (N-s) (N-m^2) (-) (-) (-) (-) (-) (-) (-)" else: header = "Name Diam Mass EA BA EI Cd_n Cd_t Ca_n Ca_t" units = "(-) (m) (kg/m) (N) (N-s) (N-m^2) (-) (-) (-) (-)" @@ -3142,6 +3168,9 @@ def line_type(self, row: DeckRecord) -> None: gj=_f(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, + df=_f(values["df"]) if "df" in values else None, + cf=_f(values["cf"]) if "cf" in values else None, ) def body(self, row: DeckRecord) -> None: diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 9f7f1ea7..343667df 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -227,6 +227,8 @@ "tramp": "ramp_time", "maxstrain": "max_strain", "max_strain": "max_strain", + "vivrmswindow": "viv_rms_window", + "viv_rms_window": "viv_rms_window", "rangestart": "range_start", "range_start": "range_start", "waveseed": "wave_seed", @@ -1124,6 +1126,7 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "ramp_time", "max_strain", "range_start", + "viv_rms_window", }: if key == "friction" and value.lower() == "none": return None @@ -1153,6 +1156,7 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "ramp_time", "max_strain", "range_start", + "viv_rms_window", } or raw in {"dtic", "tmaxic", "cdscaleic", "threshic", "writelog", "dtout", "dtwave"}: try: numeric = _native_float(value) @@ -2582,7 +2586,7 @@ def effective(key: str, default: float) -> float: raise DeckFormatError( f"{self._label}: standalone OPTION frictionMu requires dtM and TMax" ) - allowed_widths = {"LINE TYPES": {10, 14}, "POINTS": {5, 9}, "LINES": {3, 4, 7}} + allowed_widths = {"LINE TYPES": {10, 11, 13, 14}, "POINTS": {5, 9}, "LINES": {3, 4, 7}} # Every row present is checked, also in a line-free deck of bodies and rods: the # native reader parses each table row whether or not a line uses it. for name in sorted(allowed_widths): @@ -2607,6 +2611,10 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: line_type_scales: dict[str, tuple[float, float]] = {} # name -> (BA, max Cd/Ca) line_type_meta: dict[str, tuple[float, float, float, float]] = {} line_type_gj: dict[str, float] = {} # name -> explicit GJ of a 14-column row, else 0 + # Cl > 0 on any LINE TYPES row (native CD_Init_Deck_Aggregate), and on an EI = 0 row + # (native init_one_model, which needs the line's Morison drag in water) + has_viv = False + has_viv_ei0 = False for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") @@ -2658,11 +2666,12 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: Syrope BA_s and BA_d must be non-negative " "with a positive sum" ) - # Native append_type: drag and added-mass coefficients (the last four - # columns in either column order) must be non-negative. + # Native append_type: drag and added-mass coefficients (columns 7-10, the last + # four of a 14-column row, in either column order) must be non-negative. + hydro_start = len(row.tokens) - 4 if len(row.tokens) == 14 else 6 hydro = [ numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") - for index in range(len(row.tokens) - 4, len(row.tokens)) + for index in range(hydro_start, hydro_start + 4) ] if any(value < 0.0 for value in hydro): raise DeckFormatError( @@ -2670,6 +2679,35 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: "(Cd_n Cd_t Ca_n Ca_t) must be non-negative" ) ei = numeric(row.tokens[5], row, "EI") + if len(row.tokens) in (11, 13): + # Native check_viv_columns: MoorDyn's cross-flow VIV columns Cl [dF cF] + cl = numeric(row.tokens[10], row, "Cl") + d_f, c_f = ( + (numeric(row.tokens[11], row, "dF"), numeric(row.tokens[12], row, "cF")) + if len(row.tokens) == 13 + else (0.08, 0.18) + ) + if cl < 0.0: + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES VIV lift coefficient Cl must be " + "non-negative (0 = VIV off)" + ) + if cl > 0.0 and not (c_f > 0.0 and 0.0 <= d_f < c_f): + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES VIV synchronisation band needs cF > 0 " + "and 0 <= dF < cF" + ) + if cl > 0.0 and ei > 0.0: + raise DeckFormatError( + f"{self._at(row)}: VIV (Cl > 0) is implemented for EI = 0 line types only" + ) + if cl > 0.0 and is_syrope: + raise DeckFormatError( + f"{self._at(row)}: VIV (Cl > 0) does not combine with the Syrope " + "working-curve model" + ) + has_viv = has_viv or cl > 0.0 + has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) 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") @@ -3453,6 +3491,12 @@ def end_key(token: str) -> str: ) if not line_ids: raise DeckFormatError(f"{self._label}: the coupled route needs at least one line") + if has_viv: + raise DeckFormatError( + f"{self._label}: VIV (LINE TYPES Cl > 0) runs in the standalone driver of an " + "EI = 0 deck; the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / " + "finite-EI decks do not carry it yet. Set Cl = 0 for this run" + ) if self.caller_driven: # native CD_Init_Deck_Aggregate: nothing on the coupled route evaluates deck # waves (the host SeaState supplies them). A deck current is a steady field on a @@ -3472,6 +3516,24 @@ def end_key(token: str) -> str: "single-turbine pure EI=0 deck without Rigid6 bodies or rods; remove the " "deck current OPTION (the host SeaState supplies the current)" ) + if has_viv_ei0 and deck_driver_route: + # native init_one_model: the lift acts with the line's Morison drag, which the + # deck switches on with water (a depth or bathymetry, a current, or waves) + waterkin_option = option_by_key.get("waterkin") + waterkin_text = "" if waterkin_option is None else waterkin_option.values[0] + has_water = ( + has_depth + or has_bathymetry + or has_waves + or bool(trains) + or (current is not None and current.values[0].lower() != "none") + or waterkin_text.lower() not in {"", "0", "none", "seastate"} + ) + if not has_water: + raise DeckFormatError( + f"{self._label}: VIV (LINE TYPES Cl > 0) acts with the line's Morison drag " + "in water: declare WtrDpth (or bathymetryFile), a current or waves" + ) if mixed_route and not self.caller_driven: n_modes_value = option_by_key.get("n_modes") if n_modes_value is not None and round(_native_float(n_modes_value.values[0])) != 0: @@ -4164,9 +4226,11 @@ def _line_type_fields(self, record: DeckRecord) -> tuple[str, ...]: fields = _FIELDS["line_type"] if len(record.tokens) == 14: return (*fields[:6], "gas", "gj", "irt", "irn", "cdn", "cdt", "can", "cat") + # MoorDyn's optional cross-flow VIV columns follow the ten standard ones + viv = {11: ("cl",), 13: ("cl", "df", "cf")}.get(len(record.tokens), ()) if self._stock_line_type_columns(record): - return (*fields[:6], "cd", "ca", "cdax", "caax") - return fields + return (*fields[:6], "cd", "ca", "cdax", "caax", *viv) + return (*fields, *viv) def _line_section_records(self, line_id: int) -> list[tuple[DeckRecord, tuple[str, ...], str]]: """Return one line's native section sequence in deck (End A to End B) order. diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index c45b3f43..f483ffc1 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -185,6 +185,24 @@ def test_build_single_catenary_validates_and_saves(tmp_path: Path) -> None: assert model.save(target, overwrite=True) == target +def test_viv_columns_do_not_combine_with_the_wide_finite_ei_row(tmp_path: Path) -> 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.0e3, + irt=0.1, + irn=0.05, + cl=0.0, + ) + with pytest.raises(ValueError, match="do not combine with gas, gj, irt, irn"): + model.to_text(validate=False) + + def test_build_spread_mooring_with_multi_section_lines() -> None: import math diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 12bc59d3..9f8e7825 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4406,7 +4406,7 @@ def test_line_free_object_deck_checks_line_type_rows_without_crashing(): ("1 2 1 -\n", ""), ("1 chain 410.0 41\n", ""), ) - with pytest.raises(DeckFormatError, match="LINE TYPES row needs 10, 14 fields"): + with pytest.raises(DeckFormatError, match="LINE TYPES row needs 10, 11, 13, 14 fields"): DeckFile.from_text(_with_section(no_lines, "BODIES", *body_rows)) # a header-only LINES section does not make the deck a line deck (the rule counts rows) with pytest.raises(DeckFormatError) as caught: @@ -4543,3 +4543,78 @@ def test_coupled_route_keeps_deck_current_only_on_pure_ei0_decks(tmp_path, old, path.write_text(source.replace(old, new), encoding="utf-8") with pytest.raises(DeckFormatError, match="deck current on the coupled route is kept only"): DeckFile.read(path, caller_driven=True) + + +# MoorDyn's optional cross-flow VIV columns: Cl, or Cl dF cF, after the ten standard ones. +_VIV_ROW = "chain 0.252 390.0 1.674e9 -1.0 0.0 1.37 0.64 1.0 0.0" + + +@pytest.mark.parametrize( + "columns, expected", + [ + (" 0.8", (0.8, None, None)), + (" 0.8 0.05 0.2", (0.8, 0.05, 0.2)), + (" 0.0 0.08 0.18", (0.0, 0.08, 0.18)), + ], +) +def test_line_type_viv_columns_are_read_and_kept(tmp_path, columns, expected): + from cabledyn import DeckModel + + text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + columns)) + DeckFile.from_text(text) + path = tmp_path / "viv.dat" + path.write_text(text, encoding="utf-8") + line_type = DeckModel.load(path).line_types["chain"] + assert (line_type.cl, line_type.df, line_type.cf) == expected + saved = tmp_path / "saved.dat" + DeckModel.load(path).save(saved) + reread = DeckModel.load(saved).line_types["chain"] + # a saved Cl row always writes the band; MoorDyn's defaults fill a Cl-only row + assert (reread.cl, reread.df, reread.cf) == ( + expected[0], + 0.08 if expected[1] is None else expected[1], + 0.18 if expected[2] is None else expected[2], + ) + + +@pytest.mark.parametrize( + "columns, message", + [ + (" -0.1", "Cl must be non-negative"), + (" 0.8 0.2 0.18", "needs cF > 0 and 0 <= dF < cF"), + (" 0.8 0.05 0.0", "needs cF > 0 and 0 <= dF < cF"), + (" 0.8 0.08", "LINE TYPES row needs 10, 11, 13, 14 fields"), + ], +) +def test_line_type_viv_columns_follow_the_native_checks(columns, message): + with pytest.raises(DeckFormatError, match=re.escape(message)): + DeckFile.from_text(_edit(_STATIC, (_VIV_ROW, _VIV_ROW + columns))) + + +def test_line_type_viv_needs_an_ei0_line_type(): + row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" + text = _edit(_DYNAMIC, (row, row + " 0.8")) + with pytest.raises(DeckFormatError, match="implemented for EI = 0 line types only"): + DeckFile.from_text(text) + + +def test_viv_is_refused_on_the_coupled_route(): + text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8")) + DeckFile.from_text(text) + with pytest.raises(DeckFormatError, match="runs in the standalone driver"): + DeckFile.from_text(text, caller_driven=True) + + +def test_viv_needs_water_on_an_ei0_line(): + text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8"), ("50.0 WtrDpth\n", "")) + with pytest.raises(DeckFormatError, match="acts with the line's Morison drag in water"): + DeckFile.from_text(text) + # without the lift the same dry deck stays valid + DeckFile.from_text(_edit(_STATIC, ("50.0 WtrDpth\n", ""))) + + +def test_viv_rms_window_option_is_non_negative(): + base = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8")) + 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"))) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 5e2b639f..fbeca086 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -57,7 +57,7 @@ MODULE CableDyn_DeckDriver CD_Get_Model_EndForces, & CD_Update_Model_CoupledMotion, CD_Update_Model_Hydro_Fields, & CD_Recompute_Model_Acceleration, CD_Step_Model, CD_Step_Model_Recovering, CD_MODEL_OK, & - CD_Audit_Model_Step + CD_Audit_Model_Step, CD_Set_Model_VIV USE CableDyn_System, ONLY: CD_SystemType, CD_SystemPointType, CD_LineEndpointBinding, & CD_Init_System_From_Points, CD_End_System, CD_System_Line_NDOF, & CD_System_Line_NElem, CD_Get_System_Point_State, CD_Get_System_Line_State, & @@ -126,6 +126,7 @@ MODULE CableDyn_DeckDriver CD_HFMF_CalcOutput, CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_SetCoupledKinematics, CD_HFMF_GetCoupledKinematics, & 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, & CD_Current_Profile_Velocity, & CD_JONSWAP_COMPONENTS, CD_JONSWAP_Random_Components, & @@ -362,6 +363,11 @@ MODULE CableDyn_DeckDriver REAL(wp), ALLOCATABLE :: syrope_owc_strain(:), syrope_owc_tension(:) ! The OWC table file the settings file names, resolved. CHARACTER(CD_DECK_PATHLEN) :: syrope_owc_file = '' + ! Cross-flow VIV (MoorDyn's optional LINE TYPES columns Cl dF cF, CableDyn_VIV): the lift + ! coefficient (0 = off) and the synchronisation half-range dF and centre cF of the + ! non-dimensional shedding frequency. A row with Cl only takes MoorDyn's dF = 0.08 and + ! cF = 0.18. + REAL(wp) :: cl = CD_ZERO, viv_df = CD_VIV_DEFAULT_DF, viv_cf = CD_VIV_DEFAULT_CF ! Deck file line of the row (0 when not read from a file), for error messages. INTEGER :: deck_line = 0 END TYPE @@ -575,6 +581,10 @@ MODULE CableDyn_DeckDriver ! element stretched beyond this strain (or non-finite) fails the run; 0 disables. REAL(wp) :: max_strain = 0.5_wp LOGICAL :: has_max_strain = .FALSE. + ! Cross-flow VIV (LINE TYPES Cl > 0): averaging time of the running cross-flow RMS values + ! of the synchronisation model (OPTION VIVrmsWindow, s); 0 = MoorDyn's 500 time steps of + ! the deck dtM (or of the run's step when the deck has none). + REAL(wp) :: viv_rms_window = CD_ZERO ! WaveKinMod-1 elevation history reduced once to its real Fourier components. ! These feed the same arbitrary-component Airy kernel used by reference-matched ! irregular seas; wave_eta_mean carries the zero-frequency waterline offset. @@ -6701,6 +6711,15 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 'EI=0/finite-EI decks reject deck water kinematics)') RETURN END IF + ! Cross-flow VIV runs in the standalone EI = 0 driver: the aggregate route (OpenFAST, FAST.Farm, + ! mixed EI = 0 / finite-EI decks) neither checkpoints its shedding phase nor feeds it the host's + ! fluid field yet. + IF (ANY(types%cl > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) runs in the standalone driver of an EI = 0 deck; '// & + 'the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / finite-EI decks do not carry it '// & + 'yet. Set Cl = 0 for this run') + RETURN + END IF IF (opts%waterkin_seastate) THEN IF (.NOT. PRESENT(external_fluid)) THEN @@ -8389,6 +8408,7 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err REAL(wp), ALLOCATABLE :: ba(:), fluid_velocity(:, :), fluid_acceleration(:, :), drag_waterline(:) REAL(wp), ALLOCATABLE :: hydro_diam(:), hydro_cdn(:), hydro_cdt(:), hydro_can(:), hydro_cat(:) REAL(wp), ALLOCATABLE :: ve_ead(:), ve_bas(:), ve_bad(:), ve_ambl(:), ve_vbet(:) + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) REAL(wp) :: anchor(3), fairlead(3) REAL(wp), PARAMETER :: factors(4) = [0.25_wp, 0.5_wp, 0.75_wp, CD_ONE] INTEGER :: j, i, e, es @@ -8425,7 +8445,11 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err END IF ALLOCATE (ba(SIZE(l0)), hydro_diam(SIZE(l0)), hydro_cdn(SIZE(l0)), hydro_cdt(SIZE(l0)), & hydro_can(SIZE(l0)), hydro_cat(SIZE(l0)), ve_ead(SIZE(l0)), ve_bas(SIZE(l0)), & - ve_bad(SIZE(l0)), ve_ambl(SIZE(l0)), ve_vbet(SIZE(l0))) + ve_bad(SIZE(l0)), ve_ambl(SIZE(l0)), ve_vbet(SIZE(l0)), viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), & + viv_df(SIZE(l0))) + viv_cl = CD_ZERO + viv_cf = CD_ZERO + viv_df = CD_ZERO ve_ead = CD_ZERO ve_bas = CD_ZERO ve_bad = CD_ZERO @@ -8462,8 +8486,14 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err hydro_cdt(e) = types(line_section_type(sections, ln%id, i))%cdt hydro_can(e) = types(line_section_type(sections, ln%id, i))%can hydro_cat(e) = types(line_section_type(sections, ln%id, i))%cat + viv_cl(e) = types(line_section_type(sections, ln%id, i))%cl + viv_cf(e) = types(line_section_type(sections, ln%id, i))%viv_cf + viv_df(e) = types(line_section_type(sections, ln%id, i))%viv_df END DO END DO + viv_cl = viv_cl(SIZE(viv_cl):1:-1) + viv_cf = viv_cf(SIZE(viv_cf):1:-1) + viv_df = viv_df(SIZE(viv_df):1:-1) ba = ba(SIZE(ba):1:-1) ve_ead = ve_ead(SIZE(ve_ead):1:-1) ve_bas = ve_bas(SIZE(ve_bas):1:-1) @@ -8486,6 +8516,9 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err syt = line_section_type(sections, ln%id, i2) END DO IF (syt > 0) THEN + IF (ANY(viv_cl > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) does not combine with a Syrope line'); RETURN + END IF CALL init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0, opts, & static_cfg, dynamic_cfg, factors, bathymetry, model, ErrStat, ErrMsg) RETURN @@ -8712,6 +8745,28 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err IF (ErrStat /= CD_MODEL_OK) THEN ErrMsg = 'CableDyn_DeckDriver: model init failed: '//TRIM(ErrMsg) IF (ErrStat /= CD_DECKDRV_BADINPUT) ErrStat = CD_DECKDRV_SOLVEFAIL + RETURN + END IF + ! Cross-flow VIV on the Cl > 0 sections (CableDyn_VIV), installed on the initialised line + ! (the static equilibrium carries no lift, as MoorDyn's initial-condition generation), and + ! the initial acceleration recomputed with the t = 0 lift. + IF (ANY(viv_cl > CD_ZERO)) THEN + BLOCK + REAL(wp) :: tw + IF (.NOT. model%has_morison_drag) THEN + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) acts with the line''s Morison drag in water: '// & + 'declare WtrDpth (or bathymetryFile), a current or waves'); RETURN + END IF + tw = opts%viv_rms_window + IF (.NOT. (tw > CD_ZERO) .AND. opts%has_dtm) tw = REAL(CD_VIV_NM, wp)*opts%dtM + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em) + IF (es == CD_MODEL_OK) CALL CD_Recompute_Model_Acceleration(model, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_DECKDRV_BADINPUT + ErrMsg = 'CableDyn_DeckDriver: VIV setup failed: '//TRIM(em) + RETURN + END IF + END BLOCK END IF END SUBROUTINE init_one_model @@ -12536,9 +12591,10 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) INTEGER :: ios, ntok ErrStat = 0; ErrMsg = '' ntok = count_tokens(line) - IF (ntok /= 10 .AND. ntok /= 14) THEN + IF (ntok /= 10 .AND. ntok /= 11 .AND. ntok /= 13 .AND. ntok /= 14) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES row needs 10 cols '// & - '(Name Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t) or 14 cols '// & + '(Name Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t), 11 or 13 cols (the same '// & + 'followed by MoorDyn''s VIV columns Cl [dF cF]) or 14 cols '// & '(Name Diam MassDenInAir EA BA/-zeta EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t)'); RETURN END IF ! EA and BA read as STRINGS: MoorDyn's viscoelastic syntax carries @@ -12550,6 +12606,24 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) ELSE READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%cdt, t%can, t%cat END IF + ELSE IF (ntok == 11 .OR. ntok == 13) THEN + ! MoorDyn v2's optional cross-flow VIV columns after the ten standard ones: Cl, or + ! Cl dF cF (MoorDyn.f90 line-type parse; dF and cF default to 0.08 and 0.18) + IF (stock_cols) THEN + IF (ntok == 11) THEN + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%can, t%cdt, t%cat, t%cl + ELSE + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%can, t%cdt, t%cat, & + t%cl, t%viv_df, t%viv_cf + END IF + ELSE + IF (ntok == 11) THEN + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%cdt, t%can, t%cat, t%cl + ELSE + READ (line, *, IOSTAT=ios) t%name, t%diam, t%mass, ea_str, ba_str, t%ei, t%cdn, t%cdt, t%can, t%cat, & + t%cl, t%viv_df, t%viv_cf + END IF + END IF ELSE IF (stock_cols) THEN CALL fail(ErrStat, ErrMsg, 'the 14-column LINE TYPES row is a CableDyn form (... Cd_n Cd_t '// & @@ -12569,10 +12643,41 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) END IF CALL parse_stiffness_columns(ea_str, ba_str, t, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN + IF (ntok == 11 .OR. ntok == 13) THEN + CALL check_viv_columns(t, ErrStat, ErrMsg) + IF (ErrStat /= 0) RETURN + END IF CALL grow_types(types, nt) nt = nt + 1; types(nt) = t END SUBROUTINE append_type + SUBROUTINE check_viv_columns(t, ErrStat, ErrMsg) + !! The VIV columns of a LINE TYPES row: a finite, non-negative Cl; with Cl > 0 a positive + !! shedding frequency band (cF > 0, 0 <= dF < cF) on an EI = 0, non-Syrope line type. + TYPE(DeckLineType), INTENT(IN) :: t + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = 0; ErrMsg = '' + IF (.NOT. (IEEE_IS_FINITE(t%cl) .AND. IEEE_IS_FINITE(t%viv_df) .AND. IEEE_IS_FINITE(t%viv_cf))) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES VIV columns (Cl dF cF) must be finite'); RETURN + END IF + IF (t%cl < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES VIV lift coefficient Cl must be non-negative (0 = VIV off)'); RETURN + END IF + IF (.NOT. (t%cl > CD_ZERO)) RETURN + IF (.NOT. (t%viv_cf > CD_ZERO .AND. t%viv_df >= CD_ZERO .AND. t%viv_df < t%viv_cf)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES VIV synchronisation band needs cF > 0 and 0 <= dF < cF'); RETURN + END IF + IF (t%ei > CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) is implemented for EI = 0 '// & + 'line types only; set EI = 0 or Cl = 0 (VIV of finite-EI cables is not available)'); RETURN + END IF + IF (t%is_syrope) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) does not combine with the '// & + 'Syrope working-curve model'); RETURN + END IF + END SUBROUTINE check_viv_columns + SUBROUTINE parse_stiffness_columns(ea_str, ba_str, t, ErrStat, ErrMsg) !! MoorDyn's bar-separated stiffness/damping columns (MoorDyn.f90 line-type !! parse): EA parts select ElasticMod (1 plain; 2 = Es|Ed; 3 = Es|alphaMBL| @@ -14479,6 +14584,8 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CASE ('maxstrain', 'max_strain') CALL rd(val, opts%max_strain, ErrStat, ErrMsg) opts%has_max_strain = ErrStat == 0 + CASE ('vivrmswindow', 'viv_rms_window') + CALL rd(val, opts%viv_rms_window, ErrStat, ErrMsg) CASE ('streamorder', 'stream_order') CALL rd(val, x1, ErrStat, ErrMsg) IF (ErrStat == 0) THEN @@ -14948,7 +15055,7 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) CASE ('g', 'gravity', 'rhow', 'wtrdnsty', 'water_density', 'wtrdpth', 'water_depth', 'dtm', 'dt', 'dtwave') rule = 'positive' CASE ('tmax', 'tensile_strain_tolerance', 'tensilestraintolerance', 'ramptime', 'ramp_time', 'tramp', & - 'maxstrain', 'max_strain', 'rangestart', 'range_start') + 'maxstrain', 'max_strain', 'rangestart', 'range_start', 'vivrmswindow', 'viv_rms_window') rule = 'non-negative' CASE ('frictionmu', 'mu', 'frictioncoefficient') IF (to_lower(TRIM(val)) == 'none') RETURN diff --git a/src/CableDyn_Hydro.f90 b/src/CableDyn_Hydro.f90 index 2e033c65..1f4287b5 100644 --- a/src/CableDyn_Hydro.f90 +++ b/src/CableDyn_Hydro.f90 @@ -53,6 +53,7 @@ MODULE CableDyn_Hydro PUBLIC :: CD_Added_Mass_Element PUBLIC :: CD_Added_Mass_Element_Matrix PUBLIC :: CD_Added_Mass_Element_Force + PUBLIC :: CD_Submerged_Fraction INTEGER, PARAMETER :: CD_HYDRO_OK = 0 INTEGER, PARAMETER :: CD_HYDRO_BADINPUT = 1 @@ -2530,6 +2531,14 @@ SUBROUTINE scatter_mass_block(M, node_row, node_col, block) END DO END SUBROUTINE scatter_mass_block + SUBROUTINE CD_Submerged_Fraction(za, zb, fraction) + !! Wetted fraction of a straight element whose end heights above the local waterline + !! are za and zb: the convention every element load of this module uses. + REAL(wp), INTENT(IN) :: za, zb + REAL(wp), INTENT(OUT) :: fraction + CALL submerged_fraction_only(za, zb, fraction) + END SUBROUTINE CD_Submerged_Fraction + SUBROUTINE submerged_fraction_only(za, zb, fraction) REAL(wp), INTENT(IN) :: za, zb REAL(wp), INTENT(OUT) :: fraction diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index c89dde2d..a1ca388c 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -54,7 +54,10 @@ MODULE CableDyn_Model CD_Cable_Buoyancy_Recovery_Load, CD_Cable_Buoyancy_Recovery_Force, & CD_Buoyancy_Recovery_Element_Load, CD_Buoyancy_Recovery_Element_Force, & CD_Cable_Added_Mass, CD_Cable_Added_Mass_Matrix, CD_Cable_Added_Mass_Force, & - CD_Added_Mass_Element, CD_Added_Mass_Element_Matrix, CD_Added_Mass_Element_Force + CD_Added_Mass_Element, CD_Added_Mass_Element_Matrix, CD_Added_Mass_Element_Force, & + CD_Submerged_Fraction + USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & + CD_VIV_Wrap_Phase, CD_VIV_NM, CD_VIV_TWO_PI USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Clear_GenAlpha_Workspace, & CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_DYN_OK, CD_DYN_ALLOCFAIL, & CD_EI0_SUBSTEPS_AUTO, CD_EI0_SUBSTEPS_OFF @@ -91,6 +94,8 @@ MODULE CableDyn_Model PUBLIC :: CD_Set_Model_Friction_Axial PUBLIC :: CD_Get_Model_Syrope_State PUBLIC :: CD_Set_Model_Syrope_State + PUBLIC :: CD_Set_Model_VIV + PUBLIC :: CD_Latch_Model_VIV_Window PUBLIC :: CD_Get_Model_Tension PUBLIC :: CD_Get_Model_EndForces PUBLIC :: CD_Get_Model_EndNodeMassDiag @@ -144,7 +149,7 @@ MODULE CableDyn_Model ! slots. commit_state_copy holds the one list of that state. TYPE :: CD_ModelCommitSlot REAL(wp), ALLOCATABLE :: q(:), v(:), a(:), ve_dl_1(:), syrope_slow(:), syrope_tmax(:) - REAL(wp), ALLOCATABLE :: fr_anchor(:, :), l0_c(:), l0_dot_c(:) + REAL(wp), ALLOCATABLE :: fr_anchor(:, :), l0_c(:), l0_dot_c(:), viv_phi(:), viv_ms(:, :) END TYPE CD_ModelCommitSlot ! Diagnostics of the rotation- and snap-resolved sub-stepping (CD_Step_Model): calls counts @@ -369,6 +374,29 @@ MODULE CableDyn_Model REAL(wp), ALLOCATABLE :: added_mass_diameter_elem(:) REAL(wp), ALLOCATABLE :: added_mass_can_elem(:) REAL(wp), ALLOCATABLE :: added_mass_cat_elem(:) + ! Cross-flow vortex-induced vibration (CableDyn_VIV; MoorDyn LINE TYPES Cl dF cF), + ! installed by CD_Set_Model_VIV after initialisation. Per element: the lift coefficient + ! viv_cl (0 = no lift on that element) and diameter viv_d; viv_rho the water density. + ! Per node: viv_node marks an interior free node next to a Cl > 0 element, with the + ! synchronisation centre/range viv_cf/viv_df and diameter viv_dn (averaged over the + ! node's Cl > 0 elements, weighted by unstretched length). The STATE is the shedding + ! phase viv_phi and the running mean squares of the cross-flow velocity and + ! acceleration viv_ms(1:2, node), with their system-rollback and step-recovery twins. + ! viv_tw is the averaging time of the mean squares [s]; 0 until CD_Latch_Model_VIV_Window + ! (or the first step) sets MoorDyn's 500 steps. viv_phi_eval is the phase the lift + ! contributor uses: the committed phase, except inside CD_Step_Model, where it is the + ! explicit generalised-alpha force-level phase. viv_rate (phase rate at the step start) + ! and viv_ms_next (mean squares updated with the step-start sample) are step scratch. + LOGICAL :: has_viv = .FALSE. + REAL(wp) :: viv_rho = CD_ZERO + REAL(wp) :: viv_tw = CD_ZERO + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_d(:) + LOGICAL, ALLOCATABLE :: viv_node(:) + REAL(wp), ALLOCATABLE :: viv_cf(:), viv_df(:), viv_dn(:) + REAL(wp), ALLOCATABLE :: viv_phi(:), viv_ms(:, :) + REAL(wp), ALLOCATABLE :: viv_phi_rollback(:), viv_ms_rollback(:, :) + REAL(wp), ALLOCATABLE :: recovery_viv_phi(:), recovery_viv_ms(:, :) + REAL(wp), ALLOCATABLE :: viv_phi_eval(:), viv_rate(:), viv_ms_next(:, :), viv_phi_next(:) TYPE(GenAlphaConfig) :: cfg ! Run audit of the committed host steps (CD_Audit_Model_Step), diagnostics only: never part ! of the state, of a copy, or of a result. audit_t holds the segment tensions of the last two @@ -2213,6 +2241,13 @@ LOGICAL FUNCTION sub_alloc(model, has_pres) RESULT(ok) IF (istat /= 0) RETURN END IF END IF + IF (model%has_viv) THEN + IF (.NOT. sized(s%viv_phi, SIZE(model%viv_phi))) THEN + IF (ALLOCATED(s%viv_phi)) DEALLOCATE (s%viv_phi, s%viv_ms) + ALLOCATE (s%viv_phi(SIZE(model%viv_phi)), s%viv_ms(2, SIZE(model%viv_phi)), STAT=istat) + IF (istat /= 0) RETURN + END IF + END IF END ASSOCIATE END DO IF (.NOT. sized(model%sub_t0, model%n_elem)) THEN @@ -2243,11 +2278,11 @@ END FUNCTION sized END FUNCTION sub_alloc SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syrope_tmax, fr_anchor, & - l0_c, l0_dot_c) + l0_c, l0_dot_c, viv_phi, viv_ms) !! The one list of the state a line step commits: the kinematics, the viscoelastic dl_1, the - !! Syrope slow strain and running maximum tension, the friction anchors, and the unstretched + !! Syrope slow strain and running maximum tension, the friction anchors, the unstretched !! lengths and rates the committed state was reached with (l0_c, l0_dot_c, active line - !! control). to_model = + !! control), and the VIV shedding phases and running mean squares. to_model = !! .FALSE. saves the model's state into the arrays given, .TRUE. returns the model to them. !! Every snapshot of the committed state in this module goes through here (the sub-step !! slots of CD_Step_Model, save_recovery_state and restore_recovery_state). A state a step @@ -2260,7 +2295,7 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr LOGICAL, INTENT(IN) :: to_model REAL(wp), INTENT(INOUT) :: q(:), v(:), a(:) REAL(wp), INTENT(INOUT), OPTIONAL :: ve_dl_1(:), syrope_slow(:), syrope_tmax(:), fr_anchor(:, :) - REAL(wp), INTENT(INOUT), OPTIONAL :: l0_c(:), l0_dot_c(:) + REAL(wp), INTENT(INOUT), OPTIONAL :: l0_c(:), l0_dot_c(:), viv_phi(:), viv_ms(:, :) IF (to_model) THEN model%q = q model%v = v @@ -2275,6 +2310,11 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr model%l0_c = l0_c model%l0_dot_c = l0_dot_c END IF + IF (model%has_viv .AND. PRESENT(viv_phi) .AND. PRESENT(viv_ms)) THEN + model%viv_phi = viv_phi + model%viv_ms = viv_ms + model%viv_phi_eval = viv_phi + END IF ELSE q = model%q v = model%v @@ -2289,6 +2329,10 @@ SUBROUTINE commit_state_copy(model, to_model, q, v, a, ve_dl_1, syrope_slow, syr l0_c = model%l0_c l0_dot_c = model%l0_dot_c END IF + IF (model%has_viv .AND. PRESENT(viv_phi) .AND. PRESENT(viv_ms)) THEN + viv_phi = model%viv_phi + viv_ms = model%viv_ms + END IF END IF END SUBROUTINE commit_state_copy @@ -2299,7 +2343,8 @@ SUBROUTINE sub_store(model, slot) CALL commit_state_copy(model, .FALSE., model%sub_slot(slot)%q, model%sub_slot(slot)%v, model%sub_slot(slot)%a, & model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor, & - model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c) + model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c, & + model%sub_slot(slot)%viv_phi, model%sub_slot(slot)%viv_ms) END SUBROUTINE sub_store SUBROUTINE sub_load(model, slot) @@ -2309,7 +2354,8 @@ SUBROUTINE sub_load(model, slot) CALL commit_state_copy(model, .TRUE., model%sub_slot(slot)%q, model%sub_slot(slot)%v, model%sub_slot(slot)%a, & model%sub_slot(slot)%ve_dl_1, model%sub_slot(slot)%syrope_slow, & model%sub_slot(slot)%syrope_tmax, model%sub_slot(slot)%fr_anchor, & - model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c) + model%sub_slot(slot)%l0_c, model%sub_slot(slot)%l0_dot_c, & + model%sub_slot(slot)%viv_phi, model%sub_slot(slot)%viv_ms) END SUBROUTINE sub_load SUBROUTINE sub_lengths_target(model) @@ -2584,7 +2630,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM has_load = model%has_seabed .OR. model%has_seabed_damping .OR. model%has_seabed_friction .OR. & model%has_damping .OR. model%has_viscoelastic .OR. model%has_syrope .OR. model%has_morison_drag .OR. & - model%has_froude_krylov .OR. model%has_buoyancy_recovery + model%has_froude_krylov .OR. model%has_buoyancy_recovery .OR. model%has_viv ! Force-blended generalised alpha: the load contributors at the committed state (q_n, v_n) ! carry the alpha_f share of the residual. They are evaluated here, in the instantaneous ! limit (ve_dt = 0), so the viscoelastic and Syrope elements give their committed force, @@ -2622,6 +2668,22 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM CALL step_start_load(ErrStat, ErrMsg) IF (force_lengths) CALL leave_committed_lengths(model, aside) IF (ErrStat /= CD_MODEL_OK) RETURN + ! VIV: phase rate and mean squares at the step-start state (after the committed-state + ! load above, which takes the committed phase), and the explicit phase for the in-step + ! lift (see viv_step_begin). Nothing is + ! committed until the step succeeds; viv_phi_eval returns to the committed phase on + ! every exit, as ve_dt below. + IF (model%has_viv) THEN + IF (.NOT. (CD_Is_Finite(dt) .AND. dt > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'dt must be finite and positive') + RETURN + END IF + CALL viv_step_begin(model, dt, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) THEN + model%viv_phi_eval = model%viv_phi + RETURN + END IF + END IF ! arm the viscoelastic contributors with the step size: in-step load ! evaluations use the backward-Euler-eliminated dl_1(q, v); it is reset to ! the instantaneous limit (0) on EVERY exit below so committed-state queries @@ -2737,6 +2799,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM IF (ALLOCATED(l0_dot_new)) model%l0_dot = l0_dot_new IF (ALLOCATED(f_ext_new)) model%f_ext = f_ext_new model%ve_dt = CD_ZERO + IF (model%has_viv) model%viv_phi_eval = model%viv_phi CALL CD_Profile_Count_Line_Step(n_iter) IF (es /= CD_DYN_OK) THEN ErrStat = model_status_from_dyn(es) @@ -2806,6 +2869,14 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM RETURN END IF END IF + ! VIV pass 1: the end-of-step phase (Heun) into viv_phi_next; committed below. + IF (model%has_viv) THEN + CALL viv_step_end(model, dt, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) THEN + converged = .FALSE. + RETURN + END IF + END IF IF (model%has_viscoelastic) THEN ! Pass 2 (mutate): commit dl_1 from the SAME lagged coefficients the in-step ! loads used (mode 3 reads the still-committed dl_1). Validated above, so no @@ -2859,6 +2930,13 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM END DO END BLOCK END IF + IF (model%has_viv) THEN + ! VIV pass 2 (mutate): the phase and the mean squares updated with the step-start + ! sample (the next step starts by adding its own sample, the end state of this one) + model%viv_phi = model%viv_phi_next + model%viv_ms = model%viv_ms_next + model%viv_phi_eval = model%viv_phi + END IF model%q = model%q_step model%v = model%v_step model%a = model%a_step @@ -3049,6 +3127,8 @@ SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrSt RETURN END IF + ! MoorDyn's VIV averaging window counts NOMINAL steps: latch it before any subdivision + IF (model%has_viv) CALL CD_Latch_Model_VIV_Window(model, dt) CALL save_recovery_state(model) hmax0 = model%audit_hmax stats0 = model%sub_stats @@ -3272,7 +3352,8 @@ SUBROUTINE save_recovery_state(model) TYPE(CD_ModelType), INTENT(INOUT) :: model CALL commit_state_copy(model, .FALSE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & - model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c) + model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c, & + model%recovery_viv_phi, model%recovery_viv_ms) END SUBROUTINE save_recovery_state SUBROUTINE restore_recovery_state(model) @@ -3280,7 +3361,8 @@ SUBROUTINE restore_recovery_state(model) TYPE(CD_ModelType), INTENT(INOUT) :: model CALL commit_state_copy(model, .TRUE., model%recovery_q0, model%recovery_v0, model%recovery_a0, & model%recovery_ve_dl_1, model%recovery_syrope_slow, model%recovery_syrope_tmax, & - model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c) + model%recovery_fr_anchor, model%recovery_l0_c, model%recovery_l0_dot_c, & + model%recovery_viv_phi, model%recovery_viv_ms) model%ve_dt = CD_ZERO END SUBROUTINE restore_recovery_state @@ -3775,6 +3857,282 @@ SUBROUTINE CD_Set_Model_Syrope_State(model, slow, tmax, ErrStat, ErrMsg) model%recovery_syrope_tmax = tmax END SUBROUTINE CD_Set_Model_Syrope_State + SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, ErrMsg) + !! Install the cross-flow VIV model (CableDyn_VIV) on an initialised line. Per element: + !! the lift coefficient cl (0 = no lift on that element), hydrodynamic diameter, and the + !! synchronisation centre cf and half-range df of the non-dimensional shedding frequency; + !! rho is the water density. t_window is the averaging time of the running cross-flow mean + !! squares [s]; 0 selects MoorDyn's 500 time steps, latched at the first step. Every + !! interior free node next to a cl > 0 element carries a lift and a shedding phase; the + !! phases start spread over [0, 2 pi) along the line (MoorDyn-C), the mean squares at 0. + !! An all-zero cl leaves the model without VIV. The mesh must be the single chain the + !! line builder makes (element e joins nodes e and e+1). The caller recomputes the + !! acceleration if the lift should enter the initial state (CD_Recompute_Model_Acceleration). + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: rho, cl(:), diameter(:), cf(:), df(:), t_window + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: n_nodes, n_elem, e, nd, istat, k + REAL(wp) :: wsum + + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_MODEL_NOT_INITIALIZED + ErrMsg = 'CableDyn_Model: model is not initialized' + RETURN + END IF + n_elem = model%n_elem + n_nodes = model%n_dof/3 + IF (SIZE(cl) /= n_elem .OR. SIZE(diameter) /= n_elem .OR. SIZE(cf) /= n_elem .OR. SIZE(df) /= n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'VIV cl, diameter, cf and df must each have shape (n_elem)') + RETURN + END IF + IF (.NOT. (CD_All_Finite(cl) .AND. CD_All_Finite(diameter) .AND. CD_All_Finite(cf) .AND. & + CD_All_Finite(df))) THEN + CALL fail(ErrStat, ErrMsg, 'VIV coefficients must be finite') + RETURN + END IF + IF (ANY(cl < CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV lift coefficient Cl must be non-negative') + RETURN + END IF + IF (.NOT. (CD_Is_Finite(t_window) .AND. t_window >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV averaging time must be finite and non-negative') + RETURN + END IF + CALL clear_viv(model) + IF (.NOT. ANY(cl > CD_ZERO)) RETURN + IF (.NOT. (CD_Is_Finite(rho) .AND. rho > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV water density must be finite and positive') + RETURN + END IF + DO e = 1, n_elem + IF (.NOT. (cl(e) > CD_ZERO)) CYCLE + IF (.NOT. (diameter(e) > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV needs a positive diameter on every Cl > 0 element') + RETURN + END IF + IF (.NOT. (cf(e) > CD_ZERO .AND. df(e) >= CD_ZERO .AND. df(e) < cf(e))) THEN + CALL fail(ErrStat, ErrMsg, 'VIV synchronisation needs cF > 0 and 0 <= dF < cF (a positive '// & + 'shedding frequency)') + RETURN + END IF + END DO + DO e = 1, n_elem + IF (model%elem_conn(1, e) /= e .OR. model%elem_conn(2, e) /= e + 1) THEN + CALL fail(ErrStat, ErrMsg, 'VIV needs a single-chain line mesh (element e joining nodes e and e+1)') + RETURN + END IF + END DO + ALLOCATE (model%viv_cl(n_elem), model%viv_d(n_elem), model%viv_node(n_nodes), model%viv_cf(n_nodes), & + model%viv_df(n_nodes), model%viv_dn(n_nodes), model%viv_phi(n_nodes), model%viv_ms(2, n_nodes), & + model%viv_phi_rollback(n_nodes), model%viv_ms_rollback(2, n_nodes), & + model%recovery_viv_phi(n_nodes), model%recovery_viv_ms(2, n_nodes), & + model%viv_phi_eval(n_nodes), model%viv_rate(n_nodes), model%viv_ms_next(2, n_nodes), & + model%viv_phi_next(n_nodes), STAT=istat) + IF (istat /= 0) THEN + CALL clear_viv(model) + CALL alloc_fail(ErrStat, ErrMsg, 'VIV storage allocation failed') + RETURN + END IF + model%viv_rho = rho + model%viv_tw = t_window + model%viv_cl = MERGE(cl, CD_ZERO, cl > CD_ZERO) + model%viv_d = MERGE(diameter, CD_ZERO, cl > CD_ZERO) + model%viv_node = .FALSE. + model%viv_cf = CD_ZERO + model%viv_df = CD_ZERO + model%viv_dn = CD_ZERO + model%viv_phi = CD_ZERO + model%viv_ms = CD_ZERO + DO nd = 2, n_nodes - 1 + IF (.NOT. (cl(nd - 1) > CD_ZERO .OR. cl(nd) > CD_ZERO)) CYCLE + IF (ANY(model%fixed_dofs >= 3*nd - 2 .AND. model%fixed_dofs <= 3*nd)) CYCLE + model%viv_node(nd) = .TRUE. + wsum = CD_ZERO + DO k = nd - 1, nd + IF (.NOT. (cl(k) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(k) + model%viv_cf(nd) = model%viv_cf(nd) + model%l0(k)*cf(k) + model%viv_df(nd) = model%viv_df(nd) + model%l0(k)*df(k) + model%viv_dn(nd) = model%viv_dn(nd) + model%l0(k)*diameter(k) + END DO + model%viv_cf(nd) = model%viv_cf(nd)/wsum + model%viv_df(nd) = model%viv_df(nd)/wsum + model%viv_dn(nd) = model%viv_dn(nd)/wsum + ! MoorDyn: phi_i = 2 pi i/N at node i = 0..N counted from End A; the model numbers its + ! nodes from End B, so node nd is MoorDyn's node n_nodes - nd + model%viv_phi(nd) = CD_VIV_TWO_PI*REAL(n_nodes - nd, wp)/REAL(n_elem, wp) + END DO + model%viv_phi_rollback = model%viv_phi + model%viv_ms_rollback = model%viv_ms + model%recovery_viv_phi = model%viv_phi + model%recovery_viv_ms = model%viv_ms + model%viv_phi_eval = model%viv_phi + model%viv_rate = CD_ZERO + model%viv_ms_next = model%viv_ms + model%viv_phi_next = model%viv_phi + model%has_viv = .TRUE. + END SUBROUTINE CD_Set_Model_VIV + + SUBROUTINE CD_Latch_Model_VIV_Window(model, dt) + !! Fix MoorDyn's default VIV averaging time, 500 steps of the nominal step dt, unless the + !! model already has one (a deck VIVrmsWindow or an earlier latch). Callers that subdivide + !! a step latch with the nominal step before subdividing; otherwise the first step does. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + IF (.NOT. model%has_viv) RETURN + IF (model%viv_tw > CD_ZERO) RETURN + IF (.NOT. (CD_Is_Finite(dt) .AND. dt > CD_ZERO)) RETURN + model%viv_tw = REAL(CD_VIV_NM, wp)*dt + END SUBROUTINE CD_Latch_Model_VIV_Window + + SUBROUTINE viv_node_coef(model, q, nd, coef, uu) + !! Lift scale of interior node nd at positions q, sum over its two elements of + !! (1/2 l0_e w_e)(1/2 rho D_e Cl_e) with w_e the wetted fraction under the drag waterline + !! (as MoorDyn's 1/4 rho d Cl (F_i l_i + F_i+1 l_i+1)), and the ambient fluid velocity there. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q(:) + INTEGER, INTENT(IN) :: nd + REAL(wp), INTENT(OUT) :: coef, uu(3) + INTEGER :: e + REAL(wp) :: wla, wlb, frac + coef = CD_ZERO + DO e = nd - 1, nd + IF (.NOT. (model%viv_cl(e) > CD_ZERO)) CYCLE + wla = CD_ZERO + wlb = CD_ZERO + IF (ALLOCATED(model%drag_waterline_z)) THEN + wla = model%drag_waterline_z(e) + wlb = model%drag_waterline_z(e + 1) + END IF + CALL CD_Submerged_Fraction(q(3*e) - wla, q(3*e + 3) - wlb, frac) + coef = coef + 0.25_wp*model%viv_rho*model%viv_d(e)*model%viv_cl(e)*model%l0(e)*frac + END DO + uu = CD_ZERO + IF (ALLOCATED(model%fluid_velocity)) uu = model%fluid_velocity(:, nd) + END SUBROUTINE viv_node_coef + + SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) + !! Step-start VIV quantities from the committed state (q_n, v_n, a_n, phi_n): the mean + !! squares with the step-start cross-flow sample (viv_ms_next), the phase rate + !! (viv_rate), and the explicit phase the in-step lift uses (viv_phi_eval): at t_{n+1}, + !! phi_n + dt rate_n, under the force blend, whose in-step force is r(q_{n+1}, v_{n+1}) + !! (the committed-state force F_n keeps phi_n); at the generalised-alpha level, + !! phi_n + (1 - alpha_f) dt rate_n, under the configuration blend. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: nd, ia + REAL(wp) :: w, alpha_f, yd, ydd, un, coef, uu(3) + LOGICAL :: ok + ErrStat = CD_MODEL_OK + ErrMsg = '' + CALL CD_Latch_Model_VIV_Window(model, dt) + w = MIN(CD_ONE, dt/model%viv_tw) + alpha_f = model%cfg%rho_inf/(model%cfg%rho_inf + CD_ONE) + IF (model%cfg%force_blend) alpha_f = CD_ZERO + model%viv_rate = CD_ZERO + model%viv_ms_next = model%viv_ms + model%viv_phi_eval = model%viv_phi + DO nd = 2, model%n_dof/3 - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_coef(model, model%q, nd, coef, uu) + ia = 3*nd - 2 + CALL CD_VIV_Crossflow_Motion(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), smoothed(model%v, ia), & + smoothed(model%a, ia), uu, yd, ydd, un, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV phase: the neighbours of a node coincide (no line tangent)') + RETURN + END IF + model%viv_ms_next(1, nd) = CD_VIV_Mean_Square(model%viv_ms(1, nd), yd, w) + model%viv_ms_next(2, nd) = CD_VIV_Mean_Square(model%viv_ms(2, nd), ydd, w) + model%viv_rate(nd) = CD_VIV_Phase_Rate(yd, ydd, model%viv_ms_next(1, nd), model%viv_ms_next(2, nd), & + model%viv_phi(nd), un, model%viv_dn(nd), model%viv_cf(nd), & + model%viv_df(nd)) + model%viv_phi_eval(nd) = model%viv_phi(nd) + (CD_ONE - alpha_f)*dt*model%viv_rate(nd) + END DO + END SUBROUTINE viv_step_begin + + SUBROUTINE viv_step_end(model, dt, ErrStat, ErrMsg) + !! End-of-step VIV phase by Heun's rule (the trapezoidal corrector of the explicit Euler + !! predictor): phi_n+1 = phi_n + dt/2 (rate_n + rate(state_n+1, phi_n + dt rate_n)), with + !! the end-state cross-flow sample added to the mean squares for that rate (not stored: + !! the next step adds it itself). Writes viv_phi_next only. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: nd, ia + REAL(wp) :: w, yd, ydd, un, coef, uu(3), ms1, ms2, rate_end + LOGICAL :: ok + ErrStat = CD_MODEL_OK + ErrMsg = '' + w = MIN(CD_ONE, dt/model%viv_tw) + model%viv_phi_next = model%viv_phi + DO nd = 2, model%n_dof/3 - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_coef(model, model%q_step, nd, coef, uu) + ia = 3*nd - 2 + CALL CD_VIV_Crossflow_Motion(model%q_step(ia - 3:ia - 1), model%q_step(ia + 3:ia + 5), & + smoothed(model%v_step, ia), smoothed(model%a_step, ia), uu, yd, ydd, un, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV phase: the neighbours of a node coincide (no line tangent)') + RETURN + END IF + ms1 = CD_VIV_Mean_Square(model%viv_ms_next(1, nd), yd, w) + ms2 = CD_VIV_Mean_Square(model%viv_ms_next(2, nd), ydd, w) + rate_end = CD_VIV_Phase_Rate(yd, ydd, ms1, ms2, model%viv_phi(nd) + dt*model%viv_rate(nd), un, & + model%viv_dn(nd), model%viv_cf(nd), model%viv_df(nd)) + model%viv_phi_next(nd) = CD_VIV_Wrap_Phase(model%viv_phi(nd) + 0.5_wp*dt*(model%viv_rate(nd) + rate_end)) + END DO + IF (.NOT. CD_All_Finite(model%viv_phi_next)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV phase update produced a non-finite phase') + END IF + END SUBROUTINE viv_step_end + + PURE FUNCTION smoothed(x, ia) RESULT(xs) + !! Node kinematics for the VIV phase and lift: the node value averaged with its two + !! neighbours, (x_{i-1} + 2 x_i + x_{i+1})/4, at the node whose x component is ia. Thorsen's + !! model follows the cross-flow motion of a continuum. The node's own acceleration weights + !! the mesh-scale zig-zag mode (neighbours moving opposite to the node) by omega^2, so at + !! steps that resolve that mode it took over the phase, and through the lift the phase + !! pumped the mode until the line lost lock-in. The average removes the zig-zag mode + !! exactly and keeps a resolved mode of wavenumber k to cos^2(k l0 / 2). The lift takes the + !! smoothed velocity as well: through its dependence on the node's own velocity, modulated by + !! the phase, the zig-zag mode was pumped even with a smoothed phase. + REAL(wp), INTENT(IN) :: x(:) + INTEGER, INTENT(IN) :: ia + REAL(wp) :: xs(3) + xs = 0.25_wp*(x(ia - 3:ia - 1) + 2.0_wp*x(ia:ia + 2) + x(ia + 3:ia + 5)) + END FUNCTION smoothed + + SUBROUTINE clear_viv(model) + !! Release the VIV storage; the model then carries no VIV. + TYPE(CD_ModelType), INTENT(INOUT) :: model + IF (ALLOCATED(model%viv_cl)) DEALLOCATE (model%viv_cl) + IF (ALLOCATED(model%viv_d)) DEALLOCATE (model%viv_d) + IF (ALLOCATED(model%viv_node)) DEALLOCATE (model%viv_node) + IF (ALLOCATED(model%viv_cf)) DEALLOCATE (model%viv_cf) + IF (ALLOCATED(model%viv_df)) DEALLOCATE (model%viv_df) + IF (ALLOCATED(model%viv_dn)) DEALLOCATE (model%viv_dn) + IF (ALLOCATED(model%viv_phi)) DEALLOCATE (model%viv_phi) + IF (ALLOCATED(model%viv_ms)) DEALLOCATE (model%viv_ms) + IF (ALLOCATED(model%viv_phi_rollback)) DEALLOCATE (model%viv_phi_rollback) + IF (ALLOCATED(model%viv_ms_rollback)) DEALLOCATE (model%viv_ms_rollback) + IF (ALLOCATED(model%recovery_viv_phi)) DEALLOCATE (model%recovery_viv_phi) + IF (ALLOCATED(model%recovery_viv_ms)) DEALLOCATE (model%recovery_viv_ms) + IF (ALLOCATED(model%viv_phi_eval)) DEALLOCATE (model%viv_phi_eval) + IF (ALLOCATED(model%viv_rate)) DEALLOCATE (model%viv_rate) + IF (ALLOCATED(model%viv_ms_next)) DEALLOCATE (model%viv_ms_next) + IF (ALLOCATED(model%viv_phi_next)) DEALLOCATE (model%viv_phi_next) + model%has_viv = .FALSE. + model%viv_rho = CD_ZERO + model%viv_tw = CD_ZERO + END SUBROUTINE clear_viv + SUBROUTINE CD_Set_Model_Friction_Axial(model, mu_axial, ErrStat, ErrMsg) !! Make the stick-slip seabed friction of a model anisotropic: the model's seabed_mu !! becomes the lateral coefficient and mu_axial the coefficient along the line (the @@ -5517,7 +5875,7 @@ SUBROUTINE recompute_model_acceleration_now(model, ErrStat, ErrMsg) END IF has_load = model%has_seabed .OR. model%has_seabed_damping .OR. model%has_seabed_friction .OR. & model%has_damping .OR. model%has_viscoelastic .OR. model%has_syrope .OR. model%has_morison_drag .OR. & - model%has_froude_krylov .OR. model%has_buoyancy_recovery + model%has_froude_krylov .OR. model%has_buoyancy_recovery .OR. model%has_viv nc = SIZE(model%fixed_dofs) prescribed_workspace_ready = ALLOCATED(model%a_prescribed_work) IF (prescribed_workspace_ready) prescribed_workspace_ready = SIZE(model%a_prescribed_work) >= nc @@ -6055,6 +6413,7 @@ SUBROUTINE CD_End_Model(model, ErrStat, ErrMsg) IF (ALLOCATED(model%added_mass_diameter_elem)) DEALLOCATE (model%added_mass_diameter_elem) IF (ALLOCATED(model%added_mass_can_elem)) DEALLOCATE (model%added_mass_can_elem) IF (ALLOCATED(model%added_mass_cat_elem)) DEALLOCATE (model%added_mass_cat_elem) + CALL clear_viv(model) model%initialized = .FALSE. model%tension_only = .FALSE. model%has_seabed = .FALSE. @@ -6318,6 +6677,41 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN CALL copy_real1(src%added_mass_cat_elem, work%added_mass_cat_elem, 'added_mass_cat_elem', ErrStat, ErrMsg) IF (ErrStat /= CD_MODEL_OK) RETURN + work%has_viv = src%has_viv + work%viv_rho = src%viv_rho + work%viv_tw = src%viv_tw + CALL copy_real1(src%viv_cl, work%viv_cl, 'viv_cl', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_d, work%viv_d, 'viv_d', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_logical1(src%viv_node, work%viv_node, 'viv_node', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_cf, work%viv_cf, 'viv_cf', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_df, work%viv_df, 'viv_df', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_dn, work%viv_dn, 'viv_dn', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_phi, work%viv_phi, 'viv_phi', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%viv_ms, work%viv_ms, 'viv_ms', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_phi_rollback, work%viv_phi_rollback, 'viv_phi_rollback', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%viv_ms_rollback, work%viv_ms_rollback, 'viv_ms_rollback', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%recovery_viv_phi, work%recovery_viv_phi, 'recovery_viv_phi', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%recovery_viv_ms, work%recovery_viv_ms, 'recovery_viv_ms', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_phi_eval, work%viv_phi_eval, 'viv_phi_eval', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_rate, work%viv_rate, 'viv_rate', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real2(src%viv_ms_next, work%viv_ms_next, 'viv_ms_next', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL copy_real1(src%viv_phi_next, work%viv_phi_next, 'viv_phi_next', ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN work%initialized = src%initialized ! Commit: release the caller's previous model, then move the fully-built copy in component by @@ -6453,6 +6847,25 @@ SUBROUTINE commit_model_copy(from, to) CALL MOVE_ALLOC(from%added_mass_diameter_elem, to%added_mass_diameter_elem) CALL MOVE_ALLOC(from%added_mass_can_elem, to%added_mass_can_elem) CALL MOVE_ALLOC(from%added_mass_cat_elem, to%added_mass_cat_elem) + to%has_viv = from%has_viv + to%viv_rho = from%viv_rho + to%viv_tw = from%viv_tw + CALL MOVE_ALLOC(from%viv_cl, to%viv_cl) + CALL MOVE_ALLOC(from%viv_d, to%viv_d) + CALL MOVE_ALLOC(from%viv_node, to%viv_node) + CALL MOVE_ALLOC(from%viv_cf, to%viv_cf) + CALL MOVE_ALLOC(from%viv_df, to%viv_df) + CALL MOVE_ALLOC(from%viv_dn, to%viv_dn) + CALL MOVE_ALLOC(from%viv_phi, to%viv_phi) + CALL MOVE_ALLOC(from%viv_ms, to%viv_ms) + CALL MOVE_ALLOC(from%viv_phi_rollback, to%viv_phi_rollback) + CALL MOVE_ALLOC(from%viv_ms_rollback, to%viv_ms_rollback) + CALL MOVE_ALLOC(from%recovery_viv_phi, to%recovery_viv_phi) + CALL MOVE_ALLOC(from%recovery_viv_ms, to%recovery_viv_ms) + CALL MOVE_ALLOC(from%viv_phi_eval, to%viv_phi_eval) + CALL MOVE_ALLOC(from%viv_rate, to%viv_rate) + CALL MOVE_ALLOC(from%viv_ms_next, to%viv_ms_next) + CALL MOVE_ALLOC(from%viv_phi_next, to%viv_phi_next) IF (from%has_bathymetry) THEN to%bathymetry%nx = from%bathymetry%nx @@ -7072,6 +7485,31 @@ SUBROUTINE model_contributor_load(model, q, v, force, jac_q, jac_v, ErrStat, Err jac_v = jac_v + jv_tmp END IF END ASSOCIATE + IF (model%has_viv) THEN + BLOCK + INTEGER :: nd, ia + REAL(wp) :: fl(3), jv3(3, 3), jp3(3, 3), jn3(3, 3), coef, uu(3) + LOGICAL :: ok + DO nd = 2, SIZE(q)/3 - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_coef(model, q, nd, coef, uu) + ia = 3*nd - 2 + CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, & + model%viv_phi_eval(nd), fl, ok, jv3, jp3, jn3) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV lift: the neighbours of a node coincide (no line tangent)') + RETURN + END IF + force(ia:ia + 2) = force(ia:ia + 2) + fl + ! the lift takes the smoothed velocity (v_{i-1} + 2 v_i + v_{i+1})/4 (smoothed) + jac_v(ia:ia + 2, ia:ia + 2) = jac_v(ia:ia + 2, ia:ia + 2) + 0.5_wp*jv3 + jac_v(ia:ia + 2, ia - 3:ia - 1) = jac_v(ia:ia + 2, ia - 3:ia - 1) + 0.25_wp*jv3 + jac_v(ia:ia + 2, ia + 3:ia + 5) = jac_v(ia:ia + 2, ia + 3:ia + 5) + 0.25_wp*jv3 + jac_q(ia:ia + 2, ia - 3:ia - 1) = jac_q(ia:ia + 2, ia - 3:ia - 1) + jp3 + jac_q(ia:ia + 2, ia + 3:ia + 5) = jac_q(ia:ia + 2, ia + 3:ia + 5) + jn3 + END DO + END BLOCK + END IF END SUBROUTINE model_contributor_load SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q_band, jac_v_band, & @@ -7364,6 +7802,48 @@ SUBROUTINE model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q END IF END DO + IF (model%has_viv) THEN + ! cross-flow VIV lift on the interior nodes (CableDyn_VIV), with its velocity Jacobian + ! and the position Jacobian through the node tangent (the two neighbours) + BLOCK + INTEGER :: nd, ia, ra, cb + REAL(wp) :: fl(3), jv3(3, 3), jp3(3, 3), jn3(3, 3), coef, uu(3) + LOGICAL :: ok + DO nd = 2, n/3 - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_coef(model, q, nd, coef, uu) + ia = 3*nd - 2 + CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, & + model%viv_phi_eval(nd), fl, ok, jv3, jp3, jn3) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV lift: the neighbours of a node coincide (no line tangent)') + RETURN + END IF + force(ia:ia + 2) = force(ia:ia + 2) + fl + DO cb = 1, 3 + DO ra = 1, 3 + ! the lift takes the smoothed velocity (v_{i-1} + 2 v_i + v_{i+1})/4 (smoothed) + CALL scatter_scalar_band(jac_v_band, model%free_map_work, kl, ku, ia + ra - 1, ia + cb - 1, & + 0.5_wp*jv3(ra, cb), ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL scatter_scalar_band(jac_v_band, model%free_map_work, kl, ku, ia + ra - 1, ia + cb - 4, & + 0.25_wp*jv3(ra, cb), ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL scatter_scalar_band(jac_v_band, model%free_map_work, kl, ku, ia + ra - 1, ia + cb + 2, & + 0.25_wp*jv3(ra, cb), ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ia + ra - 1, ia + cb - 4, & + jp3(ra, cb), ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL scatter_scalar_band(jac_q_band, model%free_map_work, kl, ku, ia + ra - 1, ia + cb + 2, & + jn3(ra, cb), ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + END DO + END DO + END DO + END BLOCK + END IF + IF (.NOT. CD_All_Finite(force) .OR. .NOT. CD_All_Finite(jac_q_band) .OR. & .NOT. CD_All_Finite(jac_v_band)) THEN CALL fail(ErrStat, ErrMsg, 'banded model load returned non-finite force/Jacobian') @@ -7575,6 +8055,26 @@ SUBROUTINE model_contributor_force(model, q, v, force, ErrStat, ErrMsg, end_node CALL scatter_element_vector(force, idx, f2) END IF END DO + ! VIV lift acts on interior nodes only, so an end-node recovery carries none of it + IF (model%has_viv .AND. .NOT. ends) THEN + BLOCK + INTEGER :: nd, ia + REAL(wp) :: fl(3), coef, uu(3) + LOGICAL :: ok + DO nd = 2, nn - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_coef(model, q, nd, coef, uu) + ia = 3*nd - 2 + CALL CD_VIV_Node_Lift(q(ia - 3:ia - 1), q(ia + 3:ia + 5), smoothed(v, ia), uu, coef, & + model%viv_phi_eval(nd), fl, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, 'VIV lift: the neighbours of a node coincide (no line tangent)') + RETURN + END IF + force(ia:ia + 2) = force(ia:ia + 2) + fl + END DO + END BLOCK + END IF IF (.NOT. CD_All_Finite(force)) CALL fail(ErrStat, ErrMsg, 'model force returned non-finite force') CONTAINS diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index b34ef6de..7a2cd623 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -18,6 +18,7 @@ MODULE CableDyn_System CD_Model_Has_Viscoelastic, CD_Get_Model_VE_Dl1, CD_Set_Model_VE_Dl1, & CD_Model_Has_Syrope, CD_Get_Model_Syrope_State, CD_Set_Model_Syrope_State, & CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & + CD_Latch_Model_VIV_Window, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & CD_Get_Model_EndNodeTangent, CD_Set_Model_EndQuery, CD_Get_Model_EndQuery, & CD_Model_Seabed_Point_Load, & @@ -235,6 +236,9 @@ MODULE CableDyn_System ! the sub-stepping diagnostics of every line (CD_SubstepStats): they roll back with the ! states, so a restored and re-advanced step counts once TYPE(CD_SubstepStats), ALLOCATABLE :: snap_sub(:) + ! VIV shedding phase and cross-flow mean squares join the snapshot (phi then the two + ! mean squares per node, 3 per node: sized like snap_q, line by line). + REAL(wp), ALLOCATABLE :: snap_viv(:) LOGICAL :: snap_valid = .FALSE. END TYPE CD_SystemType @@ -469,6 +473,7 @@ SUBROUTINE CD_End_System(system, ErrStat, ErrMsg) IF (ALLOCATED(system%snap_l0_c)) DEALLOCATE (system%snap_l0_c, system%snap_l0_dot_c) IF (ALLOCATED(system%snap_fbase)) DEALLOCATE (system%snap_fbase) IF (ALLOCATED(system%snap_ve_dl_1)) DEALLOCATE (system%snap_ve_dl_1) + IF (ALLOCATED(system%snap_viv)) DEALLOCATE (system%snap_viv) IF (ALLOCATED(system%snap_syrope_slow)) DEALLOCATE (system%snap_syrope_slow, system%snap_syrope_tmax) IF (ALLOCATED(system%snap_fr_anchor)) DEALLOCATE (system%snap_fr_anchor) IF (ALLOCATED(system%snap_sub)) DEALLOCATE (system%snap_sub) @@ -1270,7 +1275,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, LOGICAL :: conv2, stall2 CHARACTER(1024) :: em REAL(wp), ALLOCATABLE :: q0(:), v0(:), a0(:), qm(:), vm(:), am(:), qs(:), vs(:), as(:) - REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:), l0cs(:), l0dcs(:) + REAL(wp), ALLOCATABLE :: dl1s(:), slows(:), tmaxs(:), frs(:, :), hmaxs(:), l0cs(:), l0dcs(:), vivs(:) TYPE(CD_SubstepStats), ALLOCATABLE :: subs(:) converged = .FALSE. @@ -1290,6 +1295,12 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, RETURN END IF + ! MoorDyn's VIV averaging window counts nominal steps: latch it before any subdivision + IF (depth == 0) THEN + DO i = 1, system%n_lines + CALL CD_Latch_Model_VIV_Window(system%lines(i), dt) + END DO + END IF CALL save_line_states(system, ErrStat, ErrMsg) IF (ErrStat /= CD_SYSTEM_OK) RETURN converged = .TRUE. @@ -1409,7 +1420,8 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, IF (CD_Model_Has_Friction(system%lines(i))) nfr = nfr + SIZE(system%lines(i)%fr_anchor, 2) END DO ALLOCATE (qs(ntot), vs(ntot), as(ntot), dl1s(nve), slows(nsy), tmaxs(nsy), frs(2, nfr), & - hmaxs(system%n_lines), subs(system%n_lines), l0cs(nel), l0dcs(nel)) + hmaxs(system%n_lines), subs(system%n_lines), l0cs(nel), l0dcs(nel), vivs(ntot)) + vivs = CD_ZERO lo = 1 lo_ve = 1 lo_sy = 1 @@ -1424,6 +1436,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, ! states, so the halves of a fallback that does not complete leave no trace hmaxs(i) = system%lines(i)%audit_hmax subs(i) = system%lines(i)%sub_stats + IF (system%lines(i)%has_viv) CALL pack_viv(system%lines(i), vivs(lo:hi)) lo = hi + 1 ne = SIZE(system%lines(i)%l0_c) l0cs(lo_el:lo_el + ne - 1) = system%lines(i)%l0_c @@ -1473,6 +1486,7 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, system%lines(i)%a = as(lo:hi) system%lines(i)%audit_hmax = hmaxs(i) system%lines(i)%sub_stats = subs(i) + IF (system%lines(i)%has_viv) CALL unpack_viv(system%lines(i), vivs(lo:hi)) lo = hi + 1 ne = SIZE(system%lines(i)%l0_c) system%lines(i)%l0_c = l0cs(lo_el:lo_el + ne - 1) @@ -3146,6 +3160,11 @@ SUBROUTINE save_line_states(system, ErrStat, ErrMsg) ! the stick-slip friction anchors move with every committed step too IF (CD_Model_Has_Friction(system%lines(i))) & system%lines(i)%fr_anchor_rollback = system%lines(i)%fr_anchor + ! the VIV shedding phase and cross-flow mean squares advance every committed step + IF (system%lines(i)%has_viv) THEN + system%lines(i)%viv_phi_rollback = system%lines(i)%viv_phi + system%lines(i)%viv_ms_rollback = system%lines(i)%viv_ms + END IF END DO END SUBROUTINE save_line_states @@ -3171,9 +3190,36 @@ SUBROUTINE restore_line_states(system) END IF IF (CD_Model_Has_Friction(system%lines(i))) & system%lines(i)%fr_anchor = system%lines(i)%fr_anchor_rollback + IF (system%lines(i)%has_viv) THEN + system%lines(i)%viv_phi = system%lines(i)%viv_phi_rollback + system%lines(i)%viv_ms = system%lines(i)%viv_ms_rollback + system%lines(i)%viv_phi_eval = system%lines(i)%viv_phi + END IF END DO END SUBROUTINE restore_line_states + PURE SUBROUTINE pack_viv(line, buf) + !! A line's committed VIV state as 3 reals per node: the phases, then the two mean + !! squares per node (the size of the line's q). + TYPE(CD_ModelType), INTENT(IN) :: line + REAL(wp), INTENT(OUT) :: buf(:) + INTEGER :: nn + nn = SIZE(line%viv_phi) + buf(1:nn) = line%viv_phi + buf(nn + 1:3*nn) = RESHAPE(line%viv_ms, [2*nn]) + END SUBROUTINE pack_viv + + PURE SUBROUTINE unpack_viv(line, buf) + !! Inverse of pack_viv; the in-step phase returns to the committed one. + TYPE(CD_ModelType), INTENT(INOUT) :: line + REAL(wp), INTENT(IN) :: buf(:) + INTEGER :: nn + nn = SIZE(line%viv_phi) + line%viv_phi = buf(1:nn) + line%viv_ms = RESHAPE(buf(nn + 1:3*nn), [2, nn]) + line%viv_phi_eval = line%viv_phi + END SUBROUTINE unpack_viv + SUBROUTINE restore_failed_step(system, failed_stat, msg, converged, stalled, n_iter, ErrStat, ErrMsg) TYPE(CD_SystemType), INTENT(INOUT) :: system INTEGER, INTENT(IN) :: failed_stat @@ -3273,7 +3319,7 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) ALLOCATE (system%snap_l0(netot), system%snap_l0_dot(netot), system%snap_fbase(ntot), & system%snap_l0_c(netot), system%snap_l0_dot_c(netot), & system%snap_ve_dl_1(netot), system%snap_syrope_slow(netot), & - system%snap_syrope_tmax(netot), system%snap_fr_anchor(ntot)) + system%snap_syrope_tmax(netot), system%snap_fr_anchor(ntot), system%snap_viv(ntot)) END BLOCK END IF lo = 1 @@ -3287,6 +3333,7 @@ SUBROUTINE CD_System_Snapshot(system, ErrStat, ErrMsg) IF (CD_Model_Has_Friction(system%lines(i))) & system%snap_fr_anchor(lo:lo + 2*SIZE(system%lines(i)%fr_anchor, 2) - 1) = & RESHAPE(system%lines(i)%fr_anchor, [2*SIZE(system%lines(i)%fr_anchor, 2)]) + IF (system%lines(i)%has_viv) CALL pack_viv(system%lines(i), system%snap_viv(lo:hi)) lo = hi + 1 END DO IF (.NOT. ALLOCATED(system%snap_sub)) ALLOCATE (system%snap_sub(system%n_lines)) @@ -3356,6 +3403,7 @@ SUBROUTINE CD_System_Restore(system, ErrStat, ErrMsg) IF (CD_Model_Has_Friction(system%lines(i))) & system%lines(i)%fr_anchor = RESHAPE(system%snap_fr_anchor(lo:lo + 2*SIZE(system%lines(i)%fr_anchor, 2) - 1), & [2, SIZE(system%lines(i)%fr_anchor, 2)]) + IF (system%lines(i)%has_viv) CALL unpack_viv(system%lines(i), system%snap_viv(lo:hi)) lo = hi + 1 END DO IF (ALLOCATED(system%snap_sub)) THEN diff --git a/src/CableDyn_VIV.f90 b/src/CableDyn_VIV.f90 new file mode 100644 index 00000000..fd6554b0 --- /dev/null +++ b/src/CableDyn_VIV.f90 @@ -0,0 +1,208 @@ +! File: src/CableDyn_VIV.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +MODULE CableDyn_VIV + !! Cross-flow vortex-induced vibration (VIV) of EI = 0 line nodes: the synchronisation + !! model of Thorsen, Saevik and Larsen (J. Fluids Struct. 49, 2014, 135-148; 61, 2016, + !! 1-19) in the form MoorDyn v2 implements it (LINE TYPES columns Cl dF cF; Davies et al., + !! J. Fluids Struct. 146, 2026, 104651). Pure node kernels; the model layer + !! (CableDyn_Model) owns the phase state and the time integration. + !! + !! At an interior node with unit tangent q (the chord of its two neighbours), velocity r', + !! acceleration r'' and ambient fluid velocity u: + !! + !! v_r = u - r' relative fluid velocity + !! v_n = v_r - (q.v_r) q its component normal to the line, U = |v_n| + !! e = q x v_n / U cross-flow unit vector + !! y' = r'.e , y'' = r''.e cross-flow velocity and acceleration of the node + !! + !! The cross-flow velocity phase is phi_y = atan2(-y''/rms(y''), y'/rms(y')) in [0, 2 pi), + !! with running RMS values. The vortex-shedding (lift) phase phi obeys + !! + !! d phi/dt = 2 pi f_hat U / D , f_hat = cF + dF sin(phi_y - phi) + !! + !! so the shedding frequency locks onto the cross-flow motion inside the non-dimensional + !! synchronisation band cF +- dF, and the lift force on the node is + !! + !! F = C cos(phi) U (q x v_n) , C = sum over the node's two elements of + !! (1/2 l0_e w_e) (1/2 rho D_e Cl_e) + !! + !! (w_e the submerged fraction of element e): per unit length 1/2 rho D Cl U^2 cos(phi) + !! along e, exactly MoorDyn's Lf = 1/2 rho_w d |Vp| Cl cos(phi) (q x Vp) l_node. + !! + !! Load convention (CableDyn_Hydro, CD_Cable_Dynamic_Load_Proc): `force` is the external + !! load; the Jacobians are residual contributions, -dF/d(node velocity) and + !! -dF/d(neighbour positions) through the node tangent. The wetted-fraction factor in C is + !! held at its current value in the Jacobians (it moves only for an element that crosses + !! the waterline); the residual itself is exact. + USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE + IMPLICIT NONE + PRIVATE + + PUBLIC :: CD_VIV_Node_Lift + PUBLIC :: CD_VIV_Crossflow_Motion + PUBLIC :: CD_VIV_Phase_Rate + PUBLIC :: CD_VIV_Mean_Square + PUBLIC :: CD_VIV_Wrap_Phase + + !> MoorDyn's running-RMS window in time steps (Line%n_m): each step updates the stored + !> mean square as ((n_m - 1) old + new) / n_m. + INTEGER, PARAMETER, PUBLIC :: CD_VIV_NM = 500 + !> MoorDyn's defaults of the synchronisation range dF and centre cF when a LINE TYPES row + !> gives Cl only. + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_DEFAULT_DF = 0.08_wp + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_DEFAULT_CF = 0.18_wp + REAL(wp), PARAMETER, PUBLIC :: CD_VIV_TWO_PI = 6.283185307179586476925286766559005768394_wp + + !> Chord below which a node tangent is undefined (a collapsed pair of neighbours). + REAL(wp), PARAMETER :: TINY_CHORD = 1.0e-12_wp + +CONTAINS + + PURE SUBROUTINE node_frame(r_prev, r_next, rd, u, q, chord, vr, vn, un, ok) + !! Unit tangent from the neighbour chord and the normal relative velocity of a node. + REAL(wp), INTENT(IN) :: r_prev(3), r_next(3), rd(3), u(3) + REAL(wp), INTENT(OUT) :: q(3), chord, vr(3), vn(3), un + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: c(3) + + c = r_next - r_prev + chord = SQRT(c(1)*c(1) + c(2)*c(2) + c(3)*c(3)) + ok = chord > TINY_CHORD + IF (.NOT. ok) THEN + q = CD_ZERO + vr = CD_ZERO + vn = CD_ZERO + un = CD_ZERO + RETURN + END IF + q = c/chord + vr = u - rd + vn = vr - (q(1)*vr(1) + q(2)*vr(2) + q(3)*vr(3))*q + un = SQRT(vn(1)*vn(1) + vn(2)*vn(2) + vn(3)*vn(3)) + END SUBROUTINE node_frame + + PURE FUNCTION cross3(a, b) RESULT(c) + REAL(wp), INTENT(IN) :: a(3), b(3) + REAL(wp) :: c(3) + c(1) = a(2)*b(3) - a(3)*b(2) + c(2) = a(3)*b(1) - a(1)*b(3) + c(3) = a(1)*b(2) - a(2)*b(1) + END FUNCTION cross3 + + PURE SUBROUTINE CD_VIV_Node_Lift(r_prev, r_next, rd, u, coef, phi, force, ok, jac_v, jac_prev, jac_next) + !! Lift force on one node, F = coef cos(phi) U (q x v_n), and optionally its residual + !! Jacobians (all three present or none): jac_v = -dF/dr', jac_prev = -dF/dr_prev, + !! jac_next = -dF/dr_next. ok = .FALSE. (and F = 0) when the two neighbours coincide. + REAL(wp), INTENT(IN) :: r_prev(3), r_next(3), rd(3), u(3), coef, phi + REAL(wp), INTENT(OUT) :: force(3) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: jac_v(3, 3), jac_prev(3, 3), jac_next(3, 3) + REAL(wp) :: q(3), chord, vr(3), vn(3), un, w(3), s, alpha + REAL(wp) :: dfdq(3, 3), dfdv(3, 3), proj(3, 3) + INTEGER :: i, j + + force = CD_ZERO + IF (PRESENT(jac_v)) THEN + jac_v = CD_ZERO + jac_prev = CD_ZERO + jac_next = CD_ZERO + END IF + CALL node_frame(r_prev, r_next, rd, u, q, chord, vr, vn, un, ok) + IF (.NOT. ok) RETURN + s = coef*COS(phi) + w = cross3(q, vn) + force = (s*un)*w + IF (.NOT. PRESENT(jac_v)) RETURN + IF (.NOT. (un > CD_ZERO)) RETURN ! F and its derivatives vanish with the normal flow + ! w = q x v_n = q x v_r. dF/dv_r = s [w (x) v_n/U + U [q]x]; dr' enters v_r with a minus + ! sign, so jac_v = -dF/dr' = +dF/dv_r. + DO j = 1, 3 + DO i = 1, 3 + dfdv(i, j) = s*w(i)*vn(j)/un + END DO + END DO + dfdv(1, 2) = dfdv(1, 2) - s*un*q(3) + dfdv(1, 3) = dfdv(1, 3) + s*un*q(2) + dfdv(2, 1) = dfdv(2, 1) + s*un*q(3) + dfdv(2, 3) = dfdv(2, 3) - s*un*q(1) + dfdv(3, 1) = dfdv(3, 1) - s*un*q(2) + dfdv(3, 2) = dfdv(3, 2) + s*un*q(1) + jac_v = dfdv + ! dF/dq = s [-(alpha/U) w (x) v_r - U [v_r]x], alpha = q.v_r (U^2 = |v_r|^2 - alpha^2 and + ! d(q x v_r)/dq = -[v_r]x), chained through dq/dr_next = (I - q q^T)/chord = -dq/dr_prev. + alpha = q(1)*vr(1) + q(2)*vr(2) + q(3)*vr(3) + DO j = 1, 3 + DO i = 1, 3 + dfdq(i, j) = -s*(alpha/un)*w(i)*vr(j) + END DO + END DO + dfdq(1, 2) = dfdq(1, 2) + s*un*vr(3) + dfdq(1, 3) = dfdq(1, 3) - s*un*vr(2) + dfdq(2, 1) = dfdq(2, 1) - s*un*vr(3) + dfdq(2, 3) = dfdq(2, 3) + s*un*vr(1) + dfdq(3, 1) = dfdq(3, 1) + s*un*vr(2) + dfdq(3, 2) = dfdq(3, 2) - s*un*vr(1) + DO j = 1, 3 + DO i = 1, 3 + proj(i, j) = -q(i)*q(j)/chord + END DO + proj(j, j) = proj(j, j) + CD_ONE/chord + END DO + jac_next = -MATMUL(dfdq, proj) + jac_prev = -jac_next + END SUBROUTINE CD_VIV_Node_Lift + + PURE SUBROUTINE CD_VIV_Crossflow_Motion(r_prev, r_next, rd, rdd, u, yd, ydd, un, ok) + !! Cross-flow velocity y' and acceleration y'' of a node along e = q x v_n / U, and the + !! normal relative flow speed U. Both are zero when there is no normal flow (MoorDyn's + !! normalisation of a zero vector). + REAL(wp), INTENT(IN) :: r_prev(3), r_next(3), rd(3), rdd(3), u(3) + REAL(wp), INTENT(OUT) :: yd, ydd, un + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: q(3), chord, vr(3), vn(3), e(3) + + yd = CD_ZERO + ydd = CD_ZERO + CALL node_frame(r_prev, r_next, rd, u, q, chord, vr, vn, un, ok) + IF (.NOT. ok) RETURN + IF (.NOT. (un > CD_ZERO)) RETURN + e = cross3(q, vn)/un + yd = rd(1)*e(1) + rd(2)*e(2) + rd(3)*e(3) + ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) + END SUBROUTINE CD_VIV_Crossflow_Motion + + ELEMENTAL REAL(wp) FUNCTION CD_VIV_Mean_Square(ms_old, sample, weight) RESULT(ms) + !! One step of the running mean square, ms_old + weight (sample^2 - ms_old); weight = + !! 1/n_m is MoorDyn's ((n_m - 1) old^2 + new^2)/n_m. + REAL(wp), INTENT(IN) :: ms_old, sample, weight + ms = ms_old + weight*(sample*sample - ms_old) + END FUNCTION CD_VIV_Mean_Square + + PURE REAL(wp) FUNCTION CD_VIV_Phase_Rate(yd, ydd, ms_yd, ms_ydd, phi, un, diameter, cf, df) RESULT(rate) + !! Rate of the vortex-shedding phase, d phi/dt = 2 pi (cF + dF sin(phi_y - phi)) U/D, with + !! the cross-flow velocity phase phi_y from y', y'' normalised by their running RMS values + !! (unnormalised while either mean square is still zero, as MoorDyn). + REAL(wp), INTENT(IN) :: yd, ydd, ms_yd, ms_ydd, phi, un, diameter, cf, df + REAL(wp) :: phi_y + + IF (.NOT. (ABS(yd) > CD_ZERO .OR. ABS(ydd) > CD_ZERO)) THEN + phi_y = CD_ZERO + ELSE IF (ms_yd > CD_ZERO .AND. ms_ydd > CD_ZERO) THEN + phi_y = ATAN2(-ydd/SQRT(ms_ydd), yd/SQRT(ms_yd)) + ELSE + phi_y = ATAN2(-ydd, yd) + END IF + IF (phi_y < CD_ZERO) phi_y = phi_y + CD_VIV_TWO_PI + rate = CD_VIV_TWO_PI*(cf + df*SIN(phi_y - phi))*un/diameter + END FUNCTION CD_VIV_Phase_Rate + + ELEMENTAL REAL(wp) FUNCTION CD_VIV_Wrap_Phase(phi) RESULT(wrapped) + !! The phase mapped to [0, 2 pi); the model only uses cos(phi) and sin(. - phi). + REAL(wp), INTENT(IN) :: phi + wrapped = MODULO(phi, CD_VIV_TWO_PI) + ! a tiny negative phase can round to exactly 2 pi + IF (wrapped >= CD_VIV_TWO_PI .OR. wrapped < CD_ZERO) wrapped = CD_ZERO + END FUNCTION CD_VIV_Wrap_Phase + +END MODULE CableDyn_VIV diff --git a/tests/test_model.f90 b/tests/test_model.f90 index b7fd128d..35b1a7b2 100644 --- a/tests/test_model.f90 +++ b/tests/test_model.f90 @@ -25,7 +25,7 @@ PROGRAM test_model CD_Update_Model_Hydro_Fields, & CD_Update_Model_External_Loads, CD_Update_Model_CoupledMotion, & CD_Recompute_Model_Acceleration, & - CD_Copy_Model, & + CD_Copy_Model, CD_Set_Model_VIV, & CD_MODEL_OK, CD_MODEL_BADINPUT, CD_MODEL_SOLVEFAIL, CD_MODEL_NOT_INITIALIZED, & CD_Update_Model_SegmentLength, CD_Set_Model_EndQuery USE CableDyn_Loads, ONLY: CD_Assemble_Distributed_Load @@ -53,6 +53,7 @@ PROGRAM test_model CALL case_resolved_substeps() CALL case_substep_paths() CALL case_substep_snap_only() + CALL case_substeps_restore_viv_state() CALL case_coupled_load_sign() CALL case_coupled_motion_update() CALL case_external_load_update() @@ -1718,6 +1719,98 @@ SUBROUTINE case_damping_model_load() CALL require(es == CD_MODEL_OK, 'damping:end') END SUBROUTINE case_damping_model_load + SUBROUTINE case_substeps_restore_viv_state() + !! The rotation-resolved sub-stepping of a line carrying VIV: a 10 m taut line in a 0.5 m/s + !! cross current with Cl 0.8 on every element, End B heaved by 1 m over 2 s so that its + !! chords turn by more than a degree per 0.02 s step. Solving the first sub-stepped pass + !! twice, the second from the restored committed state (TEST-ONLY sub_test_repeat), changes + !! nothing bit for bit, the shedding phases and running mean squares included; a failing + !! sub-step (TEST-ONLY sub_test_fail) returns the plain step, and the run then equals the + !! run with ei0_substeps off bit for bit. Without the VIV state in the sub-step slots the + !! sub-steps advanced the phase again from the plain step's phase. + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, NSTEP = 60 + REAL(wp), PARAMETER :: DT = 0.02_wp, AMP = 1.0_wp, PER = 2.0_wp + TYPE(CD_ModelType) :: auto_m, rep_m, fb_m, off_m + TYPE(GenAlphaConfig) :: cfg + INTEGER :: conn(2, NE), fixed(6), es, k, n_iter + REAL(wp) :: q0(3*NN), v0(3*NN), f_ext(3*NN), pq(3*NN), pv(3*NN), pa(3*NN), fluid(3, NN), wl(NN) + REAL(wp) :: l0(NE), ea(NE), rho_a(NE), cl(NE), dia(NE), cf(NE), df(NE), phi0(NN), w, t + LOGICAL :: conv, stalled, all_conv + CHARACTER(200) :: em + + DO k = 1, NE + conn(:, k) = [k, k + 1] + END DO + q0 = 0.0_wp + DO k = 1, NN + q0(3*k - 2) = REAL(k - 1, wp) + q0(3*k) = -5.0_wp + END DO + v0 = 0.0_wp + f_ext = 0.0_wp + fixed = [1, 2, 3, 3*NN - 2, 3*NN - 1, 3*NN] + l0 = 0.99_wp + ea = 1.0e6_wp + rho_a = 10.0_wp + fluid = 0.0_wp + fluid(2, :) = 0.5_wp + wl = 0.0_wp + cl = 0.8_wp + dia = 0.1_wp + cf = 0.18_wp + df = 0.08_wp + CALL CD_Init_Model(auto_m, q0, v0, conn, l0, ea, rho_a, .TRUE., f_ext, fixed, cfg, es, em, & + fluid_velocity=fluid, drag_waterline_z=wl, drag_rho=1025.0_wp, & + drag_diameter=0.1_wp, drag_cdn=1.2_wp, drag_cdt=0.0_wp) + CALL require(es == CD_MODEL_OK, 'substep-viv:init: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + CALL CD_Set_Model_VIV(auto_m, 1025.0_wp, cl, dia, cf, df, 0.25_wp, es, em) + CALL require(es == CD_MODEL_OK, 'substep-viv:viv: '//TRIM(em)) + IF (es /= CD_MODEL_OK) RETURN + phi0 = auto_m%viv_phi + CALL CD_Copy_Model(auto_m, rep_m, es, em) + rep_m%sub_test_repeat = .TRUE. + CALL CD_Copy_Model(auto_m, fb_m, es, em) + fb_m%sub_test_fail = 1 + CALL CD_Copy_Model(auto_m, off_m, es, em) + off_m%cfg%ei0_substeps = CD_EI0_SUBSTEPS_OFF + w = 2.0_wp*ACOS(-1.0_wp)/PER + all_conv = .TRUE. + DO k = 1, NSTEP + ! End B heaves on z0 + AMP (1 - cos wt) from rest; End A holds + t = REAL(k, wp)*DT + pq = q0 + pv = 0.0_wp + pa = 0.0_wp + pq(3*NN) = q0(3*NN) + AMP*(1.0_wp - COS(w*t)) + pv(3*NN) = AMP*w*SIN(w*t) + pa(3*NN) = AMP*w*w*COS(w*t) + CALL CD_Step_Model(auto_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(rep_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(fb_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + CALL CD_Step_Model(off_m, DT, conv, stalled, n_iter, es, em, prescribed_q=pq, prescribed_v=pv, prescribed_a=pa) + all_conv = all_conv .AND. es == CD_MODEL_OK .AND. conv + END DO + WRITE (*, '(A,I0,A,I0,A,I0,A)') ' sub-steps with VIV: ', auto_m%sub_stats%events, ' of ', & + auto_m%sub_stats%calls, ' steps sub-stepped, ', fb_m%sub_stats%fallbacks, ' failing-sub-step fallbacks' + CALL require(all_conv, 'substep-viv:converged') + CALL require(auto_m%sub_stats%events > 0, 'substep-viv:sub-stepped') + CALL require(ANY(auto_m%viv_phi /= phi0) .AND. ANY(auto_m%viv_ms /= 0.0_wp), 'substep-viv:states-move') + CALL require(ALL(rep_m%q == auto_m%q) .AND. ALL(rep_m%v == auto_m%v) .AND. ALL(rep_m%a == auto_m%a) .AND. & + ALL(rep_m%viv_phi == auto_m%viv_phi) .AND. ALL(rep_m%viv_ms == auto_m%viv_ms), & + 'substep-viv:restore-is-complete') + CALL require(fb_m%sub_stats%fallbacks > 0 .AND. ALL(fb_m%q == off_m%q) .AND. ALL(fb_m%v == off_m%v) .AND. & + ALL(fb_m%a == off_m%a) .AND. ALL(fb_m%viv_phi == off_m%viv_phi) .AND. & + ALL(fb_m%viv_ms == off_m%viv_ms), 'substep-viv:fallback-is-the-plain-step') + CALL CD_End_Model(auto_m, es, em) + CALL CD_End_Model(rep_m, es, em) + CALL CD_End_Model(fb_m, es, em) + CALL CD_End_Model(off_m, es, em) + END SUBROUTINE case_substeps_restore_viv_state + SUBROUTINE case_morison_drag_model_load() !! Model-owned Morison current drag contributes to the coupled-load boundary. !! This mirrors the hydro primitive's one fully wet horizontal element case: diff --git a/tests/test_viv_kernels.f90 b/tests/test_viv_kernels.f90 new file mode 100644 index 00000000..afe04541 --- /dev/null +++ b/tests/test_viv_kernels.f90 @@ -0,0 +1,135 @@ +! File: tests/test_viv_kernels.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_kernels + !! Gate for the node kernels of the cross-flow VIV synchronisation model (CableDyn_VIV): + !! 1) the lift equals MoorDyn's Lf = 1/4 rho d |Vp| Cl cos(phi) (q x Vp) (l_i + l_i+1) through + !! coef = sum (1/2 l0)(1/2 rho D Cl); it is normal to the tangent and to the normal flow, + !! |F| = coef |cos(phi)| U^2, and vanishes for flow along the line; + !! 2) its residual Jacobians (-dF/dr', -dF/dr_prev, -dF/dr_next) match central differences; + !! 3) the cross-flow velocity and acceleration are the components along e = q x v_n / U; + !! 4) the phase rate is 2 pi (cF + dF sin(phi_y - phi)) U/D, with phi_y from the RMS-normalised + !! y', y'' (cF at phase lock, cF + dF a quarter period ahead); + !! 5) the running mean square is MoorDyn's ((n_m - 1) old^2 + new^2)/n_m; + !! 6) the phase wraps to [0, 2 pi), and a node whose neighbours coincide fails closed. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM + IMPLICIT NONE + REAL(wp), PARAMETER :: RHO = 1025.0_wp, DIAM = 0.1_wp, CL = 0.8_wp, L1 = 2.0_wp, L2 = 1.5_wp + REAL(wp) :: rp(3), rn(3), rd(3), u(3), coef, phi, f(3), q(3), vr(3), vn(3), un, w(3), ref(3) + REAL(wp) :: jv(3, 3), jp(3, 3), jn(3, 3), fd(3, 3), fp(3), fm(3), h, e(3), yd, ydd, un2, rate + REAL(wp) :: ms, ms_md + LOGICAL :: ok + INTEGER :: nfail, j, k + + nfail = 0 + rp = [0.1_wp, -0.2_wp, -50.3_wp] + rn = [3.6_wp, 0.4_wp, -49.8_wp] + rd = [0.05_wp, -0.12_wp, 0.31_wp] + u = [0.2_wp, 0.15_wp, -0.03_wp] + coef = (0.5_wp*L1 + 0.5_wp*L2)*0.5_wp*RHO*DIAM*CL + phi = 0.7_wp + + ! (1) MoorDyn's lift and its geometry + CALL CD_VIV_Node_Lift(rp, rn, rd, u, coef, phi, f, ok) + CALL require(ok, 'lift: frame defined') + q = (rn - rp)/NORM2(rn - rp) + vr = u - rd + vn = vr - DOT_PRODUCT(q, vr)*q + un = NORM2(vn) + w = cross(q, vn) + ref = 0.25_wp*RHO*DIAM*un*CL*COS(phi)*w*(L1 + L2) + CALL require(NORM2(f - ref) <= 1.0e-12_wp*NORM2(ref), 'lift equals MoorDyn''s Lf') + CALL require(ABS(DOT_PRODUCT(f, q)) <= 1.0e-12_wp*NORM2(f) .AND. ABS(DOT_PRODUCT(f, vn)) <= 1.0e-12_wp*NORM2(f)*un, & + 'lift normal to the tangent and to the normal flow') + CALL require(ABS(NORM2(f) - coef*ABS(COS(phi))*un*un) <= 1.0e-12_wp*NORM2(f), '|lift| = coef |cos phi| U^2') + CALL CD_VIV_Node_Lift(rp, rn, rd, rd + 0.3_wp*q, coef, phi, f, ok) + CALL require(ok .AND. NORM2(f) <= 1.0e-14_wp, 'no lift for flow along the line') + + ! (2) Jacobians against central differences + CALL CD_VIV_Node_Lift(rp, rn, rd, u, coef, phi, f, ok, jv, jp, jn) + h = 1.0e-6_wp + DO j = 1, 3 + CALL CD_VIV_Node_Lift(rp, rn, rd + h*unit(j), u, coef, phi, fp, ok) + CALL CD_VIV_Node_Lift(rp, rn, rd - h*unit(j), u, coef, phi, fm, ok) + fd(:, j) = -(fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jv - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'velocity Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Node_Lift(rp + h*unit(j), rn, rd, u, coef, phi, fp, ok) + CALL CD_VIV_Node_Lift(rp - h*unit(j), rn, rd, u, coef, phi, fm, ok) + fd(:, j) = -(fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jp - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'previous-node Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Node_Lift(rp, rn + h*unit(j), rd, u, coef, phi, fp, ok) + CALL CD_VIV_Node_Lift(rp, rn - h*unit(j), rd, u, coef, phi, fm, ok) + fd(:, j) = -(fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jn - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'next-node Jacobian matches differences') + + ! (3) cross-flow motion along e = q x v_n / U + CALL CD_VIV_Crossflow_Motion(rp, rn, rd, [1.0_wp, 2.0_wp, -0.5_wp], u, yd, ydd, un2, ok) + e = w/un + CALL require(ok .AND. ABS(un2 - un) <= 1.0e-14_wp, 'cross-flow: normal flow speed') + CALL require(ABS(yd - DOT_PRODUCT(rd, e)) <= 1.0e-14_wp .AND. & + ABS(ydd - DOT_PRODUCT([1.0_wp, 2.0_wp, -0.5_wp], e)) <= 1.0e-14_wp, & + 'cross-flow velocity and acceleration along e') + + ! (4) phase rate: at phase lock (phi_y = phi) the band centre, a quarter period ahead cF + dF + ! (y' = cos, y'' = -sin with unit RMS: phi_y is the motion phase) + rate = CD_VIV_Phase_Rate(COS(1.1_wp), -SIN(1.1_wp), 1.0_wp, 1.0_wp, 1.1_wp, 0.15_wp, DIAM, 0.18_wp, & + 0.08_wp) + CALL require(ABS(rate - CD_VIV_TWO_PI*0.18_wp*0.15_wp/DIAM) <= 1.0e-12_wp*rate, 'rate at phase lock is cF U/D') + rate = CD_VIV_Phase_Rate(COS(1.1_wp), -SIN(1.1_wp), 1.0_wp, 1.0_wp, 1.1_wp - 0.25_wp*CD_VIV_TWO_PI, & + 0.15_wp, DIAM, 0.18_wp, 0.08_wp) + CALL require(ABS(rate - CD_VIV_TWO_PI*0.26_wp*0.15_wp/DIAM) <= 1.0e-12_wp*rate, 'rate a quarter period ahead is (cF+dF) U/D') + + ! (5) MoorDyn's running mean square + ms_md = 0.3_wp + DO k = 1, 50 + ms = CD_VIV_Mean_Square(ms_md, SIN(0.1_wp*k), 1.0_wp/REAL(CD_VIV_NM, wp)) + CALL require(ABS(ms - (REAL(CD_VIV_NM - 1, wp)*ms_md + SIN(0.1_wp*k)**2)/REAL(CD_VIV_NM, wp)) <= 1.0e-15_wp, & + 'mean square is MoorDyn''s running RMS update') + ms_md = ms + END DO + + ! (6) wrap and degenerate frame + CALL require(CD_VIV_Wrap_Phase(-1.0e-300_wp) >= 0.0_wp .AND. CD_VIV_Wrap_Phase(-1.0e-300_wp) < CD_VIV_TWO_PI, & + 'a tiny negative phase wraps into [0, 2 pi)') + CALL require(ABS(CD_VIV_Wrap_Phase(7.0_wp) - (7.0_wp - CD_VIV_TWO_PI)) <= 1.0e-15_wp, 'phase wraps by 2 pi') + CALL CD_VIV_Node_Lift(rp, rp, rd, u, coef, phi, f, ok) + CALL require(.NOT. ok .AND. NORM2(f) <= 0.0_wp, 'coinciding neighbours fail closed with no lift') + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: VIV synchronisation-model kernels' + +CONTAINS + + 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(j) RESULT(e) + INTEGER, INTENT(IN) :: j + REAL(wp) :: e(3) + e = 0.0_wp + e(j) = 1.0_wp + END FUNCTION unit + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + WRITE (*, '(A)') 'MISMATCH: '//msg + nfail = nfail + 1 + END IF + END SUBROUTINE require + +END PROGRAM test_viv_kernels diff --git a/tests/test_viv_lockin.py b/tests/test_viv_lockin.py new file mode 100644 index 00000000..82500fae --- /dev/null +++ b/tests/test_viv_lockin.py @@ -0,0 +1,158 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Cross-flow VIV lock-in of a taut line against MoorDyn-F. + +A 100 m line (50 segments, D 0.1 m, 10 kg/m, EA 5e7 N, about 50 kN) between two points at 50 m +depth in a uniform 0.15 m/s cross current, lift coefficient 0.8 with MoorDyn's band (dF 0.08, +cF 0.18): the shedding frequency cF U/D = 0.27 Hz sits on the first vertical mode, and the line +locks in. MoorDyn-F (OpenFAST v5 moordyn_driver, dtM 5e-4 s) gives a mid-span A/D of 0.662 at +0.293 Hz over 150-300 s. Gates, over 60-120 s: + +* at dtM 0.01 s the mid-span A/D is within 3 % of MoorDyn-F's and the response frequency within + one spectral bin (1/60 Hz) of it, with the quarter-span amplitude of the first mode; +* at dtM 0.002 s, a step that resolves the mesh zig-zag mode, the line stays locked in with the + same amplitude (within 2 %): with the nodes' own kinematics in the synchronisation model the + zig-zag mode was pumped there and the line lost lock-in after about 70 s. + +usage: test_viv_lockin.py --exe --output +""" + +from __future__ import annotations + +import argparse +import math +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python")) +from cabledyn import read_output # noqa: E402 + +FAILURES: list[str] = [] +MD_AD, MD_F = 0.662, 0.293 # MoorDyn-F reference, mid span +D = 0.1 + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +CURRENT = """MoorDyn v2 water kinematics file +uniform cross-flow current for the VIV lock-in gate +--------------------------- WAVES ------------------------------------- +0 WaveKinMod - type of wave input +"" WaveKinFile - file containing wave elevation time series +0.000000E+00 dtWave - time step to use in setting up wave kinematics grid (s) +0 WaveDir - wave heading (deg) +2 - X wave input type +-10, 110, 2 - X wave grid point data +2 - Y wave input type +-10, 10, 2 - Y wave grid point data +2 - Z wave input type +-100, 0, 2 - Z wave grid point data +--------------------------- CURRENT ------------------------------------- +1 CurrentMod - type of current input +z-depth x-current y-current +(m) (m/s) (m/s) +0.0 0.0 0.15 +-100.0 0.0 0.15 +--------------------- need this line ------------------ +""" + + +def deck(dtm: float) -> str: + length = 100.0 / (1.0 + 5.0e4 / 5.0e7) + return f"""--------------------- CableDyn Input File --------------------------------- +VIV lock-in gate: taut line in a uniform cross current +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF +(name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-) +riser 0.10 10.0 5.0e7 -0.8 0.0 1.2 1.0 0.0 0.0 0.8 0.08 0.18 +----------------------- POINTS ---------------------------------------------- +ID Attachment X Y Z M V CdA CA +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Coupled 0.0 0.0 -50.0 0 0 0 0 +2 Fixed 100.0 0.0 -50.0 0 0 0 0 +----------------------- LINES ----------------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs Outputs +(#) (name) (#) (#) (m) (-) (-) +1 riser 1 2 {length:.6f} 50 - +---------------------- OPTIONS ---------------------------------------------- +{dtm} dtM +100.0 WtrDpth +1025.0 rhoW +9.80665 g +current.dat WaterKin +0.25 VIVrmsWindow +120.0 TMax +---------------------- OUTPUTS ----------------------------------------------- +L1N25PZ +L1N12PZ +END +------------------------- need this line -------------------------------------- +""" + + +def response(path: Path) -> tuple[float, float, float]: + """Mid A/D, mid peak frequency, quarter A/D over 60-120 s.""" + hist = read_output(path) + t = hist.column(hist.channels[0]) + mask = t >= 60.0 + mid = hist.column("L1N25PZ")[mask] + qtr = hist.column("L1N12PZ")[mask] + mid = mid - mid.mean() + dt = float(np.median(np.diff(t[mask]))) + freq = np.fft.rfftfreq(mid.size, dt) + power = np.abs(np.fft.rfft(mid * np.hanning(mid.size))) + return ( + math.sqrt(2.0) * float(mid.std()) / D, + float(freq[1:][np.argmax(power[1:])]), + math.sqrt(2.0) * float((qtr - qtr.mean()).std()) / D, + ) + + +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) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + (out / "current.dat").write_text(CURRENT, encoding="utf-8", newline="\n") + results = {} + for dtm in (0.01, 0.002): + name = f"viv_dt{dtm}" + (out / f"{name}.dat").write_text(deck(dtm), encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, f"{name}.dat", name], cwd=out, capture_output=True, text=True) + if proc.returncode != 0: + print(proc.stdout[-2000:], proc.stderr[-2000:]) + check(False, f"dtM {dtm}: the run completes (exit {proc.returncode})") + continue + results[dtm] = response(out / f"{name}.out") + if 0.01 in results: + ad, f, qtr = results[0.01] + check(abs(ad - MD_AD) <= 0.03 * MD_AD, + f"dtM 0.01 s: mid-span A/D {ad:.3f}, MoorDyn-F {MD_AD} (within 3 %)") + check(abs(f - MD_F) <= 1.0 / 60.0, + f"dtM 0.01 s: response frequency {f:.3f} Hz, MoorDyn-F {MD_F} Hz (within 1/60 Hz)") + ratio = math.sin(math.pi * 22.0 / 100.0) + check(abs(qtr / ad - ratio) <= 0.05, + f"dtM 0.01 s: quarter/mid amplitude {qtr / ad:.3f}, first mode {ratio:.3f}") + if 0.01 in results and 0.002 in results: + a1, a2 = results[0.01][0], results[0.002][0] + check(abs(a2 - a1) <= 0.02 * a1, + f"dtM 0.002 s stays locked in: mid-span A/D {a2:.3f} against {a1:.3f} at 0.01 s (within 2 %)") + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) From 7980bcc4f9cae0ed6a51421a8e8db1278448d1c1 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 27 Oct 2026 09:15:30 +0900 Subject: [PATCH 07/51] feat(viv): cross-flow VIV on finite-EI cables (#56) The cross-flow VIV synchronisation model of #55 now runs on finite-EI (cubic-Hermite) cables in the standalone driver: the same LINE TYPES columns `Cl` or `Cl dF cF` on an `EI > 0` type. Model. The lift is a distributed load per unit deformed length, f = 1/2 rho d Cl cos(phi) U (t x v_r), with t the unit tangent of the centreline, v_r the relative flow and cos(phi) interpolated linearly between the element's end nodes. It is integrated against the Hermite shape functions at the drag element's three Gauss points (a point above the surface carries none), with its exact position and velocity Jacobians in the tangent (the residual path and the parallel tangent-only path). Each node carries a phase, driven by the node's cross-flow motion along its own tangent, the slope degrees of freedom; d, cF and dF at a node are the length-weighted averages over its lifting elements, and the phases start at 2 pi i/N from End A. As on EI = 0 lines the phase is explicit: the step's evaluations take the phase predicted from the step-start rate (at t_n+1 under the force blend, whose committed force F_n keeps phi_n; at the generalised-alpha level under the configuration blend), and the commit is the Heun update. With VIV the converged force is not cached as the next step's F_n (it took the predicted phase). No smoothing is needed: the Hermite tangent and the integrated lift leave no mesh-scale mode for the synchronisation loop to pump. State. The phases and running mean squares are saved and restored with the kinematics by the recovering step, the snapshot and the deallocation; every evaluation outside a step (end forces, node recovery, the held-field update, the committed acceleration) takes the committed phase. The phase commit cannot fail, so a step is never left half committed: a node whose end tangent is degenerate takes the step-start rate over the step. Installing or removing VIV refreshes the committed acceleration with the lift (the previous VIV state and acceleration come back if that solve fails), and a later drag reconfiguration carries the lift scale and the shedding diameter with it. An internal wave family (Set_Waves) is refused on a VIV cable; deck waves and current reach the standalone Hermite march as its held fluid field, which the phase follows. Routes. `build_one_hermite_cable` installs VIV only for the standalone finite-EI march. A finite-EI line with two moving ends (compatibility route), a finite-EI line beside bodies, rods or free points (multibody march), the single-cable `CD_Init_Deck_HermiteCable` entry and the aggregate (coupled, mixed) route refuse `Cl > 0` by name; `DeckFile` mirrors the refusals. Validation (VALIDATION.md L2-VIV-EI, gated in `viv_lockin` and `hermite_viv`): - the #55 benchmark line as a finite-EI cable with EI = 1 N m^2: mid/quarter-span A/D 0.662/0.421 against the EI = 0 line's 0.663/0.421 at the same frequency, unchanged at dtM 1e-2, 2e-3 and 5e-4 s; - a bending-stiff, neutrally buoyant cable (EA 5e9 N, EI 5e7 N m^2, beta = pi^2 EI/(T L^2) ~ 1) against the EI = 0 string of equal first-mode frequency, tension T(1 + beta): the same mode-1 lock-in (A/D within 2.5 %, same frequency) for U <= 0.24 m/s; for U >= 0.27 m/s the string jumps to mode 2 while the cable stays in mode 1, its bending having raised f2/f1 to about 3.15; - a lazy-wave power cable (examples/lazy_wave_buoyancy_smeared.dat with Cl 0.8, 0.5 m/s current) shows out-of-plane VIV at 0.47 Hz with the fairlead tension oscillating at twice that frequency, and stays still without the lift. Tests: `hermite_viv` (the setter's refusals, the acceleration refresh, the drag reconfiguration, the lock-in with and without lift, a mid-run snapshot replaying the state and phase bit for bit, the recovering step equal to the plain step), `viv_kernels` section 7 (the per-length lift and its flow and tangent Jacobians against central differences), `viv_lockin` (the two comparisons above, the EI = 1 cable at dtM 0.01 and 0.002 s), and the deck-file tests. Full suite: 305/305 ctest, 2082 pytest; every shipped example's output is byte-identical to dev. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 7 + CMakeLists.txt | 15 +- VALIDATION.md | 1 + doc/capabilities.rst | 8 +- doc/migrating.rst | 5 +- doc/options.rst | 3 +- doc/theory.rst | 30 +- doc/troubleshooting.rst | 8 +- python/cabledyn/builder.py | 2 +- python/cabledyn/deck_file.py | 23 +- python/tests/test_deck_file.py | 18 +- src/CableDyn_DeckDriver.f90 | 103 +++++- src/CableDyn_HermiteCableDynamic.f90 | 481 ++++++++++++++++++++++++++- src/CableDyn_VIV.f90 | 89 +++++ tests/test_hermite_viv.f90 | 210 ++++++++++++ tests/test_viv_kernels.f90 | 28 +- tests/test_viv_lockin.py | 84 ++++- 17 files changed, 1061 insertions(+), 54 deletions(-) create mode 100644 tests/test_hermite_viv.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index fbe1f1b6..02657bfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ All notable changes to CableDyn are recorded in this file. The format follows and frequency to two to three digits through mode-1 and mode-3 lock-in, at any `dtM` from 5e-4 to 1e-2 s. The Python deck tools read and keep the columns. The coupled and mixed routes refuse `Cl > 0` by name. +- Cross-flow VIV of finite-EI cables in the standalone driver: the same LINE TYPES columns on an + `EI > 0` type give a distributed lift, Gauss-integrated over each cubic-Hermite element with + exact tangents, and a shedding phase at each node driven along the node's own tangent. A taut + line with `EI` near zero reproduces the `EI = 0` lock-in to three digits, at any `dtM` from + 5e-4 to 1e-2 s without smoothing; a bending-stiff line matches the string of equal first-mode + frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. A finite-EI + line with two moving ends, or beside bodies, rods or free points, refuses `Cl > 0`. - Bend stiffeners (`STIFFENERS` table): a tapered polyurethane sleeve over an end of a finite-EI line, given as conical segments from the root outward (outer diameters, bore, modulus, density). Each element it covers takes the compliance average of the cable-plus-sleeve diff --git a/CMakeLists.txt b/CMakeLists.txt index 22d27f5d..5911ec2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1175,6 +1175,11 @@ target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) add_test(NAME viv_kernels COMMAND test_viv_kernels) set_tests_properties(viv_kernels PROPERTIES LABELS "fortran;unit;dynamic;viv") +add_executable(test_hermite_viv tests/test_hermite_viv.f90) +target_link_libraries(test_hermite_viv PRIVATE cabledyn_core) +add_test(NAME hermite_viv COMMAND test_hermite_viv) +set_tests_properties(hermite_viv PROPERTIES LABELS "fortran;dynamic;viv") + add_executable(test_hfmf_mirror tests/test_hfmf_mirror.f90) target_link_libraries(test_hfmf_mirror PRIVATE cabledyn_core) add_test(NAME hfmf_mirror COMMAND test_hfmf_mirror WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -1627,9 +1632,17 @@ if(Python3_Interpreter_FOUND) COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_viv_lockin.py --exe $ --output ${CMAKE_BINARY_DIR}/viv_lockin) + # eight benchmark runs, four at a time (PROCESSORS reserves them, so no other test shares + # the cores); a checked Debug build is about ten times slower than Release + if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(_viv_lockin_timeout 2400) + else() + set(_viv_lockin_timeout 600) + endif() set_tests_properties(viv_lockin PROPERTIES LABELS "python;integration;dynamic;viv;validation" - TIMEOUT 600 + PROCESSORS 4 + TIMEOUT ${_viv_lockin_timeout} ENVIRONMENT "${_cabledyn_python_test_environment}") else() message(STATUS "viv_lockin: skipped (numpy not importable in ${Python3_EXECUTABLE})") diff --git a/VALIDATION.md b/VALIDATION.md index fe21a1f6..a025c0a3 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -63,6 +63,7 @@ article's methods, are compared in | **L2-80** | Lozon 80 m all-chain mooring | catenary (H) / MoorDyn-F (fairlead) | 0.03% / 1.8% | <2% / <5% | Pass | | **L2-arb** | Closed-form catenary reference check | OrcaFlex VolturnUS-S ref | 0.69% | <2% | Pass | | **L2-VIV** | Cross-flow VIV lock-in of a taut 100 m line, U = 0.06–0.42 m/s | MoorDyn-F (OpenFAST v5 `moordyn_driver`, `dtM` 5e-4 s) | mode-1 and mode-3 lock-in (U ≤ 0.18 and ≥ 0.36 m/s): mid-span A/D within 1.2%, frequency within one spectral bin; same response at `dtM` 5e-4 to 1e-2 s; at 0.21–0.33 m/s the codes settle on different modes (MoorDyn-F mode 1, CableDyn mode 2) | A/D <3%, frequency within one spectral bin (`viv_lockin`) | Pass scoped | +| **L2-VIV-EI** | Cross-flow VIV of a finite-EI cable: the L2-VIV line with EI = 1 N m², and a bending-stiff line (EA 5e9 N, EI 5e7 N m², β = π²EI/(TL²) ≈ 1, neutrally buoyant) against the EI = 0 string of equal first-mode frequency, U = 0.10–0.36 m/s | CableDyn `EI = 0` line (verification) | EI = 1: mid/quarter A/D 0.662/0.421 against 0.663/0.421, same frequency, at `dtM` 5e-4 to 1e-2 s; stiff line: mode-1 lock-in A/D within 2.5% of the string's at the same frequency for U ≤ 0.24 m/s; for U ≥ 0.27 m/s the string jumps to mode 2 while the stiff line stays in mode 1 (bending raises f₂/f₁ to 3.15) | EI = 1: A/D within 1% at `dtM` 0.01 and 0.002 s (5e-4 s run once over 200 s); stiff line at U 0.21 m/s: A/D within 3%; frequency within one spectral bin; at U 0.30 m/s stiff line A/D > 0.6, string < 0.15 (`viv_lockin`, `hermite_viv`) | Pass | | **L3-1** | WD0050 static | OrcaFlex | 0.15 / 0.85% | <2% | Pass | | **L3-2** | Regular-wave dynamic | OrcaFlex (pinned, dt-converged) | mean 0.30%, swing 8.4% | <2% / <15% | Pass | | **L3-3** | Current-deflected static | OrcaFlex | 0.07–0.67% | <2% | Pass | diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 450b8b01..68335dcb 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -115,9 +115,11 @@ Line and constitutive capability torsion is rejected * - Cross-flow VIV (LINE TYPES ``Cl``, ``dF``, ``cF``) - Standalone only - - MoorDyn v2's synchronisation model on ``EI = 0`` lines (:ref:`theory-viv`); in-line VIV - and finite-EI cables are not provided; the coupled OpenFAST and FAST.Farm routes and - mixed ``EI = 0`` / finite-EI decks refuse ``Cl > 0`` by name + - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on + finite-EI cables of the Hermite march (:ref:`theory-viv`); in-line VIV is not provided; + the coupled OpenFAST and FAST.Farm routes, mixed ``EI = 0`` / finite-EI decks, finite-EI + lines with two moving ends and finite-EI lines beside bodies, rods or free points refuse + ``Cl > 0`` by name Loads and environment --------------------- diff --git a/doc/migrating.rst b/doc/migrating.rst index 9a851f77..66cf82f4 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -93,8 +93,9 @@ Keyword map - same row; the native order is ``Cd_n Cd_t Ca_n Ca_t`` and the header decides which is meant. ``EI > 0`` switches the line to the bending element. * - ``LINE TYPES`` VIV columns ``Cl`` or ``Cl dF cF`` - - same columns and the same synchronisation model on ``EI = 0`` types in the standalone - driver (:ref:`theory-viv`); the running-RMS window is ``VIVrmsWindow`` seconds, by default + - same columns and the same synchronisation model in the standalone driver, on ``EI = 0`` + types and as a distributed lift on finite-EI types (:ref:`theory-viv`); the running-RMS + window is ``VIVrmsWindow`` seconds, by default 500 steps of ``dtM`` as MoorDyn's * - ``ElasticMod 2/3`` viscoelastic ``EA``/``BA`` - ``Es|Ed`` / ``Es|alphaMBL|vbeta`` in ``EA`` and ``BA_s|BA_d`` in ``BA`` diff --git a/doc/options.rst b/doc/options.rst index e5accfcf..936b05ac 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -683,7 +683,8 @@ Ambient fluid and prescribed motion of the VIV synchronisation model (:ref:`theory-viv`). ``0`` takes MoorDyn's 500 steps of ``dtM`` (of the first step when the deck has no ``dtM``); set it to compare runs at different ``dtM`` with the same averaging time - - standalone ``EI = 0`` lines with a LINE TYPES ``Cl > 0`` + - standalone lines (``EI = 0``, or finite-EI on the Hermite march) with a LINE TYPES + ``Cl > 0`` - ``0.25 VIVrmsWindow`` * - ``motionFile`` - path, or ``0``/``none`` diff --git a/doc/theory.rst b/doc/theory.rst index 9b96cc7e..9b0e3c0a 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -720,10 +720,10 @@ The fluid acceleration is the local (Eulerian) acceleration of the wave field. Cross-flow vortex-induced vibration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -``EI = 0`` lines can carry the cross-flow lift of the synchronisation model of +Lines can carry the cross-flow lift of the synchronisation model of :ref:`Thorsen et al. (2014) ` and :ref:`(2016) ` in the form MoorDyn v2 implements it: a LINE TYPES row with a lift coefficient :math:`C_L > 0` (see -:doc:`file_formats`). At an interior node with unit tangent :math:`\mathbf{q}` (the chord of its +:doc:`file_formats`). On an ``EI = 0`` line, at an interior node with unit tangent :math:`\mathbf{q}` (the chord of its neighbours) and normal relative flow :math:`\mathbf{v}_n` of speed :math:`U = \lvert\mathbf{v}_n\rvert`, each node carries a vortex-shedding phase :math:`\phi` and the lift @@ -757,8 +757,30 @@ the phase and the velocity in the lift are the node values averaged with the nei wavenumber :math:`k` to :math:`\cos^2(k l_0/2)` and removes the mesh-scale zig-zag mode exactly. With the node's own kinematics, a step that resolves the zig-zag mode lets the synchronisation loop pump it until the line loses lock-in; a coarse step only hides this behind the -integrator's numerical damping. VIV runs in the standalone driver; the coupled and mixed -aggregate routes refuse a deck with :math:`C_L > 0`. +integrator's numerical damping. + +On a finite-EI (cubic-Hermite) cable the lift is a distributed load per unit deformed length, + +.. math:: + + \mathbf{f}_L = \tfrac{1}{2}\rho\,d\,C_L\cos\phi\;U\;\mathbf{t}\times\mathbf{v}_r , + +with :math:`\mathbf{t}` the unit tangent of the centreline, :math:`\mathbf{v}_r` the relative flow +(its normal part has speed :math:`U`) and :math:`\cos\phi` interpolated linearly between the +element's end nodes. It is integrated against the Hermite shape functions at the three Gauss +points of the drag (a point above the surface carries none), and its exact position and +velocity derivatives enter the tangent. Each node carries a phase, driven as above by the +node's cross-flow motion along its own tangent, the slope degrees of freedom; :math:`d`, +:math:`c_F` and :math:`d_F` at a node are the length-weighted averages over its lifting +elements. The phase is explicit with the Heun commit as on ``EI = 0`` lines, and no smoothing is +needed: the Hermite tangent and the integrated lift leave no mesh-scale mode for the loop to +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 +carries it, including deck waves and current through its held fluid field; a finite-EI line +with two moving ends, or beside bodies, rods or free points, refuses :math:`C_L > 0`. + +VIV runs in the standalone driver; the coupled and mixed aggregate routes refuse a deck with +:math:`C_L > 0`. Buoyancy and wetting ~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 5d80a286..4420f6de 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -839,8 +839,12 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com * - a ``Rigid`` end-connection direction reversed by exactly 180 degrees in one host update - drive the platform through intermediate orientations * - VIV on the coupled or mixed route (``VIV (LINE TYPES Cl > 0) runs in the standalone driver - of an EI = 0 deck``) - - run the VIV study on a standalone ``EI = 0`` deck, or set ``Cl = 0`` for the coupled run + of an EI = 0 or finite-EI deck``) + - run the VIV study on a standalone ``EI = 0`` or finite-EI deck, or set ``Cl = 0`` for the + coupled run + * - VIV on a finite-EI line with two moving ends (``needs its End B fixed``) or beside + bodies, rods or free points (``does not run with bodies, rods or free points yet``) + - fix End B of the line, or set ``Cl = 0`` for its line type * - 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/builder.py b/python/cabledyn/builder.py index 1aa415b3..17d8e717 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -194,7 +194,7 @@ class LineType: inertias). All four set writes the 14-column row; all ``None`` writes the 10-column row. cl, df, cf : float | None - Optional cross-flow VIV columns of an ``EI = 0`` type (MoorDyn's lift + Optional cross-flow VIV columns of a type (MoorDyn's lift coefficient and the half-range and centre of the synchronisation band in non-dimensional frequency). ``cl`` set writes the 13-column row, with MoorDyn's ``df = 0.08`` and ``cf = 0.18`` where they are ``None``. diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 343667df..a3d1fe0d 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2615,6 +2615,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: # (native init_one_model, which needs the line's Morison drag in water) has_viv = False has_viv_ei0 = False + viv_type_names: set[str] = set() for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") @@ -2697,10 +2698,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: LINE TYPES VIV synchronisation band needs cF > 0 " "and 0 <= dF < cF" ) - if cl > 0.0 and ei > 0.0: - raise DeckFormatError( - f"{self._at(row)}: VIV (Cl > 0) is implemented for EI = 0 line types only" - ) if cl > 0.0 and is_syrope: raise DeckFormatError( f"{self._at(row)}: VIV (Cl > 0) does not combine with the Syrope " @@ -2708,6 +2705,8 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: ) has_viv = has_viv or cl > 0.0 has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) + if cl > 0.0: + viv_type_names.add(row.tokens[0].lower()) 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") @@ -3494,8 +3493,8 @@ def end_key(token: str) -> str: if has_viv: raise DeckFormatError( f"{self._label}: VIV (LINE TYPES Cl > 0) runs in the standalone driver of an " - "EI = 0 deck; the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / " - "finite-EI decks do not carry it yet. Set Cl = 0 for this run" + "EI = 0 or finite-EI deck; the coupled OpenFAST and FAST.Farm routes and mixed " + "EI = 0 / finite-EI decks do not carry it yet. Set Cl = 0 for this run" ) if self.caller_driven: # native CD_Init_Deck_Aggregate: nothing on the coupled route evaluates deck @@ -3600,6 +3599,18 @@ def is_body_kind(kind: str, pinned: bool) -> bool: ) elif has_rigid6: needs_multibody = non_rigid6_points + if deck_driver_route and viv_type_names: + # native run_deck_driver: the finite-EI lift runs on the cubic-Hermite march, which + # builds no bodies, rods or Free/Connect points (a moving End B is refused above) + for line_id in finite_line_ids: + if not viv_type_names.intersection(section_types_by_line[line_id]): + continue + if needs_multibody: + raise DeckFormatError( + f"{self._label}: VIV (LINE TYPES Cl > 0) of a finite-EI line does not run " + "with bodies, rods or free points yet; set Cl = 0 for the finite-EI lines " + "of this deck" + ) if failures and deck_driver_route: # native CD_Run_Deck_Driver: FAILURE runs on the point-system object graph only if not has_dtm: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 9f8e7825..c9fc05ed 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4591,11 +4591,16 @@ def test_line_type_viv_columns_follow_the_native_checks(columns, message): DeckFile.from_text(_edit(_STATIC, (_VIV_ROW, _VIV_ROW + columns))) -def test_line_type_viv_needs_an_ei0_line_type(): +def test_line_type_viv_is_accepted_on_a_finite_ei_line_type(tmp_path): + from cabledyn import DeckModel + row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" text = _edit(_DYNAMIC, (row, row + " 0.8")) - with pytest.raises(DeckFormatError, match="implemented for EI = 0 line types only"): - DeckFile.from_text(text) + DeckFile.from_text(text) + path = tmp_path / "viv_ei.dat" + path.write_text(text, encoding="utf-8") + line_type = DeckModel.load(path).line_types["chain"] + assert (line_type.ei, line_type.cl) == (1.0e4, 0.8) def test_viv_is_refused_on_the_coupled_route(): @@ -4613,6 +4618,13 @@ def test_viv_needs_water_on_an_ei0_line(): DeckFile.from_text(_edit(_STATIC, ("50.0 WtrDpth\n", ""))) +def test_finite_ei_viv_is_refused_beside_free_points(): + row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" + base = _edit(_DYNAMIC, ("2 Coupled 0.0 0.0 0.0 0 0 0 0", "2 Free 0.0 0.0 0.0 1000 0 0 0")) + with pytest.raises(DeckFormatError, match="does not run with bodies, rods or free points"): + DeckFile.from_text(_edit(base, (row, row + " 0.8"))) + + def test_viv_rms_window_option_is_non_negative(): base = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8")) DeckFile.from_text(_edit(base, ("50.0 WtrDpth\n", "50.0 WtrDpth\n0.25 VIVrmsWindow\n"))) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index fbeca086..49aaf8e7 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -103,7 +103,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Set_Output_Recovery, & CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & - CD_HermiteCable_Dyn_Set_Friction_Axial, & + CD_HermiteCable_Dyn_Set_Friction_Axial, CD_HermiteCable_Dyn_Set_VIV, & 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 @@ -1641,7 +1641,8 @@ 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) + fairlead_orientation, init_note, coarse_pass, fold_support, & + install_viv) !! 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. @@ -1672,12 +1673,16 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! The static seabed friction the calling route accepts (FOLD_FRICTION_*, default ! FOLD_FRICTION_FULL), for the remedy of the note on a run past the anchor. INTEGER, INTENT(IN), OPTIONAL :: fold_support + ! Install the cross-flow VIV of the line's Cl > 0 sections (the standalone finite-EI march; + ! the other routes refuse such a line before building it). + LOGICAL, INTENT(IN), OPTIONAL :: install_viv 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 :: 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(:) + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) REAL(wp), ALLOCATABLE :: ba_raw(:), ba(:), dry_b(:) REAL(wp), ALLOCATABLE :: contact_kn(:), contact_cn(:) REAL(wp) :: anchor(3), fairlead(3), res, tvec(3), tnrm, contact_z, seed_z, seed_floor_a, seed_floor_b @@ -2921,7 +2926,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! property of the original element containing its reference-arc midpoint. ALLOCATE (cdn(SIZE(l0)), cdt(SIZE(l0)), can(SIZE(l0)), cat(SIZE(l0))) CALL finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) + ALLOCATE (viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), viv_df(SIZE(l0))) + CALL finite_viv_arrays(ln, sections, types, viv_cl, viv_cf, viv_df) IF (SIZE(l0_am) /= SIZE(l0)) THEN + CALL remap_elem_by_reference_arc(viv_cl, l0, l0_am) + CALL remap_elem_by_reference_arc(viv_cf, l0, l0_am) + CALL remap_elem_by_reference_arc(viv_df, l0, l0_am) CALL remap_elem_by_reference_arc(rho_a, l0, l0_am) CALL remap_elem_by_reference_arc(diam, l0, l0_am) CALL remap_elem_by_reference_arc(cdn, l0, l0_am) @@ -3123,6 +3133,18 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable drag wiring failed: '//TRIM(em)); RETURN END IF + ! Cross-flow VIV on the Cl > 0 sections, with the drag's diameters (CableDyn_VIV); an + ! OPTION VIVrmsWindow of 0 takes MoorDyn's 500 time steps. + IF (PRESENT(install_viv)) THEN + IF (install_viv .AND. ANY(viv_cl > CD_ZERO)) THEN + CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & + MERGE(opts%viv_rms_window, REAL(CD_VIV_NM, wp)*dt, & + opts%viv_rms_window > CD_ZERO), es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable VIV wiring failed: '//TRIM(em)); RETURN + END IF + END IF + END IF CALL CD_HFMF_Set_AddedMass(cable, opts%rhoW, diam, can, cat, CD_ZERO, es, em) IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable added-mass wiring failed: '//TRIM(em)); RETURN @@ -6484,6 +6506,10 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable cannot consume WaveKinMod 2/SEASTATE; '// & 'use the aggregate facade with its external SeaState field'); RETURN END IF + IF (line_has_viv(lines(1), types, sections)) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: VIV (LINE TYPES Cl > 0) runs in the standalone '// & + 'deck driver; set Cl = 0 for this entry'); RETURN + END IF IF (opts%has_bathymetry_file) THEN CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & points=points) @@ -6711,11 +6737,12 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 'EI=0/finite-EI decks reject deck water kinematics)') RETURN END IF - ! Cross-flow VIV runs in the standalone EI = 0 driver: the aggregate route (OpenFAST, FAST.Farm, - ! mixed EI = 0 / finite-EI decks) neither checkpoints its shedding phase nor feeds it the host's - ! fluid field yet. + ! Cross-flow VIV runs in the standalone driver (EI = 0 decks and finite-EI decks): the aggregate + ! route (OpenFAST, FAST.Farm, mixed EI = 0 / finite-EI decks) neither checkpoints its shedding + ! phase nor feeds it the host's fluid field yet. IF (ANY(types%cl > CD_ZERO)) THEN - CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) runs in the standalone driver of an EI = 0 deck; '// & + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) runs in the standalone driver of an EI = 0 or '// & + 'finite-EI deck; '// & 'the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / finite-EI decks do not carry it '// & 'yet. Set Cl = 0 for this run') RETURN @@ -8054,16 +8081,26 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) ! 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 + 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) + 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.) + hermite_models(li), j, ErrStat, ErrMsg, standalone_controls=.TRUE., & + install_viv=.TRUE.) END IF IF (ErrStat /= CD_DECKDRV_OK) EXIT END DO @@ -9289,6 +9326,45 @@ SUBROUTINE finite_hydro_arrays(ln, sections, types, diam, cdn, cdt, can, cat) cat = cat(SIZE(cat):1:-1) END SUBROUTINE finite_hydro_arrays + SUBROUTINE finite_viv_arrays(ln, sections, types, cl, cf, df) + !! Expand the section VIV columns (Cl dF cF) to finite-EI element arrays, in the element + !! order of finite_hydro_arrays. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckLineType), INTENT(IN) :: types(:) + REAL(wp), INTENT(OUT) :: cl(:), cf(:), df(:) + INTEGER :: i, j, e, tidx + + e = 0 + DO i = 1, SIZE(sections) + IF (sections(i)%line_id /= ln%id) CYCLE + tidx = sections(i)%ltype + DO j = 1, sections(i)%nsegs + e = e + 1 + cl(e) = types(tidx)%cl + cf(e) = types(tidx)%viv_cf + df(e) = types(tidx)%viv_df + END DO + END DO + cl = cl(SIZE(cl):1:-1) + cf = cf(SIZE(cf):1:-1) + df = df(SIZE(df):1:-1) + END SUBROUTINE finite_viv_arrays + + LOGICAL FUNCTION line_has_viv(ln, types, sections) RESULT(has) + !! Whether a section of the line uses a line type with a VIV lift coefficient Cl > 0. + TYPE(DeckLine), INTENT(IN) :: ln + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + INTEGER :: j + has = .FALSE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= ln%id) CYCLE + IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE + IF (types(sections(j)%ltype)%cl > CD_ZERO) has = .TRUE. + END DO + END FUNCTION line_has_viv + SUBROUTINE CD_Stiffener_Overlay(stf, l0, diam, ei, mpl) !! Add the bend stiffeners of a finite-EI line (ln%stf columns) to its element properties, !! in public element order (End A first). A stiffener is a polyurethane sleeve bonded to the @@ -12653,7 +12729,7 @@ END SUBROUTINE append_type SUBROUTINE check_viv_columns(t, ErrStat, ErrMsg) !! The VIV columns of a LINE TYPES row: a finite, non-negative Cl; with Cl > 0 a positive - !! shedding frequency band (cF > 0, 0 <= dF < cF) on an EI = 0, non-Syrope line type. + !! shedding frequency band (cF > 0, 0 <= dF < cF) on a non-Syrope line type. TYPE(DeckLineType), INTENT(IN) :: t INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -12668,10 +12744,6 @@ SUBROUTINE check_viv_columns(t, ErrStat, ErrMsg) IF (.NOT. (t%viv_cf > CD_ZERO .AND. t%viv_df >= CD_ZERO .AND. t%viv_df < t%viv_cf)) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES VIV synchronisation band needs cF > 0 and 0 <= dF < cF'); RETURN END IF - IF (t%ei > CD_ZERO) THEN - CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) is implemented for EI = 0 '// & - 'line types only; set EI = 0 or Cl = 0 (VIV of finite-EI cables is not available)'); RETURN - END IF IF (t%is_syrope) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) does not combine with the '// & 'Syrope working-curve model'); RETURN @@ -19542,6 +19614,11 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod pc = points pa = find_point(points, cab_lines(c)%nodeA) IF (TRIM(pc(pa)%ptype) /= 'fixed') pc(pa)%ptype = 'coupled' + IF (line_has_viv(cab_lines(c), types, sections)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) of a finite-EI line does not run with bodies, rods '// & + 'or free points yet; set Cl = 0 for the finite-EI lines of this deck') + GOTO 900 + END IF mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_active(cab_lines(c))) & .AND. TRIM(points(pa)%ptype) /= 'fixed' IF (mb%cab_clamp(c)) THEN diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 60bcb3ad..1d6682df 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -63,6 +63,8 @@ MODULE CableDyn_HermiteCableDynamic CD_HermiteCable_Axial_Strain_Lower_Bound, CD_HermiteCable_Dry_Buoyancy, & CD_HCABLE_OK USE CableDyn_Linalg, ONLY: CD_Factor_Banded, CD_Solve_Factored_Banded, CD_LINALG_OK + USE CableDyn_VIV, ONLY: CD_VIV_Lift_Per_Length, CD_VIV_Crossflow_Along, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM USE CableDyn_Hydro, ONLY: CD_Morison_Drag_Per_Length_Jac, CD_Airy_Wave_Kinematics_Precomputed, & CD_Component_Wave_Kinematics, CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Contact_Gate, CD_SEABED_CONTACT_BLEND, & @@ -121,6 +123,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Snapshot PUBLIC :: CD_HermiteCable_Dyn_Set_Friction_Anchors PUBLIC :: CD_HermiteCable_Dyn_Set_Friction_Axial + PUBLIC :: CD_HermiteCable_Dyn_Set_VIV PUBLIC :: CD_HermiteCable_Dyn_Restore PUBLIC :: CD_HermiteCable_Dyn_Energy PUBLIC :: CD_HermiteCable_Dyn_Curvature @@ -269,6 +272,18 @@ MODULE CableDyn_HermiteCableDynamic ! the recovering step, snap_fr_anchor the aggregate snapshot. LOGICAL :: fr_active = .FALSE. REAL(wp), ALLOCATABLE :: fr_anchor(:, :), fr_k(:), ws_recovery_fr(:, :), snap_fr_anchor(:, :) + ! Cross-flow VIV (CD_HermiteCable_Dyn_Set_VIV, CableDyn_VIV): viv_k(e) = 1/2 rho D Cl of each + ! element (0: no lift), the synchronisation band and diameter per node, the shedding phase + ! and the running mean squares of the cross-flow velocity and acceleration per node. The lift + ! of a step takes viv_phi_eval (the committed phase for F_n, the step's predicted phase in + ! the Newton iterations); viv_rate/viv_ms_next hold the step-start rate and mean squares. + ! ws_recovery_viv_* is the step-start copy of the recovering step, snap_viv_* the snapshot. + LOGICAL :: has_viv = .FALSE. + REAL(wp) :: viv_tw = CD_ZERO + REAL(wp), ALLOCATABLE :: viv_cl(:), viv_k(:), viv_cf(:), viv_df(:), viv_dn(:), viv_phi(:), viv_phi_eval(:) + REAL(wp), ALLOCATABLE :: viv_rate(:), viv_ms(:, :), viv_ms_next(:, :) + REAL(wp), ALLOCATABLE :: ws_recovery_viv_phi(:), ws_recovery_viv_ms(:, :), snap_viv_phi(:), snap_viv_ms(:, :) + LOGICAL, ALLOCATABLE :: viv_node(:) REAL(wp), ALLOCATABLE :: Mgb(:, :) ! constant global mass (band) LOGICAL, ALLOCATABLE :: freemask(:), solve_mask(:) INTEGER, ALLOCATABLE :: fmap(:) ! free -> global DOF index @@ -950,6 +965,299 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM model%tr_valid = .FALSE. END SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial + SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg) + !! Install the cross-flow VIV synchronisation model (CableDyn_VIV) on a cable with drag: + !! per element the lift coefficient cl (0: no lift) and the band df/cf, and the running-RMS + !! averaging time t_window (s; 0 takes 500 steps of the first step). The lift acts on the + !! wetted Gauss points of every element with cl > 0, its phase lives on the nodes of those + !! elements; the phases start at 2 pi i/N with node i counted from End A (the model's last + !! node), as MoorDyn's. The phase follows the drag's current and a held host field (which + !! carries any waves); the internal wave families (Set_Waves) are refused with VIV. The + !! committed acceleration is refreshed with the new lift; if that fails, the previous VIV + !! configuration, its state and the acceleration are restored. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: e, k, ne, nn, es + REAL(wp) :: wsum, tw_old + LOGICAL :: had_viv + CHARACTER(LEN=1024) :: em + REAL(wp), ALLOCATABLE :: a_old(:), o_cl(:), o_k(:), o_cf(:), o_df(:), o_dn(:), o_phi(:), o_phi_eval(:), & + o_rate(:), o_ms(:, :), o_ms_next(:, :), o_rec_phi(:), o_rec_ms(:, :), & + o_snap_phi(:), o_snap_ms(:, :) + LOGICAL, ALLOCATABLE :: o_node(:) + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: model not initialised'; RETURN + END IF + ne = model%ne + nn = model%nn + IF (SIZE(cl) /= ne .OR. SIZE(cf) /= ne .OR. SIZE(df) /= ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: cl, cf and df must each have one value per element'; RETURN + END IF + IF (.NOT. (CD_All_Finite(cl) .AND. CD_All_Finite(cf) .AND. CD_All_Finite(df) .AND. & + CD_Is_Finite(t_window))) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: inputs must be finite'; RETURN + END IF + IF (ANY(cl < CD_ZERO) .OR. t_window < CD_ZERO .OR. & + ANY(cl > CD_ZERO .AND. .NOT. (cf > CD_ZERO .AND. df >= CD_ZERO .AND. df < cf))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: need cl >= 0, t_window >= 0 and 0 <= df < cf where cl > 0' + RETURN + END IF + IF (.NOT. model%has_drag) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: VIV needs the cable''s drag in water (set the drag first)'; RETURN + END IF + IF (model%has_wave) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: internal waves are configured; VIV takes waves as a held '// & + 'host fluid field (CD_HermiteCable_Dyn_Set_Held_Fluid)'; RETURN + END IF + ! the previous configuration and state, kept for a rollback + had_viv = model%has_viv + tw_old = model%viv_tw + a_old = model%a + CALL move_viv(.FALSE.) + CALL clear_viv(model) + model%rc_epoch = model%rc_epoch + 1 + model%fc_valid = .FALSE. + model%fc_clears = model%fc_clears + 1 + model%tr_valid = .FALSE. + IF (.NOT. ANY(cl > CD_ZERO)) THEN + IF (had_viv) CALL refresh_acceleration() + RETURN + END IF + ALLOCATE (model%viv_cl(ne), model%viv_k(ne), model%viv_cf(nn), model%viv_df(nn), model%viv_dn(nn), & + model%viv_phi(nn), & + model%viv_phi_eval(nn), model%viv_rate(nn), model%viv_ms(2, nn), model%viv_ms_next(2, nn), & + model%ws_recovery_viv_phi(nn), model%ws_recovery_viv_ms(2, nn), model%snap_viv_phi(nn), & + model%snap_viv_ms(2, nn), model%viv_node(nn)) + model%viv_cl = cl + model%viv_cf = CD_ZERO + model%viv_df = CD_ZERO + model%viv_node = .FALSE. + model%viv_phi = CD_ZERO + model%viv_ms = CD_ZERO + ! node values: the length-weighted average over the node's lifting elements + DO k = 1, nn + wsum = CD_ZERO + DO e = MAX(1, k - 1), MIN(ne, k) + IF (.NOT. (cl(e) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(e) + model%viv_cf(k) = model%viv_cf(k) + model%l0(e)*cf(e) + model%viv_df(k) = model%viv_df(k) + model%l0(e)*df(e) + END DO + IF (.NOT. (wsum > CD_ZERO)) CYCLE + model%viv_node(k) = .TRUE. + model%viv_cf(k) = model%viv_cf(k)/wsum + model%viv_df(k) = model%viv_df(k)/wsum + model%viv_phi(k) = CD_VIV_TWO_PI*REAL(nn - k, wp)/REAL(ne, wp) + END DO + CALL viv_drag_terms(model) + model%viv_phi_eval = model%viv_phi + model%viv_rate = CD_ZERO + model%viv_ms_next = model%viv_ms + model%ws_recovery_viv_phi = model%viv_phi + model%ws_recovery_viv_ms = model%viv_ms + model%snap_viv_phi = model%viv_phi + model%snap_viv_ms = model%viv_ms + model%viv_tw = t_window + model%has_viv = .TRUE. + ! the lift is part of the committed load: the first step's predictor and phase rate need it + CALL refresh_acceleration() + + CONTAINS + SUBROUTINE refresh_acceleration() + CALL solve_consistent_acceleration(model, es, em) + IF (es == CD_HCDYN_OK) RETURN + CALL clear_viv(model) + CALL move_viv(.TRUE.) + model%has_viv = had_viv + model%viv_tw = tw_old + model%a = a_old + ErrStat = es + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: acceleration refresh failed: '//TRIM(em) + END SUBROUTINE refresh_acceleration + + SUBROUTINE move_viv(back) + !! Move the VIV arrays from the model into the o_ copies (back = .FALSE.) or back. + LOGICAL, INTENT(IN) :: back + IF (back) THEN + CALL MOVE_ALLOC(o_cl, model%viv_cl); CALL MOVE_ALLOC(o_k, model%viv_k) + CALL MOVE_ALLOC(o_cf, model%viv_cf); CALL MOVE_ALLOC(o_df, model%viv_df) + CALL MOVE_ALLOC(o_dn, model%viv_dn); CALL MOVE_ALLOC(o_phi, model%viv_phi) + CALL MOVE_ALLOC(o_phi_eval, model%viv_phi_eval); CALL MOVE_ALLOC(o_rate, model%viv_rate) + CALL MOVE_ALLOC(o_ms, model%viv_ms); CALL MOVE_ALLOC(o_ms_next, model%viv_ms_next) + CALL MOVE_ALLOC(o_rec_phi, model%ws_recovery_viv_phi); CALL MOVE_ALLOC(o_rec_ms, model%ws_recovery_viv_ms) + CALL MOVE_ALLOC(o_snap_phi, model%snap_viv_phi); CALL MOVE_ALLOC(o_snap_ms, model%snap_viv_ms) + CALL MOVE_ALLOC(o_node, model%viv_node) + ELSE + CALL MOVE_ALLOC(model%viv_cl, o_cl); CALL MOVE_ALLOC(model%viv_k, o_k) + CALL MOVE_ALLOC(model%viv_cf, o_cf); CALL MOVE_ALLOC(model%viv_df, o_df) + CALL MOVE_ALLOC(model%viv_dn, o_dn); CALL MOVE_ALLOC(model%viv_phi, o_phi) + CALL MOVE_ALLOC(model%viv_phi_eval, o_phi_eval); CALL MOVE_ALLOC(model%viv_rate, o_rate) + CALL MOVE_ALLOC(model%viv_ms, o_ms); CALL MOVE_ALLOC(model%viv_ms_next, o_ms_next) + CALL MOVE_ALLOC(model%ws_recovery_viv_phi, o_rec_phi); CALL MOVE_ALLOC(model%ws_recovery_viv_ms, o_rec_ms) + CALL MOVE_ALLOC(model%snap_viv_phi, o_snap_phi); CALL MOVE_ALLOC(model%snap_viv_ms, o_snap_ms) + CALL MOVE_ALLOC(model%viv_node, o_node) + END IF + END SUBROUTINE move_viv + END SUBROUTINE CD_HermiteCable_Dyn_Set_VIV + + SUBROUTINE clear_viv(model) + !! Release the VIV storage; the model then carries no lift. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + IF (ALLOCATED(model%viv_k)) DEALLOCATE (model%viv_cl, model%viv_k) + IF (ALLOCATED(model%viv_cf)) DEALLOCATE (model%viv_cf, model%viv_df, model%viv_dn, model%viv_phi, & + model%viv_phi_eval, model%viv_rate, model%viv_ms, & + model%viv_ms_next, model%ws_recovery_viv_phi, & + model%ws_recovery_viv_ms, model%snap_viv_phi, model%snap_viv_ms, & + model%viv_node) + model%has_viv = .FALSE. + model%viv_tw = CD_ZERO + END SUBROUTINE clear_viv + + SUBROUTINE viv_drag_terms(model) + !! The VIV quantities taken from the drag configuration, set with VIV and again whenever the + !! drag is reconfigured: the lift scale viv_k = 1/2 rho D Cl of each element and the node + !! diameter viv_dn, the length-weighted average over the node's lifting elements. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER :: e, k + REAL(wp) :: wsum + model%viv_k = 0.5_wp*model%rho_w*model%diam*model%viv_cl + model%viv_dn = CD_ZERO + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + wsum = CD_ZERO + DO e = MAX(1, k - 1), MIN(model%ne, k) + IF (.NOT. (model%viv_cl(e) > CD_ZERO)) CYCLE + wsum = wsum + model%l0(e) + model%viv_dn(k) = model%viv_dn(k) + model%l0(e)*model%diam(e) + END DO + model%viv_dn(k) = model%viv_dn(k)/wsum + END DO + END SUBROUTINE viv_drag_terms + + SUBROUTINE viv_node_motion(model, k, yd, ydd, un, ok) + !! Cross-flow velocity and acceleration of node k at the committed state, along its own + !! tangent (the slope DOFs), in the flow the drag sees there (current plus a held field). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: yd, ydd, un + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: uu(3) + INTEGER :: i0 + i0 = 6*(k - 1) + uu = model%current + IF (model%has_held_field) uu = uu + model%hf_u(:, k) + CALL CD_VIV_Crossflow_Along(model%q(i0 + 4:i0 + 6), model%v(i0 + 1:i0 + 3), model%a(i0 + 1:i0 + 3), uu, & + yd, ydd, un, ok) + END SUBROUTINE viv_node_motion + + SUBROUTINE viv_step_begin(model, dt, ErrStat, ErrMsg) + !! Step-start VIV quantities from the committed state (q, v, a, phi): the mean squares with + !! the step-start cross-flow sample (viv_ms_next), the phase rate (viv_rate) and the phase the + !! step's lift takes (viv_phi_eval): the explicit phase at t_{n+1} under the force blend, + !! whose in-step force is R(q_{n+1}, v_{n+1}) (F_n keeps phi_n), and at the generalised-alpha + !! level under the configuration blend. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: k + REAL(wp) :: w, frac, yd, ydd, un + LOGICAL :: ok + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. (model%viv_tw > CD_ZERO)) model%viv_tw = REAL(CD_VIV_NM, wp)*dt + w = MIN(CD_ONE, dt/model%viv_tw) + frac = CD_ONE + IF (.NOT. model%force_blend) frac = CD_ONE - model%alpha_f + model%viv_rate = CD_ZERO + model%viv_ms_next = model%viv_ms + model%viv_phi_eval = model%viv_phi + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + CALL viv_node_motion(model, k, yd, ydd, un, ok) + IF (.NOT. ok) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'VIV phase: degenerate node tangent'; RETURN + END IF + model%viv_ms_next(1, k) = CD_VIV_Mean_Square(model%viv_ms(1, k), yd, w) + model%viv_ms_next(2, k) = CD_VIV_Mean_Square(model%viv_ms(2, k), ydd, w) + model%viv_rate(k) = CD_VIV_Phase_Rate(yd, ydd, model%viv_ms_next(1, k), model%viv_ms_next(2, k), & + model%viv_phi(k), un, model%viv_dn(k), model%viv_cf(k), & + model%viv_df(k)) + model%viv_phi_eval(k) = model%viv_phi(k) + frac*dt*model%viv_rate(k) + END DO + END SUBROUTINE viv_step_begin + + SUBROUTINE viv_step_end(model, dt) + !! Commit the VIV state at the converged end state (q, v, a just committed): the phase by + !! Heun's rule phi_n + dt/2 (rate_n + rate(state_n+1, phi_n + dt rate_n)), with the end-state + !! sample added to the mean squares for that rate only, and the step-start mean squares. The + !! lift then takes the committed phase again. It cannot fail, so the step it ends is never + !! left half committed: a node whose end tangent is degenerate, or whose end rate is not + !! finite, takes the step-start rate over the step (phi_n + dt rate_n). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + INTEGER :: k + REAL(wp) :: w, yd, ydd, un, ms1, ms2, rate_end + LOGICAL :: ok + w = MIN(CD_ONE, dt/model%viv_tw) + DO k = 1, model%nn + IF (.NOT. model%viv_node(k)) CYCLE + rate_end = model%viv_rate(k) + CALL viv_node_motion(model, k, yd, ydd, un, ok) + IF (ok) THEN + ms1 = CD_VIV_Mean_Square(model%viv_ms_next(1, k), yd, w) + ms2 = CD_VIV_Mean_Square(model%viv_ms_next(2, k), ydd, w) + rate_end = CD_VIV_Phase_Rate(yd, ydd, ms1, ms2, model%viv_phi(k) + dt*model%viv_rate(k), un, & + model%viv_dn(k), model%viv_cf(k), model%viv_df(k)) + IF (.NOT. CD_Is_Finite(rate_end)) rate_end = model%viv_rate(k) + END IF + model%viv_phi(k) = CD_VIV_Wrap_Phase(model%viv_phi(k) + 0.5_wp*dt*(model%viv_rate(k) + rate_end)) + END DO + model%viv_ms = model%viv_ms_next + model%viv_phi_eval = model%viv_phi + END SUBROUTINE viv_step_end + + SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, djv) + !! The VIV lift load of element e at the phase viv_phi_eval in the flow the drag sees (current, + !! held field), with its Jacobians djq, djv (both or neither). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(OUT) :: flift(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: djq(12, 12), djv(12, 12) + REAL(wp) :: qe(12), ve(12), uu(3), wl, kn(2) + flift = CD_ZERO + IF (PRESENT(djq)) THEN + djq = CD_ZERO; djv = CD_ZERO + END IF + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. (model%viv_k(e) > CD_ZERO)) RETURN + qe(1:6) = q_cfg(6*(e - 1) + 1:6*e); qe(7:12) = q_cfg(6*e + 1:6*(e + 1)) + ve(1:6) = v_cfg(6*(e - 1) + 1:6*e); ve(7:12) = v_cfg(6*e + 1:6*(e + 1)) + uu = model%current + wl = model%waterline_z + IF (model%has_held_field) THEN + uu = uu + 0.5_wp*(model%hf_u(:, e) + model%hf_u(:, e + 1)) + wl = 0.5_wp*(model%hf_wl(e) + model%hf_wl(e + 1)) + END IF + kn = model%viv_k(e)*[COS(model%viv_phi_eval(e)), COS(model%viv_phi_eval(e + 1))] + IF (PRESENT(djq)) THEN + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, djq, djv, ErrStat, ErrMsg) + ELSE + CALL CD_HermiteCable_VIV_Lift_Element(qe, ve, model%l0(e), uu, wl, kn, flift, ErrStat=ErrStat, & + ErrMsg=ErrMsg) + END IF + END SUBROUTINE viv_element_lift + SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Anchors(model, anchors, ErrStat, ErrMsg) !! Switch the seabed friction of a contact model with mu > 0 to elastic-plastic friction !! springs anchored at anchors(1:2, node) (x, y in the solve frame). The spring stiffness @@ -2380,6 +2688,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Drag(model, rho_w, diam, cdn, cdt, waterline_ model%rho_w = rho_w; model%waterline_z = waterline_z; model%current = current model%gravity = grav_new model%has_drag = .TRUE. + ! the lift scale and the shedding diameter follow the drag's density and diameters + IF (model%has_viv) CALL viv_drag_terms(model) ! Refresh the consistent acceleration now that the load set includes drag: at v = 0 a current ! exerts a non-zero rest drag, so the predictor for the first step must see it. @@ -2395,6 +2705,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Drag(model, rho_w, diam, cdn, cdt, waterline_ DEALLOCATE (model%diam, model%cdn, model%cdt) END IF model%has_drag = had_drag + ! VIV needs drag, so a VIV model had it: back to the restored configuration + IF (model%has_viv) CALL viv_drag_terms(model) END IF END SUBROUTINE CD_HermiteCable_Dyn_Set_Drag @@ -2593,6 +2905,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Waves(model, height, period, direction_deg, d IF (.NOT. model%initialized) THEN ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Set_Waves: model not initialised'; RETURN END IF + IF (model%has_viv) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Waves: VIV is configured; its phase follows the current and a held host '// & + 'fluid field, so waves reach a VIV cable as a held field'; RETURN + END IF IF (model%has_held_field) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Waves: a held host fluid field is configured; an internal '// & @@ -2715,6 +3032,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Irregular_Waves(model, amplitude, period, pha ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Irregular_Waves: model not initialised'; RETURN END IF + IF (model%has_viv) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Irregular_Waves: VIV is configured; its phase follows the current and a held host '// & + 'fluid field, so waves reach a VIV cable as a held field'; RETURN + END IF IF (model%has_held_field) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_Irregular_Waves: a held host fluid field is configured; '// & @@ -3038,6 +3360,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Step(model, dt, max_iter, tol, ErrStat, ErrMsg, i pres_a, residual_history, history_count, endconn_direction, endconn_direction_rate, & endconn_direction_acceleration, tensile_failed) model%tors_use_step = .FALSE. + ! every evaluation outside a step takes the committed VIV phase + IF (model%has_viv) model%viv_phi_eval = model%viv_phi END SUBROUTINE CD_HermiteCable_Dyn_Step SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion_Drive(model, ends, phi, ErrStat, ErrMsg) @@ -3392,6 +3716,13 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%fc_d0 = model%endconn_d0 model%fc_valid = .TRUE. END IF + ! VIV: F_n above took the committed phase; the step's evaluations take its predicted phase. + IF (model%has_viv) THEN + CALL viv_step_begin(model, dt, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2); RETURN + END IF + END IF ! Condensed torsion: F_n above used the committed end frames and Phi; every evaluation of the ! step from here on uses the step's target (set by CD_HermiteCable_Dyn_Step). model%tors_use_step = model%torsion%active @@ -4000,6 +4331,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r END IF IF (has_endconn_motion) CALL impose_step_rigid_kinematics(model%q, model%v, model%a) IF (model%fr_active) CALL commit_friction_anchors(model) + IF (model%has_viv) CALL viv_step_end(model, dt) model%t = model%t + dt IF (has_endconn_motion) model%endconn_d0 = step_endconn_target IF (model%torsion%active) THEN @@ -4031,8 +4363,11 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r END IF model%tr_dt = dt ! The converged iterate's unblended force is F at the committed state: cache it, keyed - ! on that state, as the next step's F_n. - IF (model%force_blend) THEN + ! on that state, as the next step's F_n. With VIV it took the step's predicted phase, not + ! the committed one, so the next step evaluates F_n afresh. + IF (model%has_viv) THEN + model%fc_valid = .FALSE. + ELSE IF (model%force_blend) THEN DO iv = 1, SIZE(model%fc_R) model%fc_R(iv) = model%ws_Rk(iv) END DO @@ -4573,6 +4908,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%ws_recovery_v0 = model%v model%ws_recovery_a0 = model%a IF (model%fr_active) model%ws_recovery_fr = model%fr_anchor + IF (model%has_viv) THEN + model%ws_recovery_viv_phi = model%viv_phi + model%ws_recovery_viv_ms = model%viv_ms + END IF IF (model%has_ctrl) THEN model%ws_recovery_l0_c = model%l0_c model%ws_recovery_l0_dot_c = model%l0_dot_c @@ -4664,6 +5003,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_viv) THEN + model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms + model%viv_phi_eval = model%viv_phi + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save @@ -4740,6 +5083,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_viv) THEN + model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms + model%viv_phi_eval = model%viv_phi + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save @@ -4784,6 +5131,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat model%q = q_save; model%v = v_save; model%a = a_save; model%t = t_save model%endconn_d0 = d0_save IF (model%fr_active) model%fr_anchor = model%ws_recovery_fr + IF (model%has_viv) THEN + model%viv_phi = model%ws_recovery_viv_phi; model%viv_ms = model%ws_recovery_viv_ms + model%viv_phi_eval = model%viv_phi + END IF IF (model%has_ctrl) model%l0_c = model%ws_recovery_l0_c IF (model%has_ctrl) model%l0_dot_c = model%ws_recovery_l0_dot_c model%na_steps_done = na_steps_save; model%na_iter_sum = na_sum_save; model%na_mn_active = na_mn_save @@ -5427,6 +5778,13 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) END IF r3 = r3 - fdrag(i0 + 1:i0 + 3) END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, model%q, model%v, e, fdrag, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN + END IF + r3 = r3 - fdrag(i0 + 1:i0 + 3) + END IF IF (model%has_attach) THEN ! A clump or buoy on the end node loads the point holding it, exactly as it loads the ! end node in the residual (assemble_attachments). @@ -5908,6 +6266,11 @@ SUBROUTINE element_end_residual(model, e, g, ErrStat, ErrMsg) IF (es /= CD_HCDYN_OK) GOTO 900 g = g - fx END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, model%q, model%v, e, fx, es, em2) + IF (es /= CD_HCDYN_OK) GOTO 900 + g = g - fx + END IF IF (model%has_am .AND. (model%has_wave .OR. model%has_held_field)) THEN IF (model%has_held_field) THEN hf_mid = 0.5_wp*(model%hf_ud(:, e) + model%hf_ud(:, e + 1)) @@ -6485,6 +6848,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) model%snap_torsion_phi = model%torsion%phi model%snap_torsion_ends = model%torsion%ends IF (model%fr_active) model%snap_fr_anchor = model%fr_anchor + IF (model%has_viv) THEN + model%snap_viv_phi = model%viv_phi + model%snap_viv_ms = model%viv_ms + END IF ! the cached committed force goes with the state it describes (see fc_clears) model%snap_fc_valid = model%fc_valid .AND. ALLOCATED(model%fc_R) model%snap_fc_clears = model%fc_clears @@ -6562,6 +6929,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) model%tors_drive_set = .FALSE. model%tors_use_step = .FALSE. IF (model%fr_active) model%fr_anchor = model%snap_fr_anchor + IF (model%has_viv) THEN + model%viv_phi = model%snap_viv_phi; model%viv_ms = model%snap_viv_ms + model%viv_phi_eval = model%viv_phi + END IF model%na_steps_done = model%snap_na_steps_done model%na_iter_sum = model%snap_na_iter_sum model%na_mn_active = model%snap_na_mn_active @@ -6622,6 +6993,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) IF (ALLOCATED(model%fr_anchor)) DEALLOCATE (model%fr_anchor, model%fr_k, model%ws_recovery_fr, & model%snap_fr_anchor) model%fr_active = .FALSE. + CALL clear_viv(model) CALL CD_End_Bathymetry(model%contact_bathymetry) model%has_contact = .FALSE.; model%has_contact_bathymetry = .FALSE. IF (ALLOCATED(model%Mgb)) DEALLOCATE (model%Mgb) @@ -7106,6 +7478,29 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta END IF END DO END IF + ! Cross-flow VIV lift (an external load like the drag, at the step's phase viv_phi_eval). + IF (model%has_viv .AND. .NOT. tangent_only) THEN + DO e = e_lo, e_hi + IF (want_tangent) THEN + CALL viv_element_lift(model, q_cfg, v_cfg, e, fdrag, es, em_e, djq, djv) + ELSE + CALL viv_element_lift(model, q_cfg, v_cfg, e, fdrag, es, em_e) + END IF + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = TRIM(em_e); RETURN + END IF + IF (want_residual) THEN + DO a = 1, 12 + gi = elem_gdof(e, a) + R(gi) = R(gi) - fdrag(a) + END DO + END IF + IF (want_tangent) THEN + CALL scatter12_band(Kb, -djq, e) + CALL scatter12_band(Kvb, -djv, e) + END IF + END DO + END IF CALL asm_mark(HC_ASM_DRAG, asm_t) ! ---- rotational line-end connections ---- @@ -7704,6 +8099,15 @@ SUBROUTINE evaluate_tangent_element(model, e, q_cfg, v_cfg, t_eval, Kstruct, Kdr Kvel = Kvel - djv END IF + IF (model%has_viv) THEN + CALL viv_element_lift(model, q_cfg, v_cfg, e, fload, es, em, djq, djv) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = TRIM(em); RETURN + END IF + Kdrag = Kdrag - djq + Kvel = Kvel - djv + END IF + IF (model%has_wave .AND. model%has_am) THEN IF (model%wv_ncomp > 0) THEN CALL CD_HermiteCable_FK_Element(qe, model%l0(e), model%am_wl, model%am_rho, model%am_diam(e), & @@ -8133,6 +8537,79 @@ SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, dia END IF END SUBROUTINE CD_HermiteCable_Drag_Element + SUBROUTINE CD_HermiteCable_VIV_Lift_Element(qe, ve, l0, fluid, waterline_z, k_node, flift, djq, djv, & + ErrStat, ErrMsg) + !! Consistent Gauss-integrated cross-flow VIV lift on one cubic-Hermite element: the load + !! integral N^T f ds of the per-length lift f = k(xi) U (t x v_r) (CD_VIV_Lift_Per_Length), + !! with k = 1/2 rho D Cl cos(phi) interpolated linearly between the element's end nodes + !! (k_node), and its force Jacobians djq = d flift/d qe, djv = d flift/d ve (both or neither). + !! The interpolation, measure and wet/dry culling are the drag element's (still waterline). + REAL(wp), INTENT(IN) :: qe(12), ve(12), l0, fluid(3), waterline_z, k_node(2) + REAL(wp), INTENT(OUT) :: flift(12) + REAL(wp), INTENT(OUT), OPTIONAL :: djq(12, 12), djv(12, 12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, PARAMETER :: NGP = 3 + REAL(wp), PARAMETER :: G3 = 0.7745966692414834_wp ! sqrt(3/5) + REAL(wp) :: gp(NGP), gw(NGP), H(4), dH(4), rpos(3), vvel(3), rp(3), speed, tangent(3), fpl(3) + REAL(wp) :: jrel(3, 3), jtan(3, 3), scale, kg + LOGICAL :: want_jac, ok + INTEGER :: g, s, c, sp, cp, a, b + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + want_jac = PRESENT(djq) + flift = CD_ZERO + IF (want_jac) THEN + djq = CD_ZERO; djv = CD_ZERO + END IF + gp = [0.5_wp*(CD_ONE - G3), 0.5_wp, 0.5_wp*(CD_ONE + G3)] + gw = [5.0_wp/18.0_wp, 8.0_wp/18.0_wp, 5.0_wp/18.0_wp] + DO g = 1, NGP + CALL CD_HermiteCable_Shapes(gp(g), l0, H, dH) + DO c = 1, 3 + rpos(c) = H(1)*qe(c) + H(2)*qe(3 + c) + H(3)*qe(6 + c) + H(4)*qe(9 + c) + vvel(c) = H(1)*ve(c) + H(2)*ve(3 + c) + H(3)*ve(6 + c) + H(4)*ve(9 + c) + rp(c) = dH(1)*qe(c) + dH(2)*qe(3 + c) + dH(3)*qe(6 + c) + dH(4)*qe(9 + c) + END DO + IF (rpos(3) > waterline_z) CYCLE ! dry Gauss point: no lift + kg = (CD_ONE - gp(g))*k_node(1) + gp(g)*k_node(2) + IF (want_jac) THEN + CALL CD_VIV_Lift_Per_Length(fluid - vvel, rp, kg, fpl, ok, jrel, jtan) + ELSE + CALL CD_VIV_Lift_Per_Length(fluid - vvel, rp, kg, fpl, ok) + END IF + IF (.NOT. ok) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'CD_HermiteCable_VIV_Lift_Element: degenerate centreline (|dr/dxi| ~ 0)'; RETURN + END IF + speed = SQRT(rp(1)**2 + rp(2)**2 + rp(3)**2) + tangent = rp/speed + scale = gw(g)*speed + DO s = 1, 4 + DO c = 1, 3 + a = 3*(s - 1) + c + flift(a) = flift(a) + scale*H(s)*fpl(c) + END DO + END DO + IF (.NOT. want_jac) CYCLE + DO s = 1, 4 + DO c = 1, 3 + a = 3*(s - 1) + c + DO sp = 1, 4 + DO cp = 1, 3 + b = 3*(sp - 1) + cp + djv(a, b) = djv(a, b) - scale*H(s)*H(sp)*jrel(c, cp) + djq(a, b) = djq(a, b) + gw(g)*H(s)*dH(sp)*(speed*jtan(c, cp) + fpl(c)*tangent(cp)) + END DO + END DO + END DO + END DO + END DO + IF (.NOT. CD_All_Finite(flift)) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_VIV_Lift_Element: non-finite lift load' + END IF + END SUBROUTINE CD_HermiteCable_VIV_Lift_Element + SUBROUTINE CD_HermiteCable_AddedMass_Element(qe, l0, waterline_z, rho, diam, can, cat, Ma, ErrStat, ErrMsg) !! Consistent Gauss-integrated Morison ADDED MASS on one cubic-Hermite bending-cable element: !! Ma = integral N^T m_a(t) N ds, m_a(t) = rho A (Can (I - t t^T) + Cat t t^T), diff --git a/src/CableDyn_VIV.f90 b/src/CableDyn_VIV.f90 index fd6554b0..27d742cc 100644 --- a/src/CableDyn_VIV.f90 +++ b/src/CableDyn_VIV.f90 @@ -40,7 +40,9 @@ MODULE CableDyn_VIV PRIVATE PUBLIC :: CD_VIV_Node_Lift + PUBLIC :: CD_VIV_Lift_Per_Length PUBLIC :: CD_VIV_Crossflow_Motion + PUBLIC :: CD_VIV_Crossflow_Along PUBLIC :: CD_VIV_Phase_Rate PUBLIC :: CD_VIV_Mean_Square PUBLIC :: CD_VIV_Wrap_Phase @@ -172,6 +174,93 @@ PURE SUBROUTINE CD_VIV_Crossflow_Motion(r_prev, r_next, rd, rdd, u, yd, ydd, un, ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) END SUBROUTINE CD_VIV_Crossflow_Motion + PURE SUBROUTINE CD_VIV_Lift_Per_Length(urel, rp, k, f, ok, jrel, jtan) + !! Lift per unit length of a cable centreline point (the finite-EI cable's Gauss points), + !! f = k U (t x v_r), with k = 1/2 rho D Cl cos(phi), the unit tangent t = rp/|rp| of the raw + !! centreline derivative rp = dr/dxi, the relative flow v_r = urel and its normal speed U. + !! Optionally (both or neither) its Jacobians jrel = df/dv_r and jtan = df/drp, for chaining + !! through the shape functions as the drag primitive is. ok = .FALSE. (and f = 0) for a + !! degenerate centreline; f and its derivatives vanish with the normal flow. + REAL(wp), INTENT(IN) :: urel(3), rp(3), k + REAL(wp), INTENT(OUT) :: f(3) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: jrel(3, 3), jtan(3, 3) + REAL(wp) :: speed, t(3), alpha, vn(3), un, w(3), dfdt(3, 3), proj(3, 3) + INTEGER :: i, j + + f = CD_ZERO + IF (PRESENT(jrel)) THEN + jrel = CD_ZERO + jtan = CD_ZERO + END IF + speed = SQRT(rp(1)*rp(1) + rp(2)*rp(2) + rp(3)*rp(3)) + ok = speed > TINY_CHORD + IF (.NOT. ok) RETURN + t = rp/speed + alpha = t(1)*urel(1) + t(2)*urel(2) + t(3)*urel(3) + vn = urel - alpha*t + un = SQRT(vn(1)*vn(1) + vn(2)*vn(2) + vn(3)*vn(3)) + w = cross3(t, urel) ! = t x v_n + f = (k*un)*w + IF (.NOT. PRESENT(jrel)) RETURN + IF (.NOT. (un > CD_ZERO)) RETURN + ! df/dv_r = k [w (x) v_n/U + U [t]x] + DO j = 1, 3 + DO i = 1, 3 + jrel(i, j) = k*w(i)*vn(j)/un + END DO + END DO + jrel(1, 2) = jrel(1, 2) - k*un*t(3) + jrel(1, 3) = jrel(1, 3) + k*un*t(2) + jrel(2, 1) = jrel(2, 1) + k*un*t(3) + jrel(2, 3) = jrel(2, 3) - k*un*t(1) + jrel(3, 1) = jrel(3, 1) - k*un*t(2) + jrel(3, 2) = jrel(3, 2) + k*un*t(1) + ! df/dt = k [-(alpha/U) w (x) v_r - U [v_r]x], chained through dt/drp = (I - t t^T)/|rp| + DO j = 1, 3 + DO i = 1, 3 + dfdt(i, j) = -k*(alpha/un)*w(i)*urel(j) + END DO + END DO + dfdt(1, 2) = dfdt(1, 2) + k*un*urel(3) + dfdt(1, 3) = dfdt(1, 3) - k*un*urel(2) + dfdt(2, 1) = dfdt(2, 1) - k*un*urel(3) + dfdt(2, 3) = dfdt(2, 3) + k*un*urel(1) + dfdt(3, 1) = dfdt(3, 1) + k*un*urel(2) + dfdt(3, 2) = dfdt(3, 2) - k*un*urel(1) + DO j = 1, 3 + DO i = 1, 3 + proj(i, j) = -t(i)*t(j)/speed + END DO + proj(j, j) = proj(j, j) + CD_ONE/speed + END DO + jtan = MATMUL(dfdt, proj) + END SUBROUTINE CD_VIV_Lift_Per_Length + + PURE SUBROUTINE CD_VIV_Crossflow_Along(tdir, rd, rdd, u, yd, ydd, un, ok) + !! CD_VIV_Crossflow_Motion with the line tangent given directly (tdir, any length: the + !! slope DOFs of a finite-EI node) instead of the chord of two neighbours. + REAL(wp), INTENT(IN) :: tdir(3), rd(3), rdd(3), u(3) + REAL(wp), INTENT(OUT) :: yd, ydd, un + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: speed, t(3), vr(3), vn(3), e(3) + + yd = CD_ZERO + ydd = CD_ZERO + un = CD_ZERO + speed = SQRT(tdir(1)*tdir(1) + tdir(2)*tdir(2) + tdir(3)*tdir(3)) + ok = speed > TINY_CHORD + IF (.NOT. ok) RETURN + t = tdir/speed + vr = u - rd + vn = vr - (t(1)*vr(1) + t(2)*vr(2) + t(3)*vr(3))*t + un = SQRT(vn(1)*vn(1) + vn(2)*vn(2) + vn(3)*vn(3)) + IF (.NOT. (un > CD_ZERO)) RETURN + e = cross3(t, vn)/un + yd = rd(1)*e(1) + rd(2)*e(2) + rd(3)*e(3) + ydd = rdd(1)*e(1) + rdd(2)*e(2) + rdd(3)*e(3) + END SUBROUTINE CD_VIV_Crossflow_Along + ELEMENTAL REAL(wp) FUNCTION CD_VIV_Mean_Square(ms_old, sample, weight) RESULT(ms) !! One step of the running mean square, ms_old + weight (sample^2 - ms_old); weight = !! 1/n_m is MoorDyn's ((n_m - 1) old^2 + new^2)/n_m. diff --git a/tests/test_hermite_viv.f90 b/tests/test_hermite_viv.f90 new file mode 100644 index 00000000..a1c75880 --- /dev/null +++ b/tests/test_hermite_viv.f90 @@ -0,0 +1,210 @@ +! File: tests/test_hermite_viv.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_viv + !! Cross-flow VIV on the cubic-Hermite cable (CD_HermiteCable_Dyn_Set_VIV): the setter's + !! refusals, the state the step carries, and the lock-in itself. + !! + !! A 100 m taut, nearly neutrally buoyant line (20 elements, D 0.1 m, EA 5e7 N, EI 1 N m^2, + !! about 50 kN), pinned at both ends in a 0.15 m/s cross current with Cl 0.8 and MoorDyn's band + !! (dF 0.08, cF 0.18): the shedding frequency cF U/D = 0.27 Hz sits on the first mode, so the + !! line locks in (the deck benchmark of tests/test_viv_lockin.py, coarser here). + !! + !! Gates: + !! * the setter refuses a model without drag, mismatched sizes, a band with dF >= cF, a negative + !! averaging time, and an internal wave family afterwards; all-zero Cl installs nothing; + !! installing the lift in the cross current changes the committed acceleration and removing + !! it brings the no-lift acceleration back; a drag reconfigured afterwards carries the lift + !! scale and the shedding diameter with it; + !! * at 60 s the mid-span cross-flow amplitude is above 0.3 D with the lift and below 0.01 D + !! without it; + !! * a snapshot taken mid-run and restored replays the following steps bit for bit (state and + !! phase), and the recovering step equals the plain step when no step fails. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & + CD_HermiteCable_Dyn_Set_VIV, CD_HermiteCable_Dyn_Set_Waves, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & + CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & + CD_HermiteCable_Dyn_End, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp + REAL(wp), PARAMETER :: RHOW = 1025.0_wp, GACC = 9.80665_wp + REAL(wp), PARAMETER :: D = 0.1_wp, MLIN = 8.10_wp, EA = 5.0e7_wp, EI = 1.0_wp, TENS = 5.0e4_wp + REAL(wp), PARAMETER :: SPAN = 100.0_wp, U = 0.15_wp, DT = 0.02_wp + INTEGER, PARAMETER :: NE = 20 + + TYPE(CD_HermiteCableDynType) :: model + REAL(wp), ALLOCATABLE :: cl(:), cf(:), df(:), q_ref(:, :), phi_ref(:, :), a_none(:) + REAL(wp) :: amp_lift, amp_none + INTEGER :: es, nfail, k, mid + CHARACTER(1024) :: em + + nfail = 0 + mid = 6*(NE/2) + 3 ! r_z of the mid-span node + ALLOCATE (cl(NE), cf(NE), df(NE)) + cl = 0.8_wp; cf = 0.18_wp; df = 0.08_wp + + ! ---- refusals ---- + CALL build(model, .FALSE.) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'VIV without drag is refused') + CALL CD_HermiteCable_Dyn_End(model) + CALL build(model, .TRUE.) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl(1:NE - 1), cf(1:NE - 1), df(1:NE - 1), 0.25_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'mismatched VIV arrays are refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, cf, 0.25_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'a band with dF >= cF is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, -1.0_wp, es, em) + CALL require(es /= CD_HCDYN_OK, 'a negative averaging time is refused') + CALL CD_HermiteCable_Dyn_Set_VIV(model, 0.0_wp*cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%has_viv, 'all-zero Cl installs no VIV') + a_none = model%a + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. model%has_viv, 'VIV installs: '//TRIM(em)) + ! at rest in the cross current the lift (about 0.9 N/m) moves the committed acceleration + CALL require(MAXVAL(ABS(model%a - a_none)) > 1.0e-3_wp, 'installing the lift refreshes the acceleration') + CALL CD_HermiteCable_Dyn_Set_VIV(model, 0.0_wp*cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. model%has_viv .AND. & + MAXVAL(ABS(model%a - a_none)) <= 1.0e-12_wp*MAXVAL(ABS(a_none)), & + 'removing the lift brings the no-lift acceleration back') + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL require(es == CD_HCDYN_OK .AND. model%has_viv, 'VIV installs again: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_Waves(model, 1.0_wp, 8.0_wp, 0.0_wp, 100.0_wp, GACC, es, em) + CALL require(es /= CD_HCDYN_OK, 'an internal wave family is refused on a VIV cable') + CALL require(ABS(model%viv_phi(NE + 1)) < TINY(1.0_wp) .AND. & + ABS(model%viv_phi(1) - 2.0_wp*PI) < 1.0e-12_wp, 'the phases start at 2 pi i/N from End A') + ! a drag reconfigured after VIV carries the lift scale and shedding diameter with it + BLOCK + REAL(wp) :: k0(NE), dn0(NE + 1), hd(NE), hn(NE), ht(NE) + k0 = model%viv_k + dn0 = model%viv_dn + hd = 2.0_wp*D; hn = 1.2_wp; ht = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Drag(model, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. ALL(ABS(model%viv_k - 2.0_wp*k0) <= 1.0e-12_wp*k0) .AND. & + ALL(ABS(model%viv_dn - 2.0_wp*dn0) <= 1.0e-12_wp*dn0), & + 'a drag reconfiguration updates the VIV lift scale and shedding diameter') + hd = D + CALL CD_HermiteCable_Dyn_Set_Drag(model, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. ALL(model%viv_k == k0) .AND. ALL(model%viv_dn == dn0), & + 'the original drag restores them exactly') + END BLOCK + + ! ---- lock-in, and the same line without lift ---- + amp_lift = run_amplitude(model) + CALL CD_HermiteCable_Dyn_End(model) + CALL build(model, .TRUE.) + amp_none = run_amplitude(model) + CALL CD_HermiteCable_Dyn_End(model) + WRITE (*, '(A,F7.4,A,F8.5)') ' mid-span cross-flow amplitude / D: with lift ', amp_lift/D, ', without ', & + amp_none/D + CALL require(amp_lift > 0.3_wp*D, 'the line locks in with the lift') + CALL require(amp_none < 0.01_wp*D, 'the line stays still without it') + + ! ---- snapshot replay and the recovering step ---- + CALL build(model, .TRUE.) + CALL CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, 0.25_wp, es, em) + CALL advance(model, 500, .FALSE.) + CALL CD_HermiteCable_Dyn_Snapshot(model, es, em) + CALL require(es == CD_HCDYN_OK, 'snapshot: '//TRIM(em)) + ALLOCATE (q_ref(SIZE(model%q), 100), phi_ref(NE + 1, 100)) + DO k = 1, 100 + CALL advance(model, 1, .FALSE.) + q_ref(:, k) = model%q + phi_ref(:, k) = model%viv_phi + END DO + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + CALL require(es == CD_HCDYN_OK, 'restore: '//TRIM(em)) + DO k = 1, 100 + CALL advance(model, 1, .FALSE.) + IF (ANY(model%q /= q_ref(:, k)) .OR. ANY(model%viv_phi /= phi_ref(:, k))) EXIT + END DO + CALL require(k > 100, 'the restored snapshot replays the state and phase bit for bit') + ! the recovering step from the same snapshot follows the plain step exactly + CALL CD_HermiteCable_Dyn_Restore(model, es, em) + DO k = 1, 100 + CALL advance(model, 1, .TRUE.) + IF (ANY(model%q /= q_ref(:, k)) .OR. ANY(model%viv_phi /= phi_ref(:, k))) EXIT + END DO + CALL require(k > 100, 'the recovering step equals the plain step') + CALL CD_HermiteCable_Dyn_End(model) + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: cross-flow VIV on the cubic-Hermite cable' + +CONTAINS + + SUBROUTINE build(m, with_drag) + !! The pinned taut line along x, pretensioned through its unstretched length, with the cross + !! current along y (drag) and the normal added mass. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + LOGICAL, INTENT(IN) :: with_drag + REAL(wp) :: seed(6*(NE + 1)), l0(NE), eav(NE), eiv(NE), wv(NE), rhoa(NE), hd(NE), hn(NE), ht(NE) + INTEGER :: fixed(6), i + seed = 0.0_wp + DO i = 1, NE + 1 + seed(6*(i - 1) + 1) = SPAN*REAL(i - 1, wp)/REAL(NE, wp) + seed(6*(i - 1) + 3) = -50.0_wp + seed(6*(i - 1) + 4) = 1.0_wp + END DO + l0 = SPAN/REAL(NE, wp)/(1.0_wp + TENS/EA) + eav = EA; eiv = EI; rhoa = MLIN + wv = (MLIN - RHOW*0.25_wp*PI*D**2)*GACC + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + CALL CD_HermiteCable_Dyn_Init(m, l0, eav, eiv, rhoa, wv, seed, fixed, -200.0_wp, 0.0_wp, 0.5_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'init: '//TRIM(em)) + IF (.NOT. with_drag) RETURN + hd = D; hn = 1.2_wp; ht = 0.0_wp + CALL CD_HermiteCable_Dyn_Set_Drag(m, RHOW, hd, hn, ht, 0.0_wp, [0.0_wp, U, 0.0_wp], es, em) + CALL require(es == CD_HCDYN_OK, 'drag: '//TRIM(em)) + hn = 1.0_wp + CALL CD_HermiteCable_Dyn_Set_AddedMass(m, RHOW, hd, hn, ht, 0.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'added mass: '//TRIM(em)) + END SUBROUTINE build + + SUBROUTINE advance(m, n, recovering) + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: n + LOGICAL, INTENT(IN) :: recovering + INTEGER :: s + DO s = 1, n + IF (recovering) THEN + CALL CD_HermiteCable_Dyn_Step_Recovering(m, DT, 50, 1.0e-8_wp, es, em) + ELSE + CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-8_wp, es, em) + END IF + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'step: '//TRIM(em)); RETURN + END IF + END DO + END SUBROUTINE advance + + REAL(wp) FUNCTION run_amplitude(m) RESULT(amp) + !! Half the peak-to-peak mid-span cross-flow (z) excursion over 40-60 s. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp) :: zmin, zmax + INTEGER :: s + zmin = HUGE(1.0_wp); zmax = -HUGE(1.0_wp) + DO s = 1, NINT(60.0_wp/DT) + CALL advance(m, 1, .FALSE.) + IF (es /= CD_HCDYN_OK) EXIT + IF (REAL(s, wp)*DT < 40.0_wp) CYCLE + zmin = MIN(zmin, m%q(mid)); zmax = MAX(zmax, m%q(mid)) + END DO + amp = 0.5_wp*(zmax - zmin) + END FUNCTION run_amplitude + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + WRITE (*, '(A,A)') 'MISMATCH: ', label + nfail = nfail + 1 + END IF + END SUBROUTINE require + +END PROGRAM test_hermite_viv diff --git a/tests/test_viv_kernels.f90 b/tests/test_viv_kernels.f90 index afe04541..e6ddad46 100644 --- a/tests/test_viv_kernels.f90 +++ b/tests/test_viv_kernels.f90 @@ -14,12 +14,12 @@ PROGRAM test_viv_kernels !! 6) the phase wraps to [0, 2 pi), and a node whose neighbours coincide fails closed. USE CableDyn_Precision, ONLY: wp USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & - CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM + CD_VIV_Wrap_Phase, CD_VIV_TWO_PI, CD_VIV_NM, CD_VIV_Lift_Per_Length IMPLICIT NONE REAL(wp), PARAMETER :: RHO = 1025.0_wp, DIAM = 0.1_wp, CL = 0.8_wp, L1 = 2.0_wp, L2 = 1.5_wp REAL(wp) :: rp(3), rn(3), rd(3), u(3), coef, phi, f(3), q(3), vr(3), vn(3), un, w(3), ref(3) REAL(wp) :: jv(3, 3), jp(3, 3), jn(3, 3), fd(3, 3), fp(3), fm(3), h, e(3), yd, ydd, un2, rate - REAL(wp) :: ms, ms_md + REAL(wp) :: ms, ms_md, rpv(3), kk, fl(3), jr(3, 3), jt(3, 3) LOGICAL :: ok INTEGER :: nfail, j, k @@ -95,6 +95,30 @@ PROGRAM test_viv_kernels ms_md = ms END DO + ! (7) per-length lift at a centreline point (the finite-EI Gauss points): the node formula with + ! the exact tangent, scaled to unit length, independent of |dr/dxi|; Jacobians vs differences + rpv = 2.5_wp*(rn - rp) + kk = 0.5_wp*RHO*DIAM*CL*COS(phi) + CALL CD_VIV_Lift_Per_Length(u - rd, rpv, kk, fl, ok, jr, jt) + CALL CD_VIV_Node_Lift(rp, rn, rd, u, 1.0_wp, phi, f, ok) + CALL require(ok .AND. NORM2(fl - 0.5_wp*RHO*DIAM*CL*f) <= 1.0e-12_wp*NORM2(fl), & + 'per-length lift = 1/2 rho D Cl cos(phi) U (t x v_n)') + DO j = 1, 3 + CALL CD_VIV_Lift_Per_Length(u - rd + h*unit(j), rpv, kk, fp, ok) + CALL CD_VIV_Lift_Per_Length(u - rd - h*unit(j), rpv, kk, fm, ok) + fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jr - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), 'per-length lift: flow Jacobian matches differences') + DO j = 1, 3 + CALL CD_VIV_Lift_Per_Length(u - rd, rpv + h*unit(j), kk, fp, ok) + CALL CD_VIV_Lift_Per_Length(u - rd, rpv - h*unit(j), kk, fm, ok) + fd(:, j) = (fp - fm)/(2.0_wp*h) + END DO + CALL require(MAXVAL(ABS(jt - fd)) <= 1.0e-6_wp*MAXVAL(ABS(fd)), & + 'per-length lift: tangent Jacobian matches differences') + CALL CD_VIV_Lift_Per_Length(u - rd, 3.0_wp*rpv, kk, fp, ok) + CALL require(NORM2(fp - fl) <= 1.0e-12_wp*NORM2(fl), 'per-length lift does not depend on |dr/dxi|') + ! (6) wrap and degenerate frame CALL require(CD_VIV_Wrap_Phase(-1.0e-300_wp) >= 0.0_wp .AND. CD_VIV_Wrap_Phase(-1.0e-300_wp) < CD_VIV_TWO_PI, & 'a tiny negative phase wraps into [0, 2 pi)') diff --git a/tests/test_viv_lockin.py b/tests/test_viv_lockin.py index 82500fae..1e664907 100644 --- a/tests/test_viv_lockin.py +++ b/tests/test_viv_lockin.py @@ -13,7 +13,17 @@ one spectral bin (1/60 Hz) of it, with the quarter-span amplitude of the first mode; * at dtM 0.002 s, a step that resolves the mesh zig-zag mode, the line stays locked in with the same amplitude (within 2 %): with the nodes' own kinematics in the synchronisation model the - zig-zag mode was pumped there and the line lost lock-in after about 70 s. + zig-zag mode was pumped there and the line lost lock-in after about 70 s; +* the same line as a finite-EI cable (EI 1 N m^2, a string to within 1e-6 of its geometric + stiffness: the cubic-Hermite route with the Gauss-integrated lift) locks in with the EI = 0 + line's mid-span and quarter-span amplitudes (within 1 %) and frequency, at dtM 0.01 s and at + 0.002 s (no smoothing needed on the Hermite route); +* a bending-stiff, neutrally buoyant cable (8.1 kg/m, EA 5e9 N, EI 5e7 N m^2, about 51 kN: + beta = pi^2 EI/(T L^2) ~ 1) against the EI = 0 string tensioned to T (1 + beta), which has + the same first-mode frequency and shape: at U 0.21 m/s both lock into mode 1 with the same + mid-span A/D (within 3 %) and frequency; at U 0.30 m/s the string jumps to mode 2 (mid-span + A/D below 0.15) while the cable, whose bending raises f2/f1 to about 3.15, stays in mode 1 + (mid-span A/D above 0.6). usage: test_viv_lockin.py --exe --output """ @@ -22,9 +32,11 @@ import argparse import math +import os import shutil import subprocess import sys +from concurrent.futures import ThreadPoolExecutor from pathlib import Path import numpy as np @@ -60,20 +72,21 @@ def check(ok: bool, message: str) -> None: 1 CurrentMod - type of current input z-depth x-current y-current (m) (m/s) (m/s) -0.0 0.0 0.15 --100.0 0.0 0.15 +0.0 0.0 {u} +-100.0 0.0 {u} --------------------- need this line ------------------ """ -def deck(dtm: float) -> str: - length = 100.0 / (1.0 + 5.0e4 / 5.0e7) +def deck(dtm: float, ei: float = 0.0, ea: float = 5.0e7, mass: float = 10.0, tension: float = 5.0e4, + waterkin: str = "current.dat") -> str: + length = 100.0 / (1.0 + tension / ea) return f"""--------------------- CableDyn Input File --------------------------------- VIV lock-in gate: taut line in a uniform cross current ----------------------- LINE TYPES ------------------------------------------ TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF (name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-) -riser 0.10 10.0 5.0e7 -0.8 0.0 1.2 1.0 0.0 0.0 0.8 0.08 0.18 +riser 0.10 {mass} {ea} -0.8 {ei} 1.2 1.0 0.0 0.0 0.8 0.08 0.18 ----------------------- POINTS ---------------------------------------------- ID Attachment X Y Z M V CdA CA (#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) @@ -88,7 +101,7 @@ def deck(dtm: float) -> str: 100.0 WtrDpth 1025.0 rhoW 9.80665 g -current.dat WaterKin +{waterkin} WaterKin 0.25 VIVrmsWindow 120.0 TMax ---------------------- OUTPUTS ----------------------------------------------- @@ -126,17 +139,39 @@ def main() -> int: if out.exists(): shutil.rmtree(out) out.mkdir(parents=True) - (out / "current.dat").write_text(CURRENT, encoding="utf-8", newline="\n") + for u in (0.15, 0.21, 0.30): + (out / f"current_{u}.dat").write_text(CURRENT.format(u=u), encoding="utf-8", newline="\n") + # the stiff cable and its equal-frequency string (neutrally buoyant: no sag stiffening) + beta = math.pi**2 * 5.0e7 / (5.0e4 * 100.0**2) + stiff = {"ei": 5.0e7, "ea": 5.0e9, "mass": 8.1} + string = {"ea": 5.0e7, "mass": 8.1, "tension": 5.0e4 * (1.0 + beta)} + runs = [ + (0.01, "viv_dt0.01", deck(0.01, waterkin="current_0.15.dat")), + (0.002, "viv_dt0.002", deck(0.002, waterkin="current_0.15.dat")), + ("fei", "viv_fei", deck(0.01, ei=1.0, waterkin="current_0.15.dat")), + ("fei_fine", "viv_fei_dt0.002", deck(0.002, ei=1.0, waterkin="current_0.15.dat")), + ] + for u in (0.21, 0.30): + runs.append((("stiff", u), f"viv_stiff_u{u}", deck(0.01, waterkin=f"current_{u}.dat", **stiff))) + runs.append((("string", u), f"viv_string_u{u}", deck(0.01, waterkin=f"current_{u}.dat", **string))) + for _, name, text in runs: + (out / f"{name}.dat").write_text(text, encoding="utf-8", newline="\n") + env = dict(os.environ, OMP_NUM_THREADS="1") + + def run(name: str) -> subprocess.CompletedProcess[str]: + cmd = [args.exe, f"{name}.dat", name] + return subprocess.run(cmd, cwd=out, capture_output=True, text=True, env=env) + + # the decks are independent: run them side by side (a checked Debug build is ~10x slower) + with ThreadPoolExecutor(max_workers=max(1, min(4, os.cpu_count() or 1))) as pool: + procs = list(pool.map(run, [name for _, name, _ in runs])) results = {} - for dtm in (0.01, 0.002): - name = f"viv_dt{dtm}" - (out / f"{name}.dat").write_text(deck(dtm), encoding="utf-8", newline="\n") - proc = subprocess.run([args.exe, f"{name}.dat", name], cwd=out, capture_output=True, text=True) + for (key, name, _), proc in zip(runs, procs): if proc.returncode != 0: print(proc.stdout[-2000:], proc.stderr[-2000:]) - check(False, f"dtM {dtm}: the run completes (exit {proc.returncode})") + check(False, f"{name}: the run completes (exit {proc.returncode})") continue - results[dtm] = response(out / f"{name}.out") + results[key] = response(out / f"{name}.out") if 0.01 in results: ad, f, qtr = results[0.01] check(abs(ad - MD_AD) <= 0.03 * MD_AD, @@ -150,6 +185,27 @@ def main() -> int: a1, a2 = results[0.01][0], results[0.002][0] check(abs(a2 - a1) <= 0.02 * a1, f"dtM 0.002 s stays locked in: mid-span A/D {a2:.3f} against {a1:.3f} at 0.01 s (within 2 %)") + if 0.01 in results and "fei" in results: + (a0, f0, q0), (a1, f1, q1) = results[0.01], results["fei"] + check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0, + f"finite-EI cable: mid/quarter A/D {a1:.3f}/{q1:.3f}, EI = 0 line {a0:.3f}/{q0:.3f} (within 1 %)") + check(abs(f1 - f0) <= 1.0 / 60.0, + f"finite-EI cable: response frequency {f1:.3f} Hz, EI = 0 line {f0:.3f} Hz (within 1/60 Hz)") + if 0.01 in results and "fei_fine" in results: + (a0, f0, q0), (a1, f1, q1) = results[0.01], results["fei_fine"] + check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0 and abs(f1 - f0) <= 1.0 / 60.0, + f"finite-EI cable at dtM 0.002 s: mid/quarter A/D {a1:.3f}/{q1:.3f} at {f1:.3f} Hz, EI = 0 " + f"line at 0.01 s {a0:.3f}/{q0:.3f} at {f0:.3f} Hz (within 1 % and one bin)") + if ("stiff", 0.21) in results and ("string", 0.21) in results: + (a1, f1, _), (a0, f0, _) = results[("stiff", 0.21)], results[("string", 0.21)] + check(abs(a1 - a0) <= 0.03 * a0 and abs(f1 - f0) <= 1.0 / 60.0, + f"U 0.21 m/s: stiff cable A/D {a1:.3f} at {f1:.3f} Hz, equal-frequency string {a0:.3f} " + f"at {f0:.3f} Hz (mode 1, within 3 % and one bin)") + if ("stiff", 0.30) in results and ("string", 0.30) in results: + a1, a0 = results[("stiff", 0.30)][0], results[("string", 0.30)][0] + check(a1 > 0.6 and a0 < 0.15, + f"U 0.30 m/s: stiff cable stays in mode 1 (mid-span A/D {a1:.3f}), the string jumps to " + f"mode 2 (mid-span A/D {a0:.3f})") print(f"{len(FAILURES)} failure(s)") return 1 if FAILURES else 0 From 3f54f1c97841d472e3e9164f0bb308b5e97e4e4c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 27 Oct 2026 16:24:09 +0900 Subject: [PATCH 08/51] fix(outputs): note that line nodes are numbered from 1, MoorDyn's from 0 (#57) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CableDyn numbers a line's nodes from 1 at End A. MoorDyn-C and MoorDyn-F number them from 0 at End A. CableDyn also runs a line written anchor-first from its fairlead. So a MoorDyn deck's `LN` channels name a different node in CableDyn, with no warning. Example: on a 100 m line with 50 segments, written in CableDyn's order, `L1N12PZ` reads the node at 22 m in CableDyn and the node at 24 m in MoorDyn. Confirmed from the t = 0 sag shape, against both MoorDyn codes. The numbering itself is unchanged; existing CableDyn decks and outputs are not affected. Changes: - **Notice:** a run prints one note when its OUTPUTS name a line node, or when a LINES `Outputs` flag writes the per-line node files. The note gives the correspondence: `N` here is MoorDyn's `N`, or `N` on a line written anchor-first. - Channels covered: `LN…`, `Ten`, `Curv`, `BendMom`, `StfMom`, `Torq`, `TwistN`. - Printed by the standalone driver and by OpenFAST (`WrScr`, for the deck OUTPUTS of the `.CD.out` file). - Rod nodes already use MoorDyn's numbering (0 = End A) and are left alone. - **Docs:** - `outputs.rst` states the numbering and both correspondences; - the `migrating.rst` "Node identity" row replaces "MoorDyn node numbers are not reproduced"; - `options.rst` links the `N0` rejection to it; - CHANGELOG entry. - **Test:** `ei0_slack_dynamics` checks that a run with a LINES `p` flag prints the note and a run without node outputs does not. Checks: - ctest 305/305 and pytest against the built driver (2092 passed); - fprettify clean; docs build with `-W`; - OpenFAST built with this branch's CableDyn module, so `CableDyn_OF.f90` compiles. No OpenFAST run was made: no shipped OpenFAST example asks for line-node channels, and the OpenFAST side calls the same check the standalone test covers. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 +++++ doc/migrating.rst | 9 +++++++-- doc/options.rst | 3 ++- doc/outputs.rst | 9 +++++++++ src/CableDyn_DeckDriver.f90 | 22 ++++++++++++++++++++++ src/openfast/CableDyn_OF.f90 | 11 ++++++++++- tests/test_ei0_slack_dynamics.f90 | 8 ++++++++ 7 files changed, 63 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02657bfa..4ed0bbc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,11 @@ All notable changes to CableDyn are recorded in this file. The format follows - Under a bend stiffener, `BendMomN` (and the `BendMoment` columns of the static profile, range graphs and element file) report the cable's own moment, the line type's EI times the curvature; lines without stiffeners are unchanged. +- A run whose outputs name line nodes (`LN…`, `TenN` and the other node channels, or a + LINES `Outputs` flag) notes that CableDyn numbers line nodes from 1 at End A while MoorDyn + numbers them from 0, so a MoorDyn deck's `N` is CableDyn's `N`, or `N` on + a line written anchor-first. The numbering itself is unchanged; the outputs and migration pages + state it. ### Fixed diff --git a/doc/migrating.rst b/doc/migrating.rst index 66cf82f4..ba7cf3f1 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -154,8 +154,13 @@ What differs on purpose * - Unsupported input - rejected at parse time with a message naming the feature, never silently ignored * - Node identity - - CableDyn meshes are its own; MoorDyn node numbers and rod-node histories are not - reproduced + - line nodes are numbered from 1 at End A, MoorDyn's from 0 at its End A, so a MoorDyn + deck's ``LN`` names another node here: MoorDyn's ``N`` is CableDyn's ``N`` + on a line kept in the order written, and ``N`` on a line written + anchor-first, which CableDyn runs from its fairlead (see above and + :ref:`node numbering `). A run reporting line nodes notes + the difference. Rod nodes keep MoorDyn's numbering (node 0 = End A); rod-node histories + are not reproduced Inside OpenFAST ~~~~~~~~~~~~~~~ diff --git a/doc/options.rst b/doc/options.rst index 936b05ac..7acce5e1 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -791,7 +791,8 @@ These names exist so a migrated MoorDyn deck fails less often at the syntax boun Other MoorDyn constructs that fail by name rather than as unknown input: ``CoupledPinned`` bodies, and ``CoupledPinned``/``VesselPinned`` rods outside a coupled host (they run in OpenFAST, see -:doc:`openfast`). Line-node output channels start at node 1 (``N0`` is rejected), and a number +:doc:`openfast`). Line-node output channels start at node 1 (``N0`` is rejected; MoorDyn numbers from 0, see +:ref:`node numbering `), and a number with a sign inside its mantissa (such as ``1+2``) is rejected instead of being read up to the sign. Water-kinematics sources diff --git a/doc/outputs.rst b/doc/outputs.rst index 3eac9688..c8cd7872 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -477,6 +477,15 @@ numeric id written with leading zeros (``Ten1N02`` = ``Ten1N2``), or an alias sp ``LINES`` and ``POINTS`` ids (not array positions); ```` is a node number on line ````, 1 = End A to ``N`` = End B, where ``N`` = 1 + the total ``NumSegs`` of the line's sections. +.. _outputs-moordyn-node-numbers: + +This is **not MoorDyn's numbering**. MoorDyn numbers a line's nodes from 0 at its End A +(``AttachA``) to ``NumSegs``, so on a line kept in the order written ``LN`` here is MoorDyn's +``LN``. A line written anchor-first (``AttachA`` a ``Fixed`` anchor, ``AttachB`` the +fairlead) runs from its fairlead here (:doc:`migrating`), so its ``N`` is MoorDyn's +``N``. The per-line files (``Node…`` columns) number the same way. A run whose +outputs name line nodes says so in a note, and ``N0`` is rejected rather than read as another node. + .. _outputs-refined-nodes: Node channels on a refined line diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 49aaf8e7..b539047b 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -245,6 +245,15 @@ MODULE CableDyn_DeckDriver REAL(wp), SAVE :: probe_v0(3) = 0.0_wp, probe_w0(3) = 0.0_wp REAL(wp), ALLOCATABLE, SAVE :: probe_rec(:, :) INTEGER, PARAMETER, PUBLIC :: CD_DECKDRV_OK = 0, CD_DECKDRV_BADINPUT = 1, CD_DECKDRV_SOLVEFAIL = 2 + ! Printed by a run that reports line nodes (an OUTPUTS channel CD_Is_Line_Node_Channel names, or + ! a LINES Outputs flag): CableDyn numbers a line's nodes from 1 = End A, MoorDyn from 0 = its End + ! A, and CableDyn runs a line written anchor-first from its fairlead (normalize_stock_endpoint_order), + ! so a MoorDyn deck's line-node channels would otherwise name other nodes without notice. + CHARACTER(*), PARAMETER, PUBLIC :: CD_LINE_NODE_NUMBERING_NOTE = 'line nodes are numbered from 1 = End '// & + 'A in the channels and line files, MoorDyn''s from 0: N here is '// & + 'MoorDyn''s N, or N on a line written anchor-first, '// & + 'which CableDyn runs from its fairlead (End A)' + PUBLIC :: CD_Is_Line_Node_Channel ! Deck token / OUTPUTS channel-name length. Public so the aggregate facade can declare its ! retained channel-name store with a matching length. @@ -7924,6 +7933,9 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, failures=fails) IF (ErrStat /= 0) RETURN + IF (ANY([(CD_Is_Line_Node_Channel(channels(j)), j=1, SIZE(channels))]) .OR. & + ANY([(line_outputs_requested(lines(j)%outputs), j=1, SIZE(lines))])) & + WRITE (output_unit, '(A)') ' Note: '//CD_LINE_NODE_NUMBERING_NOTE//'.' ! Torsion (both ends of a line torsionally restrained) runs on the standalone cubic-Hermite ! route and the multibody march, in statics and dynamics (quasi-static torsion: no torsional ! inertia). One restrained end carries no torque (the other end is free to twist), so it is @@ -32378,6 +32390,16 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r END IF END SUBROUTINE check_channel + LOGICAL FUNCTION CD_Is_Line_Node_Channel(ch) RESULT(yes) + !! True for an OUTPUTS channel that names a node of a line (TenN, Curv, BendMom, StfMom, + !! Torq, TwistN, LN...), whose node numbering differs from MoorDyn's + !! (CD_LINE_NODE_NUMBERING_NOTE); the line total Twist names no node. + CHARACTER(*), INTENT(IN) :: ch + INTEGER :: line_id, node_id, kind, comp + CALL parse_line_node_channel(ch, line_id, node_id, kind, comp) + yes = kind /= 0 .AND. kind /= 11 + END FUNCTION CD_Is_Line_Node_Channel + PURE LOGICAL FUNCTION names_node_zero(lo) RESULT(yes) !! True when a lower-cased line-node channel names node 0 ("...n0" at the end or before !! a letter), the MoorDyn End A numbering. diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 2e13f9c0..9fc90ee1 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -72,7 +72,8 @@ MODULE CableDyn USE CableDyn_Precision, ONLY: wp USE CableDyn_Conventions, ONLY: CD_NATIVE_CHANNEL_FMT USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_SeaState_Steady_Current, CD_HYDRO_OK - USE CableDyn_DeckDriver, ONLY: CD_Deck_Query_dtM, CD_DECKDRV_OK + USE CableDyn_DeckDriver, ONLY: CD_Deck_Query_dtM, CD_DECKDRV_OK, CD_Is_Line_Node_Channel, & + CD_LINE_NODE_NUMBERING_NOTE USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_UpdateStates_Moving, & CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_GetMovingPointMesh, & CD_AGG_Snapshot, CD_AGG_Restore, & @@ -306,6 +307,14 @@ SUBROUTINE open_native_outputs( id, root, t_start, ErrStat, ErrMsg, write_profil nch = CD_AGG_NumChannels(Inst(id)%agg) IF (nch <= 0) RETURN + ! MoorDyn numbers line nodes from N0, CableDyn from N1: say so as the standalone driver does + DO ic = 1, nch + CALL CD_AGG_ChannelHeader(Inst(id)%agg, ic, hdr, unt, es, em) + IF (es /= CD_AGG_OK) EXIT + IF (.NOT. CD_Is_Line_Node_Channel(hdr)) CYCLE + CALL WrScr( ' Note: '//CD_LINE_NODE_NUMBERING_NOTE//'.' ) + EXIT + END DO ! One run-level path has one owner. A rebuilt state must adopt the existing ! unit through restore_native_outputs rather than attempting a second OPEN. DO owner = 1, SIZE(Inst) diff --git a/tests/test_ei0_slack_dynamics.f90 b/tests/test_ei0_slack_dynamics.f90 index 5cefc951..e7157fe3 100644 --- a/tests/test_ei0_slack_dynamics.f90 +++ b/tests/test_ei0_slack_dynamics.f90 @@ -816,6 +816,14 @@ SUBROUTINE case_run_audit() CALL require(ok, 'audit:rhoinf-run') CALL require(file_contains('ei0slack_audit_rho.log', 'Note: rhoInf = 0.990 leaves almost no numerical'), & 'audit:rhoinf-note') + ! line nodes are numbered from 1 = End A, MoorDyn's from 0: noted when a run reports line nodes + CALL require(.NOT. file_contains('ei0slack_audit_rho.log', 'line nodes are numbered from 1'), & + 'audit:no-node-numbering-note') + CALL light_cable_deck('ei0slack_audit_node.dat', 0.1_wp, 1.0_wp, '', 'p') + CALL run_driver_logged('ei0slack_audit_node.dat', 'ei0slack_audit_node', 'ei0slack_audit_node.log', ok) + CALL require(ok, 'audit:node-run') + CALL require(file_contains('ei0slack_audit_node.log', 'Note: line nodes are numbered from 1 = End A'), & + 'audit:node-numbering-note') ! a 10 m sway at dtM 0.2 s turns the segments by several degrees per step: taken as given ! (off ei0_substeps) the run notes the turn CALL write_motion('ei0slack_sway.txt', 1, [5.0_wp, 0.0_wp, -14.0_wp], 2, 10.0_wp, 10.0_wp, 10.0_wp, & From d7bfaae1ebef4855df1b9c74b46af50016eeb468 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 27 Oct 2026 17:44:14 +0900 Subject: [PATCH 09/51] docs: describe CableDyn as geometrically exact, not geometrically nonlinear (#58) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The run banner said "Geometrically nonlinear cable & mooring dynamics for floating wind". That undersells the formulation. Both line elements use the exact large-deformation axial strain (ε = |r′| − 1) and curvature (κ = |r′ × r″| / |r′|³), never linearised. This PR changes every place that describes CableDyn so it matches the repository description: "geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables (for floating offshore wind)". Changes: - **Run banner** (`CableDyn_Banner.f90`), lines 3–4. Width is unchanged and each line is at most 68 characters. The copies in `installation.rst` and `quickstart.rst` are updated. - **OpenFAST identity line** (`CableDyn_OF.f90`, `WrScr`), and its copy in `tutorial_openfast.rst`. - **README** intro and the **manual landing page** (`index.rst`). Both now state that the strain and curvature are the exact measures; the manual links to `theory`. - **Citation:** - the `CITATION.cff` title and abstract, and the `citing.rst` reference and BibTeX; - the BibTeX key now names the version it cites (`CableDyn_0_1_1` → `CableDyn_0_3_0`). - **Package metadata:** the CMake project `DESCRIPTION`, the description in both `pyproject.toml` files, and the `cabledyn` package docstring. - CHANGELOG entry. Wording only. No numerics change. Checks: - ctest 305/305 and pytest against the built driver (2092 passed); - docs build with `-W`; ruff clean; - OpenFAST built with this branch's CableDyn module, so the `CableDyn_OF.f90` line compiles. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 4 ++++ CITATION.cff | 7 ++++--- CMakeLists.txt | 2 +- README.md | 7 +++++-- doc/citing.rst | 10 ++++++---- doc/index.rst | 8 +++++--- doc/installation.rst | 4 ++-- doc/quickstart.rst | 4 ++-- doc/tutorial_openfast.rst | 2 +- pyproject.toml | 2 +- python/cabledyn/__init__.py | 2 +- python/pyproject.toml | 2 +- src/CableDyn_Banner.f90 | 4 ++-- src/openfast/CableDyn_OF.f90 | 3 ++- 14 files changed, 37 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ed0bbc1..406d1636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,10 @@ All notable changes to CableDyn are recorded in this file. The format follows numbers them from 0, so a MoorDyn deck's `N` is CableDyn's `N`, or `N` on a line written anchor-first. The numbering itself is unchanged; the outputs and migration pages state it. +- The run banner, README, manual, citation and package descriptions call CableDyn what it is: a + geometrically exact finite-element solver for the statics and dynamics of mooring lines and + dynamic power cables (its strain and curvature are the exact large-deformation measures), in + place of "geometrically nonlinear cable & mooring dynamics". ### Fixed diff --git a/CITATION.cff b/CITATION.cff index f2786fe1..da0c3bda 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -3,11 +3,12 @@ message: >- If you use CableDyn in academic work, please cite the journal article given as the preferred citation. To identify the exact software release used, also cite this software entry with its version. -title: "CableDyn: A cable and mooring dynamics solver for floating offshore wind" +title: "CableDyn: Geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables for floating offshore wind" type: software abstract: >- - CableDyn is an open-source finite-element solver for the static and dynamic - analysis of offshore mooring lines and dynamic power cables. It combines + CableDyn is an open-source, geometrically exact finite-element solver for the + static and dynamic analysis of offshore mooring lines and dynamic power cables. + Its strain and curvature are the exact large-deformation measures. It combines tension-only elements for moorings with cubic-Hermite finite-bending elements for power cables, solves the static equilibrium by Newton's method, and integrates the dynamics with the implicit generalised-alpha scheme. It runs as diff --git a/CMakeLists.txt b/CMakeLists.txt index 5911ec2c..a3680b28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ cmake_minimum_required(VERSION 3.20) # VERSION is a bare numeric triple matching the release version. project(CableDynCore VERSION 0.3.0 LANGUAGES C Fortran - DESCRIPTION "CableDyn geometrically nonlinear cable/mooring solver — Fortran core") + DESCRIPTION "CableDyn geometrically exact cable/mooring solver — Fortran core") option(CABLEDYN_ENABLE_COVERAGE "Instrument the GNU Fortran core for gcov/gcovr source coverage" OFF) option(CABLEDYN_ENABLE_OPENMP "Enable OpenMP acceleration when the compiler provides it" ON) diff --git a/README.md b/README.md index c5d2048d..cafb45b1 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,11 @@ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE) [![DOI](https://img.shields.io/badge/DOI-10.1016%2Fj.oceaneng.2026.128332-blue.svg)](https://doi.org/10.1016/j.oceaneng.2026.128332) -CableDyn is an open-source finite-element solver for the static and dynamic -analysis of offshore mooring lines and dynamic power cables. It is written in +CableDyn is an open-source, geometrically exact finite-element solver for the +static and dynamic analysis of offshore mooring lines and dynamic power cables. +Its strain and curvature are the exact large-deformation measures, never +linearised, so large displacements and rotations, slack and snap, and a line +lifting off the seabed lie inside the formulation. It is written in Fortran 2018 and runs as a standalone program, as a mooring module of OpenFAST, maintained by NLR (National Laboratory of the Rockies, formerly NREL) (`CompMooring = 5`), through a C interface, or from Python. It reads input decks diff --git a/doc/citing.rst b/doc/citing.rst index d3d89e60..bde7a978 100644 --- a/doc/citing.rst +++ b/doc/citing.rst @@ -36,14 +36,16 @@ Incheon, Republic of Korea. Software release ---------------- -Seo, J. H. (2026). *CableDyn: A cable and mooring dynamics solver for floating offshore -wind* (version 0.3.0) [Computer software]. https://github.com/SMI-Lab-Inha/CableDyn +Seo, J. H. (2026). *CableDyn: Geometrically exact finite-element statics and dynamics of +mooring lines and dynamic power cables for floating offshore wind* (version 0.3.0) [Computer +software]. https://github.com/SMI-Lab-Inha/CableDyn .. code-block:: bibtex - @software{CableDyn_0_1_1, + @software{CableDyn_0_3_0, author = {Seo, Jae Hoon}, - title = {{CableDyn}: A cable and mooring dynamics solver for floating offshore wind}, + title = {{CableDyn}: Geometrically exact finite-element statics and dynamics of mooring + lines and dynamic power cables for floating offshore wind}, version = {0.3.0}, year = {2026}, url = {https://github.com/SMI-Lab-Inha/CableDyn}, diff --git a/doc/index.rst b/doc/index.rst index a56a337a..37d9dfb6 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -3,9 +3,11 @@ CableDyn ======== -**CableDyn** is an open-source (`Apache-2.0 `_) -cable and mooring dynamics solver for floating offshore wind turbines and substations, written -in modern **Fortran 2018**. It targets dynamic power cables in the lazy-wave configuration and +**CableDyn** is an open-source (`Apache-2.0 `_), +geometrically exact finite-element solver for the statics and dynamics of mooring lines and +dynamic power cables of floating offshore wind turbines and substations, written in modern +**Fortran 2018**. Its strain and curvature are the exact large-deformation measures, never +linearised (:doc:`theory`). It targets dynamic power cables in the lazy-wave configuration and taut, semi-taut, and catenary moorings. It reads MoorDyn v2 input decks and has been compared with MoorDyn-C, MoorDyn-F, and OrcaFlex on common reference cases. diff --git a/doc/installation.rst b/doc/installation.rst index c0d87a03..77c5f1cc 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -121,8 +121,8 @@ Check that it runs =================================================================== CableDyn v0.3.0 - Geometrically nonlinear cable & mooring dynamics for floating wind - (lazy-wave power cables and taut / semi-taut / catenary moorings) + Geometrically exact finite-element statics and dynamics of + mooring lines and dynamic power cables for floating offshore wind ------------------------------------------------------------------- Author Prof. Jae Hoon Seo Affil. Inha University, Republic of Korea diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 2f950838..8d35cbed 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -39,8 +39,8 @@ The run takes well under a second: =================================================================== CableDyn v0.3.0 - Geometrically nonlinear cable & mooring dynamics for floating wind - (lazy-wave power cables and taut / semi-taut / catenary moorings) + Geometrically exact finite-element statics and dynamics of + mooring lines and dynamic power cables for floating offshore wind ------------------------------------------------------------------- Author Prof. Jae Hoon Seo Affil. Inha University, Republic of Korea diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index 50c2e217..156ce2f6 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -169,7 +169,7 @@ The CableDyn part of the console (other modules' lines trimmed): .. code-block:: text Running CableDyn (v0.3.0, 2026-10-23). - CableDyn: geometrically nonlinear cable & mooring dynamics for floating wind. + CableDyn: geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables. ... CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM) Parsing CableDyn input file: .\CableDyn_UMaine.dat diff --git a/pyproject.toml b/pyproject.toml index af814b55..4b6ea160 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,7 +13,7 @@ build-backend = "scikit_build_core.build" [project] name = "cabledyn" version = "0.3.0" -description = "Python APIs for the CableDyn standalone driver and native coupling library" +description = "Python tools for CableDyn, a geometrically exact finite-element solver for mooring lines and dynamic power cables" readme = "python/README.md" requires-python = ">=3.10" license = "Apache-2.0" diff --git a/python/cabledyn/__init__.py b/python/cabledyn/__init__.py index 7916bbcb..fd926e14 100644 --- a/python/cabledyn/__init__.py +++ b/python/cabledyn/__init__.py @@ -1,5 +1,5 @@ # SPDX-License-Identifier: Apache-2.0 -"""Python interfaces for the CableDyn cable and mooring dynamics solver. +"""Python interfaces for CableDyn, the geometrically exact cable and mooring solver. The standalone-driver API works with the statically linked release executable. The in-process :class:`CableDyn` class, and the ``abi_version``, ``abi_minor``, diff --git a/python/pyproject.toml b/python/pyproject.toml index 9d9a0a83..9d12e9f6 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "cabledyn" version = "0.3.0" -description = "Python APIs for the CableDyn standalone driver and native coupling library" +description = "Python tools for CableDyn, a geometrically exact finite-element solver for mooring lines and dynamic power cables" readme = "README.md" requires-python = ">=3.10" license = "Apache-2.0" diff --git a/src/CableDyn_Banner.f90 b/src/CableDyn_Banner.f90 index 4c69e862..b5a86dfb 100644 --- a/src/CableDyn_Banner.f90 +++ b/src/CableDyn_Banner.f90 @@ -27,9 +27,9 @@ PURE FUNCTION CD_Banner_Line(i) RESULT(s) CASE (2) s = ' CableDyn v0.3.0' CASE (3) - s = ' Geometrically nonlinear cable & mooring dynamics for floating wind' + s = ' Geometrically exact finite-element statics and dynamics of' CASE (4) - s = ' (lazy-wave power cables and taut / semi-taut / catenary moorings)' + s = ' mooring lines and dynamic power cables for floating offshore wind' CASE (5) s = ' -------------------------------------------------------------------' CASE (6) diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 9fc90ee1..8b26f507 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -543,7 +543,8 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! ------------------------------------------------------------------------------ CALL DispNVD( CableDyn_ProgDesc ) InitOut%Ver = CableDyn_ProgDesc - CALL WrScr( ' CableDyn: geometrically nonlinear cable & mooring dynamics for floating wind.' ) + CALL WrScr( ' CableDyn: geometrically exact finite-element statics and dynamics of mooring lines '// & + 'and dynamic power cables.' ) CALL WrScr( ' Author Prof. Jae Hoon Seo, Inha University. License Apache-2.0.' ) CALL WrScr( ' CompMooring = 5: mooring and dynamic power-cable loads are computed by CableDyn,' ) CALL WrScr( ' an OpenFAST mooring module alongside MoorDyn (CompMooring = 3) in this binary.' ) From 149c064090a254d7e8cafcbf1e7b32c57440586d Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 27 Oct 2026 23:33:02 +0900 Subject: [PATCH 10/51] fix(statics): solve light slack finite-EI lines; keep a line's azimuth continuous (#59) * fix(statics): solve light slack finite-EI lines; keep a line's azimuth continuous A finite-EI line longer than its span with no net weight, or too little for its bending stiffness, failed its static solve. With no catenary to start from, both routes reached the compressed straight strut (a saddle) or stalled at the round-off of the axial forces, EA eps |r|/h, which a weightless line's unit force scale puts above the tolerance (0.001 N/m on a 120 m line with EI 1e4 failed; 0.01 N/m passed). When both routes fail on a slack, planar line in still water with |w| < 100 EI/L^3, the line is now solved with that auxiliary weight (of the sign of its net weight, downward for a weightless line) and carried back to its own weight by a continuation in the weight, held in the vertical plane of its chord and accepting the round-off floor of the axial forces; the result is audited and stability-checked as the routes' are. A weightless line bows as the pinned-pinned elastica: end thrust 7.0563 N and mid-span bow 17.9399 m against 7.0564 N and 17.9399 m exact. Nothing in the deck chooses the side of its bow, so it is solved bowed downward and a note says so; with its ends one above the other it is still refused, now by that cause. The tangent azimuth of a line along +X jumped between 0 and about 360 from one output row to the next as the line swayed a fraction of a degree to either side, or by the sign of a round-off component: on the IEA-15 mixed OpenFAST deck 315 to 485 of 801 rows of each cable azimuth channel read 359.9x. A line whose static chord heads within 45 deg of +X now reports its azimuths in (-180, 180], every other line in [0, 360) as before, so the cut of a line's range lies at least 45 deg from its heading; a round-off component across the cut reads on its included side. Signed-off-by: Jae Hoon Seo * fix(statics): keep a Fixed End A in recursive builds; return the weightless-bow note The recursive builds of a finite-EI line (weight continuation, coarse current pass, still-water references) ran without the standalone controls, so they refused a Fixed End A that the standalone build of the same line admits; the weight continuation of a weightless line with both ends Fixed (legal in a deck with dynamic points) failed on it. They now inherit the outer build's allowance (fixed_fairlead). All 52 examples are unchanged. The weightless-bow note was reported before the build cleared its note buffer, so the coupled aggregate, which prints nothing itself, never received it. It is now reported with the other initialisation notes. Signed-off-by: Jae Hoon Seo --------- Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 12 + CMakeLists.txt | 26 +- doc/outputs.rst | 20 +- doc/solver_paths.rst | 11 + doc/standalone_driver.rst | 5 +- doc/theory.rst | 26 ++ doc/troubleshooting.rst | 25 +- python/tests/test_native_model.py | 13 +- src/CableDyn_DeckDriver.f90 | 359 ++++++++++++++++-- src/CableDyn_Model.f90 | 4 + src/CableDyn_OpenFAST_HermiteFMF.f90 | 3 + .../msg_weightless_finite_ei_vertical.dat | 37 ++ tests/test_driver_channels.f90 | 129 +++++++ tests/test_flagship_compression_note.f90 | 49 +++ tests/test_light_slack_statics.py | 201 ++++++++++ 15 files changed, 863 insertions(+), 57 deletions(-) create mode 100644 tests/data/msg_weightless_finite_ei_vertical.dat create mode 100644 tests/test_light_slack_statics.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 406d1636..678d4d7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,18 @@ All notable changes to CableDyn are recorded in this file. The format follows cable's fairlead to the restored input mesh, whose last bits differ from the boundary the uninterrupted run committed, and the cable's `.CD.out` channels drifted by up to 1e-6 (relative) within seconds. The checkpoint now carries the cable's committed boundary. +- A finite-EI line longer than its span with no net weight, or too little for its bending + stiffness (0.001 N/m on a 120 m line with `EI` 1e4 N m²), failed its static solve: both routes + reached the compressed straight strut or stalled at the round-off of the axial forces. Such a + line is now solved heavier and carried back to its own weight in the vertical plane of its + chord. A weightless line bows as the Euler elastica (end thrust and bow to 3e-5 of the exact + solution); nothing in the deck chooses the side of its bow, so it is solved bowed downward and + a note says so. With its ends one above the other it is still refused, by name. +- A line along +X reported its tangent azimuth (`LNAzi`, the static profile's `Azimuth`) + at 0 or about 360 from one row to the next as it swayed a fraction of a degree to either + side, or by the sign of a round-off component: in OpenFAST about half the rows of a cable in + the x-z plane read 359.9x. A line whose chord heads within 45° of +X now reports its azimuths + in (−180, 180], every other line in [0, 360) as before. ## [0.3.0] - 2026-10-23 diff --git a/CMakeLists.txt b/CMakeLists.txt index a3680b28..db960784 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2458,9 +2458,14 @@ function(cabledyn_msg_test name deck rc must_match must_not) -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_msg_${name} PROPERTIES LABELS "fortran;driver;integration;static") endfunction() -# A neutrally buoyant finite-EI line longer than its span has no catenary and no tension-only bow. -cabledyn_msg_test(weightless_finite_ei msg_weightless_finite_ei.dat 2 - "weightless .neutrally buoyant. line is longer than its span;shorten the line to its span, or give it net weight" +# A neutrally buoyant finite-EI line longer than its span has no catenary: it bows under the +# compression its bending stiffness carries, and the run says that nothing chose the bow's side. +cabledyn_msg_test(weightless_finite_ei msg_weightless_finite_ei.dat 0 + "line 1 is weightless and longer than its span, so it bows;solved bowed downward in the vertical plane" + "net-heavy") +# With its ends one above the other nothing chooses the side of the bow either: refused, by name. +cabledyn_msg_test(weightless_finite_ei_vertical msg_weightless_finite_ei_vertical.dat 2 + "weightless .neutrally buoyant. line is longer than its vertical span;nothing chooses the side of the bow;offset its ends horizontally" "net-heavy") # An EI=0 line type rejected as net-buoyant whose mass is a relative 4e-9 below the displaced water # mass is named weightless and slack; one a relative 2e-6 below it keeps the plain message. @@ -2601,6 +2606,21 @@ if(Python3_Interpreter_FOUND) else() message(STATUS "statics_robustness_matrix: skipped (numpy/scipy not importable in ${Python3_EXECUTABLE})") endif() + # A finite-EI line longer than its span with little or no net weight: the weightless bow is the + # pinned-pinned elastica, light lines bow toward their weight, and a march from the bow stays at rest. + if(_statics_matrix_deps_rc EQUAL 0) + add_test( + NAME light_slack_statics + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_light_slack_statics.py + --exe $ + --output ${CMAKE_CURRENT_BINARY_DIR}/light_slack_statics) + set_tests_properties(light_slack_statics PROPERTIES + LABELS "python;driver;integration;static;validation" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + else() + message(STATUS "light_slack_statics: skipped (numpy/scipy not importable in ${Python3_EXECUTABLE})") + endif() endif() add_executable(test_driver_channels tests/test_driver_channels.f90) diff --git a/doc/outputs.rst b/doc/outputs.rst index c8cd7872..87d8c0e8 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -232,7 +232,7 @@ finite-EI line of the run: - signed inclination below horizontal, ``Declination − 90`` * - ``Azimuth`` - ``(deg)`` - - axial-tangent azimuth from +X toward +Y, in [0, 360) + - axial-tangent azimuth from +X toward +Y, in the line's range (:ref:`outputs-azimuth-range`) * - ``DeckNode`` - ``(-)`` - the deck node of the row, the ```` of the node channels (1 = End A … 1 + the total @@ -486,6 +486,21 @@ fairlead) runs from its fairlead here (:doc:`migrating`), so its ``N`` is Moo ``N``. The per-line files (``Node…`` columns) number the same way. A run whose outputs name line nodes says so in a note, and ``N0`` is rejected rather than read as another node. +.. _outputs-azimuth-range: + +Azimuth range +~~~~~~~~~~~~~ + +The azimuth of a line's tangent (``LNAzi``, the ``Azimuth`` column of the static profile +and the azimuth of the initialisation summary) is reported in **(−180, 180]** on a line whose +chord from End A to End B, at the deck positions, heads within 45° of +X, and in **[0, 360)** on +every other line. The cut of a line's range then lies at least 45° from its heading: a line +swaying about its heading reads continuously, where a line along +X would otherwise jump +between 0 and 360 as it moves a fraction of a degree to either side. The range is fixed for +the run, so the motion of the line cannot switch it. A round-off component across the cut +reads on its included side (0, or 180 in the signed range), and one across +X reads exactly 0. +A line a host builds through the C interface without a deck reports [0, 360). + .. _outputs-refined-nodes: Node channels on a refined line @@ -691,7 +706,8 @@ Line-node channels - declination of the node's axial tangent from +Z (0 = up, 90 = horizontal, 180 = down) - deg * - ``LNAzi`` - - azimuth of the node's axial tangent from +X toward +Y, in [0, 360) + - azimuth of the node's axial tangent from +X toward +Y, in the line's range + (:ref:`outputs-azimuth-range`) - deg * - ``TorqN`` - torque (twisting moment) at node ``J`` of a line restrained in torsion at both ends diff --git a/doc/solver_paths.rst b/doc/solver_paths.rst index 81209a89..0996a2bc 100644 --- a/doc/solver_paths.rst +++ b/doc/solver_paths.rst @@ -94,6 +94,17 @@ Every attempt uses the same physical inputs, tolerance, and acceptance checks. N contact hierarchy are projected to the declared floor before polishing; this changes only the prolonged seed, never the contact law or the final equations. +**Weight continuation** (a light slack line). A line longer than its span with too little net +weight for its bending stiffness (:math:`|w| < 100\,EI/L^3`) has no catenary to start from, and +both routes can end on the compressed straight strut or stall at the round-off of its axial +forces. When both fail, the line is solved heavier, with :math:`100\,EI/L^3` of the sign of its +net weight added (downward for a weightless line), and that equilibrium is carried back to its +own weight in the vertical plane of its chord, accepting the round-off floor of the axial +forces. It applies to a planar line in still water over a level seabed, without attachments or +``tensile_safety True``, whose chord is not vertical. A weightless line bows as the Euler +elastica; nothing in the deck chooses the plane or the side of the bow, and a note says how it +was solved (:doc:`theory`). + **Acceptance checks.** A residual-converged state is rejected when the sampled :math:`\max(L_0\,\kappa)` of any element exceeds 0.7 (an unresolved fold). With ``adaptive_mesh = True``, exhausting the refinement cap while curvature resolution or diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index d79cdecf..67abac60 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -142,8 +142,9 @@ force inclination differs slightly from the tangent inclination because the end the end node's share of the distributed load (and, on a finite-EI line, the end shear). ``declination`` is the angle from global ``+Z`` (the convention also used by OrcaFlex): 0 degrees up, 90 degrees -horizontal, and 180 degrees down. ``azimuth`` is measured from global ``+X`` toward ``+Y`` in -``[0, 360)``. Therefore ``inclination = declination - 90 degrees``; the two values are printed +horizontal, and 180 degrees down. ``azimuth`` is measured from global ``+X`` toward ``+Y``, in +``(-180, 180]`` on a line heading within 45 degrees of ``+X`` and in ``[0, 360)`` otherwise +(:ref:`outputs-azimuth-range`). Therefore ``inclination = declination - 90 degrees``; the two values are printed together deliberately so the convention is auditable. For the production Hermite finite-EI route, the reported vector is the complete fairlead reaction, diff --git a/doc/theory.rst b/doc/theory.rst index 9b0e3c0a..215a53f8 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1479,6 +1479,32 @@ mesh-sequenced route described below first and this route as its fallback): mesh-sequenced solve below, audited alike. On the Lozon cables the two routes give the same equilibrium to the solver tolerance (positions within 2e-5 m, curvature within 1e-6 1/m). +A line longer than its span with little net weight for its bending stiffness has no catenary +to start from. With no weight at all it bows under the axial compression its bending stiffness +carries, the Euler elastica (about :math:`\pi^2 EI/L^2`). Both routes can then end on the +compressed straight strut, a saddle, or stall at the round-off of the axial forces, +:math:`EA\,\varepsilon\,|\mathbf r|/h` (the axial strain is formed from coordinate differences over +an element of length :math:`h`), which a weightless line's unit force scale puts above the +tolerance. When both routes fail on a slack line with :math:`|w| < 100\,EI/L^3` (largest +:math:`EI`), the line is solved with the auxiliary weight :math:`w_a = 100\,EI/L^3` added to every +element, of the sign of its net weight and downward for a weightless one, which the routes +handle. That equilibrium is carried back to the line's own weight by a continuation in the +weight, held in the vertical plane of the chord: steps of a quarter of the remaining +:math:`w_a`, the last from :math:`w_a/256` to none, a failed step halved. The steps accept the +round-off floor :math:`8\,EA\,\varepsilon\,|\mathbf r|_{\max}/h_{\min}` of the axial forces when it +lies above the tolerances of the routes, and a floor above the static tolerance is reported as +for the routes. The result is audited and checked for stability like theirs. The continuation +runs on a planar line in still water over a level seabed, without attachments or +``tensile_safety True``, whose chord is not vertical (the auxiliary weight must have a +component across it). For a weightless line nothing in the deck chooses the plane or the side +of the bow: the limit of a vanishing weight puts it on the lower side in the vertical plane of +the chord, and a note says so. Its tangent there has one zero eigenvalue, the bow turning about +the chord: the planar solve holds that mode, and a dynamic run leaves it free and at rest. On a +pinned 120 m line +with its ends 113 m apart the end thrust and the mid-span bow match the inextensible elastica, +:math:`P = 4K(m)^2EI/L^2` and :math:`\delta = \sqrt{m}\,L/K(m)` with +:math:`\text{chord}/L = 2E(m)/K(m) - 1`, to :math:`3\times10^{-5}` and :math:`10^{-6}` relative. + A deck current loads the line at rest with its steady Morison drag (the relative velocity is the current itself; the element fluid velocity is the mean of the current at its two nodes, as in the dynamics). The drag follows the line and is not a potential force: it is carried diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 4420f6de..9fe01b00 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -488,14 +488,23 @@ but a few geometries are genuinely hard: - **A large grounded touchdown on the** ``EI = 0`` **path.** A long, near-horizontal grounded run can make the linear-Lagrange tangent singular regardless of seed. If the case is a lazy-wave or bending-dominated cable, use the finite-EI path (``EI > 0``), which is built for it. -- **A weightless finite-EI line longer than its span.** ``the weightless (neutrally buoyant) - line is longer than its span`` means every element has zero net weight (to a relative 1e-6 of - its displaced weight, attachments included). Such a line has no catenary: with no weight a - tension-only line is straight, and a longer one could only bow by bending under axial - compression, which a cable does not carry. Shorten the line to its span, or give it net weight - (a larger ``MassDenInAir``, or clumps) or a tension that holds it taut. A line heavier than - water with the same symptom gets ``the net-heavy line is too long for its span to hang as a - catenary`` instead. +- **A weightless finite-EI line longer than its span.** Every element has zero net weight (to a + relative 1e-6 of its displaced weight, attachments included), so the line has no catenary: it + bows under the axial compression its bending stiffness carries (the Euler elastica). It is + solved, with the note ``line N is weightless and longer than its span``: nothing in the deck + chooses the plane or the side of the bow, so it is solved bowed downward in the vertical plane + through its ends, the limit of a vanishing net weight, and the bow can turn about the chord at + no cost. If the line has a net weight, however small, give it (``MassDenInAir``) to settle + the shape; a light line, heavy or buoyant, bows toward its weight + (:doc:`solver_paths`, weight continuation). With its ends one above the other nothing chooses + the side of the bow: ``the weightless (neutrally buoyant) line is longer than its vertical + span`` stops the run. In a current, with attachments, over a non-level seabed, under + ``tensile_safety True`` or with an end connection out of the plane of the chord the + continuation does not apply, and a line the routes cannot solve stops with ``the weightless + (neutrally buoyant) line is longer than its span``. Shorten the line to its span, or give it + net weight (a larger ``MassDenInAir``, or clumps) or a tension that holds it taut. A line + heavier than water that is too long for its span gets ``the net-heavy line is too long for + its span to hang as a catenary`` instead. - **A finite-EI lazy-wave cable at too coarse a mesh.** An under-resolved arch or touchdown carries a large element ``h·κ`` and can stall the dynamic Newton. The resolution metric flags this; the builder can auto-refine a fragile mesh when the deck opts in (``adaptive_mesh True``). diff --git a/python/tests/test_native_model.py b/python/tests/test_native_model.py index bb258212..a742d41d 100644 --- a/python/tests/test_native_model.py +++ b/python/tests/test_native_model.py @@ -373,15 +373,14 @@ def test_home_relative_deck_path_is_expanded(tmp_path, monkeypatch): def test_long_failure_message_is_kept_whole(): - # The weightless-line diagnosis names the cause, three nested solver reasons, and the - # remedy; it is longer than the 1024 characters the handle once retained, and its closing - # advice must reach the caller. - deck = REPO / "tests" / "data" / "msg_weightless_finite_ei.dat" + # A deck path of 1100 characters that does not exist: the diagnosis names the whole path and + # the reason, longer than the 1024 characters the handle once retained, and its closing + # reason must reach the caller. + deck = "missing_" + "d" * 1100 + ".dat" with cabledyn.CableDyn() as m: with pytest.raises(CableDynError) as caught: m.init_deck(deck) detail = caught.value.detail assert len(detail) > 1024 - assert "weightless (neutrally buoyant) line is longer than its span" in detail - assert detail.endswith("or a tension that holds it taut") - assert "net-heavy" not in detail + assert "cannot open deck: " in detail and deck in detail + assert detail.endswith("(file not found)") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index b539047b..5ddf4743 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -170,8 +170,13 @@ MODULE CableDyn_DeckDriver ! of a typed mass (a mass written to seven digits against a diameter does not cancel exactly). ! It only selects the wording of a diagnosis -- an EI=0 line type rejected as net-buoyant ! whose mass lies within it below the displaced water mass, a finite-EI line whose every - ! element weighs within it of nothing -- and changes no acceptance rule. + ! element weighs within it of nothing -- and the side a weightless slack line bows to + ! (light_aux_weight); it changes no acceptance rule. REAL(wp), PARAMETER :: NEUTRAL_BUOYANCY_REL_TOL = 1.0e-6_wp + ! An azimuth within AZI_ROUNDOFF_DEG of 0 (mod 360) is reported as exactly 0 + ! (wrap_azimuth_deg): far above the round-off of a tangent's angle (~1e-12 deg) and far + ! below the output resolution (~4e-5 deg at 360). + REAL(wp), PARAMETER :: AZI_ROUNDOFF_DEG = 1.0e-9_wp ! A section whose segments are longer than COARSE_SECTION_FRACTION of its line (coarser than a ! uniform eight-segment line) is warned about as too coarse (warn_coarse_sections). A static ! strain above STATIC_STRAIN_NOTE_DEFAULT is noted (static_strain_note) when OPTION maxStrain @@ -469,6 +474,9 @@ MODULE CableDyn_DeckDriver LOGICAL :: stock_row = .FALSE. LOGICAL :: has_syrope_ic = .FALSE. REAL(wp) :: syrope_tmax0 = CD_ZERO, syrope_tmean0 = CD_ZERO + ! The range of the line's tangent azimuths: (-180, 180] when set, otherwise [0, 360) + ! (set_azimuth_ranges). + LOGICAL :: azi_signed = .FALSE. ! Public deck order is End A (column 1) then End B (column 2). The no-moment ! Ez vectors follow the A-to-B convention and are expressed in the connected ! parent's reference axes (global axes for fixed/anchored ends). @@ -1651,7 +1659,7 @@ 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) + install_viv, aux_weight, fixed_fairlead) !! 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. @@ -1685,6 +1693,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! Install the cross-flow VIV of the line's Cl > 0 sections (the standalone finite-EI march; ! the other routes refuse such a line before building it). LOGICAL, INTENT(IN), OPTIONAL :: install_viv + ! An auxiliary weight [N/m] added to every element's net weight (light_line_route: the + ! line solved heavier, whose equilibrium is carried back to its own weight). + REAL(wp), INTENT(IN), OPTIONAL :: aux_weight + ! 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 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(:) @@ -1712,6 +1726,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), PARAMETER :: COUPLED_STATIC_TOL = 1.0e-6_wp ! Newton-iteration budget of one mesh-sequenced fallback solve: a bounded failure path. INTEGER, PARAMETER :: FALLBACK_SEQUENCE_BUDGET = 2000 + LOGICAL :: fixed_fairlead_ok, weightless_bow LOGICAL :: standalone_mode, contact_enabled, used_trivial_seed, anchor_on_flat_bed, allow_extra_sequence LOGICAL :: polish_ready ! Set when the attachment polish needed its fallbacks (attachment_fallback_checks). @@ -1727,7 +1742,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, LOGICAL :: primary_done, primary_inadmissible, tolerance_note, stable, kink_refined, sequence_done LOGICAL :: primary_walked, walk_rejected, primary_walk_planar ! Why the bow behind the fairlead was not reached (bow_route), blank when not tried. - CHARACTER(1024) :: bow_msg, refine_msg + CHARACTER(1024) :: bow_msg, refine_msg, light_msg ! Set when the deck-mesh equilibrium failed the stability test and the refined one passed. LOGICAL :: stability_refined ! Elements of the mesh whose equilibrium failed the stability test before that refinement. @@ -1774,6 +1789,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, step_max_iter = 200 step_tol = 5.0e-3_wp standalone_mode = .FALSE. + weightless_bow = .FALSE. contact_enabled = .FALSE. anchor_on_flat_bed = .FALSE. used_trivial_seed = .FALSE. @@ -1807,6 +1823,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, step_tol = opts%dynamic_rel_tol END IF END IF + fixed_fairlead_ok = standalone_mode + IF (PRESENT(fixed_fairlead)) fixed_fairlead_ok = fixed_fairlead_ok .OR. fixed_fairlead ! Hand the dynamic integrator an equilibrium converged at least as tightly as ! its own Newton stopping criterion. A looser static tolerance can otherwise ! appear as an artificial load impulse on the first nominally stationary step, @@ -1833,7 +1851,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! -- ignoring their point mass/load state -- instead of failing closed. (ptype is stored ! lower-case; the aggregator inherits this check since it calls build_one_hermite_cable too.) IF (TRIM(points(pb)%ptype) /= 'coupled' .AND. TRIM(points(pb)%ptype) /= 'vessel' .AND. & - .NOT. (standalone_mode .AND. TRIM(points(pb)%ptype) == 'fixed')) THEN + .NOT. (fixed_fairlead_ok .AND. TRIM(points(pb)%ptype) == 'fixed')) THEN 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 @@ -1966,10 +1984,17 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL attachment_nodes(l0, ln%att(1, :), att_node, att_offset) CALL smear_attachments(w, l0, att_node, ln%att, opts%rhoW, opts%g) END IF + IF (PRESENT(aux_weight)) w = w + aux_weight ! Zero net weight everywhere (to the neutral-buoyancy band, attachments included): the line has ! no catenary, and the net-heavy diagnosis of a line too long for its span does not apply. weightless_line = ALL(ABS(w) <= NEUTRAL_BUOYANCY_REL_TOL*opts%rhoW*opts%g*QUARTER_PI*diam**2) - IF (weightless_line) THEN + IF (weightless_line .AND. .NOT. NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-6_wp*NORM2(fairlead - anchor)) THEN + geom_cause = 'the weightless (neutrally buoyant) line is longer than its vertical span, so it could only '// & + 'bow by bending under axial compression, and with its ends one above the other nothing chooses '// & + 'the side of the bow' + geom_advice = 'shorten the line to its span, or give it net weight (MassDenInAir above the displaced '// & + 'water mass, or clumps) or a tension that holds it taut, or offset its ends horizontally' + ELSE IF (weightless_line) THEN geom_cause = 'the weightless (neutrally buoyant) line is longer than its span, so it cannot hang as a '// & 'catenary: with no net weight a tension-only line is straight, and a longer one could only bow '// & 'by bending under axial compression' @@ -2792,6 +2817,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, primary_done = .TRUE. saddle_kept = .TRUE. END IF + ! A slack line too light for both routes is solved heavier and carried back to its own + ! weight (light_line_route). + IF (.NOT. (sequence_done .OR. primary_done) .AND. light_line_eligible()) THEN + CALL light_line_route(sequence_done, light_msg) + IF (.NOT. sequence_done) sequence_msg = TRIM(short_message(sequence_msg, 240))// & + '; weight continuation: '//TRIM(light_msg) + END IF IF (.NOT. (sequence_done .OR. primary_done)) THEN ! A mesh below the conditioning limit is the likely cause and is named first. IF (LEN_TRIM(fine_note) > 0) THEN @@ -2846,6 +2878,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, init_note = '' IF (LEN_TRIM(fine_note) > 0) init_note = TRIM(fine_note) END IF + IF (weightless_bow) & + CALL report_note('line '//TRIM(int_to_str(ln%id))//' is weightless and longer than its span, so it '// & + 'bows under the compression its bending stiffness carries. Nothing in the deck chooses '// & + 'the plane or the side of the bow: it is solved bowed downward in the vertical plane '// & + 'through its ends, the limit of a vanishing net weight, and the bow can turn about '// & + 'the chord at no cost. Give the line its net weight (MassDenInAir) to settle its shape') ! "line N carries ..." reads as one clause; the mesh variant is a "line N: ..." note IF (LEN_TRIM(compression_note) > 0) THEN IF (starts_with(compression_note, 'carries')) THEN @@ -3052,6 +3090,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable coupled-shell init failed: '//TRIM(em)); RETURN 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 IF (ALLOCATED(ei_cable)) cable%line%EI_line = ei_cable IF (ANY(ba > CD_ZERO)) THEN @@ -3551,12 +3590,12 @@ SUBROUTINE still_water_compression(text) opts_sw%has_current_profile = .FALSE. 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., bathymetry=bathymetry, & - fairlead_orientation=fairlead_dcm, init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esw, emw, & - standalone_controls=.FALSE., fairlead_orientation=fairlead_dcm, & - init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=sw_note) 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, & @@ -3571,6 +3610,204 @@ SUBROUTINE still_water_compression(text) CALL CD_HFMF_End(sw_cable) END SUBROUTINE still_water_compression + REAL(wp) FUNCTION light_aux_weight() RESULT(aux) + !! The auxiliary weight of light_line_route [N/m]: LIGHT_AUX bending-weight ratios + !! w L^3/EI of the stiffest section, heavy enough for the routes. It takes the sign of + !! the line's net weight; a weightless line is made heavy (the bow hangs downward). + REAL(wp), PARAMETER :: LIGHT_AUX = 100.0_wp + aux = LIGHT_AUX*MAXVAL(ei)/SUM(l0)**3 + IF (.NOT. weightless_line .AND. SUM(w*l0) < CD_ZERO) aux = -aux + END FUNCTION light_aux_weight + + LOGICAL FUNCTION light_line_eligible() RESULT(ok) + !! light_line_route applies to a slack, planar line (no current, no attachments, a + !! level seabed, no tensile_safety) whose weight, of one sign along it, is below the + !! auxiliary weight, and whose chord is not vertical (the auxiliary weight then has a + !! component across the chord that chooses the side of the bow). + REAL(wp) :: chord + ok = .FALSE. + IF (PRESENT(aux_weight) .OR. PRESENT(coarse_pass)) RETURN + IF (opts%has_current .OR. ALLOCATED(cur_obj) .OR. require_3d_static .OR. has_att .OR. tensile_error) RETURN + IF (LEN_TRIM(fine_note) > 0) RETURN + IF (PRESENT(bathymetry)) THEN + IF (.NOT. bathymetry_flat) RETURN + END IF + IF (.NOT. (ALL(w >= CD_ZERO) .OR. ALL(w <= CD_ZERO))) RETURN + IF (MAXVAL(ei) <= CD_ZERO) RETURN + chord = NORM2(fairlead - anchor) + IF (.NOT. SUM(l0) > chord) RETURN + IF (.NOT. NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-6_wp*chord) RETURN + ok = MAXVAL(ABS(w)) < ABS(light_aux_weight()) + END FUNCTION light_line_eligible + + SUBROUTINE light_line_route(done, why) + !! A slack line with too little weight for its bending stiffness: nothing hangs it as a + !! catenary, so it bows under the compression its bending stiffness carries (the + !! elastica, about pi^2 EI/L^2), and the routes' seeds lead to the compressed straight + !! strut (a saddle) or stall at the round-off of its axial forces. The line is solved + !! with the auxiliary weight of light_aux_weight (a recursive build: the routes) and that + !! equilibrium is carried back to the line's own weight by a continuation in the weight + !! (a quarter per step, the last from 1/256 to none, a failed step halved), held in the + !! vertical plane of the chord. Below the tolerances of the routes the continuation also + !! accepts the round-off floor of the axial forces, ROUNDOFF_RUNG EA eps |r|/h on the + !! largest coordinate |r| and shortest element h (EA (|r'| - 1) is formed from + !! coordinate differences). done is set with the audited, stable state in the *_am + !! outputs; otherwise why says what stopped it. + LOGICAL, INTENT(OUT) :: done + CHARACTER(*), INTENT(OUT) :: why + REAL(wp), PARAMETER :: LAST_FRACTION = 1.0_wp/256.0_wp, ROUNDOFF_RUNG = 8.0_wp + INTEGER, PARAMETER :: MAX_HALVINGS = 10 + TYPE(CD_HFMF_ModuleType) :: aux_cable + REAL(wp), ALLOCATABLE :: q_c(:), q_n(:), curv_n(:), w_k(:), knnode(:) + REAL(wp) :: aux, f, f_try, res_n, tol_k(3), tol_used + INTEGER :: aux_node, es_r, it_r, nfail, k, k_tol + LOGICAL :: last, stable_r + CHARACTER(1024) :: em_r + CHARACTER(2048) :: aux_note + done = .FALSE. + why = '' + aux = light_aux_weight() + IF (PRESENT(bathymetry)) THEN + 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) + 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) + 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: ' + why = TRIM(why)//' '//TRIM(short_message(em_r, 240)) + CALL CD_HFMF_End(aux_cable) + RETURN + END IF + IF (SIZE(aux_cable%line%l0) /= SIZE(l0)) THEN + why = 'the equilibrium with the auxiliary weight was solved on a refined mesh' + CALL CD_HFMF_End(aux_cable) + RETURN + END IF + q_c = aux_cable%line%q + CALL CD_HFMF_End(aux_cable) + ALLOCATE (q_n(ndof), curv_n(nnode), w_k(SIZE(w))) + IF (contact_enabled) THEN + ALLOCATE (knnode(nnode)) + knnode = CD_ZERO + DO k = 1, SIZE(l0) + knnode(k) = knnode(k) + 0.5_wp*opts%kbot*diam(k)*l0(k) + knnode(k + 1) = knnode(k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) + END DO + END IF + iters = 0 + f = CD_ONE + f_try = 0.25_wp + nfail = 0 + DO + last = f_try <= CD_ZERO + w_k = w + aux*f_try + tol_k = [static_tol_target, MAX(static_tol_target, COUPLED_STATIC_TOL), & + ROUNDOFF_RUNG*EPSILON(CD_ONE)*MAXVAL(ea)*position_magnitude(q_c)/MINVAL(l0)/ & + MAX(CD_ONE, SUM(ABS(w_k)*l0))] + ! The continuation steps go straight to the loosest tolerance; the last tries each. + IF (.NOT. last) tol_k(1:2) = MAXVAL(tol_k) + es_r = CD_HCSTAT_NOCONVERGE + tol_used = CD_ZERO + DO k_tol = 1, 3 + IF (k_tol > 1) THEN + IF (.NOT. (tol_k(k_tol) > MAXVAL(tol_k(1:k_tol - 1)))) CYCLE + END IF + IF (contact_enabled) THEN + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w_k, q_c, fixed_dofs, contact_z, CD_ZERO, 1, 80, & + tol_k(k_tol), 0.7_wp, q_n, curv_n, res_n, it_r, es_r, em_r, & + n_buoy_steps=1, contact_kn=knnode, contact_frame_cs=frame_cs, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_b, water_weight=opts%rhoW*opts%g) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w_k, q_c, fixed_dofs, contact_z, CD_ZERO, 1, 80, & + tol_k(k_tol), 0.7_wp, q_n, curv_n, res_n, it_r, es_r, em_r, & + n_buoy_steps=1, & + axial_quadrature_order=opts%axial_quadrature_order, & + bending_quadrature_order=opts%bending_quadrature_order, & + endconn_stiffness=endconn_k, endconn_direction=endconn_d0_local, & + endconn_mode=endconn_mode, waterline_z=CD_ZERO, & + dry_buoyancy=dry_b, water_weight=opts%rhoW*opts%g) + END IF + iters = iters + it_r + IF (es_r == CD_HCSTAT_OK) THEN + tol_used = tol_k(k_tol) + EXIT + END IF + IF (es_r == CD_HCSTAT_BADINPUT) EXIT + END DO + IF (es_r == CD_HCSTAT_OK) THEN + q_c = q_n + f = f_try + IF (last) EXIT + f_try = MERGE(CD_ZERO, 0.25_wp*f, 0.25_wp*f < LAST_FRACTION) + ELSE + nfail = nfail + 1 + IF (nfail > MAX_HALVINGS .OR. es_r == CD_HCSTAT_BADINPUT) THEN + WRITE (why, '(A,ES10.3,A)') 'stopped at ', aux*f, ' N/m above the line''s own weight: ' + why = TRIM(why)//' '//TRIM(short_message(em_r, 240)) + RETURN + END IF + f_try = 0.5_wp*(f + f_try) + END IF + END DO + IF (ALLOCATED(l0_am)) DEALLOCATE (l0_am) + IF (ALLOCATED(ea_am)) DEALLOCATE (ea_am) + IF (ALLOCATED(ei_am)) DEALLOCATE (ei_am) + IF (ALLOCATED(w_am)) DEALLOCATE (w_am) + IF (ALLOCATED(fixed_am)) DEALLOCATE (fixed_am) + IF (ALLOCATED(q_static)) DEALLOCATE (q_static) + IF (ALLOCATED(curv)) DEALLOCATE (curv) + l0_am = l0 + ea_am = ea + ei_am = ei + w_am = w + fixed_am = fixed_dofs + CALL MOVE_ALLOC(q_c, q_static) + CALL MOVE_ALLOC(curv_n, curv) + res = res_n + applied_scale = 1 + compression_note = '' + CALL audit_hermite_static(l0_am, q_static, ea_am, ei_am, w_am, diam, endconn_mode, done, why, & + compression_note) + IF (done) THEN + CALL hermite_static_stable(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, fixed_am, & + contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & + endconn_mode, opts, stable_r, es_r, em_r) + IF (es_r /= CD_DECKDRV_OK) THEN + done = .FALSE. + why = em_r + ELSE IF (.NOT. stable_r) THEN + done = .FALSE. + why = 'the equilibrium at the line''s own weight is an unstable equilibrium (tangent stiffness '// & + 'not positive definite)' + END IF + END IF + IF (.NOT. done) THEN + compression_note = '' + RETURN + END IF + tolerance_note = tol_used > static_tol_target + weightless_bow = weightless_line + END SUBROUTINE light_line_route + + PURE REAL(wp) FUNCTION position_magnitude(q) RESULT(r) + !! The largest node coordinate magnitude of a Hermite state (6 values per node). + REAL(wp), INTENT(IN) :: q(:) + INTEGER :: k + r = CD_ZERO + DO k = 1, SIZE(q)/6 + r = MAX(r, MAXVAL(ABS(q(6*(k - 1) + 1:6*(k - 1) + 3)))) + END DO + END FUNCTION position_magnitude + LOGICAL FUNCTION symmetric_current_retry() RESULT(retry) !! Set up the symmetry-breaking pass (see route_pass): out-of-plane DOFs freed and a !! cross-flow of SYM_BREAK of the horizontal current speed added. Only for an in-plane @@ -4008,12 +4245,13 @@ SUBROUTINE coarse_current_first(done, fail_msg) opts_c%adaptive_mesh = .FALSE. IF (PRESENT(bathymetry)) THEN CALL build_one_hermite_cable(ln, sec_c, types, points, opts_c, dt, c_cable, c_node, esc, emc, & - standalone_controls=.FALSE., bathymetry=bathymetry, & + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, & fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE.) ELSE CALL build_one_hermite_cable(ln, sec_c, types, points, opts_c, dt, c_cable, c_node, esc, emc, & - standalone_controls=.FALSE., fairlead_orientation=fairlead_dcm, & - init_note=c_note, coarse_pass=.TRUE.) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=c_note, coarse_pass=.TRUE.) END IF IF (esc /= CD_DECKDRV_OK) THEN CALL CD_HFMF_End(c_cable) @@ -4144,12 +4382,12 @@ SUBROUTINE still_water_reference(esr, emr) opts_sw%has_current_profile = .FALSE. 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., bathymetry=bathymetry, & - fairlead_orientation=fairlead_dcm, init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, init_note=sw_note) ELSE CALL build_one_hermite_cable(ln, sections, types, points, opts_sw, dt, sw_cable, sw_node, esr, emr, & - standalone_controls=.FALSE., fairlead_orientation=fairlead_dcm, & - init_note=sw_note) + standalone_controls=.FALSE., fixed_fairlead=fixed_fairlead_ok, & + fairlead_orientation=fairlead_dcm, init_note=sw_note) END IF IF (esr /= CD_DECKDRV_OK) THEN CALL CD_HFMF_End(sw_cable) @@ -8796,6 +9034,7 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err IF (ErrStat /= CD_DECKDRV_BADINPUT) ErrStat = CD_DECKDRV_SOLVEFAIL RETURN END IF + model%azimuth_signed = ln%azi_signed ! Cross-flow VIV on the Cl > 0 sections (CableDyn_VIV), installed on the initialised line ! (the static equilibrium carries no lift, as MoorDyn's initial-condition generation), and ! the initial acceleration recomputed with the t = 0 lift. @@ -11532,6 +11771,7 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti CALL normalize_stock_endpoint_order(points, lines, sections) CALL finalize_and_validate(types, bodies, rod_types, rods, points, lines, sections, opts, channels, ext_march, & static_finite_ok, ErrStat, ErrMsg, channel_lines) + IF (ErrStat == 0) CALL set_azimuth_ranges(points, lines) IF (ErrStat == 0 .AND. opts%has_motion_file) THEN BLOCK CHARACTER(:), ALLOCATABLE :: resolved_path @@ -15331,6 +15571,25 @@ SUBROUTINE normalize_turbine_points(points, allow_turbine, ErrStat, ErrMsg) END DO END SUBROUTINE normalize_turbine_points + SUBROUTINE set_azimuth_ranges(points, lines) + !! The range of each line's tangent azimuths (DeckLine%azi_signed): a line whose chord from + !! End A to End B, at the deck positions, heads within 45 deg of +X reports them in + !! (-180, 180], every other line in [0, 360). The cut of a line's range then lies at least + !! 45 deg from its heading, so a line swaying about its heading reads continuously (a line + !! along +X no longer jumps between 0 and 360), and the range is fixed for the run: the + !! motion of the line cannot switch it. + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(INOUT) :: lines(:) + INTEGER :: i, ia, ib + DO i = 1, SIZE(lines) + ia = find_point(points, lines(i)%nodeA) + ib = find_point(points, lines(i)%nodeB) + IF (ia == 0 .OR. ib == 0) CYCLE + lines(i)%azi_signed = points(ib)%pos(1) - points(ia)%pos(1) > & + ABS(points(ib)%pos(2) - points(ia)%pos(2)) + END DO + END SUBROUTINE set_azimuth_ranges + SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) !! Stock MoorDyn decks write lines anchor (End A) -> fairlead (End B); the CableDyn !! deck convention is the reverse (End A = fairlead side, End B = anchor). When a @@ -16688,7 +16947,7 @@ SUBROUTINE write_static_config_out(out_root, lines, ne, q_all, q_off, ten_all, t END IF curv = line_geom_from_r(5, r_line, nnode, node) dec = line_geom_from_r(7, r_line, nnode, node) - azi = line_geom_from_r(8, r_line, nnode, node) + azi = line_geom_from_r(8, r_line, nnode, node, lines(li)%azi_signed) WRITE (unit, '(I0,A,I0,10(A,ES15.7E3))') lines(li)%id, tab, node, tab, s, tab, r_node(1), & tab, r_node(2), tab, r_node(3), tab, tenv, tab, curv, tab, CD_ZERO, tab, dec, & tab, dec - 90.0_wp, tab, azi @@ -29742,7 +30001,8 @@ SUBROUTINE write_planned_row(unit, time, channels, lines, points, work, label, E CASE (4) ! acceleration val = work%line_a(off + k) CASE DEFAULT ! geometric channels (curvature / EI=0 bend moment / declination / azimuth) - val = line_geom_value(work%ch_aux(i), work%ch_node(i), nnode, work%line_q(off + 1:off + nd), stride) + val = line_geom_value(work%ch_aux(i), work%ch_node(i), nnode, work%line_q(off + 1:off + nd), stride, & + lines(li)%azi_signed) END SELECT END IF END IF @@ -30331,7 +30591,7 @@ SUBROUTINE system_channel_value(ch, lines, points, system, work, val, ErrStat, E CASE (4) ! acceleration val = work%a(3*(inode - 1) + comp) CASE DEFAULT ! curvature (5) / bend moment (6, EI=0 => 0) / declination (7) / azimuth (8) - val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3) + val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3, lines(li)%azi_signed) END SELECT END IF END IF @@ -30471,7 +30731,7 @@ SUBROUTINE finite_model_channel_value(ch, lines, points, models, work, val, ErrS 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) + val = line_geom_value(kind, node, nnode, work%q(1:6*nnode), 6, lines(li)%azi_signed) END SELECT END IF END IF @@ -30651,7 +30911,7 @@ SUBROUTINE model_channel_value(ch, lines, points, models, work, val, ErrStat, Er CASE (4) ! acceleration val = work%a(3*(inode - 1) + comp) CASE DEFAULT ! curvature (5) / bend moment (6, EI=0 => 0) / declination (7) / azimuth (8) - val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3) + val = line_geom_value(kind, node, nnode, work%q(1:ndof), 3, lines(li)%azi_signed) END SELECT END IF END IF @@ -32254,7 +32514,7 @@ REAL(wp) FUNCTION channel_value(ch, lines, points, ne, q_all, q_off, ten_all, te CASE (1) ! position v = q_all(q_off(li) + 3*(deck_to_internal_node(node, ne(li)) - 1) + comp) CASE (5, 6, 7, 8) ! curvature / bend moment / declination / azimuth (static EI=0 => bend moment 0) - v = line_geom_value(kind, node, nnode, q_all(q_off(li) + 1:q_off(li + 1)), 3) + v = line_geom_value(kind, node, nnode, q_all(q_off(li) + 1:q_off(li + 1)), 3, lines(li)%azi_signed) CASE DEFAULT ! velocity (2) / acceleration (4): zero in a static configuration v = CD_ZERO END SELECT @@ -32902,17 +33162,42 @@ PURE REAL(wp) FUNCTION tangent_declination_deg(t) RESULT(dec) dec = ACOS(MAX(-CD_ONE, MIN(CD_ONE, t(3)/n)))*CD_RAD2DEG END FUNCTION tangent_declination_deg - PURE REAL(wp) FUNCTION tangent_azimuth_deg(t) RESULT(azi) - !! Azimuth [deg] in [0,360): horizontal-plane angle from +GX toward +GY. A - !! vertical tangent has no defined azimuth and returns 0. + PURE REAL(wp) FUNCTION tangent_azimuth_deg(t, signed) RESULT(azi) + !! Azimuth [deg]: horizontal-plane angle from +GX toward +GY, in [0,360), or in + !! (-180,180] when signed (the line's range, DeckLine%azi_signed). A vertical tangent has + !! no defined azimuth and returns 0. REAL(wp), INTENT(IN) :: t(3) + LOGICAL, INTENT(IN), OPTIONAL :: signed azi = CD_ZERO IF (ABS(t(1)) <= TINY(CD_ONE) .AND. ABS(t(2)) <= TINY(CD_ONE)) RETURN - azi = ATAN2(t(2), t(1))*CD_RAD2DEG - IF (azi < CD_ZERO) azi = azi + 360.0_wp + azi = wrap_azimuth_deg(ATAN2(t(2), t(1))*CD_RAD2DEG, signed) END FUNCTION tangent_azimuth_deg - PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride) RESULT(v) + PURE REAL(wp) FUNCTION wrap_azimuth_deg(a, signed) RESULT(azi) + !! An azimuth [deg] in (-540, 540) wrapped into [0,360), or into (-180,180] when signed. + !! An angle within AZI_ROUNDOFF_DEG of the cut of the range is put on its included side + !! (0, or 180 when signed), and one within it of 0 is exactly 0: a tangent lying on the + !! cut, or along +X, has a round-off component across it whose sign would otherwise + !! report it at either end of the range, or at +-1e-13, from one row to the next. + REAL(wp), INTENT(IN) :: a + LOGICAL, INTENT(IN), OPTIONAL :: signed + LOGICAL :: sgn + sgn = .FALSE. + IF (PRESENT(signed)) sgn = signed + azi = a + IF (sgn) THEN + IF (azi > 180.0_wp) azi = azi - 360.0_wp + IF (azi <= -180.0_wp) azi = azi + 360.0_wp + IF (azi < -180.0_wp + AZI_ROUNDOFF_DEG) azi = 180.0_wp + ELSE + IF (azi < CD_ZERO) azi = azi + 360.0_wp + IF (azi >= 360.0_wp) azi = azi - 360.0_wp + IF (azi > 360.0_wp - AZI_ROUNDOFF_DEG) azi = CD_ZERO + END IF + IF (ABS(azi) < AZI_ROUNDOFF_DEG) azi = CD_ZERO + END FUNCTION wrap_azimuth_deg + + PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride, signed) RESULT(v) !! Shared evaluator for the GEOMETRIC output channels so every writer computes them !! identically. `q_flat` holds the line node positions in INTERNAL order !! (anchor->fairlead) with `stride` reals per node (3 for EI=0, 6 for finite-EI). @@ -32920,9 +33205,10 @@ PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride) R !! 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 - !! kind = 6 returns 0. + !! 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(:) + LOGICAL, INTENT(IN), OPTIONAL :: signed REAL(wp) :: r(3, nnode) INTEGER :: j, base ! Deck node j (1 = End A) <-> internal node (nnode+1-j); extract deck-ordered positions. @@ -32930,16 +33216,18 @@ PURE REAL(wp) FUNCTION line_geom_value(kind, deck_node, nnode, q_flat, stride) R base = stride*(nnode - j) r(:, j) = q_flat(base + 1:base + 3) END DO - v = line_geom_from_r(kind, r, nnode, deck_node) + v = line_geom_from_r(kind, r, nnode, deck_node, signed) END FUNCTION line_geom_value - PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node) RESULT(v) + PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node, signed) RESULT(v) !! Geometric channel value (kind: 5 curvature, 7 declination, 8 azimuth) from the !! deck-ordered node positions r(3, nnode). Factored out of line_geom_value so a caller !! that writes EVERY node of a line (the .static.out profile) builds r ONCE per line !! rather than rebuilding it inside each per-node call -- O(nnode) instead of O(nnode^2). + !! signed: the line's azimuth range (DeckLine%azi_signed). INTEGER, INTENT(IN) :: kind, nnode, deck_node REAL(wp), INTENT(IN) :: r(3, nnode) + LOGICAL, INTENT(IN), OPTIONAL :: signed v = CD_ZERO SELECT CASE (kind) CASE (5) ! curvature [1/m] (OrcaFlex "Curvature" is the geometric centreline curvature) @@ -32947,7 +33235,7 @@ PURE REAL(wp) FUNCTION line_geom_from_r(kind, r, nnode, deck_node) RESULT(v) CASE (7) ! declination [deg] v = tangent_declination_deg(deck_node_tangent(r, nnode, deck_node)) CASE (8) ! azimuth [deg] - v = tangent_azimuth_deg(deck_node_tangent(r, nnode, deck_node)) + v = tangent_azimuth_deg(deck_node_tangent(r, nnode, deck_node), signed) END SELECT END FUNCTION line_geom_from_r @@ -34299,7 +34587,7 @@ SUBROUTINE eval_system_line_channel(system, li, ch, val, ErrStat, ErrMsg) CASE (4) ! acceleration val = a(3*(inode - 1) + comp) CASE DEFAULT ! curvature (5) / bend moment (6, EI=0 => 0) / declination (7) / azimuth (8) - val = line_geom_value(kind, node, nnode, q, 3) + val = line_geom_value(kind, node, nnode, q, 3, system%lines(li)%azimuth_signed) END SELECT END BLOCK END SUBROUTINE eval_system_line_channel @@ -34487,9 +34775,10 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) END IF END BLOCK CASE (8) ! azimuth: local-frame azimuth plus the cable's frame heading, wrapped - val = line_geom_value(kind, node, nnode, cable%line%q(1:6*nnode), 6) + val = line_geom_value(kind, node, nnode, cable%line%q(1:6*nnode), 6, cable%azimuth_signed) IF (.NOT. cable_frame_is_identity(cable)) THEN - val = MODULO(val + ATAN2(cable%frame_s, cable%frame_c)*45.0_wp/QUARTER_PI, 360.0_wp) + val = wrap_azimuth_deg(val + ATAN2(cable%frame_s, cable%frame_c)*45.0_wp/QUARTER_PI, & + cable%azimuth_signed) END IF CASE DEFAULT ! declination (7) -- rotation-invariant geometric scalar val = line_geom_value(kind, node, nnode, cable%line%q(1:6*nnode), 6) diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index a1ca388c..7f80f50b 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -189,6 +189,9 @@ MODULE CableDyn_Model !! Persistent positions-only EI=0 model state and immutable mesh/properties. LOGICAL :: initialized = .FALSE. LOGICAL :: tension_only = .FALSE. + ! The range of the line's tangent azimuth channels: (-180, 180] when set, otherwise + ! [0, 360) (the deck line's, set by the deck driver that builds the model). + LOGICAL :: azimuth_signed = .FALSE. INTEGER :: n_dof = 0 INTEGER :: n_elem = 0 INTEGER, ALLOCATABLE :: elem_conn(:, :) @@ -6473,6 +6476,7 @@ SUBROUTINE CD_Copy_Model(src, dst, ErrStat, ErrMsg) ! released automatically on every early return. The final assignment is the single commit point. work%tension_only = src%tension_only + work%azimuth_signed = src%azimuth_signed work%n_dof = src%n_dof work%n_elem = src%n_elem work%has_seabed = src%has_seabed diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index c7533c28..4ea5e7d3 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -109,6 +109,9 @@ MODULE CableDyn_OpenFAST_HermiteFMF ! kinematics IN (global -> local) and loads OUT (local -> global), so every caller ! works purely in global coordinates. Identity (1, 0) leaves all paths bit-for-bit. REAL(wp) :: frame_c = 1.0_wp, frame_s = 0.0_wp + ! The range of the cable's tangent azimuth channels: (-180, 180] when set, otherwise + ! [0, 360) (the deck line's, set by the deck driver that builds the cable). + LOGICAL :: azimuth_signed = .FALSE. ! A finite or rigid connection at the coupled endpoint is attached to the host, so its ! no-moment direction is expressed in parent axes and rotates with the input ! mesh orientation. The DCM convention is OpenFAST's global-to-parent matrix. diff --git a/tests/data/msg_weightless_finite_ei_vertical.dat b/tests/data/msg_weightless_finite_ei_vertical.dat new file mode 100644 index 00000000..b0b52c6b --- /dev/null +++ b/tests/data/msg_weightless_finite_ei_vertical.dat @@ -0,0 +1,37 @@ +--------------------- CableDyn Input File --- +msg_weightless_finite_ei_vertical +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +neut 0.2 32.2013247 100000000 -1 10000 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -20 0 0 0 0 +2 Fixed 0 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pt +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 neut 120 120 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/test_driver_channels.f90 b/tests/test_driver_channels.f90 index a938f913..41bba17e 100644 --- a/tests/test_driver_channels.f90 +++ b/tests/test_driver_channels.f90 @@ -38,6 +38,7 @@ PROGRAM test_driver_channels CALL test_finite_straight_bendmom() CALL test_motion_accel_channels() CALL test_fail_closed() + CALL test_azimuth_ranges() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -58,6 +59,12 @@ SUBROUTINE require(cond, label) END IF END SUBROUTINE require + LOGICAL FUNCTION exact(a, b) RESULT(same) + !! a equals b bit for bit (order comparisons, which -Wcompare-reals accepts). + REAL(wp), INTENT(IN) :: a, b + same = .NOT. (a < b .OR. a > b) + END FUNCTION exact + ! ---- independent reference geometry (NOT the production code) ---- REAL(wp) FUNCTION ref_curv(p1, p2, p3) RESULT(k) @@ -532,6 +539,128 @@ END SUBROUTINE read_out_table ! ---- deck fixtures ---- + ! ---- Azimuth range of a line: (-180, 180] near +X, [0, 360) otherwise ---- + + SUBROUTINE test_azimuth_ranges() + !! A line whose static chord (End A -> End B) heads within 45 deg of +X reports its tangent + !! azimuths in (-180, 180], every other line in [0, 360), so a line swaying about +X no longer + !! jumps between 0 and 360. A round-off component across the cut of the range reads on its + !! included side, and one across +X reads exactly 0. + INTEGER :: es, ok, u, ios, lineid, node, n1, n2, n3 + LOGICAL :: conv + CHARACTER(256) :: em + CHARACTER(2048) :: hdr, buf + REAL(wp) :: v(6), a3_min, a3_max, s, x, y, z, tn, cv, bm, dc, inc, az, a1_min, a1_max, a2_min, a2_max + REAL(wp), PARAMETER :: HEAD = 2.862405226111748_wp ! ATAN2(20, 400) [deg] + + CALL require(exact(tangent_azimuth_deg([1.0_wp, -1.0e-17_wp, 0.0_wp]), 0.0_wp), & + 'round-off just below +x reads exactly 0, not 360') + CALL require(exact(tangent_azimuth_deg([1.0_wp, -1.0e-17_wp, 0.0_wp], .TRUE.), 0.0_wp), & + 'round-off just below +x reads exactly 0 in the signed range') + CALL require(ABS(tangent_azimuth_deg([1.0_wp, -1.0e-3_wp, 0.0_wp]) - (360.0_wp - 1.0e-3_wp*DEG)) < 1.0e-6_wp, & + 'a heading just below +x is 359.94 deg in [0, 360)') + CALL require(ABS(tangent_azimuth_deg([1.0_wp, -1.0e-3_wp, 0.0_wp], .TRUE.) + 1.0e-3_wp*DEG) < 1.0e-6_wp, & + 'a heading just below +x is -0.057 deg in (-180, 180]') + CALL require(ABS(tangent_azimuth_deg([0.0_wp, -1.0_wp, 0.0_wp], .TRUE.) + 90.0_wp) < 1.0e-10_wp, & + 'signed azimuth -y = -90 deg') + CALL require(exact(tangent_azimuth_deg([-1.0_wp, 0.0_wp, 0.0_wp], .TRUE.), 180.0_wp), 'signed azimuth -x = 180 deg') + CALL require(exact(tangent_azimuth_deg([-1.0_wp, -1.0e-17_wp, 0.0_wp], .TRUE.), 180.0_wp), & + 'round-off just below -x reads 180 in the signed range, not -180') + + ! Three lines, each from a fairlead (End A) to an anchor 400 m away: line 1 heads 2.86 deg + ! below +X (the signed range), line 2 2.86 deg below -X and line 3 at 300 deg (the [0, 360) + ! range: 60 deg from +X). + CALL write_azimuth_deck('chan_azi.dat') + CALL CD_Run_Deck_Driver('chan_azi.dat', 'chan_azi', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'azimuth-range deck converged: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL read_out_table('chan_azi.out', hdr, v, 6, ok) + CALL require(ok == 0, 'read azimuth-range .out') + IF (ok /= 0) RETURN + CALL require(ABS(v(2) + HEAD) < 1.0e-6_wp, 'L1N3Azi = -2.862 deg on a line heading below +X') + CALL require(ABS(v(3) + HEAD) < 1.0e-6_wp, 'L1N1Azi = -2.862 deg at End A') + CALL require(ABS(v(4) - (180.0_wp + HEAD)) < 2.0e-5_wp, 'L2N3Azi = 182.862 deg on a line heading below -X') + CALL require(ABS(v(5) - (180.0_wp + HEAD)) < 2.0e-5_wp, 'L2N1Azi = 182.862 deg at End A') + CALL require(ABS(v(6) - 300.0_wp) < 2.0e-5_wp, 'L3N3Azi = 300 deg on a line heading 60 deg below +X') + ! The static profile reports every node of each line in the line's range. + a1_min = HUGE(1.0_wp); a1_max = -HUGE(1.0_wp); a2_min = HUGE(1.0_wp); a2_max = -HUGE(1.0_wp) + a3_min = HUGE(1.0_wp); a3_max = -HUGE(1.0_wp) + n1 = 0; n2 = 0; n3 = 0 + OPEN (NEWUNIT=u, FILE='chan_azi.static.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL require(ios == 0, 'open chan_azi.static.out') + IF (ios /= 0) RETURN + DO lineid = 1, 3 + READ (u, '(A)', IOSTAT=ios) buf + END DO + DO + READ (u, '(A)', IOSTAT=ios) buf + IF (ios /= 0) EXIT + IF (LEN_TRIM(buf) == 0) CYCLE + READ (buf, *, IOSTAT=ios) lineid, node, s, x, y, z, tn, cv, bm, dc, inc, az + IF (ios /= 0) EXIT + IF (lineid == 1) THEN + n1 = n1 + 1; a1_min = MIN(a1_min, az); a1_max = MAX(a1_max, az) + ELSE IF (lineid == 2) THEN + n2 = n2 + 1; a2_min = MIN(a2_min, az); a2_max = MAX(a2_max, az) + ELSE + n3 = n3 + 1; a3_min = MIN(a3_min, az); a3_max = MAX(a3_max, az) + END IF + END DO + CLOSE (u) + CALL require(n1 == 21 .AND. n2 == 21 .AND. n3 == 21, 'static.out lists the three lines') + CALL require(ABS(a3_min - 300.0_wp) < 2.0e-5_wp .AND. ABS(a3_max - 300.0_wp) < 2.0e-5_wp, & + 'static.out Azimuth of line 3 is 300 deg at every node') + CALL require(ABS(a1_min + HEAD) < 1.0e-6_wp .AND. ABS(a1_max + HEAD) < 1.0e-6_wp, & + 'static.out Azimuth of line 1 is -2.862 deg at every node') + CALL require(ABS(a2_min - (180.0_wp + HEAD)) < 2.0e-5_wp .AND. ABS(a2_max - (180.0_wp + HEAD)) < 2.0e-5_wp, & + 'static.out Azimuth of line 2 is 182.862 deg at every node') + WRITE (*, '(A,F10.5,A,F10.5)') 'azimuth ranges: L1N3Azi=', v(2), ' L2N3Azi=', v(4) + END SUBROUTINE test_azimuth_ranges + + SUBROUTINE write_azimuth_deck(path) + !! Three EI = 0 chains on a flat seabed, each from a fairlead at the surface to an anchor 400 m + !! away horizontally: lines 1 and 2 toward +X and -X with the anchor 20 m toward -Y, line 3 + !! at 300 deg. + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u, ios + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + WRITE (u, '(A)') 'azimuth-range deck' + 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)') 'chain 0.252 390.0 1.674e9 -1.0 0.0 1.37 0.64 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 10.0 0.0 0.0' + WRITE (u, '(A)') '2 Fixed 410.0 -20.0 -50.0' + WRITE (u, '(A)') '3 Coupled -10.0 0.0 0.0' + WRITE (u, '(A)') '4 Fixed -410.0 -20.0 -50.0' + WRITE (u, '(A)') '5 Coupled 0.0 10.0 0.0' + WRITE (u, '(A)') '6 Fixed 200.0 -336.41016151377546 -50.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 4 -' + WRITE (u, '(A)') '3 5 6 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 chain 410.0 20' + WRITE (u, '(A)') '2 chain 410.0 20' + WRITE (u, '(A)') '3 chain 410.0 20' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'L1N3Azi L1N1Azi L2N3Azi L2N1Azi L3N3Azi' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_azimuth_deck + SUBROUTINE write_static_channels_deck(path, explicit_decl) !! WD0050 grounded chain (EI=0 static) requesting the full geometric channel set. !! explicit_decl requests columns 4-5 by their FairDecl/AnchDecl spelling instead of the diff --git a/tests/test_flagship_compression_note.f90 b/tests/test_flagship_compression_note.f90 index 47ab8401..3b53933a 100644 --- a/tests/test_flagship_compression_note.f90 +++ b/tests/test_flagship_compression_note.f90 @@ -18,6 +18,9 @@ PROGRAM test_flagship_compression_note !! !! A deck whose finite-EI elements are shorter than sqrt(EI/EA) (the conditioning limit !! of the static Newton system) carries the fine-mesh note; the flagship does not. + !! + !! A weightless finite-EI line longer than its span, solved by weight continuation, returns + !! the note that its bow was chosen downward to the aggregate caller, which prints nothing. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Branch_Audit, CD_HermiteBranchAuditType, CD_HCSTAT_OK @@ -133,6 +136,7 @@ PROGRAM test_flagship_compression_note CALL CD_AGG_End(agg, es, em) CALL case_fine_mesh_note() + CALL case_weightless_bow_note() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' flagship compression-note check(s) failed' @@ -185,6 +189,51 @@ SUBROUTINE case_fine_mesh_note() CALL CD_AGG_End(small, es_s, em_s) END SUBROUTINE case_fine_mesh_note + SUBROUTINE case_weightless_bow_note() + !! A neutrally buoyant 120 m line, EI 1e4 N m^2, pinned 113 m apart (the elastica of + !! tests/test_light_slack_statics.py). + TYPE(CD_AGG_ModuleType), SAVE :: light + INTEGER :: u, es_l + CHARACTER(512) :: em_l + OPEN (NEWUNIT=u, FILE='weightless_bow_note.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'weightless finite-EI line longer than its span' + 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)') 'light 0.2 32.2013247 1.0e8 -1 1.0e4 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 -20.0' + WRITE (u, '(A)') '2 Fixed 80.0 0.0 -100.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 light 120.0 120' + 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)') '--- need this line ---' + CLOSE (u) + CALL CD_AGG_Init_From_Deck(light, 'weightless_bow_note.dat', 0.025_wp, es_l, em_l) + CALL check(es_l == CD_AGG_OK, 'weightless line initialises in the aggregate: '//TRIM(em_l)) + IF (es_l /= CD_AGG_OK) RETURN + IF (ALLOCATED(light%init_lines)) THEN + WRITE (*, '(2A)') ' note: ', TRIM(light%init_lines(1)%note) + CALL check(INDEX(light%init_lines(1)%note, 'is weightless and longer than its span') > 0 .AND. & + INDEX(light%init_lines(1)%note, 'bowed downward') > 0, & + 'the aggregate caller receives the weightless-bow note') + ELSE + CALL check(.FALSE., 'weightless line records its init summary') + END IF + CALL CD_AGG_End(light, es_l, em_l) + END SUBROUTINE case_weightless_bow_note + SUBROUTINE check(ok, label) LOGICAL, INTENT(IN) :: ok CHARACTER(*), INTENT(IN) :: label diff --git a/tests/test_light_slack_statics.py b/tests/test_light_slack_statics.py new file mode 100644 index 00000000..db446cf6 --- /dev/null +++ b/tests/test_light_slack_statics.py @@ -0,0 +1,201 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Static equilibrium of a finite-EI line longer than its span with little or no net weight. + +Such a line cannot hang as a catenary: it bows under the axial compression its bending stiffness +carries (the Euler elastica). Gates, each on the driver's own output files, for a 120 m line +pinned at both ends 113 m apart on a chord inclined 45 deg: + +* weightless: the line solves, the run notes that nothing chooses the plane or side of the bow, + the bow lies in the vertical plane of the chord on its lower side, and its end thrust and + mid-span bow are those of the inextensible pinned-pinned elastica (P = 4 K(m)^2 EI/L^2 and + delta = sqrt(m) L/K(m), with chord/L = 2 E(m)/K(m) - 1); so too with both ends Fixed (legal in + a deck with a dynamic point: a weighted Connect point on two chains, well clear of the line); +* light: with a net weight of +1e-3 N/m (heavy) or -1e-3 N/m (buoyant) the line solves with no + such note and bows down or up, its end forces within its whole weight of the elastica's thrust; +* dynamics: a march from the weightless equilibrium stays at rest. + +usage: test_light_slack_statics.py --exe --output +""" + +from __future__ import annotations + +import argparse +import math +import subprocess +import sys +from pathlib import Path + +import numpy as np +from scipy.optimize import brentq +from scipy.special import ellipe, ellipk + +G, RHO = 9.80665, 1025.0 +DIAM, EA, EI, LENGTH, NSEG = 0.2, 1.0e8, 1.0e4, 120.0, 120 +END_A = np.array([0.0, 0.0, -20.0]) +END_B = np.array([80.0, 0.0, -100.0]) +FAILURES: list[str] = [] + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +def elastica() -> tuple[float, float]: + """End thrust [N] and mid-span bow [m] of the inextensible pinned-pinned elastica.""" + ratio = np.linalg.norm(END_B - END_A) / LENGTH + m = brentq(lambda m: 2.0 * ellipe(m) / ellipk(m) - 1.0 - ratio, 1.0e-12, 0.99) + k = ellipk(m) + return 4.0 * k * k * EI / LENGTH ** 2, math.sqrt(m) * LENGTH / k + + +def write_deck(path: Path, weight: float, tmax: float = 0.0, end_a: str = "Coupled") -> None: + """The line with a net weight [N/m] (0: neutrally buoyant to the 7 digits written).""" + mass = RHO * math.pi * DIAM ** 2 / 4.0 + weight / G + crowfoot = end_a == "Fixed" + if crowfoot: + tmax = max(tmax, 0.05) + outputs = ["FairTen1", "AnchTen1"] + if tmax > 0.0: + outputs += ["L1N61PX", "L1N61PY", "L1N61PZ"] + path.write_text("\n".join([ + "--------------------- CableDyn Input File ---", + "light slack finite-EI line", + "--------------------- LINE TYPES ---", + "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t", + "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)", + f"light {DIAM} {mass:.7f} {EA:.6g} -1 {EI:.6g} 1.2 0.1 1 0", + *(["chain 0.2 250.0 1.0e9 -1 0.0 1.2 0.6 1 0"] if crowfoot else []), + "--------------------- POINTS ---", + "ID Type X Y Z Mass Vol CdA Ca", + "(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)", + "1 {} {:g} {:g} {:g} 0 0 0 0".format(end_a, *END_A), + "2 Fixed {:g} {:g} {:g} 0 0 0 0".format(*END_B), + *(["3 Fixed -100 300 -20 0 0 0 0", "4 Connect 0 300 -80 5000 0 0 0", + "5 Fixed 100 300 -20 0 0 0 0"] if crowfoot else []), + "--------------------- LINES ---", + "ID NodeA NodeB Outputs", + "(-) (-) (-) (-)", + "1 1 2 -", + *(["2 3 4 -", "3 5 4 -"] if crowfoot else []), + "--------------------- SECTIONS ---", + "LineID LineType Length NumSegs", + "(-) (-) (m) (-)", + f"1 light {LENGTH:g} {NSEG}", + *(["2 chain 120 20", "3 chain 120 20"] if crowfoot else []), + "--------------------- OPTIONS ---", + "9.80665 g", + "1025.0 rhoW", + "200.0 WtrDpth", + "100000.0 kBot", + "1.0e4 cBot", + "0.05 dtM", + f"{tmax:g} TMax", + "--------------------- OUTPUTS ---", + *[f'"{c}"' for c in outputs], + "--------------------- need this line ---", + "", + ])) + + +def run(exe: str, workdir: Path, name: str, weight: float, tmax: float = 0.0, end_a: str = "Coupled"): + deck = workdir / f"{name}.dat" + write_deck(deck, weight, tmax, end_a) + proc = subprocess.run([exe, deck.name, name], cwd=workdir, capture_output=True, text=True, timeout=600) + return proc.returncode, proc.stdout + proc.stderr + + +def static_profile(path: Path) -> np.ndarray: + """Rows of the static profile: node, x, y, z, tension.""" + rows = [line.split() for line in path.read_text().splitlines()[3:] if line.strip()] + return np.array([[float(r[1]), float(r[3]), float(r[4]), float(r[5]), float(r[6])] for r in rows]) + + +def time_series(path: Path) -> tuple[list[str], np.ndarray]: + """Channel names and rows of a driver .out file.""" + lines = path.read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.split() and line.split()[0].startswith("Time")) + data = np.array([[float(v) for v in line.split()] for line in lines[head + 1:] + if line.strip() and not line.lstrip().startswith("(")]) + return lines[head].split(), data + + +def bow(mid: np.ndarray) -> np.ndarray: + """Offset of the mid-span node from the chord.""" + d = (END_B - END_A) / np.linalg.norm(END_B - END_A) + mid = mid - END_A + return mid - np.dot(mid, d) * d + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + work = Path(args.output) + work.mkdir(parents=True, exist_ok=True) + thrust, delta = elastica() + print(f"elastica: thrust {thrust:.5f} N, mid-span bow {delta:.5f} m") + + for name, end_a in (("weightless", "Coupled"), ("weightless_fixed", "Fixed")): + rc, log = run(args.exe, work, name, 0.0, end_a=end_a) + check(rc == 0, f"{name} line (End A {end_a}) solves (rc {rc})") + if rc != 0: + print(log) + continue + check("is weightless and longer than its span" in log and "bowed downward" in log, + f"{name}: the run notes the weightless bow and the side it was solved on") + if end_a == "Coupled": + prof = static_profile(work / f"{name}.static.out") + in_plane = np.all(prof[:, 2] == 0.0) + mid, ends = prof[len(prof) // 2, 1:4], (prof[0, 4], prof[-1, 4]) + else: + # the multibody route writes no static profile: its first output row is the equilibrium + names, data = time_series(work / f"{name}.out") + mid = data[0, [names.index("L1N61PX"), names.index("L1N61PY"), names.index("L1N61PZ")]] + in_plane = mid[1] == 0.0 + ends = (data[0, names.index("FairTen1")], data[0, names.index("AnchTen1")]) + b = bow(mid) + check(in_plane, f"{name}: the bow lies in the vertical plane of the chord") + check(b[2] < 0.0, f"{name}: the weightless line bows downward") + check(abs(ends[0] - thrust) < 1.0e-3 * thrust and abs(ends[1] - thrust) < 1.0e-3 * thrust, + f"{name}: end thrust {ends[0]:.5f} / {ends[1]:.5f} N = elastica {thrust:.5f} N") + check(abs(np.linalg.norm(b) - delta) < 1.0e-3 * delta, + f"{name}: mid-span bow {np.linalg.norm(b):.5f} m = elastica {delta:.5f} m") + + for name, weight, down in (("light_heavy", 1.0e-3, True), ("light_buoyant", -1.0e-3, False)): + rc, log = run(args.exe, work, name, weight) + check(rc == 0, f"{name} line ({weight:+g} N/m) solves (rc {rc})") + if rc != 0: + continue + check("is weightless" not in log, f"{name}: no weightless note") + prof = static_profile(work / f"{name}.static.out") + b = bow(prof[len(prof) // 2, 1:4]) + check((b[2] < 0.0) == down, f"{name} line bows {'down' if down else 'up'}ward") + # the end forces differ from the weightless thrust by at most the line's whole weight + check(max(abs(prof[0, 4] - thrust), abs(prof[-1, 4] - thrust)) <= abs(weight) * LENGTH, + f"{name}: end forces {prof[0, 4]:.4f} / {prof[-1, 4]:.4f} N within the line's weight " + f"{abs(weight) * LENGTH:.3f} N of the elastica's thrust") + + rc, log = run(args.exe, work, "weightless_march", 0.0, tmax=2.0) + check(rc == 0, f"march from the weightless equilibrium runs (rc {rc})") + if rc == 0: + names, data = time_series(work / "weightless_march.out") + mid = data[:, [names.index("L1N61PX"), names.index("L1N61PY"), names.index("L1N61PZ")]] + drift = np.max(np.linalg.norm(mid - mid[0], axis=1)) + ten = data[:, names.index("FairTen1")] + check(drift < 1.0e-6, f"the bow stays at rest (mid-span drift {drift:.2e} m)") + check(np.max(np.abs(ten - thrust)) < 1.0e-3 * thrust, "the end thrust stays at the elastica's") + + if FAILURES: + print(f"FAIL: {len(FAILURES)} check(s) failed") + return 1 + print("PASS: light slack finite-EI statics") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) From abd9ad6dc6365543d96e70d06416be7abec9d81e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 28 Oct 2026 14:02:25 +0900 Subject: [PATCH 11/51] feat(viv): cross-flow VIV on the coupled routes (#60) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MoorDyn-F runs its VIV model inside OpenFAST, but CableDyn refused `Cl > 0` on the aggregate route. That route serves OpenFAST, FAST.Farm and the standalone runner of a mixed `EI = 0` / finite-EI deck. This PR lifts the refusal on all three. ## Changes - **Lift on the aggregate.** The aggregate installs the lift on its finite-EI cables (`install_viv`), as the standalone Hermite march does. Its `EI = 0` lines already built it through `init_one_model`. The phase follows the host's fluid field (`CD_AGG_SetFluidFields`). - **Correction rewinds.** The in-memory snapshot/restore already carried the VIV state on both line kinds, so OpenFAST's correction iterations needed no change. - **OpenFAST checkpoint.** The state mirror (`x%states`) now carries the VIV state: the phase and the two running mean squares per node, then the averaging time. - An `EI = 0` line ends its span with this block. The block is sized by `CD_System_Line_VIV_MirrorSize` and goes through `CD_Get/Set_System_Line_VIV_State`, which sit over the model-level `CD_Get/Set_Model_VIV_State`. - A cable's mirror carries the same block before its torsion block (`CD_HFMF_VIVMirrorSize`). - A reload also sets the rollback and recovery copies of the state, and the in-step phase. - **Linearisation.** The variable registration covers the new blocks. Linearisation stays quasi-static, with no continuous states. - **Averaging window.** Without `VIVrmsWindow`, both line kinds average over MoorDyn's 500 steps of the deck `dtM`, also when OpenFAST steps CableDyn at a `dtM` adjusted to its `DT`. With no deck `dtM`, they average over 500 coupling steps. - **Single-cable entry.** `CD_Init_Deck_HermiteCable` applies no fluid field, so it still refuses `Cl > 0`. Its message now points to the aggregate. - **Python.** `DeckFile` drops the coupled/mixed refusal. On the coupled route it does not ask for water in the deck, since the host supplies it. - **Docs.** capabilities, coupling, theory, migrating, troubleshooting and CHANGELOG. ## Checks - **New `viv_coupled` test** (22 s). An `EI = 0` riser and a finite-EI cable (EI 1 N·m²) sit side by side on the coupled aggregate in a 0.15 m/s host current: each 100 m long at 50 kN, 50 segments. - Lock-in over 60–120 s: | | A/D | Frequency | |---|---|---| | Riser | 0.6645 | 0.292 Hz | | Cable | 0.6646 | 0.292 Hz | | MoorDyn-F | 0.662 | 0.293 Hz | | Standalone CableDyn | 0.665 | | - With `Cl = 0` both lines stay still (A/D below 4e-5). - Checkpoint restart, using the shell's rebuild recipe: it continues bit for bit. A rebuild without the VIV reload diverges. - A correction rewind repeats bit for bit. - Averaging window: deck `dtM` 0.001 s at a 0.01 s coupling step gives both line kinds 0.5 s; with no deck `dtM`, both get 5 s. - **OpenFAST 5 with `CompMooring = 5`.** This ran on the IEA-15 MW mixed deck with `Cl 0.8` on the lazy-wave cable, a SeaState 0.5 m/s current across it, no waves, 60 s. It was checkpointed at 30 s and restarted. - The restarted CableDyn and OpenFAST outputs are identical to the uninterrupted run at every row (max difference 0). - The lift raises the cable's lateral sway by 4–10 % along its span over the `Cl = 0` run. - **Test suite:** ctest 308/308; Python 793 passed. - **Examples:** all 52 shipped examples are unchanged. None uses `Cl > 0` on these routes. - **Format:** fprettify is clean. Remaining VIV refusals: a finite-EI line beside bodies, rods or free points (next PR), and a finite-EI line with two moving ends (the Cosserat compatibility element, which has no VIV). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 +- CMakeLists.txt | 5 + doc/capabilities.rst | 10 +- doc/coupling.rst | 3 +- doc/migrating.rst | 2 +- doc/options.rst | 6 +- doc/theory.rst | 8 +- doc/troubleshooting.rst | 4 - python/cabledyn/deck_file.py | 17 +- python/tests/test_deck_file.py | 7 +- src/CableDyn_DeckDriver.f90 | 24 +- src/CableDyn_Model.f90 | 77 ++++++ src/CableDyn_OpenFAST_HermiteFMF.f90 | 45 +++- src/CableDyn_System.f90 | 76 ++++++ src/openfast/CableDyn_OF.f90 | 64 ++++- tests/test_viv_coupled.f90 | 355 +++++++++++++++++++++++++++ 16 files changed, 655 insertions(+), 57 deletions(-) create mode 100644 tests/test_viv_coupled.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 678d4d7e..1093a611 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,7 @@ All notable changes to CableDyn are recorded in this file. The format follows with the same phase start and running-RMS window (`VIVrmsWindow`, default 500 steps of `dtM`). On a taut 100 m line in a uniform current it follows MoorDyn-F's lock-in amplitude and frequency to two to three digits through mode-1 and mode-3 lock-in, at any `dtM` from - 5e-4 to 1e-2 s. The Python deck tools read and keep the columns. The coupled and mixed - routes refuse `Cl > 0` by name. + 5e-4 to 1e-2 s. The Python deck tools read and keep the columns. - Cross-flow VIV of finite-EI cables in the standalone driver: the same LINE TYPES columns on an `EI > 0` type give a distributed lift, Gauss-integrated over each cubic-Hermite element with exact tangents, and a shedding phase at each node driven along the node's own tangent. A taut @@ -24,6 +23,12 @@ All notable changes to CableDyn are recorded in this file. The format follows 5e-4 to 1e-2 s without smoothing; a bending-stiff line matches the string of equal first-mode frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. A finite-EI line with two moving ends, or beside bodies, rods or free points, refuses `Cl > 0`. +- Cross-flow VIV on the coupled routes: OpenFAST (`CompMooring = 5`), FAST.Farm and the + standalone runner of a mixed `EI = 0` / finite-EI deck carry the lift on both line kinds, with + the host's fluid field. The phases, running mean squares and averaging time are part of the + checkpoint state and of the correction rewind, so a restart continues bit for bit. A riser and + a cable in a 0.15 m/s host current lock in at A/D 0.665 and 0.292 Hz, MoorDyn-F's 0.662 and + 0.293 Hz. - Bend stiffeners (`STIFFENERS` table): a tapered polyurethane sleeve over an end of a finite-EI line, given as conical segments from the root outward (outer diameters, bore, modulus, density). Each element it covers takes the compliance average of the cable-plus-sleeve diff --git a/CMakeLists.txt b/CMakeLists.txt index db960784..58831b66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1180,6 +1180,11 @@ target_link_libraries(test_hermite_viv PRIVATE cabledyn_core) add_test(NAME hermite_viv COMMAND test_hermite_viv) set_tests_properties(hermite_viv PROPERTIES LABELS "fortran;dynamic;viv") +add_executable(test_viv_coupled tests/test_viv_coupled.f90) +target_link_libraries(test_viv_coupled PRIVATE cabledyn_core) +add_test(NAME viv_coupled COMMAND test_viv_coupled WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(viv_coupled PROPERTIES LABELS "fortran;integration;dynamic;viv;openfast") + add_executable(test_hfmf_mirror tests/test_hfmf_mirror.f90) target_link_libraries(test_hfmf_mirror PRIVATE cabledyn_core) add_test(NAME hfmf_mirror COMMAND test_hfmf_mirror WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 68335dcb..c59c3e9c 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -114,12 +114,12 @@ Line and constitutive capability ``EI = 0`` lines, or all finite-EI lines on the Hermite route; flat seabed); a deck with torsion is rejected * - Cross-flow VIV (LINE TYPES ``Cl``, ``dF``, ``cF``) - - Standalone only + - Standalone and coupled - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on - finite-EI cables of the Hermite march (:ref:`theory-viv`); in-line VIV is not provided; - the coupled OpenFAST and FAST.Farm routes, mixed ``EI = 0`` / finite-EI decks, finite-EI - lines with two moving ends and finite-EI lines beside bodies, rods or free points refuse - ``Cl > 0`` by name + finite-EI cables of the Hermite march (: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; + finite-EI lines with two moving ends and finite-EI lines beside bodies, rods or free + points refuse ``Cl > 0`` by name Loads and environment --------------------- diff --git a/doc/coupling.rst b/doc/coupling.rst index 8ec85665..f1184768 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -56,8 +56,7 @@ solve is mathematically incorrect; changing ``NumCrctn`` does not change that de - deck ``waves``/``wavetrain`` OPTIONS (the host SeaState supplies the waves), and a deck ``current`` except as a steady current on a single-turbine, pure ``EI = 0`` deck without Rigid6 bodies or rods in a SeaState without waves or current (a WaterKin ``CurrentMod 1`` - table remains available), - - cross-flow VIV (a LINE TYPES ``Cl > 0``), which runs in the standalone driver only, and + table remains available), and - fluid-source combinations that the nodewise SeaState field cannot separate without double counting. diff --git a/doc/migrating.rst b/doc/migrating.rst index ba7cf3f1..b14d72fb 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -93,7 +93,7 @@ Keyword map - same row; the native order is ``Cd_n Cd_t Ca_n Ca_t`` and the header decides which is meant. ``EI > 0`` switches the line to the bending element. * - ``LINE TYPES`` VIV columns ``Cl`` or ``Cl dF cF`` - - same columns and the same synchronisation model in the standalone driver, on ``EI = 0`` + - same columns and the same synchronisation model, standalone and coupled, on ``EI = 0`` types and as a distributed lift on finite-EI types (:ref:`theory-viv`); the running-RMS window is ``VIVrmsWindow`` seconds, by default 500 steps of ``dtM`` as MoorDyn's diff --git a/doc/options.rst b/doc/options.rst index 7acce5e1..0783b8a3 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -681,10 +681,10 @@ Ambient fluid and prescribed motion - ``0`` - finite, ≥ 0; the averaging time of the running RMS cross-flow velocity and acceleration of the VIV synchronisation model (:ref:`theory-viv`). ``0`` takes MoorDyn's 500 steps of - ``dtM`` (of the first step when the deck has no ``dtM``); set it to compare runs at + the deck ``dtM``, also where OpenFAST steps CableDyn at a ``dtM`` adjusted to its ``DT`` + (500 steps of the first step when the deck has no ``dtM``); set it to compare runs at different ``dtM`` with the same averaging time - - standalone lines (``EI = 0``, or finite-EI on the Hermite march) with a LINE TYPES - ``Cl > 0`` + - lines with a LINE TYPES ``Cl > 0``, on every route - ``0.25 VIVrmsWindow`` * - ``motionFile`` - path, or ``0``/``none`` diff --git a/doc/theory.rst b/doc/theory.rst index 215a53f8..3e6d8682 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -779,8 +779,12 @@ pump, and the response is the same from ``dtM`` 5e-4 to 1e-2 s. A finite-EI line carries it, including deck waves and current through its held fluid field; a finite-EI line with two moving ends, or beside bodies, rods or free points, refuses :math:`C_L > 0`. -VIV runs in the standalone driver; the coupled and mixed aggregate routes refuse a deck with -:math:`C_L > 0`. +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 +coupled routes the phase follows the host's fluid field (a SeaState current or waves), and the +phases, the running mean squares and the averaging time are part of the checkpoint state, so a +restart continues the uninterrupted run bit for bit. The OpenFAST correction iterations rewind +them with the rest of the state. Buoyancy and wetting ~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 9fe01b00..330469fa 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -847,10 +847,6 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com - linearise a pinned-hang-off, uncontrolled variant of the deck; time-domain runs support both * - a ``Rigid`` end-connection direction reversed by exactly 180 degrees in one host update - drive the platform through intermediate orientations - * - VIV on the coupled or mixed route (``VIV (LINE TYPES Cl > 0) runs in the standalone driver - of an EI = 0 or finite-EI deck``) - - run the VIV study on a standalone ``EI = 0`` or finite-EI deck, or set ``Cl = 0`` for the - coupled run * - VIV on a finite-EI line with two moving ends (``needs its End B fixed``) or beside bodies, rods or free points (``does not run with bodies, rods or free points yet``) - fix End B of the line, or set ``Cl = 0`` for its line type diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index a3d1fe0d..7150a6a4 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2611,9 +2611,8 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: line_type_scales: dict[str, tuple[float, float]] = {} # name -> (BA, max Cd/Ca) line_type_meta: dict[str, tuple[float, float, float, float]] = {} line_type_gj: dict[str, float] = {} # name -> explicit GJ of a 14-column row, else 0 - # Cl > 0 on any LINE TYPES row (native CD_Init_Deck_Aggregate), and on an EI = 0 row - # (native init_one_model, which needs the line's Morison drag in water) - has_viv = False + # Cl > 0 on an EI = 0 row (native init_one_model, which needs the line's Morison drag in + # water) has_viv_ei0 = False viv_type_names: set[str] = set() for row in self.line_types: @@ -2703,7 +2702,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: VIV (Cl > 0) does not combine with the Syrope " "working-curve model" ) - has_viv = has_viv or cl > 0.0 has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) if cl > 0.0: viv_type_names.add(row.tokens[0].lower()) @@ -3490,12 +3488,6 @@ def end_key(token: str) -> str: ) if not line_ids: raise DeckFormatError(f"{self._label}: the coupled route needs at least one line") - if has_viv: - raise DeckFormatError( - f"{self._label}: VIV (LINE TYPES Cl > 0) runs in the standalone driver of an " - "EI = 0 or finite-EI deck; the coupled OpenFAST and FAST.Farm routes and mixed " - "EI = 0 / finite-EI decks do not carry it yet. Set Cl = 0 for this run" - ) if self.caller_driven: # native CD_Init_Deck_Aggregate: nothing on the coupled route evaluates deck # waves (the host SeaState supplies them). A deck current is a steady field on a @@ -3515,9 +3507,10 @@ def end_key(token: str) -> str: "single-turbine pure EI=0 deck without Rigid6 bodies or rods; remove the " "deck current OPTION (the host SeaState supplies the current)" ) - if has_viv_ei0 and deck_driver_route: + if has_viv_ei0 and not self.caller_driven: # native init_one_model: the lift acts with the line's Morison drag, which the - # deck switches on with water (a depth or bathymetry, a current, or waves) + # deck switches on with water (a depth or bathymetry, a current, or waves); on the + # coupled route the host supplies the water waterkin_option = option_by_key.get("waterkin") waterkin_text = "" if waterkin_option is None else waterkin_option.values[0] has_water = ( diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index c9fc05ed..bb4319ee 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4603,11 +4603,12 @@ def test_line_type_viv_is_accepted_on_a_finite_ei_line_type(tmp_path): assert (line_type.ei, line_type.cl) == (1.0e4, 0.8) -def test_viv_is_refused_on_the_coupled_route(): +def test_viv_is_accepted_on_the_coupled_route(): text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8")) DeckFile.from_text(text) - with pytest.raises(DeckFormatError, match="runs in the standalone driver"): - DeckFile.from_text(text, caller_driven=True) + DeckFile.from_text(text, caller_driven=True) + # the host supplies the water, so a deck without a depth is not refused there + DeckFile.from_text(_edit(text, ("50.0 WtrDpth\n", "")), caller_driven=True) def test_viv_needs_water_on_an_ei0_line(): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 5ddf4743..49f8f31f 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -3182,11 +3182,14 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable drag wiring failed: '//TRIM(em)); RETURN END IF ! Cross-flow VIV on the Cl > 0 sections, with the drag's diameters (CableDyn_VIV); an - ! OPTION VIVrmsWindow of 0 takes MoorDyn's 500 time steps. + ! OPTION VIVrmsWindow of 0 takes MoorDyn's 500 time steps of the deck dtM, as the EI = 0 + ! lines do (init_one_model), and of the coupling step dt where the deck gives none: a + ! coupled host may step the cable at a dt adjusted from the deck dtM. IF (PRESENT(install_viv)) THEN IF (install_viv .AND. ANY(viv_cl > CD_ZERO)) THEN CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & - MERGE(opts%viv_rms_window, REAL(CD_VIV_NM, wp)*dt, & + MERGE(opts%viv_rms_window, & + REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & opts%viv_rms_window > CD_ZERO), es, em) IF (es /= CD_HCDYN_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable VIV wiring failed: '//TRIM(em)); RETURN @@ -6754,8 +6757,8 @@ SUBROUTINE CD_Init_Deck_HermiteCable(deck_path, dt, cable, coupled_node, ErrStat 'use the aggregate facade with its external SeaState field'); RETURN END IF IF (line_has_viv(lines(1), types, sections)) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: VIV (LINE TYPES Cl > 0) runs in the standalone '// & - 'deck driver; set Cl = 0 for this entry'); RETURN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_HermiteCable: VIV (LINE TYPES Cl > 0) acts with an ambient '// & + 'fluid field, which this single-cable entry does not apply; use the aggregate facade'); RETURN END IF IF (opts%has_bathymetry_file) THEN CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & @@ -6984,16 +6987,6 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 'EI=0/finite-EI decks reject deck water kinematics)') RETURN END IF - ! Cross-flow VIV runs in the standalone driver (EI = 0 decks and finite-EI decks): the aggregate - ! route (OpenFAST, FAST.Farm, mixed EI = 0 / finite-EI decks) neither checkpoints its shedding - ! phase nor feeds it the host's fluid field yet. - IF (ANY(types%cl > CD_ZERO)) THEN - CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) runs in the standalone driver of an EI = 0 or '// & - 'finite-EI deck; '// & - 'the coupled OpenFAST and FAST.Farm routes and mixed EI = 0 / finite-EI decks do not carry it '// & - 'yet. Set Cl = 0 for this run') - RETURN - END IF IF (opts%waterkin_seastate) THEN IF (.NOT. PRESENT(external_fluid)) THEN @@ -7445,12 +7438,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (opts%has_bathymetry_file) THEN CALL build_one_hermite_cable(lines(i), sections, types, points, opts, dt, agg%cables(c), cn, es, em, & bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, & - init_note=agg%cable_note(c), & + init_note=agg%cable_note(c), install_viv=.TRUE., & fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_FULL, & deck_has_dynamic_points(points))) ELSE CALL build_one_hermite_cable(lines(i), sections, types, points, opts, 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))) END IF diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 7f80f50b..adf6de6f 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -96,6 +96,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Set_Model_Syrope_State PUBLIC :: CD_Set_Model_VIV PUBLIC :: CD_Latch_Model_VIV_Window + PUBLIC :: CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Model_Has_VIV PUBLIC :: CD_Get_Model_Tension PUBLIC :: CD_Get_Model_EndForces PUBLIC :: CD_Get_Model_EndNodeMassDiag @@ -3991,6 +3992,82 @@ SUBROUTINE CD_Latch_Model_VIV_Window(model, dt) model%viv_tw = REAL(CD_VIV_NM, wp)*dt END SUBROUTINE CD_Latch_Model_VIV_Window + SUBROUTINE CD_Get_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) + !! Copy the committed VIV state for a checkpoint: the shedding phase per node (n_nodes), + !! the running mean squares of the cross-flow velocity and acceleration (2, n_nodes), and + !! the averaging time (0 while unlatched). A model without VIV returns zeros. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: phi(:), ms(:, :), t_window + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + phi = CD_ZERO + ms = CD_ZERO + t_window = CD_ZERO + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_MODEL_NOT_INITIALIZED + ErrMsg = 'CableDyn_Model: model is not initialized' + RETURN + END IF + IF (SIZE(phi) /= model%n_dof/3 .OR. SIZE(ms, 1) /= 2 .OR. SIZE(ms, 2) /= model%n_dof/3) THEN + CALL fail(ErrStat, ErrMsg, 'VIV state outputs must have shapes (n_nodes) and (2, n_nodes)') + RETURN + END IF + IF (.NOT. model%has_viv) RETURN + phi = model%viv_phi + ms = model%viv_ms + t_window = model%viv_tw + END SUBROUTINE CD_Get_Model_VIV_State + + SUBROUTINE CD_Set_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) + !! Overwrite the committed VIV state from a checkpoint (see CD_Get_Model_VIV_State). + !! Fails closed on a model without VIV, a shape mismatch, non-finite values, a negative + !! mean square or averaging time. + TYPE(CD_ModelType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: phi(:), ms(:, :), t_window + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_MODEL_NOT_INITIALIZED + ErrMsg = 'CableDyn_Model: model is not initialized' + RETURN + END IF + IF (.NOT. model%has_viv) THEN + CALL fail(ErrStat, ErrMsg, 'model carries no VIV state to set') + RETURN + END IF + IF (SIZE(phi) /= model%n_dof/3 .OR. SIZE(ms, 1) /= 2 .OR. SIZE(ms, 2) /= model%n_dof/3) THEN + CALL fail(ErrStat, ErrMsg, 'VIV state inputs must have shapes (n_nodes) and (2, n_nodes)') + RETURN + END IF + IF (.NOT. (CD_All_Finite(phi) .AND. CD_All_Finite(ms) .AND. CD_Is_Finite(t_window))) THEN + CALL fail(ErrStat, ErrMsg, 'VIV state mirror must be finite') + RETURN + END IF + IF (ANY(ms < CD_ZERO) .OR. t_window < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'VIV mean squares and averaging time must be non-negative') + RETURN + END IF + model%viv_phi = phi + model%viv_ms = ms + model%viv_tw = t_window + ! the rollback and recovery twins follow (see CD_Set_Model_VE_Dl1) + model%viv_phi_rollback = phi + model%viv_ms_rollback = ms + model%recovery_viv_phi = phi + model%recovery_viv_ms = ms + model%viv_phi_eval = phi + END SUBROUTINE CD_Set_Model_VIV_State + + PURE LOGICAL FUNCTION CD_Model_Has_VIV(model) RESULT(has) + !! True if the model carries the cross-flow VIV phase state. + TYPE(CD_ModelType), INTENT(IN) :: model + has = model%has_viv + END FUNCTION CD_Model_Has_VIV + SUBROUTINE viv_node_coef(model, q, nd, coef, uu) !! Lift scale of interior node nd at positions q, sum over its two elements of !! (1/2 l0_e w_e)(1/2 rho D_e Cl_e) with w_e the wetted fraction under the drag waterline diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 4ea5e7d3..5871b946 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -87,6 +87,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_BoundaryMirrorSize PUBLIC :: CD_HFMF_ForceMirrorSize PUBLIC :: CD_HFMF_TorsionMirrorSize + PUBLIC :: CD_HFMF_VIVMirrorSize PUBLIC :: CD_HFMF_PackMirror PUBLIC :: CD_HFMF_UnpackMirror PUBLIC :: CD_HFMF_End @@ -1532,14 +1533,14 @@ INTEGER FUNCTION CD_HFMF_MirrorSize(self) RESULT(n) !! is re-derived by CD_Recompute_System_Acceleration) the cable reloads it exactly. !! A cable on a frictional seabed appends its stick-slip friction anchors, (x, y) per !! node (CD_HFMF_FrictionMirrorSize slots): they are committed state like q. Then come - !! the committed boundary (CD_HFMF_BoundaryMirrorSize), the force-blend state and the - !! torsion state. Zero if uninitialised. + !! the committed boundary (CD_HFMF_BoundaryMirrorSize), the force-blend state, the VIV + !! state and the torsion state. Zero if uninitialised. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN IF (ALLOCATED(self%line%freemask)) n = 3*COUNT(self%line%freemask) n = n + CD_HFMF_FrictionMirrorSize(self) + CD_HFMF_BoundaryMirrorSize(self) + & - CD_HFMF_ForceMirrorSize(self) + CD_HFMF_TorsionMirrorSize(self) + CD_HFMF_ForceMirrorSize(self) + CD_HFMF_VIVMirrorSize(self) + CD_HFMF_TorsionMirrorSize(self) END FUNCTION CD_HFMF_MirrorSize INTEGER FUNCTION CD_HFMF_BoundaryMirrorSize(self) RESULT(n) @@ -1576,6 +1577,16 @@ INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) IF (self%line%force_blend) n = 1 + self%line%ndof END FUNCTION CD_HFMF_ForceMirrorSize + INTEGER FUNCTION CD_HFMF_VIVMirrorSize(self) RESULT(n) + !! Mirror slots of the cross-flow VIV state, before the torsion block: the shedding phase + !! per node, the running mean squares of the cross-flow velocity and acceleration per node + !! (interleaved) and the averaging time (3 nn + 1 values); zero without VIV. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + n = 0 + IF (.NOT. self%initialized) RETURN + IF (self%line%has_viv) n = 3*self%line%nn + 1 + END FUNCTION CD_HFMF_VIVMirrorSize + INTEGER FUNCTION CD_HFMF_FrictionMirrorSize(self) RESULT(n) !! Mirror slots of the stick-slip friction anchors (2 per node), zero without friction. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self @@ -1586,7 +1597,7 @@ END FUNCTION CD_HFMF_FrictionMirrorSize SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) !! Write the cable's continuous state into buf as [v_free; q_free; a_free], then the - !! friction, boundary, force-blend and torsion blocks -- the layout CD_HFMF_MirrorSize + !! friction, boundary, force-blend, VIV and torsion blocks -- the layout CD_HFMF_MirrorSize !! sizes. The mirror is written every mooring step and reloaded ONLY by a !! checkpoint-restart rebuild or the state-const CalcOutput restore !! (CD_HFMF_UnpackMirror); the module stays self-authoritative in normal marching. @@ -1644,6 +1655,12 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) END IF k = k + 1 + self%line%ndof END IF + IF (self%line%has_viv) THEN + buf(k + 1:k + self%line%nn) = self%line%viv_phi + buf(k + self%line%nn + 1:k + 3*self%line%nn) = RESHAPE(self%line%viv_ms, [2*self%line%nn]) + buf(k + 3*self%line%nn + 1) = self%line%viv_tw + k = k + 3*self%line%nn + 1 + END IF IF (self%line%torsion%active) THEN buf(k + 1) = self%line%torsion%theta buf(k + 2) = self%line%torsion%phi @@ -1704,6 +1721,15 @@ 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 + ! 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 + IF (ANY(buf(kb + 1:kb + 2*self%line%nn + 1) < CD_ZERO)) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_UnpackMirror: the VIV mean squares and averaging time must be non-negative' + RETURN + END IF + END IF k = 0 DO i = 1, self%line%ndof IF (self%line%freemask(i)) THEN @@ -1757,6 +1783,17 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) END IF k = k + 1 + self%line%ndof END IF + ! the VIV state, with the step-start copy of a recovering step and the in-step phase + IF (self%line%has_viv) THEN + self%line%viv_phi = buf(k + 1:k + self%line%nn) + self%line%viv_ms = RESHAPE(buf(k + self%line%nn + 1:k + 3*self%line%nn), [2, self%line%nn]) + self%line%viv_tw = buf(k + 3*self%line%nn + 1) + self%line%viv_phi_eval = self%line%viv_phi + self%line%viv_ms_next = self%line%viv_ms + self%line%ws_recovery_viv_phi = self%line%viv_phi + self%line%ws_recovery_viv_ms = self%line%viv_ms + k = k + 3*self%line%nn + 1 + END IF IF (self%line%torsion%active) THEN self%line%torsion%theta = buf(k + 1) self%line%torsion%phi = buf(k + 2) diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 7a2cd623..e46ab3c6 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -17,6 +17,7 @@ MODULE CableDyn_System CD_Get_Model_State, CD_Get_Model_Tension, & CD_Model_Has_Viscoelastic, CD_Get_Model_VE_Dl1, CD_Set_Model_VE_Dl1, & CD_Model_Has_Syrope, CD_Get_Model_Syrope_State, CD_Set_Model_Syrope_State, & + CD_Model_Has_VIV, CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, & CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & CD_Latch_Model_VIV_Window, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & @@ -77,6 +78,7 @@ MODULE CableDyn_System PUBLIC :: CD_Get_System_Line_Friction_Anchors PUBLIC :: CD_Set_System_Line_Friction_Anchors PUBLIC :: CD_Get_System_Line_Syrope_State + PUBLIC :: CD_System_Line_VIV_MirrorSize, CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State PUBLIC :: CD_Set_System_Line_Syrope_State PUBLIC :: CD_Get_System_PointBlocks PUBLIC :: CD_Get_System_Point_State @@ -948,6 +950,80 @@ SUBROUTINE CD_Get_System_Line_Syrope_State(system, line_index, slow, tmax, ErrSt ErrMsg = '' END SUBROUTINE CD_Get_System_Line_Syrope_State + PURE INTEGER FUNCTION CD_System_Line_VIV_MirrorSize(system, line_index) RESULT(n) + !! Reals of one contained line's VIV checkpoint block (CD_Get_System_Line_VIV_State): + !! 3 per node plus the averaging time, or 0 for a line without VIV. + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + n = 0 + IF (line_index < 1 .OR. line_index > system%n_lines) RETURN + IF (.NOT. CD_Model_Has_VIV(system%lines(line_index))) RETURN + n = 3*SIZE(system%lines(line_index)%viv_phi) + 1 + END FUNCTION CD_System_Line_VIV_MirrorSize + + SUBROUTINE CD_Get_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg) + !! One contained line's committed VIV state as a flat checkpoint block: the shedding + !! phases (n_nodes), the cross-flow velocity and acceleration mean squares interleaved + !! per node (2 n_nodes), then the averaging time. + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + REAL(wp), INTENT(OUT) :: buf(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: nn, es + CHARACTER(160) :: em + REAL(wp), ALLOCATABLE :: phi(:), ms(:, :) + + buf = CD_ZERO + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + IF (SIZE(buf) /= CD_System_Line_VIV_MirrorSize(system, line_index) .OR. SIZE(buf) == 0) THEN + CALL fail(ErrStat, ErrMsg, 'line VIV state block has the wrong size') + RETURN + END IF + nn = (SIZE(buf) - 1)/3 + ALLOCATE (phi(nn), ms(2, nn)) + CALL CD_Get_Model_VIV_State(system%lines(line_index), phi, ms, buf(3*nn + 1), es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_SYSTEM_SOLVEFAIL + ErrMsg = 'CableDyn_System: line VIV state query failed: '//TRIM(em) + RETURN + END IF + buf(1:nn) = phi + buf(nn + 1:3*nn) = RESHAPE(ms, [2*nn]) + ErrStat = CD_SYSTEM_OK + ErrMsg = '' + END SUBROUTINE CD_Get_System_Line_VIV_State + + SUBROUTINE CD_Set_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg) + !! Overwrite one contained line's VIV state from a checkpoint block (see + !! CD_Get_System_Line_VIV_State). + TYPE(CD_SystemType), INTENT(INOUT) :: system + INTEGER, INTENT(IN) :: line_index + REAL(wp), INTENT(IN) :: buf(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: nn, es + CHARACTER(160) :: em + + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + IF (SIZE(buf) /= CD_System_Line_VIV_MirrorSize(system, line_index) .OR. SIZE(buf) == 0) THEN + CALL fail(ErrStat, ErrMsg, 'line VIV state block has the wrong size') + RETURN + END IF + nn = (SIZE(buf) - 1)/3 + CALL CD_Set_Model_VIV_State(system%lines(line_index), buf(1:nn), RESHAPE(buf(nn + 1:3*nn), [2, nn]), & + buf(3*nn + 1), es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_SYSTEM_SOLVEFAIL + ErrMsg = 'CableDyn_System: line VIV state reload failed: '//TRIM(em) + RETURN + END IF + ErrStat = CD_SYSTEM_OK + ErrMsg = '' + END SUBROUTINE CD_Set_System_Line_VIV_State + SUBROUTINE CD_Set_System_Line_Syrope_State(system, line_index, slow, tmax, ErrStat, ErrMsg) !! Overwrite one contained line's per-element Syrope states from a checkpoint mirror !! (the cross-process restart reload). diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 8b26f507..a8a72f8f 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -93,7 +93,8 @@ MODULE CableDyn CD_AGG_WriteStaticProfile USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & CD_HFMF_FrictionMirrorSize, CD_HFMF_BoundaryMirrorSize, & - CD_HFMF_ForceMirrorSize, CD_HFMF_TorsionMirrorSize, CD_HFMF_OK + CD_HFMF_ForceMirrorSize, CD_HFMF_TorsionMirrorSize, CD_HFMF_VIVMirrorSize, & + CD_HFMF_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -112,6 +113,8 @@ MODULE CableDyn CD_Set_System_Line_VE_Dl1, & CD_System_Line_Has_Syrope, CD_Get_System_Line_Syrope_State, & CD_Set_System_Line_Syrope_State, & + CD_System_Line_VIV_MirrorSize, CD_Get_System_Line_VIV_State, & + CD_Set_System_Line_VIV_State, & CD_System_Line_Has_Friction, CD_Get_System_Line_Friction_Anchors, & CD_Set_System_Line_Friction_Anchors, & CD_Recompute_System_Acceleration, CD_SYSTEM_OK @@ -1089,6 +1092,9 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er RETURN END IF END IF + ! a line with cross-flow VIV ends its span with the VIV state (the shedding phase and + ! the two running mean squares per node, then the averaging time) + nstates = nstates + CD_System_Line_VIV_MirrorSize( Inst(id)%agg%sys%fast%system, il ) m%LineStateIsN(il) = nstates END DO ! finite-EI cables append their free-DOF [v_free; q_free; a_free] mirror after the mooring block @@ -3326,6 +3332,26 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) DEALLOCATE (CblLinVel) END DO + ! VIV states: the shedding phase and running mean squares per node and the averaging + ! time, the last block of a VIV line's span. Coverage-only, like the Syrope block. + DO il = 1, inst_%nlines + nve = CD_System_Line_VIV_MirrorSize( inst_%agg%sys%fast%system, il ) + IF (nve <= 0) CYCLE + LinStr = 'Line '//TRIM(Num2LStr(il)) + ALLOCATE (CblLinVel(nve), STAT=ErrStat2) + IF (ErrStat2 /= 0) THEN + CALL SetErrStat( ErrID_Fatal, 'Could not allocate line VIV lin-name work array.', & + ErrStat, ErrMsg, RoutineName ); RETURN + END IF + DO j = 1, nve + CblLinVel(j) = TRIM(LinStr)//' VIV state '//TRIM(Num2LStr(j)) + END DO + CALL MV_AddVar( Vars%x, TRIM(LinStr)//' VIV state', FieldScalar, DatLoc(CD_x_states), & + iAry=m%LineStateIsN(il) - nve + 1, Num=nve, Perturb=0.1_R8Ki, & + LinNames=CblLinVel ) + DEALLOCATE (CblLinVel) + END DO + ! finite-EI cable states: pack_state_mirror appends the free-DOF mirror ! [v_free; q_free] of each cable AFTER the EI=0 mooring block, at the x%states ! offset koff = LineStateIsN(nlines) (0 when there are no mooring lines). Register @@ -3342,10 +3368,11 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) IF (csz <= 0) CYCLE ! uninitialised cable contributes no states ! free DOFs; mirror = [v_free; q_free; a_free] then the friction anchors, the - ! committed boundary, the force-blend state and the torsion state (if any) + ! committed boundary, the force-blend state, the VIV state and the torsion state (if any) nf = (csz - CD_HFMF_FrictionMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_BoundaryMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_ForceMirrorSize( inst_%agg%cables(ic) ) - & + CD_HFMF_VIVMirrorSize( inst_%agg%cables(ic) ) - & CD_HFMF_TorsionMirrorSize( inst_%agg%cables(ic) ))/3 LinStr = 'Cable '//TRIM(Num2LStr(ic)) ! Build the per-DOF linearization names in an explicit pre-allocated loop, NOT an @@ -3379,8 +3406,8 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) LinNames=CblLinAcc ) DEALLOCATE (CblLinVel, CblLinPos, CblLinAcc) ! stick-slip friction anchors (x, y per node), the force-blend committed force - ! (flag + force) and the torsion state (Theta, Phi, end frames) after the acceleration - ! block: coverage-only, like the acceleration block + ! (flag + force), the VIV state and the torsion state (Theta, Phi, end frames) after + ! the acceleration block: coverage-only, like the acceleration block IF (csz > 3*nf) THEN ALLOCATE (CblLinVel(csz - 3*nf), STAT=ErrStat2) IF (ErrStat2 /= 0) THEN @@ -3721,6 +3748,23 @@ SUBROUTINE reload_interiors_ary(inst_, m, states, t_clock, ErrStat, ErrMsg) END IF END BLOCK END IF + ! VIV state reload: the last block of the line's span (mirrors pack_state_mirror) + nve = CD_System_Line_VIV_MirrorSize( inst_%agg%sys%fast%system, il ) + IF (nve > 0) THEN + IF (m%LineStateIsN(il) > SIZE(states)) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: line '//TRIM(Num2LStr(il))// & + ' VIV state mirror extends past the state vector.', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + BLOCK + REAL(wp) :: vbuf(nve) + vbuf = REAL(states(m%LineStateIsN(il) - nve + 1:m%LineStateIsN(il)), wp) + CALL CD_Set_System_Line_VIV_State( inst_%agg%sys%fast%system, il, vbuf, es, em ) + IF (es /= CD_SYSTEM_OK) THEN + CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + END BLOCK + END IF END DO CALL reload_cable_mirrors( inst_, m, states, t_clock, .FALSE., koff, ErrStat, ErrMsg ) IF (ErrStat >= AbortErrLev) RETURN @@ -4015,6 +4059,18 @@ SUBROUTINE pack_state_mirror_ary(inst_, m, states, ErrStat, ErrMsg) states(k + 3*nin + nve:k + 3*nin + 2*nve - 1) = REAL(tmx, DbKi) END BLOCK END IF + ! VIV state: the last block of the line's span + nve = CD_System_Line_VIV_MirrorSize( inst_%agg%sys%fast%system, il ) + IF (nve > 0) THEN + BLOCK + REAL(wp) :: vbuf(nve) + CALL CD_Get_System_Line_VIV_State( inst_%agg%sys%fast%system, il, vbuf, es, em ) + IF (es /= CD_SYSTEM_OK) THEN + CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + states(m%LineStateIsN(il) - nve + 1:m%LineStateIsN(il)) = REAL(vbuf, DbKi) + END BLOCK + END IF END DO ! finite-EI cables: append per-cable free-DOF [v_free; q_free; a_free] after the mooring block koff = 0 diff --git a/tests/test_viv_coupled.f90 b/tests/test_viv_coupled.f90 new file mode 100644 index 00000000..99fc075e --- /dev/null +++ b/tests/test_viv_coupled.f90 @@ -0,0 +1,355 @@ +! File: tests/test_viv_coupled.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viv_coupled + !! Cross-flow VIV on the coupled aggregate route (the OpenFAST and FAST.Farm shells and the + !! standalone mixed EI = 0 / finite-EI runner), on a deck with an EI = 0 riser and a finite-EI + !! cable (EI 1 N m^2) side by side: each 100 m long at 50 kN, D 0.1 m, 50 segments, ends held at + !! 50 m depth, Cl 0.8 with MoorDyn's band (dF 0.08, cF 0.18), in a uniform 0.15 m/s host current + !! across the lines (the deck of tests/test_viv_lockin.py). + !! + !! Gates: + !! * lock-in: over 60-120 s the mid-span cross-flow amplitude of both lines is MoorDyn-F's + !! A/D 0.662 within 0.03 and the response frequency its 0.293 Hz within 0.01 Hz; with Cl = 0 + !! the lines stay still (A/D below 0.01); + !! * checkpoint restart (the shell's rebuild recipe: a fresh instance takes the coupled + !! kinematics, each EI = 0 line's interior [v; q; a] and VIV block and each cable's mirror, + !! then the host field): the restarted run continues bit for bit, and a rebuild that skips the + !! VIV reload does not; + !! * correction rewind: a step taken after CD_AGG_Snapshot and repeated after CD_AGG_Restore + !! lands on the same state, phases included, bit for bit; + !! * averaging window: without VIVrmsWindow both line kinds average over MoorDyn's 500 steps + !! of the deck dtM, also when the coupling step differs from it (dtM 0.001 s at a 0.01 s + !! step: 0.5 s), and over 500 coupling steps when the deck has no dtM (5 s). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK, & + CD_AGG_NMovingPoints, CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & + CD_AGG_UpdateStates_Moving, CD_AGG_CalcOutput, CD_AGG_NFluidNodes, & + CD_AGG_SetFluidFields, CD_AGG_Snapshot, CD_AGG_Restore + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_VIVMirrorSize, CD_HFMF_PackMirror, & + CD_HFMF_UnpackMirror, CD_HFMF_OK + USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_Get_System_Line_State, & + CD_Update_System_Line_Interior_State, CD_System_Line_VIV_MirrorSize, & + CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State, CD_SYSTEM_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: DT = 0.01_wp, U = 0.15_wp, D = 0.1_wp + REAL(wp), PARAMETER :: MD_AD = 0.662_wp, MD_F = 0.293_wp + INTEGER, PARAMETER :: MID = 26 + INTEGER :: nfail + + nfail = 0 + CALL write_deck('viv_coupled.dat', 0.8_wp) + CALL write_deck('viv_coupled_nolift.dat', 0.0_wp) + CALL case_lockin() + CALL case_restart() + CALL case_rewind() + CALL case_window() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' coupled VIV check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: cross-flow VIV on the coupled aggregate route' + +CONTAINS + + SUBROUTINE case_lockin() + !! 120 s in the host current; the response statistics over 60-120 s. + INTEGER, PARAMETER :: NSTEP = 12000, NSKIP = 6000 + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: zs(NSTEP - NSKIP, 2), ad(2), f(2) + INTEGER :: pass, s, k + CHARACTER(16) :: what(2) = ['EI = 0 riser ', 'finite-EI cable '] + DO pass = 1, 2 + IF (.NOT. start(agg, MERGE('viv_coupled.dat ', 'viv_coupled_nolift.dat', pass == 1))) RETURN + DO s = 1, NSKIP + IF (.NOT. advance(agg)) RETURN + END DO + DO s = 1, NSTEP - NSKIP + IF (.NOT. advance(agg)) RETURN + zs(s, 1) = agg%sys%fast%system%lines(1)%q(3*MID) + zs(s, 2) = agg%cables(1)%line%q(6*(MID - 1) + 3) + END DO + CALL finish(agg) + DO k = 1, 2 + CALL response(zs(:, k), ad(k), f(k)) + IF (pass == 1) THEN + WRITE (*, '(2A,F7.4,A,F7.4,A)') ' ', what(k), ad(k), ' A/D at ', f(k), ' Hz (MoorDyn-F 0.662 at 0.293)' + CALL check(ABS(ad(k) - MD_AD) < 0.03_wp, TRIM(what(k))//' locks in at MoorDyn-F''s amplitude') + CALL check(ABS(f(k) - MD_F) < 0.01_wp, TRIM(what(k))//' locks in at MoorDyn-F''s frequency') + ELSE + WRITE (*, '(2A,ES10.3,A)') ' ', what(k), ad(k), ' A/D with Cl = 0' + CALL check(ad(k) < 0.01_wp, TRIM(what(k))//' stays still without the lift') + END IF + END DO + END DO + END SUBROUTINE case_lockin + + SUBROUTINE case_restart() + !! Checkpoint after 10 s, while the lock-in builds up; 50 steps on. + INTEGER, PARAMETER :: NPRE = 1000, NPOST = 50 + TYPE(CD_AGG_ModuleType) :: a, b, c + INTEGER :: s + LOGICAL :: same_b, same_c + IF (.NOT. start(a, 'viv_coupled.dat')) RETURN + DO s = 1, NPRE + IF (.NOT. advance(a)) RETURN + END DO + IF (.NOT. rebuild(a, b, .TRUE.)) RETURN + IF (.NOT. rebuild(a, c, .FALSE.)) RETURN + same_b = .TRUE. + same_c = .TRUE. + DO s = 1, NPOST + IF (.NOT. advance(a)) RETURN + IF (.NOT. advance(b)) RETURN + IF (.NOT. advance(c)) RETURN + same_b = same_b .AND. identical(a, b) + same_c = same_c .AND. identical(a, c) + END DO + CALL check(same_b, 'the restarted run continues bit for bit') + CALL check(.NOT. same_c, 'a restart without the VIV state does not') + CALL finish(a) + CALL finish(b) + CALL finish(c) + END SUBROUTINE case_restart + + SUBROUTINE case_rewind() + !! A correction iteration: snapshot, step, restore, the same step again. + TYPE(CD_AGG_ModuleType) :: a, b + INTEGER :: s, es + CHARACTER(512) :: em + IF (.NOT. start(a, 'viv_coupled.dat')) RETURN + IF (.NOT. start(b, 'viv_coupled.dat')) RETURN + DO s = 1, 500 + IF (.NOT. advance(a)) RETURN + IF (.NOT. advance(b)) RETURN + END DO + CALL CD_AGG_Snapshot(a, es, em) + CALL check(es == CD_AGG_OK, 'snapshot: '//TRIM(em)) + IF (.NOT. advance(a)) RETURN + CALL CD_AGG_Restore(a, es, em) + CALL check(es == CD_AGG_OK, 'restore: '//TRIM(em)) + DO s = 1, 20 + IF (.NOT. advance(a)) RETURN + IF (.NOT. advance(b)) RETURN + END DO + CALL check(identical(a, b), 'a rewound step repeats bit for bit') + CALL CD_AGG_End(a, es, em) + CALL CD_AGG_End(b, es, em) + END SUBROUTINE case_rewind + + SUBROUTINE case_window() + !! The default VIV averaging time of both line kinds, with and without a deck dtM. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: tw_line, tw_cable + INTEGER :: pass + CALL write_deck('viv_coupled_dtm.dat', 0.8_wp, window=0.0_wp, dtm=0.001_wp) + CALL write_deck('viv_coupled_nodtm.dat', 0.8_wp, window=0.0_wp) + DO pass = 1, 2 + IF (.NOT. start(agg, MERGE('viv_coupled_dtm.dat ', 'viv_coupled_nodtm.dat', pass == 1))) RETURN + IF (.NOT. advance(agg)) RETURN + tw_line = agg%sys%fast%system%lines(1)%viv_tw + tw_cable = agg%cables(1)%line%viv_tw + WRITE (*, '(A,2F8.4,A)') ' averaging window (line, cable): ', tw_line, tw_cable, ' s' + IF (pass == 1) THEN + CALL check(ABS(tw_line - 0.5_wp) < 1.0e-12_wp .AND. ABS(tw_cable - 0.5_wp) < 1.0e-12_wp, & + 'both line kinds average over 500 steps of the deck dtM at a coarser coupling step') + ELSE + CALL check(ABS(tw_line - 5.0_wp) < 1.0e-12_wp .AND. ABS(tw_cable - 5.0_wp) < 1.0e-12_wp, & + 'both line kinds average over 500 coupling steps without a deck dtM') + END IF + CALL finish(agg) + END DO + END SUBROUTINE case_window + + LOGICAL FUNCTION start(agg, path) RESULT(ok) + !! A host-fluid build of the deck at dt. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + CHARACTER(*), INTENT(IN) :: path + INTEGER :: es + CHARACTER(512) :: em + CALL CD_AGG_Init_From_Deck(agg, TRIM(path), DT, es, em, external_fluid=.TRUE.) + ok = es == CD_AGG_OK + CALL check(ok, 'init '//TRIM(path)//': '//TRIM(em)) + IF (ok) ok = agg%ncable == 1 .AND. agg%has_sys + IF (ok) ok = SIZE(agg%sys%fast%system%lines(1)%q) == 3*(MID*2 - 1) + CALL check(ok, 'one EI = 0 line and one cable of 50 elements are built') + END FUNCTION start + + LOGICAL FUNCTION advance(agg) RESULT(ok) + !! One coupling step with the ends held, after the host samples its current. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :) + INTEGER :: es, npt, ni + LOGICAL :: cv, st + CHARACTER(512) :: em + CALL set_current(agg) + npt = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, npt), vel(3, npt), acc(3, npt), load(3, npt)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em) + vel = 0.0_wp + acc = 0.0_wp + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em) + ok = es == CD_AGG_OK .AND. cv + IF (.NOT. ok) CALL check(.FALSE., 'step: '//TRIM(em)) + IF (ok) CALL CD_AGG_CalcOutput(agg, es, em) + END FUNCTION advance + + SUBROUTINE set_current(agg) + !! The host's uniform current U along +y over every fluid node, still surface at z = 0. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), ALLOCATABLE :: fv(:, :), fa(:, :), wl(:) + INTEGER :: es, nfl + CHARACTER(512) :: em + nfl = CD_AGG_NFluidNodes(agg, es, em) + ALLOCATE (fv(3, nfl), fa(3, nfl), wl(nfl)) + fv = 0.0_wp + fv(2, :) = U + fa = 0.0_wp + wl = 0.0_wp + CALL CD_AGG_SetFluidFields(agg, fv, fa, wl, es, em) + IF (es /= CD_AGG_OK) CALL check(.FALSE., 'host current: '//TRIM(em)) + END SUBROUTINE set_current + + LOGICAL FUNCTION rebuild(a, b, with_viv) RESULT(ok) + !! The shell's checkpoint rebuild of a into a fresh b: the coupled kinematics, each EI = 0 + !! line's interior [v; q; a] and (with_viv) its VIV block, each cable's mirror (which + !! carries the cable's VIV block; zeroed to the build's state when not with_viv). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: a, b + LOGICAL, INTENT(IN) :: with_viv + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), qL(:), vL(:), aL(:), buf(:), & + fresh(:) + INTEGER :: es, npt, il, ndof, nv, nvc + CHARACTER(512) :: em + ok = start(b, 'viv_coupled.dat') + IF (.NOT. ok) RETURN + npt = CD_AGG_NMovingPoints(a, es, em) + ALLOCATE (pos(3, npt), vel(3, npt), acc(3, npt), load(3, npt)) + CALL CD_AGG_GetMovingPointMesh(a, pos, vel, acc, load, es, em) + CALL CD_AGG_UpdateStates_Moving(b, pos, vel, acc, es, em) + ok = es == CD_AGG_OK + DO il = 1, CD_System_NLines(a%sys%fast%system, es, em) + ndof = CD_System_Line_NDOF(a%sys%fast%system, il, es, em) + ALLOCATE (qL(ndof), vL(ndof), aL(ndof)) + CALL CD_Get_System_Line_State(a%sys%fast%system, il, qL, vL, aL, es, em) + CALL CD_Update_System_Line_Interior_State(b%sys%fast%system, il, qL(4:ndof - 3), vL(4:ndof - 3), es, em, & + a_interior=aL(4:ndof - 3)) + ok = ok .AND. es == CD_SYSTEM_OK + nv = CD_System_Line_VIV_MirrorSize(a%sys%fast%system, il) + ok = ok .AND. nv == 3*(ndof/3) + 1 + IF (with_viv .AND. nv > 0) THEN + ALLOCATE (buf(nv)) + CALL CD_Get_System_Line_VIV_State(a%sys%fast%system, il, buf, es, em) + CALL CD_Set_System_Line_VIV_State(b%sys%fast%system, il, buf, es, em) + ok = ok .AND. es == CD_SYSTEM_OK + DEALLOCATE (buf) + END IF + DEALLOCATE (qL, vL, aL) + END DO + ALLOCATE (buf(CD_HFMF_MirrorSize(a%cables(1))), fresh(CD_HFMF_MirrorSize(b%cables(1)))) + CALL CD_HFMF_PackMirror(a%cables(1), buf, es, em) + nvc = CD_HFMF_VIVMirrorSize(a%cables(1)) + ok = ok .AND. nvc == 3*a%cables(1)%line%nn + 1 + IF (.NOT. with_viv) THEN + ! the cable's VIV block as the fresh build has it (the torsion-free cable ends with it) + CALL CD_HFMF_PackMirror(b%cables(1), fresh, es, em) + buf(SIZE(buf) - nvc + 1:) = fresh(SIZE(fresh) - nvc + 1:) + END IF + CALL CD_HFMF_UnpackMirror(b%cables(1), buf, a%cables(1)%line%t, es, em) + ok = ok .AND. es == CD_HFMF_OK + CALL check(ok, 'checkpoint rebuild: '//TRIM(em)) + END FUNCTION rebuild + + LOGICAL FUNCTION identical(a, b) RESULT(same) + !! Both lines' state and shedding phases are the same bits. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: a, b + same = MAXVAL(ABS(a%sys%fast%system%lines(1)%q - b%sys%fast%system%lines(1)%q)) <= 0.0_wp .AND. & + MAXVAL(ABS(a%sys%fast%system%lines(1)%viv_phi - b%sys%fast%system%lines(1)%viv_phi)) <= 0.0_wp .AND. & + MAXVAL(ABS(a%cables(1)%line%q - b%cables(1)%line%q)) <= 0.0_wp .AND. & + MAXVAL(ABS(a%cables(1)%line%viv_phi - b%cables(1)%line%viv_phi)) <= 0.0_wp + END FUNCTION identical + + SUBROUTINE response(z, ad, f) + !! Cross-flow amplitude A/D = sqrt(2) std(z)/D and the mean up-crossing frequency of z. + REAL(wp), INTENT(IN) :: z(:) + REAL(wp), INTENT(OUT) :: ad, f + REAL(wp) :: zm, t0, t1 + INTEGER :: i, n + zm = SUM(z)/SIZE(z) + ad = SQRT(2.0_wp*SUM((z - zm)**2)/SIZE(z))/D + n = 0 + t0 = 0.0_wp + t1 = 0.0_wp + DO i = 2, SIZE(z) + IF (z(i - 1) < zm .AND. z(i) >= zm) THEN + n = n + 1 + t1 = (REAL(i - 1, wp) + (zm - z(i - 1))/(z(i) - z(i - 1)))*DT + IF (n == 1) t0 = t1 + END IF + END DO + f = 0.0_wp + IF (n > 1) f = REAL(n - 1, wp)/(t1 - t0) + END SUBROUTINE response + + SUBROUTINE write_deck(path, cl, window, dtm) + !! The EI = 0 riser (line 1) and the finite-EI cable (line 2), 20 m apart across the current; + !! VIVrmsWindow 0.25 s unless window is given (0: none), and a deck dtM when dtm is given. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: cl + REAL(wp), INTENT(IN), OPTIONAL :: window, dtm + INTEGER :: u + REAL(wp) :: tw + CHARACTER(32) :: len_txt, cl_txt + WRITE (len_txt, '(F12.6)') 100.0_wp/(1.0_wp + 5.0e4_wp/5.0e7_wp) + WRITE (cl_txt, '(F4.2)') cl + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ---' + WRITE (u, '(A)') 'coupled VIV gate: taut riser and cable in a host cross current' + WRITE (u, '(A)') '--------------------- LINE TYPES ---' + WRITE (u, '(A)') 'TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx Cl dF cF' + WRITE (u, '(A)') '(name) (m) (kg/m) (N) (N-s/-) (-) (-) (-) (-) (-) (-) (-) (-)' + WRITE (u, '(A)') 'riser 0.10 10.0 5.0e7 -0.8 0.0 1.2 1.0 0.0 0.0 '//TRIM(cl_txt)//' 0.08 0.18' + WRITE (u, '(A)') 'cable 0.10 10.0 5.0e7 -0.8 1.0 1.2 1.0 0.0 0.0 '//TRIM(cl_txt)//' 0.08 0.18' + WRITE (u, '(A)') '--------------------- POINTS ---' + WRITE (u, '(A)') 'ID Attachment X Y Z M V CdA CA' + WRITE (u, '(A)') '(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + 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)') '3 Coupled 0.0 20.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 100.0 20.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--------------------- LINES ---' + WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' + WRITE (u, '(A)') '(#) (name) (#) (#) (m) (-) (-)' + WRITE (u, '(A)') '1 riser 1 2 '//TRIM(ADJUSTL(len_txt))//' 50 -' + WRITE (u, '(A)') '2 cable 3 4 '//TRIM(ADJUSTL(len_txt))//' 50 -' + WRITE (u, '(A)') '--------------------- OPTIONS ---' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '9.80665 g' + tw = 0.25_wp + IF (PRESENT(window)) tw = window + IF (tw > 0.0_wp) WRITE (u, '(F6.3,A)') tw, ' VIVrmsWindow' + IF (PRESENT(dtm)) WRITE (u, '(ES12.5,A)') dtm, ' dtM' + WRITE (u, '(A)') '--------------------- need this line ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE finish(agg) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + INTEGER :: es + CHARACTER(512) :: em + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE finish + + SUBROUTINE check(ok, label) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: label + IF (ok) THEN + WRITE (*, '(2A)') ' ok ', label + ELSE + WRITE (*, '(2A)') ' FAIL ', label + nfail = nfail + 1 + END IF + END SUBROUTINE check + +END PROGRAM test_viv_coupled From 47580d862cc2b174346aa2d6f82216a9af2e4f21 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 28 Oct 2026 15:35:21 +0900 Subject: [PATCH 12/51] feat(viv): cross-flow VIV of finite-EI cables on the multibody march (#61) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A finite-EI cable runs on the multibody march when its deck has a Rigid6 body or rod, or Free or Connect points. That march refused `Cl > 0`, so VIV of such a cable was not possible. This PR lifts the refusal. ## Changes - **Lift on the multibody march.** Its cable builds now pass `install_viv`, as the Hermite march's do. Both builds are covered: clamped and pinned. - **Fluid field.** The march already refreshes each cable's held fluid field every step, so the phase sees the deck's waves and current. - **Re-steps.** Each outer iteration and each step halving re-steps the cables from `CD_HFMF_Snapshot` / `CD_HFMF_Restore`. That pair already carries the VIV phase and running mean squares, so a re-step does not advance the phase twice. - **Python.** `DeckFile` drops the matching refusal. A finite-EI line with two moving ends still refuses `Cl > 0`: that is the Cosserat compatibility element, which has no VIV. - **Docs.** capabilities, theory, troubleshooting and CHANGELOG. ## Checks - **`viv_lockin`**, new case: the same 100 m finite-EI cable (EI 1 N·m², 0.15 m/s current) as the Hermite case, with End A Fixed. A 5 t Connect point hung on two chains 300 m away puts the deck on the multibody march. | Route | Mid / quarter A/D | Frequency | |---|---|---| | Multibody march | 0.662 / 0.421 | 0.300 Hz | | Hermite march | 0.662 / 0.421 | 0.300 Hz | The gate is within 1 % and one frequency bin. - **A cable on a moving buoy.** `buoy_clamped_cable` (a clamped cable on a moored Rigid6 buoy) with `Cl 0.8`, in current, ran 30 s on the monolithic body step: at most 3 outer iterations, no step halvings. - **Python:** `buoy_clamped_cable` with `Cl 0.8` passes the validator; it was refused before. - **Test suite:** ctest all green; Python 2064 passed. - **Examples:** all 52 shipped examples byte-identical to dev (none uses `Cl > 0` on the multibody march). - **Format:** fprettify and ruff are clean. Remaining VIV refusal: a finite-EI line with two moving ends. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 +++-- doc/capabilities.rst | 7 +++---- doc/theory.rst | 5 +++-- doc/troubleshooting.rst | 3 +-- python/cabledyn/deck_file.py | 15 --------------- python/tests/test_deck_file.py | 9 ++++----- src/CableDyn_DeckDriver.f90 | 8 ++------ tests/test_viv_lockin.py | 29 +++++++++++++++++++++++++++++ 8 files changed, 45 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1093a611..204025d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,8 +21,9 @@ All notable changes to CableDyn are recorded in this file. The format follows exact tangents, and a shedding phase at each node driven along the node's own tangent. A taut line with `EI` near zero reproduces the `EI = 0` lock-in to three digits, at any `dtM` from 5e-4 to 1e-2 s without smoothing; a bending-stiff line matches the string of equal first-mode - frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. A finite-EI - line with two moving ends, or beside bodies, rods or free points, refuses `Cl > 0`. + frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. The + multibody march carries it too (a cable on a Rigid6 body or rod, or beside free points), with + the same lock-in. A finite-EI line with two moving ends refuses `Cl > 0`. - Cross-flow VIV on the coupled routes: OpenFAST (`CompMooring = 5`), FAST.Farm and the standalone runner of a mixed `EI = 0` / finite-EI deck carry the lift on both line kinds, with the host's fluid field. The phases, running mean squares and averaging time are part of the diff --git a/doc/capabilities.rst b/doc/capabilities.rst index c59c3e9c..666b9511 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -116,10 +116,9 @@ Line and constitutive capability * - Cross-flow VIV (LINE TYPES ``Cl``, ``dF``, ``cF``) - Standalone and coupled - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on - finite-EI cables of the Hermite march (: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; - finite-EI lines with two moving ends and finite-EI lines beside bodies, rods or free - points refuse ``Cl > 0`` by name + 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 Loads and environment --------------------- diff --git a/doc/theory.rst b/doc/theory.rst index 3e6d8682..8cf279c6 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -776,8 +776,9 @@ elements. The phase is explicit with the Heun commit as on ``EI = 0`` lines, and needed: the Hermite tangent and the integrated lift leave no mesh-scale mode for the loop to 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 -carries it, including deck waves and current through its held fluid field; a finite-EI line -with two moving ends, or beside bodies, rods or free points, refuses :math:`C_L > 0`. +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`. 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 330469fa..92b59cfb 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -847,8 +847,7 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com - linearise a pinned-hang-off, uncontrolled variant of the deck; time-domain runs support both * - 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``) or beside - bodies, rods or free points (``does not run with bodies, rods or free points yet``) + * - 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 * - a host/file fluid combination named as inseparable - select host wave/current and file wave/current independently as documented, or place the diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 7150a6a4..f4849988 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2614,7 +2614,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: # Cl > 0 on an EI = 0 row (native init_one_model, which needs the line's Morison drag in # water) has_viv_ei0 = False - viv_type_names: set[str] = set() for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") @@ -2703,8 +2702,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: "working-curve model" ) has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) - if cl > 0.0: - viv_type_names.add(row.tokens[0].lower()) 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") @@ -3592,18 +3589,6 @@ def is_body_kind(kind: str, pinned: bool) -> bool: ) elif has_rigid6: needs_multibody = non_rigid6_points - if deck_driver_route and viv_type_names: - # native run_deck_driver: the finite-EI lift runs on the cubic-Hermite march, which - # builds no bodies, rods or Free/Connect points (a moving End B is refused above) - for line_id in finite_line_ids: - if not viv_type_names.intersection(section_types_by_line[line_id]): - continue - if needs_multibody: - raise DeckFormatError( - f"{self._label}: VIV (LINE TYPES Cl > 0) of a finite-EI line does not run " - "with bodies, rods or free points yet; set Cl = 0 for the finite-EI lines " - "of this deck" - ) if failures and deck_driver_route: # native CD_Run_Deck_Driver: FAILURE runs on the point-system object graph only if not has_dtm: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index bb4319ee..6bec1952 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4619,11 +4619,10 @@ def test_viv_needs_water_on_an_ei0_line(): DeckFile.from_text(_edit(_STATIC, ("50.0 WtrDpth\n", ""))) -def test_finite_ei_viv_is_refused_beside_free_points(): - row = "chain 0.252 390.0 1.674e9 -1.0 1.0e4 1.37 0.64 1.0 0.0" - base = _edit(_DYNAMIC, ("2 Coupled 0.0 0.0 0.0 0 0 0 0", "2 Free 0.0 0.0 0.0 1000 0 0 0")) - with pytest.raises(DeckFormatError, match="does not run with bodies, rods or free points"): - DeckFile.from_text(_edit(base, (row, row + " 0.8"))) +def test_finite_ei_viv_is_accepted_on_the_multibody_march(): + # the clamped cable of a moored Rigid6 buoy (native multibody march) + row = "cable 0.20 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0" + DeckFile.from_text(_example("buoy_clamped_cable.dat", (row, row + " 0.8"))) def test_viv_rms_window_option_is_non_negative(): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 49f8f31f..93251c5a 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -19879,11 +19879,6 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod pc = points pa = find_point(points, cab_lines(c)%nodeA) IF (TRIM(pc(pa)%ptype) /= 'fixed') pc(pa)%ptype = 'coupled' - IF (line_has_viv(cab_lines(c), types, sections)) THEN - CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) of a finite-EI line does not run with bodies, rods '// & - 'or free points yet; set Cl = 0 for the finite-EI lines of this deck') - GOTO 900 - END IF mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_active(cab_lines(c))) & .AND. TRIM(points(pa)%ptype) /= 'fixed' IF (mb%cab_clamp(c)) THEN @@ -19899,7 +19894,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod lnc%endconn_ez_ref(:, 1) = dclamp 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), & + 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))) END BLOCK @@ -19909,6 +19904,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod ELSE CALL build_one_hermite_cable(cab_lines(c), sections, types, pc, opts, opts%dtM, mb%cables(c), node, & ErrStat, ErrMsg, standalone_controls=.TRUE., bathymetry=bathymetry, & + install_viv=.TRUE., & fold_support=MERGE(FOLD_FRICTION_NONE, FOLD_FRICTION_NO_AS_LAID, & deck_has_non_rigid6_dynamic_points(points, bodies))) END IF diff --git a/tests/test_viv_lockin.py b/tests/test_viv_lockin.py index 1e664907..0102c6c3 100644 --- a/tests/test_viv_lockin.py +++ b/tests/test_viv_lockin.py @@ -18,6 +18,9 @@ stiffness: the cubic-Hermite route with the Gauss-integrated lift) locks in with the EI = 0 line's mid-span and quarter-span amplitudes (within 1 %) and frequency, at dtM 0.01 s and at 0.002 s (no smoothing needed on the Hermite route); +* the same finite-EI cable on the multibody march (End A Fixed, and a weighted Connect point on + two chains 300 m away, which puts the deck on that march) locks in as on the Hermite route + (within 1 % and one bin); * a bending-stiff, neutrally buoyant cable (8.1 kg/m, EA 5e9 N, EI 5e7 N m^2, about 51 kN: beta = pi^2 EI/(T L^2) ~ 1) against the EI = 0 string tensioned to T (1 + beta), which has the same first-mode frequency and shape: at U 0.21 m/s both lock into mode 1 with the same @@ -112,6 +115,26 @@ def deck(dtm: float, ei: float = 0.0, ea: float = 5.0e7, mass: float = 10.0, ten """ +def multibody(text: str) -> str: + """The deck with End A Fixed and, 300 m away, a 5 t Connect point hung on two chains: a deck + with a dynamic point runs on the multibody march.""" + for old, new in ( + ("1 Coupled 0.0 0.0 -50.0", "1 Fixed 0.0 0.0 -50.0"), + ("riser 0.10", "chain 0.20 250.0 1.0e9 -1.0 0.0 1.2 1.0 0.0 0.0" + " 0.0 0.08 0.18\nriser 0.10"), + ("2 Fixed 100.0 0.0 -50.0 0 0 0 0", + "2 Fixed 100.0 0.0 -50.0 0 0 0 0\n" + "3 Fixed 0.0 300.0 -20.0 0 0 0 0\n" + "4 Connect 50.0 300.0 -60.0 5000 0 0 0\n" + "5 Fixed 100.0 300.0 -20.0 0 0 0 0"), + (" 50 -\n", " 50 -\n2 chain 3 4 70.0 20 -\n" + "3 chain 5 4 70.0 20 -\n"), + ): + assert text.count(old) == 1, old + text = text.replace(old, new) + return text + + def response(path: Path) -> tuple[float, float, float]: """Mid A/D, mid peak frequency, quarter A/D over 60-120 s.""" hist = read_output(path) @@ -150,6 +173,7 @@ def main() -> int: (0.002, "viv_dt0.002", deck(0.002, waterkin="current_0.15.dat")), ("fei", "viv_fei", deck(0.01, ei=1.0, waterkin="current_0.15.dat")), ("fei_fine", "viv_fei_dt0.002", deck(0.002, ei=1.0, waterkin="current_0.15.dat")), + ("fei_mb", "viv_fei_multibody", multibody(deck(0.01, ei=1.0, waterkin="current_0.15.dat"))), ] for u in (0.21, 0.30): runs.append((("stiff", u), f"viv_stiff_u{u}", deck(0.01, waterkin=f"current_{u}.dat", **stiff))) @@ -196,6 +220,11 @@ def run(name: str) -> subprocess.CompletedProcess[str]: check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0 and abs(f1 - f0) <= 1.0 / 60.0, f"finite-EI cable at dtM 0.002 s: mid/quarter A/D {a1:.3f}/{q1:.3f} at {f1:.3f} Hz, EI = 0 " f"line at 0.01 s {a0:.3f}/{q0:.3f} at {f0:.3f} Hz (within 1 % and one bin)") + if "fei" in results and "fei_mb" in results: + (a0, f0, q0), (a1, f1, q1) = results["fei"], results["fei_mb"] + check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0 and abs(f1 - f0) <= 1.0 / 60.0, + f"finite-EI cable on the multibody march: mid/quarter A/D {a1:.3f}/{q1:.3f} at {f1:.3f} Hz, " + f"Hermite route {a0:.3f}/{q0:.3f} at {f0:.3f} Hz (within 1 % and one bin)") if ("stiff", 0.21) in results and ("string", 0.21) in results: (a1, f1, _), (a0, f0, _) = results[("stiff", 0.21)], results[("string", 0.21)] check(abs(a1 - a0) <= 0.03 * a0 and abs(f1 - f0) <= 1.0 / 60.0, From 31f7fef2df51695913148124c8c01a69695029c5 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 28 Oct 2026 17:28:09 +0900 Subject: [PATCH 13/51] feat(outputs): LINES Outputs flag V, the VIV lift at the nodes (#62) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MoorDyn's line flag `V` writes the cross-flow VIV lift at each node of a line. CableDyn rejected the flag, so the lift was not reachable as an output. This PR adds it. ## Changes - **New file `.Line.V.out`.** The LINES `Outputs` flag `V` writes the lift `(x, y, z)` at every node, End A to End B, at the same times as `.out`. - **Routes.** The file is written on the dynamic runs of every standalone route that carries VIV: - `EI = 0` models and the point system; - Rigid6 bodies and rods; - the multibody march and the Hermite march. - **`EI = 0` lines.** The lift comes from `CD_Get_Model_VIV_Lift`, at the committed state. The end nodes carry none, as in MoorDyn. - **Finite-EI lines.** `CD_HermiteCable_Dyn_VIV_Node_Lift` sums the translational part of each element's consistent lift load at its two nodes. The writer turns it from the cable's solve frame into the global frame. - **Case.** The flag is upper case, as in MoorDyn. Its lower-case `v` (node velocities) is not written and stays a parse error, with a message that says so. - **Refusals.** - The mixed `EI = 0` / finite-EI runner refuses `V` along with `p` and `t`. - The two-moving-end finite-EI route has no VIV and refuses the flag by name. - The Python deck validator follows both refusals. It also gains the missing native refusal of `Cl > 0` on that route. - **Docs:** outputs, migrating and CHANGELOG. ## Checks - **`viv_lockin`.** It reads the V files of the `EI = 0` line, the finite-EI cable on the Hermite march and the same cable on the multibody march, all in lock-in: - the `EI = 0` line's end nodes carry no lift; - at the interior nodes, the standard deviation of the cross-flow lift over 60–120 s agrees within 1 % across all three; - the exception is each end node's neighbour, where the `EI = 0` line's end half-segments carry no lift while a cable element shares its lift between its two nodes. - **New `msg_line_flag_velocity` test:** lower-case `v` fails with a message that names `V`. - **Python:** the flag is accepted and case-checked. It is refused on the mixed route, and on a farm-shared finite-EI cable (Turbine1 to Turbine2), where `Cl > 0` is refused too. The native driver gives the same messages on that deck. - **Test suite:** ctest 309/309; Python 2027 passed. - **Examples:** all 52 shipped examples byte-identical to dev. - **Format:** fprettify and ruff are clean. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 + CMakeLists.txt | 4 + app/cabledyn.f90 | 2 +- doc/migrating.rst | 5 + doc/outputs.rst | 20 +- python/cabledyn/deck_file.py | 35 ++- python/tests/test_deck_file.py | 34 ++- src/CableDyn_DeckDriver.f90 | 397 +++++++++++++++++++------- src/CableDyn_HermiteCableDynamic.f90 | 28 ++ src/CableDyn_Model.f90 | 34 ++- src/CableDyn_System.f90 | 28 +- tests/data/msg_line_flag_velocity.dat | 37 +++ tests/test_viv_lockin.py | 48 +++- 13 files changed, 552 insertions(+), 125 deletions(-) create mode 100644 tests/data/msg_line_flag_velocity.dat diff --git a/CHANGELOG.md b/CHANGELOG.md index 204025d1..ca12e8f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,11 @@ All notable changes to CableDyn are recorded in this file. The format follows frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. The multibody march carries it too (a cable on a Rigid6 body or rod, or beside free points), with the same lock-in. A finite-EI line with two moving ends refuses `Cl > 0`. +- LINES Outputs flag `V` (MoorDyn's): the cross-flow VIV lift force at the nodes of a line, + written to `.Line.V.out` on dynamic runs of the standalone routes that carry VIV. On + a finite-EI line each element's lift is lumped to its nodes; at the interior nodes of a taut + line in lock-in it matches the `EI = 0` line's within 0.1 %. Upper case only, as in MoorDyn, + whose `v` (node velocities) CableDyn does not write. - Cross-flow VIV on the coupled routes: OpenFAST (`CompMooring = 5`), FAST.Farm and the standalone runner of a mixed `EI = 0` / finite-EI deck carry the lift on both line kinds, with the host's fluid field. The phases, running mean squares and averaging time are part of the diff --git a/CMakeLists.txt b/CMakeLists.txt index 58831b66..9c3b79d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2472,6 +2472,10 @@ cabledyn_msg_test(weightless_finite_ei msg_weightless_finite_ei.dat 0 cabledyn_msg_test(weightless_finite_ei_vertical msg_weightless_finite_ei_vertical.dat 2 "weightless .neutrally buoyant. line is longer than its vertical span;nothing chooses the side of the bow;offset its ends horizontally" "net-heavy") +# MoorDyn's line flag v (node velocities) is not written; V (the VIV lift) is upper case. +cabledyn_msg_test(line_flag_velocity msg_line_flag_velocity.dat 1 + "supported line-output flags are p, t, r and V .the VIV lift, upper case as MoorDyn's." + "net-heavy") # An EI=0 line type rejected as net-buoyant whose mass is a relative 4e-9 below the displaced water # mass is named weightless and slack; one a relative 2e-6 below it keeps the plain message. cabledyn_msg_test(weightless_ei0 msg_weightless_ei0.dat 1 diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index bac2d593..abb2ad00 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -483,7 +483,7 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h RETURN END IF IF (line_outputs) THEN - run_msg = 'CableDyn_driver: mixed-deck LINE Outputs p/t are not supported; '// & + run_msg = 'CableDyn_driver: mixed-deck LINE Outputs p/t/V are not supported; '// & 'use main OUTPUTS channels or remove the per-line flags' RETURN END IF diff --git a/doc/migrating.rst b/doc/migrating.rst index b14d72fb..53a743d1 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -97,6 +97,11 @@ Keyword map types and as a distributed lift on finite-EI types (:ref:`theory-viv`); the running-RMS window is ``VIVrmsWindow`` seconds, by default 500 steps of ``dtM`` as MoorDyn's + * - ``LINES`` ``Outputs`` flags ``p``, ``t``, ``V`` + - the same quantities, one file per flag where MoorDyn writes one file per line: + ``.Line.p.out``, ``.t.out`` and ``.V.out`` (the VIV lift at the nodes), on the + standalone routes (:doc:`outputs`); MoorDyn's other line flags (``v``, ``U``, ``D``, + ``c``, ``s``, ``d``, ...) are not written and are a parse error * - ``ElasticMod 2/3`` viscoelastic ``EA``/``BA`` - ``Es|Ed`` / ``Es|alphaMBL|vbeta`` in ``EA`` and ``BA_s|BA_d`` in ``BA`` * - Syrope line type and ``SYROPE IC`` diff --git a/doc/outputs.rst b/doc/outputs.rst index 87d8c0e8..7da7d638 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -318,10 +318,11 @@ B)``, header row, units row, data (12 columns): Per-line files (``LINES`` ``Outputs`` flag) ------------------------------------------- -Set the ``Outputs`` column of a ``LINES`` row to any combination of the letters below -(case-insensitive, e.g. ``ptr``); ``-`` or an empty field requests nothing. Any other letter is a -parse error. Mixed ``EI = 0`` + finite-EI decks reject the ``p`` and ``t`` flags (use main-file -channels instead) and accept ``r``. +Set the ``Outputs`` column of a ``LINES`` row to any combination of the letters below (e.g. +``ptr``); ``-`` or an empty field requests nothing. ``p``, ``t`` and ``r`` are case-insensitive; +``V`` is upper case, as in MoorDyn, whose lower-case ``v`` (node velocities) CableDyn does not +write. Any other letter is a parse error. Mixed ``EI = 0`` + finite-EI decks reject the ``p``, +``t`` and ``V`` flags (use main-file channels instead) and accept ``r``. .. list-table:: :header-rows: 1 @@ -338,6 +339,14 @@ channels instead) and accept ``r``. - segment (element) tensions, End A → End B; on a finite-EI line the mean of the axial components of the element's own two equilibrium end forces (``OutputRecovery element``: the axial resultant at the element midpoint) + * - ``V`` + - ``.Line.V.out`` + - cross-flow VIV lift force at the nodes, End A → End B, on dynamic runs (MoorDyn's line + 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 * - ``r`` - ``.Line.range.out`` - range graph: minimum, maximum and mean over the run of the node tension, curvature, bend @@ -365,6 +374,9 @@ deck node of that node, 0 for a node the refinement added. * - ``.t.out`` - ``Segment Tension(N)`` - ``Time(s) Segment1Tension(N) Segment2Tension(N) … SegmentTension(N)`` + * - ``.V.out`` + - (none) + - ``Time(s) Node1LiftX(N) Node1LiftY(N) Node1LiftZ(N) Node2LiftX(N) … NodeLiftZ(N)`` Dynamic per-line rows are written at the same times as ``.out``. diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index f4849988..24fb33c1 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2614,6 +2614,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: # Cl > 0 on an EI = 0 row (native init_one_model, which needs the line's Morison drag in # water) has_viv_ei0 = False + viv_type_names: set[str] = set() for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): numeric(row.tokens[index], row, f"LINE TYPES column {index + 1}") @@ -2702,6 +2703,8 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: "working-curve model" ) has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) + if cl > 0.0: + viv_type_names.add(row.tokens[0].lower()) 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") @@ -2891,7 +2894,8 @@ def end_key(token: str) -> str: # lines whose stock anchor-first row the native reader turns around (its ends swap) swapped_lines: set[str] = set() range_lines = 0 - series_lines = 0 # lines with per-line time-series files (flags p, t) + lift_lines = 0 # lines with the VIV lift file (flag V) + series_lines = 0 # lines with per-line time-series files (flags p, t, V) for row in self.lines: if len(row.tokens) not in {3, 4, 7}: raise DeckFormatError(f"{self._at(row)}: LINES row needs 3, 4, or 7 fields") @@ -2900,14 +2904,17 @@ def end_key(token: str) -> str: if len(row.tokens) == 7 else (row.tokens[3] if len(row.tokens) == 4 else "-") ) - if output_flags != "-" and not re.fullmatch(r"[pPtTrR]+", output_flags): + # V (the VIV lift) is case-sensitive, as MoorDyn's v (node velocities) is not written + if output_flags != "-" and not re.fullmatch(r"[pPtTrRV]+", output_flags): raise DeckFormatError( - f"{self._at(row)}: LINE Outputs accepts only '-', 'p', 't', and 'r'" + f"{self._at(row)}: LINE Outputs accepts only '-', 'p', 't', 'r', and 'V'" ) if "r" in output_flags.lower(): range_lines += 1 - if "p" in output_flags.lower() or "t" in output_flags.lower(): + if "p" in output_flags.lower() or "t" in output_flags.lower() or "V" in output_flags: series_lines += 1 + if "V" in output_flags: + lift_lines += 1 if len(row.tokens) == 7: line_type = row.tokens[1] endpoints: tuple[str, ...] = row.tokens[2:4] @@ -3546,7 +3553,7 @@ def end_key(token: str) -> str: if series_lines: raise DeckFormatError( f"{self._label}: a mixed EI=0/finite-EI deck writes no per-line files; " - "use OUTPUTS channels instead of the LINES Outputs flags p and t" + "use OUTPUTS channels instead of the LINES Outputs flags p, t and V" ) # Native deck_needs_multibody: a dynamic deck that no single-family march covers @@ -3589,6 +3596,24 @@ 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 failures and deck_driver_route: # native CD_Run_Deck_Driver: FAILURE runs on the point-system object graph only if not has_dtm: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 6bec1952..d1452838 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -938,6 +938,19 @@ def test_attachments_accept_an_axial_drag_area_and_a_deck_current(tmp_path): DeckFile.from_text(text) +def test_viv_lift_flag_is_upper_case_and_standalone(): + # V writes the VIV lift file; as MoorDyn's line flags it is case-sensitive (v, MoorDyn's + # node velocities, is not written) + deck = DeckFile.from_text(_edit(_DYNAMIC, ("1 2 1 -\n", "1 2 1 pV\n"))) + assert deck.lines[0].tokens[3] == "pV" + with pytest.raises(DeckFormatError, match="accepts only '-', 'p', 't', 'r', and 'V'"): + DeckFile.from_text(_edit(_DYNAMIC, ("1 2 1 -\n", "1 2 1 pv\n"))) + # a mixed EI=0/finite-EI deck writes no per-line files + mixed = _ATTACHMENT_DECK.format(rows="1 60.0 100 0.1 0.1 1.0", options="") + with pytest.raises(DeckFormatError, match="flags p, t and V"): + DeckFile.from_text(mixed.replace("1 2 1 -\n", "1 2 1 V\n")) + + def test_attachments_are_accepted_on_the_coupled_route(tmp_path): path = tmp_path / "attachments-coupled.dat" path.write_text( @@ -2467,7 +2480,7 @@ def test_range_flag_and_range_start_follow_native_rules(): ("50.0 WtrDpth\n", "50.0 WtrDpth\n0 RangeStart\n"), ) ) - with pytest.raises(DeckFormatError, match="accepts only '-', 'p', 't', and 'r'"): + with pytest.raises(DeckFormatError, match="accepts only '-', 'p', 't', 'r', and 'V'"): DeckFile.from_text(_edit(_STATIC, ("1 2 1 -\n", "1 2 1 rx\n"))) assert DeckFile.from_text(_edit(_STATIC, ("1 2 1 -\n", "1 2 1 r\n"))).lines[0].tokens[3] == "r" @@ -4076,6 +4089,25 @@ def test_reserved_windows_device_names_are_refused(monkeypatch, tmp_path): ) +def test_viv_and_lift_flag_refused_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 + 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"), + ("1 1 3 -\n2 2 3 -\n", "1 1 2 -\n"), + ("1 chain 380 20\n2 chain 380 20\n", "1 chain 620 30\n"), + ("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"))) + # 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"))) + + @pytest.mark.parametrize( ("edit", "message"), [ diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 93251c5a..e07937c8 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -57,11 +57,12 @@ MODULE CableDyn_DeckDriver CD_Get_Model_EndForces, & CD_Update_Model_CoupledMotion, CD_Update_Model_Hydro_Fields, & CD_Recompute_Model_Acceleration, CD_Step_Model, CD_Step_Model_Recovering, CD_MODEL_OK, & - CD_Audit_Model_Step, CD_Set_Model_VIV + CD_Audit_Model_Step, CD_Set_Model_VIV, CD_Get_Model_VIV_Lift USE CableDyn_System, ONLY: CD_SystemType, CD_SystemPointType, CD_LineEndpointBinding, & CD_Init_System_From_Points, CD_End_System, CD_System_Line_NDOF, & CD_System_Line_NElem, CD_Get_System_Point_State, CD_Get_System_Line_State, & - CD_Get_System_Line_Tension, CD_Update_System_Point_Fluid_Fields, & + CD_Get_System_Line_Tension, CD_Get_System_Line_VIV_Lift, & + CD_Update_System_Point_Fluid_Fields, & CD_Get_System_CoupledMotion, CD_Update_System_Point_States, & CD_Calc_System_CoupledLoads, CD_Step_System, CD_Step_System_DynamicPoints, & CD_Step_System_Junction, CD_System_Junction_Rewind, CD_System_Point_Base, & @@ -104,6 +105,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Set_ForceBlend, CD_HC_FORCE_BLEND_DEFAULT, & CD_HermiteCable_Dyn_Set_Friction_Anchors, & CD_HermiteCable_Dyn_Set_Friction_Axial, CD_HermiteCable_Dyn_Set_VIV, & + 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 @@ -16460,7 +16462,8 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END DO IF (.NOT. valid_line_output_flags(lines(i)%outputs)) THEN CALL fail(ErrStat, ErrMsg, 'LINE Outputs "'//TRIM(lines(i)%outputs)// & - '": supported line-output flags are p, t and r'); RETURN + '": supported line-output flags are p, t, r and V (the VIV lift, upper case as MoorDyn''s)') + RETURN END IF IF (find_point(points, lines(i)%nodeA) == 0) THEN CALL fail(ErrStat, ErrMsg, 'LINE '//TRIM(int_to_str(lines(i)%id))//' references undefined POINT id '// & @@ -17033,12 +17036,14 @@ SUBROUTINE write_static_line_tension_file(out_root, line_id, nelem, tension_line CLOSE (unit) END SUBROUTINE write_static_line_tension_file - SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_units, ErrStat, ErrMsg) + SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_units, ErrStat, ErrMsg, lift_units) !! Open optional per-line dynamic time-series files requested by LINE Outputs flags. CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_ModelType), INTENT(IN) :: models(:) INTEGER, ALLOCATABLE, INTENT(OUT) :: pos_units(:), ten_units(:) + ! the VIV lift files (flag V) of the lines, when the caller takes them + INTEGER, ALLOCATABLE, INTENT(OUT), OPTIONAL :: lift_units(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -17051,11 +17056,15 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni ALLOCATE (pos_units(SIZE(lines)), ten_units(SIZE(lines))) pos_units = 0 ten_units = 0 + IF (PRESENT(lift_units)) THEN + ALLOCATE (lift_units(SIZE(lines))) + lift_units = 0 + END IF DO i = 1, SIZE(lines) IF (.NOT. line_outputs_requested(lines(i)%outputs)) CYCLE ndof = CD_Model_NDOF(models(i), es, em) IF (es /= CD_MODEL_OK) THEN - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = CD_DECKDRV_SOLVEFAIL ErrMsg = 'CableDyn_DeckDriver: dynamic line-output DOF query failed: '//TRIM(em) RETURN @@ -17066,7 +17075,7 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open dynamic line position output file: '//TRIM(path)); RETURN END IF WRITE (pos_units(i), '(A)') '# CableDyn dynamic line node positions; public node order EndA -> EndB' @@ -17082,7 +17091,7 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open dynamic line tension output file: '//TRIM(path)); RETURN END IF WRITE (ten_units(i), '(A)') '# CableDyn dynamic line segment tensions; public segment order EndA -> EndB' @@ -17092,15 +17101,26 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni END DO WRITE (ten_units(i), '(A)') '' END IF + IF (PRESENT(lift_units)) THEN + IF (line_output_has_lift(lines(i)%outputs)) THEN + CALL open_line_lift_file(out_root, lines(i)%id, nnode, lift_units(i), ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) THEN + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units); RETURN + END IF + END IF + END IF END DO END SUBROUTINE open_dynamic_line_outputs - SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg) + SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units) !! Open optional per-line dynamic time-series files for a point-system deck. CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_SystemType), INTENT(IN) :: system INTEGER, ALLOCATABLE, INTENT(OUT) :: pos_units(:), ten_units(:) + ! the VIV lift files (flag V) of the lines, when the caller takes them + INTEGER, ALLOCATABLE, INTENT(OUT), OPTIONAL :: lift_units(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -17113,11 +17133,15 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ALLOCATE (pos_units(SIZE(lines)), ten_units(SIZE(lines))) pos_units = 0 ten_units = 0 + IF (PRESENT(lift_units)) THEN + ALLOCATE (lift_units(SIZE(lines))) + lift_units = 0 + END IF DO i = 1, SIZE(lines) IF (.NOT. line_outputs_requested(lines(i)%outputs)) CYCLE ndof = CD_System_Line_NDOF(system, i, es, em) IF (es /= CD_SYSTEM_OK) THEN - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = CD_DECKDRV_SOLVEFAIL ErrMsg = 'CableDyn_DeckDriver: system dynamic line-output DOF query failed: '//TRIM(em) RETURN @@ -17128,7 +17152,7 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open system dynamic line position output file: '//TRIM(path)); RETURN END IF WRITE (pos_units(i), '(A)') '# CableDyn dynamic line node positions; public node order EndA -> EndB' @@ -17144,7 +17168,7 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open system dynamic line tension output file: '//TRIM(path)); RETURN END IF WRITE (ten_units(i), '(A)') '# CableDyn dynamic line segment tensions; public segment order EndA -> EndB' @@ -17154,26 +17178,37 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, END DO WRITE (ten_units(i), '(A)') '' END IF + IF (PRESENT(lift_units)) THEN + IF (line_output_has_lift(lines(i)%outputs)) THEN + CALL open_line_lift_file(out_root, lines(i)%id, nnode, lift_units(i), ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) THEN + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units); RETURN + END IF + END IF + END IF END DO END SUBROUTINE open_dynamic_system_line_outputs - SUBROUTINE write_dynamic_line_outputs(time, lines, models, pos_units, ten_units, work, ErrStat, ErrMsg) + SUBROUTINE write_dynamic_line_outputs(time, lines, models, pos_units, ten_units, work, ErrStat, ErrMsg, lift_units) !! Append one time row to every requested dynamic per-line output file. REAL(wp), INTENT(IN) :: time TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_ModelType), INTENT(IN) :: models(:) INTEGER, INTENT(IN) :: pos_units(:), ten_units(:) + INTEGER, INTENT(IN), OPTIONAL :: lift_units(:) TYPE(ModelOutputWorkspace), INTENT(INOUT) :: work INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, ndof, nnode, ne, es + INTEGER :: i, ndof, nnode, ne, es, lift_unit CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' DO i = 1, SIZE(lines) - IF (pos_units(i) == 0 .AND. ten_units(i) == 0) CYCLE + lift_unit = 0 + IF (PRESENT(lift_units)) lift_unit = lift_units(i) + IF (pos_units(i) == 0 .AND. ten_units(i) == 0 .AND. lift_unit == 0) CYCLE ndof = CD_Model_NDOF(models(i), es, em) IF (es /= CD_MODEL_OK) THEN ErrStat = CD_DECKDRV_SOLVEFAIL @@ -17210,6 +17245,22 @@ SUBROUTINE write_dynamic_line_outputs(time, lines, models, pos_units, ten_units, RETURN END IF END IF + IF (lift_unit /= 0) THEN + BLOCK + REAL(wp) :: lift(3, nnode) + CALL CD_Get_Model_VIV_Lift(models(i), lift, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: dynamic line VIV lift recovery failed: '//TRIM(em) + RETURN + END IF + CALL write_line_position_row(lift_unit, time, RESHAPE(lift, [3*nnode]), 3, ne, ErrStat) + IF (ErrStat /= CD_DECKDRV_OK) THEN + ErrMsg = 'CableDyn_DeckDriver: non-finite dynamic line VIV lift output' + RETURN + END IF + END BLOCK + END IF END DO END SUBROUTINE write_dynamic_line_outputs @@ -17267,23 +17318,27 @@ SUBROUTINE write_line_tension_row(unit, time, tension, ErrStat) END IF END SUBROUTINE write_line_tension_row - SUBROUTINE write_dynamic_system_line_outputs(time, lines, system, pos_units, ten_units, work, ErrStat, ErrMsg) + SUBROUTINE write_dynamic_system_line_outputs(time, lines, system, pos_units, ten_units, work, ErrStat, ErrMsg, & + lift_units) !! Append one time row to requested dynamic per-line output files for a point-system deck. REAL(wp), INTENT(IN) :: time TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_SystemType), INTENT(IN) :: system INTEGER, INTENT(IN) :: pos_units(:), ten_units(:) + INTEGER, INTENT(IN), OPTIONAL :: lift_units(:) TYPE(ModelOutputWorkspace), INTENT(INOUT) :: work INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, ndof, nnode, ne, es + INTEGER :: i, ndof, nnode, ne, es, lift_unit CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' DO i = 1, SIZE(lines) - IF (pos_units(i) == 0 .AND. ten_units(i) == 0) CYCLE + lift_unit = 0 + IF (PRESENT(lift_units)) lift_unit = lift_units(i) + IF (pos_units(i) == 0 .AND. ten_units(i) == 0 .AND. lift_unit == 0) CYCLE ndof = CD_System_Line_NDOF(system, i, es, em) IF (es /= CD_SYSTEM_OK) THEN ErrStat = CD_DECKDRV_SOLVEFAIL @@ -17320,6 +17375,22 @@ SUBROUTINE write_dynamic_system_line_outputs(time, lines, system, pos_units, ten RETURN END IF END IF + IF (lift_unit /= 0) THEN + BLOCK + REAL(wp) :: lift(3, nnode) + CALL CD_Get_System_Line_VIV_Lift(system, i, lift, es, em) + IF (es /= CD_SYSTEM_OK) THEN + ErrStat = CD_DECKDRV_SOLVEFAIL + ErrMsg = 'CableDyn_DeckDriver: dynamic line VIV lift recovery failed: '//TRIM(em) + RETURN + END IF + CALL write_line_position_row(lift_unit, time, RESHAPE(lift, [3*nnode]), 3, ne, ErrStat) + IF (ErrStat /= CD_DECKDRV_OK) THEN + ErrMsg = 'CableDyn_DeckDriver: non-finite dynamic line VIV lift output' + RETURN + END IF + END BLOCK + END IF END DO END SUBROUTINE write_dynamic_system_line_outputs @@ -17434,8 +17505,9 @@ SUBROUTINE write_dynamic_finite_line_outputs(time, lines, models, pos_units, ten END DO END SUBROUTINE write_dynamic_finite_line_outputs - SUBROUTINE close_dynamic_line_outputs(pos_units, ten_units) + 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(:) INTEGER :: i IF (ALLOCATED(pos_units)) THEN @@ -17450,8 +17522,53 @@ SUBROUTINE close_dynamic_line_outputs(pos_units, ten_units) END DO DEALLOCATE (ten_units) END IF + IF (PRESENT(lift_units)) THEN + IF (ALLOCATED(lift_units)) THEN + DO i = 1, SIZE(lift_units) + IF (lift_units(i) /= 0) CLOSE (lift_units(i)) + END DO + DEALLOCATE (lift_units) + END IF + END IF END SUBROUTINE close_dynamic_line_outputs + SUBROUTINE open_line_lift_file(out_root, line_id, nnode, unit, ErrStat, ErrMsg, deck_nodes) + !! Open .Line.V.out (LINES Outputs flag V) and write its header: the VIV + !! lift force at each node, End A -> End B. deck_nodes, on a line whose mesh the static solve + !! refined, names the deck node of each node (0: added), as the .p.out file does. + CHARACTER(*), INTENT(IN) :: out_root + INTEGER, INTENT(IN) :: line_id, nnode + INTEGER, INTENT(OUT) :: unit + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER, INTENT(IN), OPTIONAL :: deck_nodes(:) + CHARACTER(LEN(out_root) + 32) :: path + INTEGER :: ios, node + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + path = TRIM(out_root)//'.Line'//TRIM(int_to_str(line_id))//'.V.out' + OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + IF (ios /= 0) THEN + unit = 0 + CALL fail(ErrStat, ErrMsg, 'cannot open dynamic line VIV lift output file: '//TRIM(path)); RETURN + END IF + WRITE (unit, '(A)') '# CableDyn dynamic line VIV lift force at the nodes; public node order EndA -> EndB' + IF (PRESENT(deck_nodes)) THEN + WRITE (unit, '(A)', ADVANCE='NO') '# DeckNode' + DO node = 1, nnode + WRITE (unit, '(A,I0)', ADVANCE='NO') char_tab(), deck_nodes(node) + END DO + WRITE (unit, '(A)') '' + END IF + WRITE (unit, '(A)', ADVANCE='NO') 'Time(s)' + DO node = 1, nnode + WRITE (unit, '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'LiftX(N)' + WRITE (unit, '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'LiftY(N)' + WRITE (unit, '(A,A,I0,A)', ADVANCE='NO') char_tab(), 'Node', node, 'LiftZ(N)' + END DO + WRITE (unit, '(A)') '' + END SUBROUTINE open_line_lift_file + SUBROUTINE open_dynamic_rod_outputs(out_root, rods, pos_units, ErrStat, ErrMsg) !! Open optional per-rod dynamic endpoint-position time-series files. CHARACTER(*), INTENT(IN) :: out_root @@ -17551,7 +17668,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: unit, ios, step, nstep, es, n_iter, step_substeps - INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) + INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:), lift_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss INTEGER :: recovery_event_count, recovery_max_substeps_used CHARACTER(LEN(out_root) + 8) :: path @@ -17596,12 +17713,13 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co RETURN END IF END IF - CALL open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_units, ErrStat, ErrMsg) + CALL open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units=lift_units) 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 close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN END IF WRITE (unit, '(A)') '# CableDyn driver output (dynamic; convergence quality is reported by status message)' @@ -17613,13 +17731,14 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co END IF IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF - CALL write_dynamic_line_outputs(CD_ZERO, lines, models, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_line_outputs(CD_ZERO, lines, models, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF ! the run audit starts from the initial state (its tension scale is that of t = 0) @@ -17631,7 +17750,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co CALL update_wave_models(models, opts, t, hydro_work, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -17653,7 +17772,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co END IF IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) converged = .FALSE. ErrStat = es ErrMsg = TRIM(em)//INSPECTION_NOTE @@ -17663,7 +17782,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL CD_Classify_Dynamic_Completion('dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) RETURN @@ -17671,7 +17790,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co CALL check_models_plausibility(models, lines, opts%max_strain, t, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) converged = .FALSE. ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE RETURN @@ -17686,20 +17805,21 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co END IF IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF - CALL write_dynamic_line_outputs(t, lines, models, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_line_outputs(t, lines, models, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL CD_Classify_Dynamic_Completion('dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK .AND. recovery_event_count > 0) THEN @@ -17727,7 +17847,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry INTEGER :: unit, ios, step, nstep, es, n_iter - INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) + INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:), lift_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path CHARACTER(1024) :: em @@ -17749,12 +17869,13 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys max_consecutive_miss = 0 first_miss_time = CD_ZERO last_miss_time = CD_ZERO - CALL open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg) + CALL open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units=lift_units) 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 close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN END IF WRITE (unit, '(A)') '# CableDyn driver output (dynamic points; convergence quality is reported by status message)' @@ -17762,7 +17883,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL update_system_point_hydro(system, points, opts, CD_ZERO, hydro_work, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -17770,7 +17891,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL update_system_line_hydro(system, opts, CD_ZERO, hydro_work, es, em, initial_condition=.TRUE.) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -17778,13 +17899,14 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL write_system_model_row(unit, CD_ZERO, channels, lines, points, system, output_work, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF - CALL write_dynamic_system_line_outputs(CD_ZERO, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_system_line_outputs(CD_ZERO, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF ! the run audit starts from the initial state (its tension scale is that of t = 0) @@ -17795,7 +17917,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL update_system_point_hydro(system, points, opts, t, hydro_work, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -17803,7 +17925,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL update_system_line_hydro(system, opts, t, hydro_work, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -17813,7 +17935,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_SYSTEM_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = CD_DECKDRV_SOLVEFAIL ErrMsg = 'CableDyn_DeckDriver: dynamic point-system step failed: '//TRIM(em) RETURN @@ -17822,7 +17944,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL CD_Classify_Dynamic_Completion('dynamic point-system run', nstep, miss_count, & max_consecutive_miss, first_miss_time, last_miss_time, & converged, ErrStat, ErrMsg) @@ -17832,7 +17954,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys IF (ErrStat /= CD_DECKDRV_OK) THEN ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) converged = .FALSE. RETURN END IF @@ -17841,7 +17963,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL check_and_fire_failures(system, lines, points, failures, t, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -17852,20 +17974,21 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys CALL write_system_model_row(unit, t, channels, lines, points, system, output_work, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF - CALL write_dynamic_system_line_outputs(t, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_system_line_outputs(t, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL CD_Classify_Dynamic_Completion('dynamic point-system run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) CALL report_system_line_audits(system, lines, opts%dtM) @@ -18101,7 +18224,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o TYPE(RigidBodyState), ALLOCATABLE :: rigid(:) INTEGER :: unit, ios, step, nstep, es, n_iter - INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) + INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:), lift_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path CHARACTER(1024) :: em @@ -18145,7 +18268,8 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o END IF WRITE (unit, '(A)') '# CableDyn driver output (Rigid6 dynamic; convergence quality is reported by status message)' CALL write_header(unit, channels) - CALL open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg) + CALL open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) RETURN @@ -18153,7 +18277,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL update_system_line_hydro(system, opts, CD_ZERO, hydro_work, es, em, initial_condition=.TRUE.) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -18162,13 +18286,14 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o rigid=rigid, opts=opts, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF - CALL write_dynamic_system_line_outputs(CD_ZERO, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_system_line_outputs(CD_ZERO, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF ! the run audit starts from the initial state (its tension scale is that of t = 0) @@ -18184,7 +18309,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL update_system_line_hydro(system, opts, t, hydro_work, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -18196,7 +18321,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -18205,7 +18330,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL CD_Classify_Dynamic_Completion('Rigid6 dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) RETURN @@ -18214,7 +18339,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o IF (ErrStat /= CD_DECKDRV_OK) THEN ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) converged = .FALSE. RETURN END IF @@ -18223,7 +18348,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o CALL check_and_fire_failures(system, lines, points, failures, t, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) ErrStat = es ErrMsg = em RETURN @@ -18235,20 +18360,21 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o rigid=rigid, opts=opts, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF - CALL write_dynamic_system_line_outputs(t, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_system_line_outputs(t, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL CD_Classify_Dynamic_Completion('Rigid6 dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) CALL report_system_line_audits(system, lines, opts%dtM) @@ -18273,7 +18399,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi TYPE(RodState), ALLOCATABLE :: rod_state(:) INTEGER :: unit, ios, step, nstep, es, n_iter - INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) + INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:), lift_units(:) INTEGER, ALLOCATABLE :: rod_pos_units(:) INTEGER :: miss_count, consecutive_miss, max_consecutive_miss CHARACTER(LEN(out_root) + 8) :: path @@ -18319,7 +18445,8 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi END IF WRITE (unit, '(A)') '# CableDyn driver output (rod dynamic; convergence quality is reported by status message)' CALL write_header(unit, channels) - CALL open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg) + CALL open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) RETURN @@ -18327,13 +18454,13 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL open_dynamic_rod_outputs(out_root, rods, rod_pos_units, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) RETURN END IF CALL update_system_line_hydro(system, opts, CD_ZERO, hydro_work, es, em, initial_condition=.TRUE.) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) ErrStat = es ErrMsg = em @@ -18343,21 +18470,22 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi rods=rod_state, opts=opts, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF - CALL write_dynamic_system_line_outputs(CD_ZERO, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_system_line_outputs(CD_ZERO, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF CALL write_dynamic_rod_outputs(CD_ZERO, rods, rod_state, rod_pos_units, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF @@ -18374,7 +18502,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL update_system_line_hydro(system, opts, t, hydro_work, es, em) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) ErrStat = es ErrMsg = em @@ -18387,7 +18515,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) ErrStat = es ErrMsg = em @@ -18397,7 +18525,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) CALL CD_Classify_Dynamic_Completion('rod dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) @@ -18407,7 +18535,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi IF (ErrStat /= CD_DECKDRV_OK) THEN ErrMsg = TRIM(ErrMsg)//INSPECTION_NOTE CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) converged = .FALSE. RETURN @@ -18419,21 +18547,22 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi rods=rod_state, opts=opts, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF - CALL write_dynamic_system_line_outputs(t, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg) + CALL write_dynamic_system_line_outputs(t, lines, system, pos_units, ten_units, output_work, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF CALL write_dynamic_rod_outputs(t, rods, rod_state, rod_pos_units, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) RETURN END IF @@ -18441,7 +18570,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi CALL update_driver_progress(progress, step, t) END DO CLOSE (unit) - CALL close_dynamic_line_outputs(pos_units, ten_units) + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL close_dynamic_rod_outputs(rod_pos_units) CALL CD_Classify_Dynamic_Completion('rod dynamic run', nstep, miss_count, max_consecutive_miss, & first_miss_time, last_miss_time, converged, ErrStat, ErrMsg) @@ -19703,6 +19832,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod TYPE(CD_LineInitSummary), ALLOCATABLE :: sum_sys(:), sum_cab(:), summaries(:) LOGICAL, ALLOCATABLE :: is_fin(:), is_ei0(:) INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:), cpos_units(:), cten_units(:), rod_units(:) + INTEGER, ALLOCATABLE :: lift_units(:), clift_units(:) INTEGER :: i, k, c, ir, ib, pa, pb, node, unit, ios, step, nstep, es, n_iter, bid INTEGER :: miss_count, consecutive_miss, max_consecutive_miss LOGICAL :: step_converged, stalled @@ -20004,12 +20134,14 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 'status message)' CALL write_header(unit, channels) IF (mb%has_sys) THEN - CALL open_dynamic_system_line_outputs(out_root, sys_lines, mb%system, pos_units, ten_units, ErrStat, ErrMsg) + CALL open_dynamic_system_line_outputs(out_root, sys_lines, mb%system, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units=lift_units) ELSE ALLOCATE (pos_units(0), ten_units(0)) END IF IF (ErrStat == CD_DECKDRV_OK) & - CALL open_dynamic_hermite_line_outputs(out_root, cab_lines, mb%cables, cpos_units, cten_units, ErrStat, ErrMsg) + CALL open_dynamic_hermite_line_outputs(out_root, cab_lines, mb%cables, cpos_units, cten_units, ErrStat, ErrMsg, & + lift_units=clift_units) IF (ErrStat == CD_DECKDRV_OK) CALL open_dynamic_rod_outputs(out_root, own, rod_units, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) GOTO 800 IF (probe_armed .AND. SIZE(mb%rigid) > 0) THEN @@ -20081,8 +20213,8 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod IF (ErrStat == CD_DECKDRV_OK .AND. converged) CALL range_write(mb_ranges, out_root, ErrStat, ErrMsg) 800 CONTINUE CLOSE (unit) - IF (ALLOCATED(pos_units)) CALL close_dynamic_line_outputs(pos_units, ten_units) - IF (ALLOCATED(cpos_units)) CALL close_dynamic_line_outputs(cpos_units, cten_units) + IF (ALLOCATED(pos_units)) CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) + IF (ALLOCATED(cpos_units)) CALL close_dynamic_line_outputs(cpos_units, cten_units, clift_units) IF (ALLOCATED(rod_units)) CALL close_dynamic_rod_outputs(rod_units) 900 CONTINUE IF (ErrStat /= CD_DECKDRV_OK) converged = .FALSE. @@ -20165,11 +20297,12 @@ SUBROUTINE mb_outputs(time) WRITE (unit, ROW_VALUES_FMT) time, (char_tab(), vals(j), j=1, SIZE(channels)) IF (mb%has_sys) THEN CALL write_dynamic_system_line_outputs(time, sys_lines, mb%system, pos_units, ten_units, output_work, & - ErrStat, ErrMsg) + ErrStat, ErrMsg, lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF IF (SIZE(mb%cables) > 0) THEN - CALL write_dynamic_hermite_line_outputs(time, cab_lines, mb%cables, cpos_units, cten_units, ErrStat, ErrMsg) + CALL write_dynamic_hermite_line_outputs(time, cab_lines, mb%cables, cpos_units, cten_units, ErrStat, ErrMsg, & + lift_units=clift_units) IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF CALL write_dynamic_rod_outputs(time, own, mb%rods, rod_units, ErrStat, ErrMsg) @@ -27975,7 +28108,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca INTEGER :: unit, ios, step, nstep, i, es, pidx, tensile_events, tensile_element INTEGER :: recovery_events, recovery_max_used - INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:) + INTEGER, ALLOCATABLE :: pos_units(:), ten_units(:), lift_units(:) 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 @@ -28031,7 +28164,8 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca END IF WRITE (unit, '(A)') '# CableDyn driver output (finite-EI dynamic; production cubic-Hermite route)' CALL write_header(unit, channels) - CALL open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + CALL open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN CLOSE (unit); RETURN END IF @@ -28042,9 +28176,9 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CALL write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) & CALL write_dynamic_hermite_line_outputs(CD_ZERO, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & - ranges=ranges) + ranges=ranges, lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) THEN - CLOSE (unit); CALL close_dynamic_line_outputs(pos_units, ten_units); RETURN + CLOSE (unit); CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units); RETURN END IF CALL start_driver_progress(progress, nstep, opts%dtM) @@ -28095,13 +28229,13 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca has_motion=opts%has_motion_file, ranges=ranges) IF (ErrStat == CD_DECKDRV_OK) & CALL write_dynamic_hermite_line_outputs(t, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & - ranges=ranges) + ranges=ranges, lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) EXIT 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) IF (opts%tensile_mode == CD_HCDYN_TENSILE_WARN) THEN DO i = 1, SIZE(cables) CALL CD_HFMF_Get_Tensile_Diagnostics(cables(i), tensile_events, tensile_force, & @@ -28540,11 +28674,14 @@ SUBROUTINE write_hermite_model_row(unit, time, channels, lines, points, cables, WRITE (unit, '(A)') '' END SUBROUTINE write_hermite_model_row - SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, ten_units, ErrStat, ErrMsg) + SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & + lift_units) CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(CD_HFMF_ModuleType), INTENT(IN) :: cables(:) INTEGER, ALLOCATABLE, INTENT(OUT) :: pos_units(:), ten_units(:) + ! the VIV lift files (flag V) of the lines, when the caller takes them + INTEGER, ALLOCATABLE, INTENT(OUT), OPTIONAL :: lift_units(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: i, ios, node, seg @@ -28552,13 +28689,17 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, ErrStat = CD_DECKDRV_OK; ErrMsg = '' ALLOCATE (pos_units(SIZE(lines)), ten_units(SIZE(lines))) pos_units = 0; ten_units = 0 + IF (PRESENT(lift_units)) THEN + ALLOCATE (lift_units(SIZE(lines))) + lift_units = 0 + END IF DO i = 1, SIZE(lines) IF (.NOT. line_outputs_requested(lines(i)%outputs)) CYCLE 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open Hermite line position output: '//TRIM(path)); RETURN END IF WRITE (pos_units(i), '(A)') '# CableDyn finite-EI Hermite line node positions; public node order EndA -> EndB' @@ -28583,7 +28724,7 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, 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 close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open Hermite line tension output: '//TRIM(path)); RETURN END IF WRITE (ten_units(i), '(A)') '# CableDyn finite-EI Hermite segment tensions; public order EndA -> EndB' @@ -28593,10 +28734,24 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, END DO WRITE (ten_units(i), '(A)') '' END IF + IF (PRESENT(lift_units)) THEN + IF (line_output_has_lift(lines(i)%outputs)) THEN + IF (ALLOCATED(cables(i)%deck_node)) THEN + CALL open_line_lift_file(out_root, lines(i)%id, cables(i)%line%nn, lift_units(i), ErrStat, ErrMsg, & + deck_nodes=[(CD_Cable_Deck_Node(cables(i), node), node=1, cables(i)%line%nn)]) + ELSE + CALL open_line_lift_file(out_root, lines(i)%id, cables(i)%line%nn, lift_units(i), ErrStat, ErrMsg) + END IF + IF (ErrStat /= CD_DECKDRV_OK) THEN + CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units); RETURN + END IF + END IF + END IF END DO END SUBROUTINE open_dynamic_hermite_line_outputs - SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, ranges) + SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, ranges, & + lift_units) !! One row of the per-line position and segment-tension files. ranges, when given, is the !! range set sampled for this row by write_hermite_model_row: a line with a range graph !! then reuses the segment tensions of that sample's recovery pass (range_sample_cable). @@ -28607,7 +28762,9 @@ SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, te INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_RangeSet), INTENT(IN), OPTIONAL :: ranges - INTEGER :: i, node, inode, seg, k + INTEGER, INTENT(IN), OPTIONAL :: lift_units(:) + INTEGER :: i, node, inode, seg, k, es + CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' DO i = 1, SIZE(lines) ! Each row is assembled in deck order and written in one WRITE; a non-finite entry @@ -28652,6 +28809,27 @@ SUBROUTINE write_dynamic_hermite_line_outputs(time, lines, cables, pos_units, te WRITE (ten_units(i), ROW_VALUES_FMT) time, (char_tab(), tension(k), k=1, SIZE(tension)) END BLOCK END IF + IF (PRESENT(lift_units)) THEN + IF (lift_units(i) /= 0) THEN + BLOCK + REAL(wp) :: lift(3, cables(i)%line%nn), row(3*cables(i)%line%nn) + CALL CD_HermiteCable_Dyn_VIV_Node_Lift(cables(i)%line, lift, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'Hermite line VIV lift recovery failed: '//TRIM(em)); RETURN + END IF + DO node = 1, cables(i)%line%nn + inode = deck_to_internal_node(node, cables(i)%line%ne) + DO k = 1, 3 + row(3*node - 3 + k) = cable_global_component(cables(i), lift(:, inode), k) + END DO + END DO + IF (.NOT. ALL(IEEE_IS_FINITE(row))) THEN + CALL fail_solve(ErrStat, ErrMsg, 'non-finite Hermite line VIV lift output'); RETURN + END IF + WRITE (lift_units(i), ROW_VALUES_FMT) time, (char_tab(), row(k), k=1, SIZE(row)) + END BLOCK + END IF + END IF END DO END SUBROUTINE write_dynamic_hermite_line_outputs @@ -28682,6 +28860,11 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod 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) @@ -35741,10 +35924,11 @@ LOGICAL FUNCTION any_line_outputs_requested(lines) RESULT(requested) TYPE(DeckLine), INTENT(IN) :: lines(:) INTEGER :: i - ! the per-line time-series files (p, t); the range graph (r) is not one of them + ! the per-line time-series files (p, t, V); the range graph (r) is not one of them requested = .FALSE. DO i = 1, SIZE(lines) - IF (line_output_has_flag(lines(i)%outputs, 'p') .OR. line_output_has_flag(lines(i)%outputs, 't')) THEN + IF (line_output_has_flag(lines(i)%outputs, 'p') .OR. line_output_has_flag(lines(i)%outputs, 't') .OR. & + line_output_has_lift(lines(i)%outputs)) THEN requested = .TRUE. RETURN END IF @@ -35760,17 +35944,24 @@ LOGICAL FUNCTION line_output_has_flag(flags, flag) RESULT(has_flag) has_flag = INDEX(lo, flag(1:1)) > 0 END FUNCTION line_output_has_flag + LOGICAL FUNCTION line_output_has_lift(flags) RESULT(has_flag) + !! The VIV lift file flag V. Case-sensitive, as MoorDyn's line flags are: there v is the node + !! velocities, which CableDyn does not write. + CHARACTER(*), INTENT(IN) :: flags + has_flag = INDEX(flags, 'V') > 0 + END FUNCTION line_output_has_lift + LOGICAL FUNCTION valid_line_output_flags(flags) RESULT(ok) CHARACTER(*), INTENT(IN) :: flags CHARACTER(NAMELEN) :: lo INTEGER :: i - lo = to_lower(TRIM(flags)) + lo = TRIM(flags) ok = .TRUE. IF (LEN_TRIM(lo) == 0 .OR. TRIM(lo) == '-') RETURN DO i = 1, LEN_TRIM(lo) SELECT CASE (lo(i:i)) - CASE ('p', 't', 'r') + CASE ('p', 'P', 't', 'T', 'r', 'R', 'V') CASE DEFAULT ok = .FALSE. RETURN diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 1d6682df..89d7fb44 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -124,6 +124,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Set_Friction_Anchors PUBLIC :: CD_HermiteCable_Dyn_Set_Friction_Axial 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_Curvature @@ -1258,6 +1259,33 @@ SUBROUTINE viv_element_lift(model, q_cfg, v_cfg, e, flift, ErrStat, ErrMsg, djq, END IF END SUBROUTINE viv_element_lift + SUBROUTINE CD_HermiteCable_Dyn_VIV_Node_Lift(model, lift, ErrStat, ErrMsg) + !! The VIV lift on every node at the committed state [N] (3, nn), in the model frame: the + !! translational components of the elements' consistent lift loads, summed at the nodes + !! (MoorDyn's nodal lift on a lumped line). Zero on a cable without VIV. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: lift(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: flift(12) + INTEGER :: e + lift = CD_ZERO + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_VIV_Node_Lift: model not initialised'; RETURN + END IF + IF (SIZE(lift, 1) /= 3 .OR. SIZE(lift, 2) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_VIV_Node_Lift: lift must be shaped (3, nn)'; RETURN + END IF + IF (.NOT. model%has_viv) RETURN + DO e = 1, model%ne + CALL viv_element_lift(model, model%q, model%v, e, flift, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + lift(:, e) = lift(:, e) + flift(1:3) + lift(:, e + 1) = lift(:, e + 1) + flift(7:9) + END DO + END SUBROUTINE CD_HermiteCable_Dyn_VIV_Node_Lift + SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Anchors(model, anchors, ErrStat, ErrMsg) !! Switch the seabed friction of a contact model with mu > 0 to elastic-plastic friction !! springs anchored at anchors(1:2, node) (x, y in the solve frame). The spring stiffness diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index adf6de6f..b7f1d3ae 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -96,7 +96,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Set_Model_Syrope_State PUBLIC :: CD_Set_Model_VIV PUBLIC :: CD_Latch_Model_VIV_Window - PUBLIC :: CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Model_Has_VIV + PUBLIC :: CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Model_Has_VIV, CD_Get_Model_VIV_Lift PUBLIC :: CD_Get_Model_Tension PUBLIC :: CD_Get_Model_EndForces PUBLIC :: CD_Get_Model_EndNodeMassDiag @@ -4062,6 +4062,38 @@ SUBROUTINE CD_Set_Model_VIV_State(model, phi, ms, t_window, ErrStat, ErrMsg) model%viv_phi_eval = phi END SUBROUTINE CD_Set_Model_VIV_State + SUBROUTINE CD_Get_Model_VIV_Lift(model, lift, ErrStat, ErrMsg) + !! The VIV lift force on every node at the committed state [N] (3, n_nodes); zero on the + !! end nodes, on nodes without VIV, and on a model without VIV. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: lift(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: nd, ia + REAL(wp) :: coef, uu(3) + LOGICAL :: ok + lift = CD_ZERO + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_MODEL_NOT_INITIALIZED + ErrMsg = 'CableDyn_Model: model is not initialized' + RETURN + END IF + IF (SIZE(lift, 1) /= 3 .OR. SIZE(lift, 2) /= model%n_dof/3) THEN + CALL fail(ErrStat, ErrMsg, 'VIV lift output must have shape (3, n_nodes)') + RETURN + END IF + IF (.NOT. model%has_viv) RETURN + DO nd = 2, model%n_dof/3 - 1 + IF (.NOT. model%viv_node(nd)) CYCLE + CALL viv_node_coef(model, model%q, nd, coef, uu) + ia = 3*nd - 2 + CALL CD_VIV_Node_Lift(model%q(ia - 3:ia - 1), model%q(ia + 3:ia + 5), smoothed(model%v, ia), uu, coef, & + model%viv_phi(nd), lift(:, nd), ok) + END DO + END SUBROUTINE CD_Get_Model_VIV_Lift + PURE LOGICAL FUNCTION CD_Model_Has_VIV(model) RESULT(has) !! True if the model carries the cross-flow VIV phase state. TYPE(CD_ModelType), INTENT(IN) :: model diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index e46ab3c6..cb3b130a 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -17,7 +17,7 @@ MODULE CableDyn_System CD_Get_Model_State, CD_Get_Model_Tension, & CD_Model_Has_Viscoelastic, CD_Get_Model_VE_Dl1, CD_Set_Model_VE_Dl1, & CD_Model_Has_Syrope, CD_Get_Model_Syrope_State, CD_Set_Model_Syrope_State, & - CD_Model_Has_VIV, CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, & + CD_Model_Has_VIV, CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Get_Model_VIV_Lift, & CD_Model_Has_Friction, CD_Get_Model_Friction_Anchors, CD_Set_Model_Friction_Anchors, & CD_Latch_Model_VIV_Window, & CD_Get_Model_EndNodeMassDiag, CD_Get_Model_EndNodeAddedMass, & @@ -78,7 +78,8 @@ MODULE CableDyn_System PUBLIC :: CD_Get_System_Line_Friction_Anchors PUBLIC :: CD_Set_System_Line_Friction_Anchors PUBLIC :: CD_Get_System_Line_Syrope_State - PUBLIC :: CD_System_Line_VIV_MirrorSize, CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State + PUBLIC :: CD_System_Line_VIV_MirrorSize, CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State, & + CD_Get_System_Line_VIV_Lift PUBLIC :: CD_Set_System_Line_Syrope_State PUBLIC :: CD_Get_System_PointBlocks PUBLIC :: CD_Get_System_Point_State @@ -1024,6 +1025,29 @@ SUBROUTINE CD_Set_System_Line_VIV_State(system, line_index, buf, ErrStat, ErrMsg ErrMsg = '' END SUBROUTINE CD_Set_System_Line_VIV_State + SUBROUTINE CD_Get_System_Line_VIV_Lift(system, line_index, lift, ErrStat, ErrMsg) + !! VIV lift force on every node of one contained line at the committed state (3, n_nodes). + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + REAL(wp), INTENT(OUT) :: lift(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(160) :: em + + lift = CD_ZERO + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + CALL CD_Get_Model_VIV_Lift(system%lines(line_index), lift, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_SYSTEM_SOLVEFAIL + ErrMsg = 'CableDyn_System: line VIV lift query failed: '//TRIM(em) + RETURN + END IF + ErrStat = CD_SYSTEM_OK + ErrMsg = '' + END SUBROUTINE CD_Get_System_Line_VIV_Lift + SUBROUTINE CD_Set_System_Line_Syrope_State(system, line_index, slow, tmax, ErrStat, ErrMsg) !! Overwrite one contained line's per-element Syrope states from a checkpoint mirror !! (the cross-process restart reload). diff --git a/tests/data/msg_line_flag_velocity.dat b/tests/data/msg_line_flag_velocity.dat new file mode 100644 index 00000000..1d73e241 --- /dev/null +++ b/tests/data/msg_line_flag_velocity.dat @@ -0,0 +1,37 @@ +--------------------- CableDyn Input File --- +msg_line_flag_velocity +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +neut 0.2 80.0 100000000 -1 0.0 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -20 0 0 0 0 +2 Fixed 80 0 -100 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 pv +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 neut 120 120 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +--------------------- need this line --- diff --git a/tests/test_viv_lockin.py b/tests/test_viv_lockin.py index 0102c6c3..7c9fa788 100644 --- a/tests/test_viv_lockin.py +++ b/tests/test_viv_lockin.py @@ -21,6 +21,11 @@ * the same finite-EI cable on the multibody march (End A Fixed, and a weighted Connect point on two chains 300 m away, which puts the deck on that march) locks in as on the Hermite route (within 1 % and one bin); +* the VIV lift files (LINES Outputs flag V) of the EI = 0 line, the cable and the cable on the + multibody march: no lift on the EI = 0 line's end nodes (MoorDyn's), and the same cross-flow + lift at the interior nodes on all three (standard deviation over 60-120 s within 1 %) but the + end nodes' neighbours: the EI = 0 line's end half-segments carry no lift, as MoorDyn's, while + a cable element shares its lift between its two nodes; * a bending-stiff, neutrally buoyant cable (8.1 kg/m, EA 5e9 N, EI 5e7 N m^2, about 51 kN: beta = pi^2 EI/(T L^2) ~ 1) against the EI = 0 string tensioned to T (1 + beta), which has the same first-mode frequency and shape: at U 0.21 m/s both lock into mode 1 with the same @@ -82,7 +87,7 @@ def check(ok: bool, message: str) -> None: def deck(dtm: float, ei: float = 0.0, ea: float = 5.0e7, mass: float = 10.0, tension: float = 5.0e4, - waterkin: str = "current.dat") -> str: + waterkin: str = "current.dat", outputs: str = "-") -> str: length = 100.0 / (1.0 + tension / ea) return f"""--------------------- CableDyn Input File --------------------------------- VIV lock-in gate: taut line in a uniform cross current @@ -98,7 +103,7 @@ def deck(dtm: float, ei: float = 0.0, ea: float = 5.0e7, mass: float = 10.0, ten ----------------------- LINES ----------------------------------------------- ID LineType AttachA AttachB UnstrLen NumSegs Outputs (#) (name) (#) (#) (m) (-) (-) -1 riser 1 2 {length:.6f} 50 - +1 riser 1 2 {length:.6f} 50 {outputs} ---------------------- OPTIONS ---------------------------------------------- {dtm} dtM 100.0 WtrDpth @@ -127,12 +132,23 @@ def multibody(text: str) -> str: "3 Fixed 0.0 300.0 -20.0 0 0 0 0\n" "4 Connect 50.0 300.0 -60.0 5000 0 0 0\n" "5 Fixed 100.0 300.0 -20.0 0 0 0 0"), - (" 50 -\n", " 50 -\n2 chain 3 4 70.0 20 -\n" - "3 chain 5 4 70.0 20 -\n"), ): assert text.count(old) == 1, old text = text.replace(old, new) - return text + riser = next(line for line in text.splitlines() if line.startswith("1 riser")) + return text.replace(riser + "\n", riser + "\n2 chain 3 4 70.0 20 -\n" + "3 chain 5 4 70.0 20 -\n") + + +def lift_std(path: Path) -> np.ndarray: + """Standard deviation over 60-120 s of the cross-flow (z) lift at each node of a V file.""" + lines = path.read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.startswith("Time")) + names = lines[head].split("\t") + data = np.loadtxt(lines[head + 1:]) + data = data[data[:, 0] >= 60.0] + cols = [j for j, name in enumerate(names) if name.endswith("LiftZ(N)")] + return data[:, cols].std(axis=0) def response(path: Path) -> tuple[float, float, float]: @@ -169,11 +185,12 @@ def main() -> int: stiff = {"ei": 5.0e7, "ea": 5.0e9, "mass": 8.1} string = {"ea": 5.0e7, "mass": 8.1, "tension": 5.0e4 * (1.0 + beta)} runs = [ - (0.01, "viv_dt0.01", deck(0.01, waterkin="current_0.15.dat")), + (0.01, "viv_dt0.01", deck(0.01, waterkin="current_0.15.dat", outputs="V")), (0.002, "viv_dt0.002", deck(0.002, waterkin="current_0.15.dat")), - ("fei", "viv_fei", deck(0.01, ei=1.0, waterkin="current_0.15.dat")), + ("fei", "viv_fei", deck(0.01, ei=1.0, waterkin="current_0.15.dat", outputs="V")), ("fei_fine", "viv_fei_dt0.002", deck(0.002, ei=1.0, waterkin="current_0.15.dat")), - ("fei_mb", "viv_fei_multibody", multibody(deck(0.01, ei=1.0, waterkin="current_0.15.dat"))), + ("fei_mb", "viv_fei_multibody", + multibody(deck(0.01, ei=1.0, waterkin="current_0.15.dat", outputs="V"))), ] for u in (0.21, 0.30): runs.append((("stiff", u), f"viv_stiff_u{u}", deck(0.01, waterkin=f"current_{u}.dat", **stiff))) @@ -225,6 +242,21 @@ def run(name: str) -> subprocess.CompletedProcess[str]: check(abs(a1 - a0) <= 0.01 * a0 and abs(q1 - q0) <= 0.01 * q0 and abs(f1 - f0) <= 1.0 / 60.0, f"finite-EI cable on the multibody march: mid/quarter A/D {a1:.3f}/{q1:.3f} at {f1:.3f} Hz, " f"Hermite route {a0:.3f}/{q0:.3f} at {f0:.3f} Hz (within 1 % and one bin)") + lifts = {} + for key, name in ((0.01, "viv_dt0.01"), ("fei", "viv_fei"), ("fei_mb", "viv_fei_multibody")): + if key in results: + lifts[key] = lift_std(out / f"{name}.Line1.V.out") + if 0.01 in lifts: + ends = lifts[0.01][[0, -1]] + check(bool(np.all(ends == 0.0)) and lifts[0.01][25] > 0.5, + f"EI = 0 line lift file: no lift on the end nodes, mid-span cross-flow lift std " + f"{lifts[0.01][25]:.3f} N") + for key, what in (("fei", "cable"), ("fei_mb", "cable on the multibody march")): + if 0.01 in lifts and key in lifts: + inner0, inner1 = lifts[0.01][2:-2], lifts[key][2:-2] + worst = float(np.max(np.abs(inner1 - inner0) / np.maximum(inner0, 1.0e-3))) + check(worst <= 0.01, f"{what} lift file: interior cross-flow lift std within {worst:.2%} of the " + "EI = 0 line's (within 1 %)") if ("stiff", 0.21) in results and ("string", 0.21) in results: (a1, f1, _), (a0, f0, _) = results[("stiff", 0.21)], results[("string", 0.21)] check(abs(a1 - a0) <= 0.03 * a0 and abs(f1 - f0) <= 1.0 / 60.0, From 4754a69ac544991777c8fb470f513e81732e493b Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 29 Oct 2026 12:20:58 +0900 Subject: [PATCH 14/51] fix(viv): seed the shedding phase from the deck's End A; MoorDyn-C's riser (#63) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MoorDyn seeds each node's VIV shedding phase at 2π i/N, with node i counted from the line's AttachA. CableDyn counted from its own End A. For two kinds of line that gives a different start: - **A line written anchor first** (the usual MoorDyn row order). The reader turns it around, so CableDyn's node 1 is MoorDyn's node N. - **A finite-EI mesh the static solve refined.** The node index no longer names the deck nodes. ## Changes - **`CD_Deck_VIV_Phase_Seed`** gives MoorDyn's seed node by node: - counted from the deck's End A; - held at the deck nodes of a refined mesh; - interpolated in unstretched arc length at the nodes the refinement added. - **Both line kinds take it.** `CD_Set_Model_VIV` (`EI = 0`) and `CD_HermiteCable_Dyn_Set_VIV` (finite-EI) gain an optional `phase_seed`. It is checked for size and finiteness. - **Routes.** The standalone, multibody and coupled builds all pass it, since they share the line builders. - **Unchanged decks.** Lines written fairlead first on the deck mesh keep their phases exactly. - **Docs:** theory, VALIDATION and CHANGELOG. VALIDATION had listed coupled VIV as unsupported; it now records it. ## Checks - **New `viv_riser` test: MoorDyn-C's own VIV case**, the catenary riser of Thorsen et al. in a uniform 0.2 m/s current, written anchor first. Results over 20–40 s at `dtM` 1e-3 s: | | CableDyn | MoorDyn-C | Measured | |---|---|---|---| | Mean fairlead tension | 69.92 N | 69.93 N | | | Tension range | 3.73 N | 3.72 N | | | Period | 0.4853 s | 0.4811 s | 0.4808 s | The period converges with `dtM` (0.4829 s at 2.5e-4 s). - **`viv_coupled`** covers the seed on the coupled routes. - **Test suite:** ctest 310/310; Python 2027 passed. - **Examples:** all 52 shipped examples are byte-identical to dev. None uses `Cl > 0`. - **Format:** fprettify is clean. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 +- CMakeLists.txt | 9 +++ VALIDATION.md | 3 +- doc/theory.rst | 5 +- src/CableDyn_DeckDriver.f90 | 77 ++++++++++++++++-- src/CableDyn_HermiteCableDynamic.f90 | 14 +++- src/CableDyn_Model.f90 | 14 +++- tests/test_viv_coupled.f90 | 62 ++++++++++++++- tests/test_viv_riser.py | 115 +++++++++++++++++++++++++++ 9 files changed, 289 insertions(+), 16 deletions(-) create mode 100644 tests/test_viv_riser.py diff --git a/CHANGELOG.md b/CHANGELOG.md index ca12e8f3..6af9ee14 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,11 @@ All notable changes to CableDyn are recorded in this file. The format follows with the same phase start and running-RMS window (`VIVrmsWindow`, default 500 steps of `dtM`). On a taut 100 m line in a uniform current it follows MoorDyn-F's lock-in amplitude and frequency to two to three digits through mode-1 and mode-3 lock-in, at any `dtM` from - 5e-4 to 1e-2 s. The Python deck tools read and keep the columns. + 5e-4 to 1e-2 s. The phases start from the deck's End A as MoorDyn's do, also on a line + written anchor first, which the reader turns around, and at the deck nodes of a refined + finite-EI mesh. MoorDyn-C's own VIV case, the catenary riser of Thorsen et al., reproduces + its mean tension and tension range and the measured lock-in frequency (period within 1 %). + The Python deck tools read and keep the columns. - Cross-flow VIV of finite-EI cables in the standalone driver: the same LINE TYPES columns on an `EI > 0` type give a distributed lift, Gauss-integrated over each cubic-Hermite element with exact tangents, and a shedding phase at each node driven along the node's own tangent. A taut diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c3b79d0..163a0b51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1649,6 +1649,15 @@ if(Python3_Interpreter_FOUND) PROCESSORS 4 TIMEOUT ${_viv_lockin_timeout} ENVIRONMENT "${_cabledyn_python_test_environment}") + # MoorDyn-C's VIV test case: the catenary riser of Thorsen et al. in a uniform current + add_test(NAME viv_riser + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_viv_riser.py + --exe $ + --output ${CMAKE_BINARY_DIR}/viv_riser) + set_tests_properties(viv_riser PROPERTIES + LABELS "python;integration;dynamic;viv;validation" + TIMEOUT ${_viv_lockin_timeout} + ENVIRONMENT "${_cabledyn_python_test_environment}") else() message(STATUS "viv_lockin: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() diff --git a/VALIDATION.md b/VALIDATION.md index a025c0a3..8414bb19 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -63,6 +63,7 @@ article's methods, are compared in | **L2-80** | Lozon 80 m all-chain mooring | catenary (H) / MoorDyn-F (fairlead) | 0.03% / 1.8% | <2% / <5% | Pass | | **L2-arb** | Closed-form catenary reference check | OrcaFlex VolturnUS-S ref | 0.69% | <2% | Pass | | **L2-VIV** | Cross-flow VIV lock-in of a taut 100 m line, U = 0.06–0.42 m/s | MoorDyn-F (OpenFAST v5 `moordyn_driver`, `dtM` 5e-4 s) | mode-1 and mode-3 lock-in (U ≤ 0.18 and ≥ 0.36 m/s): mid-span A/D within 1.2%, frequency within one spectral bin; same response at `dtM` 5e-4 to 1e-2 s; at 0.21–0.33 m/s the codes settle on different modes (MoorDyn-F mode 1, CableDyn mode 2) | A/D <3%, frequency within one spectral bin (`viv_lockin`) | Pass scoped | +| **L2-VIV-riser** | Catenary riser of Thorsen et al. in a uniform 0.2 m/s current (MoorDyn-C's VIV test: D 0.024 m, EI 10.5 N m², 100 segments, `Cl` 0.7), deck written anchor first | measured cross-flow frequency 1.04 Hz; MoorDyn-C v2.7.2 (RK4, `dtM` 1e-4 s) | over 20–40 s at `dtM` 1e-3 s: mean fairlead tension 69.92 N against 69.93 N, range 3.73 N against 3.72 N, tension period 0.4853 s against the measured 0.4808 s and MoorDyn-C's 0.4811 s (0.4843 / 0.4829 s at `dtM` 5e-4 / 2.5e-4 s) | mean 0.2%, range 10%, period 1.5% (`viv_riser`) | Pass | | **L2-VIV-EI** | Cross-flow VIV of a finite-EI cable: the L2-VIV line with EI = 1 N m², and a bending-stiff line (EA 5e9 N, EI 5e7 N m², β = π²EI/(TL²) ≈ 1, neutrally buoyant) against the EI = 0 string of equal first-mode frequency, U = 0.10–0.36 m/s | CableDyn `EI = 0` line (verification) | EI = 1: mid/quarter A/D 0.662/0.421 against 0.663/0.421, same frequency, at `dtM` 5e-4 to 1e-2 s; stiff line: mode-1 lock-in A/D within 2.5% of the string's at the same frequency for U ≤ 0.24 m/s; for U ≥ 0.27 m/s the string jumps to mode 2 while the stiff line stays in mode 1 (bending raises f₂/f₁ to 3.15) | EI = 1: A/D within 1% at `dtM` 0.01 and 0.002 s (5e-4 s run once over 200 s); stiff line at U 0.21 m/s: A/D within 3%; frequency within one spectral bin; at U 0.30 m/s stiff line A/D > 0.6, string < 0.15 (`viv_lockin`, `hermite_viv`) | Pass | | **L3-1** | WD0050 static | OrcaFlex | 0.15 / 0.85% | <2% | Pass | | **L3-2** | Regular-wave dynamic | OrcaFlex (pinned, dt-converged) | mean 0.30%, swing 8.4% | <2% / <15% | Pass | @@ -793,7 +794,7 @@ stop with a named error. | Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | -| VIV (`compVIV`) | Not supported | outside CableDyn's scope | +| Cross-flow VIV (LINE TYPES `Cl`) | Pass verified | `EI = 0` lines and finite-EI cables on the aggregate with the host's fluid field: an `EI = 0` riser and a cable (EI 1 N m²) in a 0.15 m/s host current lock in at A/D 0.6645 / 0.6646 and 0.292 Hz (MoorDyn-F 0.662 at 0.293 Hz; standalone 0.665); the phases, running mean squares and averaging time ride in the checkpoint state and the correction rewind: a rebuild from the checkpoint continues bit for bit, one without the VIV reload does not (`viv_coupled`). OpenFAST (IEA-15 UMaine mixed deck, `Cl` 0.8 on the lazy-wave cable, SeaState 0.5 m/s current, 60 s): `openfast -restart` at 30 s reproduces every later CableDyn and OpenFAST output row bit for bit | **Standalone mixed aggregate.** `CableDyn_driver.exe` partitions and steps the same aggregate used by OpenFAST. The IEA-15 three-chain + touchdown-cable deck diff --git a/doc/theory.rst b/doc/theory.rst index 8cf279c6..11c57108 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -746,7 +746,10 @@ along :math:`\mathbf{e} = \mathbf{q}\times\mathbf{v}_n/U`: so the shedding frequency locks onto the cross-flow motion inside the band :math:`c_F \pm d_F` (MoorDyn's defaults 0.18 and 0.08). The running RMS values average over ``VIVrmsWindow`` seconds, by default 500 steps of ``dtM`` as in MoorDyn, and the phases start at -:math:`2\pi i/N` along the line from End A. The static equilibrium carries no lift. +:math:`2\pi i/N` at node :math:`i` counted from the deck's End A (MoorDyn's ``AttachA``), also on +a line written anchor first, which the reader turns around. On a finite-EI mesh the static solve +refined, the deck nodes keep that seed and the nodes it added take the seed interpolated in +arc length. The static equilibrium carries no lift. In the implicit step the phase is explicit: the step's lift takes the phase predicted at :math:`t_{n+1}` from the step-start rate (the generalised-α level under the configuration blend), diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index e07937c8..a60b4dc4 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -193,6 +193,7 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Init_Deck_Models PUBLIC :: CD_Init_Deck_System PUBLIC :: CD_Init_Deck_HermiteCable + PUBLIC :: CD_Deck_VIV_Phase_Seed PUBLIC :: CD_Stiffener_Overlay PUBLIC :: CD_Init_Deck_Aggregate PUBLIC :: CD_Deck_Query_dtM @@ -3189,10 +3190,27 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! coupled host may step the cable at a dt adjusted from the deck dtM. IF (PRESENT(install_viv)) THEN IF (install_viv .AND. ANY(viv_cl > CD_ZERO)) THEN - CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & - MERGE(opts%viv_rms_window, & - REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & - opts%viv_rms_window > CD_ZERO), es, em) + ! MoorDyn's phase seed counts the deck nodes from the deck's End A: a line the reader turned + ! around, or a mesh the static solve refined, takes it node by node (CD_Deck_VIV_Phase_Seed) + IF (ln%ends_swapped .OR. ALLOCATED(cable%deck_node)) THEN + BLOCK + REAL(wp) :: seed(cable%line%nn) + IF (ALLOCATED(cable%deck_node)) THEN + CALL CD_Deck_VIV_Phase_Seed(cable%line%l0, ln%ends_swapped, seed, deck_map=cable%deck_node) + ELSE + CALL CD_Deck_VIV_Phase_Seed(cable%line%l0, ln%ends_swapped, seed) + END IF + CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & + MERGE(opts%viv_rms_window, & + REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & + opts%viv_rms_window > CD_ZERO), es, em, phase_seed=seed) + END BLOCK + ELSE + CALL CD_HermiteCable_Dyn_Set_VIV(cable%line, viv_cl, viv_cf, viv_df, & + MERGE(opts%viv_rms_window, & + REAL(CD_VIV_NM, wp)*MERGE(opts%dtM, dt, opts%has_dtm), & + opts%viv_rms_window > CD_ZERO), es, em) + END IF IF (es /= CD_HCDYN_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable VIV wiring failed: '//TRIM(em)); RETURN END IF @@ -9043,7 +9061,17 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err END IF tw = opts%viv_rms_window IF (.NOT. (tw > CD_ZERO) .AND. opts%has_dtm) tw = REAL(CD_VIV_NM, wp)*opts%dtM - CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em) + IF (ln%ends_swapped) THEN + ! MoorDyn counts the phase seed from the deck's End A, which the reader turned around + BLOCK + REAL(wp) :: seed(model%n_dof/3) + CALL CD_Deck_VIV_Phase_Seed(model%l0, .TRUE., seed) + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em, & + phase_seed=seed) + END BLOCK + ELSE + CALL CD_Set_Model_VIV(model, opts%rhoW, viv_cl, hydro_diam, viv_cf, viv_df, tw, es, em) + END IF IF (es == CD_MODEL_OK) CALL CD_Recompute_Model_Acceleration(model, es, em) IF (es /= CD_MODEL_OK) THEN ErrStat = CD_DECKDRV_BADINPUT @@ -34966,6 +34994,45 @@ PURE FUNCTION cable_frame_is_identity(cable) RESULT(is_id) is_id = .NOT. (ABS(cable%frame_s) > CD_ZERO .OR. ABS(cable%frame_c - CD_ONE) > CD_ZERO) END FUNCTION cable_frame_is_identity + PURE SUBROUTINE CD_Deck_VIV_Phase_Seed(l0, swapped, seed, deck_map) + !! MoorDyn's VIV phase seed i/N (phase 2 pi i/N at node i = 0 .. N counted from the deck's + !! End A, N the deck's segment count) at every node of a line, in the model's internal node + !! order (node 1 = End B; element e of length l0(e) joins nodes e and e + 1). swapped: the + !! reader turned the line's ends around, so the deck's End A is the model's End B. deck_map: + !! the mesh node (public order, End A = 1) of each deck node, on a mesh the static solve + !! refined; a node it added takes the seed interpolated linearly in unstretched arc length + !! between its two deck nodes. Without deck_map the mesh is the deck's. + REAL(wp), INTENT(IN) :: l0(:) + LOGICAL, INTENT(IN) :: swapped + REAL(wp), INTENT(OUT) :: seed(:) + INTEGER, INTENT(IN), OPTIONAL :: deck_map(:) + REAL(wp) :: s(SIZE(l0) + 1), f + INTEGER :: ne, nn, p, j, nd + ne = SIZE(l0) + nn = ne + 1 + ! unstretched arc length from End A at public node p (internal element ne + 1 - p follows it) + s(1) = CD_ZERO + DO p = 1, ne + s(p + 1) = s(p) + l0(ne + 1 - p) + END DO + DO p = 1, nn + IF (PRESENT(deck_map)) THEN + nd = SIZE(deck_map) - 1 + f = CD_ONE + DO j = 1, nd + IF (p >= deck_map(j) .AND. p <= deck_map(j + 1)) THEN + f = (REAL(j - 1, wp) + (s(p) - s(deck_map(j)))/(s(deck_map(j + 1)) - s(deck_map(j))))/REAL(nd, wp) + EXIT + END IF + END DO + ELSE + f = REAL(p - 1, wp)/REAL(ne, wp) + END IF + IF (swapped) f = CD_ONE - f + seed(nn + 1 - p) = f + END DO + END SUBROUTINE CD_Deck_VIV_Phase_Seed + PURE INTEGER FUNCTION CD_Cable_Deck_Node(cable, node) RESULT(deck_node) !! The deck node at public node `node` (End A = 1) of a finite-EI cable's final mesh: the !! node itself when the mesh is the deck mesh, 0 for a node the refinement added (the diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 89d7fb44..b303cb3d 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -966,13 +966,15 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial(model, mu_axial, ErrStat, ErrM model%tr_valid = .FALSE. END SUBROUTINE CD_HermiteCable_Dyn_Set_Friction_Axial - SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg) + SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, ErrMsg, phase_seed) !! Install the cross-flow VIV synchronisation model (CableDyn_VIV) on a cable with drag: !! per element the lift coefficient cl (0: no lift) and the band df/cf, and the running-RMS !! averaging time t_window (s; 0 takes 500 steps of the first step). The lift acts on the !! wetted Gauss points of every element with cl > 0, its phase lives on the nodes of those !! elements; the phases start at 2 pi i/N with node i counted from End A (the model's last - !! node), as MoorDyn's. The phase follows the drag's current and a held host field (which + !! node), as MoorDyn's; phase_seed, per node, gives i/N instead (a line whose deck End A the + !! reader turned around, or a mesh refined from the deck's). The phase follows the drag's + !! current and a held host field (which !! carries any waves); the internal wave families (Set_Waves) are refused with VIV. The !! committed acceleration is refreshed with the new lift; if that fails, the previous VIV !! configuration, its state and the acceleration are restored. @@ -980,6 +982,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err REAL(wp), INTENT(IN) :: cl(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: phase_seed(:) INTEGER :: e, k, ne, nn, es REAL(wp) :: wsum, tw_old LOGICAL :: had_viv @@ -1013,6 +1016,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: VIV needs the cable''s drag in water (set the drag first)'; RETURN END IF + IF (PRESENT(phase_seed)) THEN + IF (SIZE(phase_seed) /= nn .OR. .NOT. CD_All_Finite(phase_seed)) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: the phase seed must be finite with one value per node'; RETURN + END IF + END IF IF (model%has_wave) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Set_VIV: internal waves are configured; VIV takes waves as a held '// & @@ -1057,6 +1066,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_VIV(model, cl, cf, df, t_window, ErrStat, Err model%viv_cf(k) = model%viv_cf(k)/wsum model%viv_df(k) = model%viv_df(k)/wsum model%viv_phi(k) = CD_VIV_TWO_PI*REAL(nn - k, wp)/REAL(ne, wp) + IF (PRESENT(phase_seed)) model%viv_phi(k) = CD_VIV_TWO_PI*phase_seed(k) END DO CALL viv_drag_terms(model) model%viv_phi_eval = model%viv_phi diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index b7f1d3ae..3c864f75 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -3861,14 +3861,16 @@ SUBROUTINE CD_Set_Model_Syrope_State(model, slow, tmax, ErrStat, ErrMsg) model%recovery_syrope_tmax = tmax END SUBROUTINE CD_Set_Model_Syrope_State - SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, ErrMsg) + SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, ErrMsg, phase_seed) !! Install the cross-flow VIV model (CableDyn_VIV) on an initialised line. Per element: !! the lift coefficient cl (0 = no lift on that element), hydrodynamic diameter, and the !! synchronisation centre cf and half-range df of the non-dimensional shedding frequency; !! rho is the water density. t_window is the averaging time of the running cross-flow mean !! squares [s]; 0 selects MoorDyn's 500 time steps, latched at the first step. Every !! interior free node next to a cl > 0 element carries a lift and a shedding phase; the - !! phases start spread over [0, 2 pi) along the line (MoorDyn-C), the mean squares at 0. + !! phases start spread over [0, 2 pi) along the line (MoorDyn-C: 2 pi i/N at node i from + !! End A; phase_seed, per node, gives i/N instead, for a line whose deck End A the reader + !! turned around), the mean squares at 0. !! An all-zero cl leaves the model without VIV. The mesh must be the single chain the !! line builder makes (element e joins nodes e and e+1). The caller recomputes the !! acceleration if the lift should enter the initial state (CD_Recompute_Model_Acceleration). @@ -3876,6 +3878,7 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, REAL(wp), INTENT(IN) :: rho, cl(:), diameter(:), cf(:), df(:), t_window INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: phase_seed(:) INTEGER :: n_nodes, n_elem, e, nd, istat, k REAL(wp) :: wsum @@ -3905,6 +3908,12 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, CALL fail(ErrStat, ErrMsg, 'VIV averaging time must be finite and non-negative') RETURN END IF + IF (PRESENT(phase_seed)) THEN + IF (SIZE(phase_seed) /= n_nodes .OR. .NOT. CD_All_Finite(phase_seed)) THEN + CALL fail(ErrStat, ErrMsg, 'VIV phase seed must be finite with shape (n_nodes)') + RETURN + END IF + END IF CALL clear_viv(model) IF (.NOT. ANY(cl > CD_ZERO)) RETURN IF (.NOT. (CD_Is_Finite(rho) .AND. rho > CD_ZERO)) THEN @@ -3968,6 +3977,7 @@ SUBROUTINE CD_Set_Model_VIV(model, rho, cl, diameter, cf, df, t_window, ErrStat, ! MoorDyn: phi_i = 2 pi i/N at node i = 0..N counted from End A; the model numbers its ! nodes from End B, so node nd is MoorDyn's node n_nodes - nd model%viv_phi(nd) = CD_VIV_TWO_PI*REAL(n_nodes - nd, wp)/REAL(n_elem, wp) + IF (PRESENT(phase_seed)) model%viv_phi(nd) = CD_VIV_TWO_PI*phase_seed(nd) END DO model%viv_phi_rollback = model%viv_phi model%viv_ms_rollback = model%viv_ms diff --git a/tests/test_viv_coupled.f90 b/tests/test_viv_coupled.f90 index 99fc075e..9272a1bd 100644 --- a/tests/test_viv_coupled.f90 +++ b/tests/test_viv_coupled.f90 @@ -20,7 +20,10 @@ PROGRAM test_viv_coupled !! lands on the same state, phases included, bit for bit; !! * averaging window: without VIVrmsWindow both line kinds average over MoorDyn's 500 steps !! of the deck dtM, also when the coupling step differs from it (dtM 0.001 s at a 0.01 s - !! step: 0.5 s), and over 500 coupling steps when the deck has no dtM (5 s). + !! step: 0.5 s), and over 500 coupling steps when the deck has no dtM (5 s); + !! * phase seed: MoorDyn's 2 pi i/N with node i counted from the deck's End A, also on a deck + !! written anchor first (which the reader turns around) and, through CD_Deck_VIV_Phase_Seed, + !! at the deck nodes of a refined mesh (added nodes interpolated in arc length). USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_End, CD_AGG_OK, & CD_AGG_NMovingPoints, CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, & @@ -28,6 +31,7 @@ PROGRAM test_viv_coupled CD_AGG_SetFluidFields, CD_AGG_Snapshot, CD_AGG_Restore USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_VIVMirrorSize, CD_HFMF_PackMirror, & CD_HFMF_UnpackMirror, CD_HFMF_OK + USE CableDyn_DeckDriver, ONLY: CD_Deck_VIV_Phase_Seed USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_Get_System_Line_State, & CD_Update_System_Line_Interior_State, CD_System_Line_VIV_MirrorSize, & CD_Get_System_Line_VIV_State, CD_Set_System_Line_VIV_State, CD_SYSTEM_OK @@ -45,6 +49,7 @@ PROGRAM test_viv_coupled CALL case_restart() CALL case_rewind() CALL case_window() + CALL case_seed() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' coupled VIV check(s) failed' ERROR STOP 1 @@ -162,6 +167,45 @@ SUBROUTINE case_window() END DO END SUBROUTINE case_window + SUBROUTINE case_seed() + !! MoorDyn's phase seed on a refined mesh and on an anchor-first deck. + REAL(wp), PARAMETER :: TWO_PI = 8.0_wp*ATAN(1.0_wp) + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: seed(5), want(5), worst_line, worst_cable + INTEGER :: k, pass, nn + ! four mesh elements (internal order, End B first) over two deck segments: deck nodes at public + ! nodes 1, 3 and 5, so public node 4 lies 3/4 of the way along the second deck segment + CALL CD_Deck_VIV_Phase_Seed([1.0_wp, 3.0_wp, 2.0_wp, 2.0_wp], .FALSE., seed, deck_map=[1, 3, 5]) + want = [1.0_wp, 0.875_wp, 0.5_wp, 0.25_wp, 0.0_wp] + CALL check(MAXVAL(ABS(seed - want)) < 1.0e-14_wp, 'refined mesh: deck nodes keep i/N, added nodes interpolate') + CALL CD_Deck_VIV_Phase_Seed([1.0_wp, 3.0_wp, 2.0_wp, 2.0_wp], .TRUE., seed, deck_map=[1, 3, 5]) + CALL check(MAXVAL(ABS(seed - (1.0_wp - want))) < 1.0e-14_wp, 'a turned-around line counts from its End B') + CALL CD_Deck_VIV_Phase_Seed([1.0_wp, 3.0_wp, 2.0_wp, 2.0_wp], .FALSE., seed) + CALL check(MAXVAL(ABS(seed - [4.0_wp, 3.0_wp, 2.0_wp, 1.0_wp, 0.0_wp]/4.0_wp)) < 1.0e-14_wp, & + 'the deck mesh keeps the node index') + CALL write_deck('viv_coupled_stock.dat', 0.8_wp, anchor_first=.TRUE.) + DO pass = 1, 2 + IF (.NOT. start(agg, MERGE('viv_coupled.dat ', 'viv_coupled_stock.dat', pass == 1))) RETURN + nn = SIZE(agg%sys%fast%system%lines(1)%viv_phi) + worst_line = 0.0_wp + worst_cable = 0.0_wp + DO k = 2, nn - 1 + ! internal node k (k = 1 at the anchor); MoorDyn's node from the deck's End A + IF (pass == 1) THEN + worst_line = MAX(worst_line, ABS(agg%sys%fast%system%lines(1)%viv_phi(k) - TWO_PI*REAL(nn - k, wp)/50.0_wp)) + worst_cable = MAX(worst_cable, ABS(agg%cables(1)%line%viv_phi(k) - TWO_PI*REAL(nn - k, wp)/50.0_wp)) + ELSE + worst_line = MAX(worst_line, ABS(agg%sys%fast%system%lines(1)%viv_phi(k) - TWO_PI*REAL(k - 1, wp)/50.0_wp)) + worst_cable = MAX(worst_cable, ABS(agg%cables(1)%line%viv_phi(k) - TWO_PI*REAL(k - 1, wp)/50.0_wp)) + END IF + END DO + CALL check(worst_line < 1.0e-12_wp .AND. worst_cable < 1.0e-12_wp, & + MERGE('fairlead-first deck: the seed counts from the fairlead', & + 'anchor-first deck: the seed counts from the anchor ', pass == 1)) + CALL finish(agg) + END DO + END SUBROUTINE case_seed + LOGICAL FUNCTION start(agg, path) RESULT(ok) !! A host-fluid build of the deck at dt. TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg @@ -291,13 +335,15 @@ SUBROUTINE response(z, ad, f) IF (n > 1) f = REAL(n - 1, wp)/(t1 - t0) END SUBROUTINE response - SUBROUTINE write_deck(path, cl, window, dtm) + SUBROUTINE write_deck(path, cl, window, dtm, anchor_first) !! The EI = 0 riser (line 1) and the finite-EI cable (line 2), 20 m apart across the current; !! VIVrmsWindow 0.25 s unless window is given (0: none), and a deck dtM when dtm is given. CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN) :: cl REAL(wp), INTENT(IN), OPTIONAL :: window, dtm + LOGICAL, INTENT(IN), OPTIONAL :: anchor_first INTEGER :: u + LOGICAL :: stock REAL(wp) :: tw CHARACTER(32) :: len_txt, cl_txt WRITE (len_txt, '(F12.6)') 100.0_wp/(1.0_wp + 5.0e4_wp/5.0e7_wp) @@ -320,8 +366,16 @@ SUBROUTINE write_deck(path, cl, window, dtm) WRITE (u, '(A)') '--------------------- LINES ---' WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs Outputs' WRITE (u, '(A)') '(#) (name) (#) (#) (m) (-) (-)' - WRITE (u, '(A)') '1 riser 1 2 '//TRIM(ADJUSTL(len_txt))//' 50 -' - WRITE (u, '(A)') '2 cable 3 4 '//TRIM(ADJUSTL(len_txt))//' 50 -' + stock = .FALSE. + IF (PRESENT(anchor_first)) stock = anchor_first + IF (stock) THEN + ! MoorDyn's common row order, AttachA the anchor: the reader turns the lines around + WRITE (u, '(A)') '1 riser 2 1 '//TRIM(ADJUSTL(len_txt))//' 50 -' + WRITE (u, '(A)') '2 cable 4 3 '//TRIM(ADJUSTL(len_txt))//' 50 -' + ELSE + WRITE (u, '(A)') '1 riser 1 2 '//TRIM(ADJUSTL(len_txt))//' 50 -' + WRITE (u, '(A)') '2 cable 3 4 '//TRIM(ADJUSTL(len_txt))//' 50 -' + END IF WRITE (u, '(A)') '--------------------- OPTIONS ---' WRITE (u, '(A)') '100.0 WtrDpth' WRITE (u, '(A)') '1025.0 rhoW' diff --git a/tests/test_viv_riser.py b/tests/test_viv_riser.py new file mode 100644 index 00000000..0c10f071 --- /dev/null +++ b/tests/test_viv_riser.py @@ -0,0 +1,115 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Cross-flow VIV of the catenary riser of Thorsen et al., MoorDyn-C's VIV test case. + +MoorDyn-C (tests/Mooring/viv/viv.txt): a 23.71 m riser model (D 0.024 m, 0.69 kg/m, EA 6.66e5 N, +EI 10.5 N m^2, 100 segments) from the seabed at 10 m depth to 1 m below the surface, in a uniform +0.2 m/s current in its plane, Cl 0.7 with MoorDyn's band. The cross-flow response, out of the +plane, locks in at the measured 1.04 Hz, so the fairlead tension oscillates at twice that: a +period of 1/(2 x 1.04 Hz) = 0.4808 s. The deck is written anchor first, as MoorDyn's, so it also +exercises the phase seed counted from the deck's End A on a line the reader turns around. + +MoorDyn-C v2.7.2 (RK4, dtM 1e-4 s) over 20-40 s: mean fairlead tension 69.93 N, peak-to-peak +3.72 N, period 0.4811 s. Gates on CableDyn at dtM 1e-3 s over the same window: + +* mean tension within 0.2 % of MoorDyn-C's; +* tension range (peak to peak) within 10 % of MoorDyn-C's; +* mean period within 1.5 % of the measured target and of MoorDyn-C's (the period converges to + MoorDyn-C's with dtM: 0.4853, 0.4843, 0.4829 s at 1e-3, 5e-4, 2.5e-4 s). + +usage: test_viv_riser.py --exe --output +""" + +from __future__ import annotations + +import argparse +import os +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +TARGET = 1.0 / (2.0 * 1.04) +MDC_MEAN, MDC_RANGE, MDC_PERIOD = 69.93, 3.72, 0.4811 +FAILURES: list[str] = [] + +DECK = """--------------------- CableDyn Input File --- +Thorsen et al. catenary riser in a uniform 0.2 m/s current (MoorDyn-C tests/Mooring/viv/viv.txt) +--------------------- LINE TYPES --- +LineType Diam MassDenInAir EA cIntDamp EI Cd Ca CdAx CaAx Cl +(-) (m) (kg/m) (N) (Pa-s) (N-m^2) (-) (-) (-) (-) (-) +cable 0.024 0.69 6.66e5 -1 10.5 1.2 2.0 0.08 0.08 0.7 +--------------------- POINTS --- +Node Type X Y Z M V CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m2) () +1 Fixed -21.0425 0 -10 0 0 0 0 +2 Coupled 0 0 -1 0 0 0 0 +--------------------- LINES --- +Line LineType NodeA NodeB UnstrLen NumSegs Outputs +(-) (-) (-) (-) (m) (-) (-) +1 cable 1 2 23.71 100 - +--------------------- OPTIONS --- +1000.0 rhoW +9.80665 g +10.0 WtrDpth +1.5e5 kBot +1.0e4 cBot +0.5 frictionMu +uniform 0.2 0 0 current +0.001 dtM +40.0 TMax +--------------------- OUTPUTS --- +FairTen1 +END +--------------------- need this line --- +""" + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +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) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + (out / "riser.dat").write_text(DECK, encoding="utf-8", newline="\n") + proc = subprocess.run([args.exe, "riser.dat", "riser"], cwd=out, capture_output=True, text=True, + env=dict(os.environ, OMP_NUM_THREADS="1")) + check(proc.returncode == 0, f"the riser run completes (exit {proc.returncode})") + if proc.returncode != 0: + print(proc.stdout[-2000:], proc.stderr[-2000:]) + return 1 + lines = (out / "riser.out").read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.split() and line.split()[0].startswith("Time")) + data = np.array([[float(v) for v in line.split()] for line in lines[head + 1:] + if line.strip() and not line.lstrip().startswith("(")]) + t, ten = data[:, 0], data[:, lines[head].split().index("FairTen1")] + w = (t > 20.0) & (t <= 40.0) + tt, x = t[w], ten[w] - ten[w].mean() + peaks = [i for i in range(1, len(x) - 1) if x[i] > x[i - 1] and x[i] >= x[i + 1] and x[i] > 0.0] + period = float(np.mean(np.diff(tt[peaks]))) + mean, span = float(ten[w].mean()), float(np.ptp(ten[w])) + check(abs(mean - MDC_MEAN) <= 0.002 * MDC_MEAN, + f"mean fairlead tension {mean:.2f} N, MoorDyn-C {MDC_MEAN} N (within 0.2 %)") + check(abs(span - MDC_RANGE) <= 0.10 * MDC_RANGE, + f"tension range {span:.2f} N, MoorDyn-C {MDC_RANGE} N (within 10 %)") + check(abs(period - TARGET) <= 0.015 * TARGET and abs(period - MDC_PERIOD) <= 0.015 * MDC_PERIOD, + f"tension period {period:.4f} s: measured 1/(2 x 1.04 Hz) = {TARGET:.4f} s, MoorDyn-C " + f"{MDC_PERIOD} s (within 1.5 %)") + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) From ca381d7fe895482eddd110be90a3010820dc87fa Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 29 Oct 2026 14:06:12 +0900 Subject: [PATCH 15/51] fix: TMax = 0 static checks, faster elevation-record waves, WvHiCOff (#64) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three fixes from a user's digital-twin feedback, in one PR. Each is a separate commit: the static check of a dynamic deck, the speed of elevation-record waves, and their high cut-off. ## 1. `TMax = 0` checks the static start of any dynamic deck Checking the static start of a dynamic deck meant cutting the deck down first. - **Motion records may outlast `TMax`.** This covers `motionFile` point rows, `TURBINES` rows and `vesselMotion`. Rows after `TMax` are still parsed and placed on the `dtM` grid, then not used; off-grid rows are still refused. A shared helper, `motion_grid_index`, replaces three copies of the grid lookup. - **`RangeStart` at `TMax = 0`** is accepted, and the range graphs hold the t = 0 row. After a `TMax > 0` it is still refused. - **A pointer in the message.** A standalone deck without `TMax` whose error asks for a dynamic run now ends with `; to check a dynamic deck's static start only, give dtM with TMax = 0`. The Python validator gives the same text. - **Checks:** - New `static_check` test: a 1 s run on a 36 s record writes byte-identical output to a run on the record cut to 1 s. - `shared_anchor`: a `TURBINES` record longer than the run gives the same run, bit for bit. ## 2. Faster elevation-record waves A WaterKin `WaveKinMod 1` record becomes about `TMax/(2 dtWave)` Fourier components, which every node summed. The JONSWAP option has 200. - **Tail bound.** `CD_Component_Wave_Kinematics` gains an optional `tail_sums` table, for tables whose k does not decrease. - Below the surface, both depth ratios fall as k grows. So the last summed component's cosh ratio, times the remaining sums of `a ω`, `a ω²` and `a ω²/k`, bounds the rest of the velocity, acceleration and pressure sums. - The sums stop once that bound is below half an ulp of what has been summed. The elevation still sums every component. - The sums run in blocks of 32, in component order. Without `tail_sums` the result is bit for bit the same. - The underflow fallback reuses each block's exponentials. - The deck driver builds the table, and the `exp(-2kd)` cache, for elevation records and JONSWAP. - **WaveKinFile reading.** The file was read one row at a time, copying the whole record per row. The rows now grow by doubling. - **Measured** on a 1024-element lazy-wave cable over 300 s: | Case | Before | After | |---|---|---| | Elevation record, `dtWave` 0.25 s | 226 s | 103 s | | Elevation record, `dtWave` 0.1 s | about 660 s | 189 s | | 10 s run on a 168,000-row record | 107 s | 3.5 s | Both elevation decks give output identical to the printed digits. The JONSWAP run changes in its eighth printed digit. - **New kernel test** in `hermite_irregular_waves`: a 1500-component table, from the surface to the seabed, with and without stretching. - The elevation is bit-identical. - Velocity, acceleration and pressure agree within 4 ulp of the summed magnitudes. ## 3. `WvHiCOff`: high cut-off of an elevation record, 0.5 Hz by default - **The option.** `WvHiCOff` (rad/s, SeaState's name and meaning) drops the record's components above it. The default is π rad/s, the 0.5 Hz at which MoorDyn-C cuts `WaveKin 3`. - `WaveKin 3` now follows the option too, bit for bit at the default. - `none WvHiCOff` keeps every component, as MoorDyn-F and earlier CableDyn did. - A record with nothing at or below the cut-off is refused by name. - **Effect.** A one-hour record at `dtWave` 0.1 s drops from 18,000 components to 1,800. On the 300 s case both records then run in 72 s. Every output channel's standard deviation moves by at most 0.002 %. - **`TMax = 0`.** A `WaveKinMod 1` deck at `TMax = 0` now reduces its record over the record's own length, instead of failing for want of a positive `TMax`. - **Checks:** - `wavekin_modes`: 1 rad/s keeps only the record's 8 s harmonic, exactly; `none` reproduces the record. - `deck_driver`: the refusal, and the `TMax = 0` run. - The Python validator accepts `WvHiCOff`, and refuses 0 and text other than `none`. ## Checks - **Test suite:** ctest 311/311; Python 2031 passed. - **Examples against dev:** 50 of 52 are byte-identical. The other two are JONSWAP decks, which change at round-off: - `lazy_wave_bend_stiffener` changes in its eighth printed digit. - `lazy_wave_vessel_rao` has one step, at 46.8 s, that converges one iteration apart under its 1e-4 solver tolerance. That moves `FairTen` by 1.5 N (1.7e-4) for half a second. At a 1e-9 tolerance, old and new agree to the last printed digit. - **Format:** fprettify, ruff and Sphinx are clean. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 25 ++++ CMakeLists.txt | 12 ++ doc/driver_format.md | 11 +- doc/file_formats.rst | 18 ++- doc/migrating.rst | 4 +- doc/modeling.rst | 3 +- doc/options.rst | 17 ++- doc/theory.rst | 14 ++ doc/troubleshooting.rst | 9 +- examples/cabledyn_options_reference.dat | 1 + python/cabledyn/deck_file.py | 47 +++++- python/tests/test_deck_file.py | 13 +- src/CableDyn_DeckDriver.f90 | 191 ++++++++++++++++++------ src/CableDyn_Hydro.f90 | 187 +++++++++++++---------- tests/test_deck_driver.f90 | 30 +++- tests/test_hermite_irregular_waves.f90 | 66 ++++++++ tests/test_shared_anchor.f90 | 14 +- tests/test_static_check.py | 142 ++++++++++++++++++ tests/test_wavekin_modes.f90 | 49 ++++++ 19 files changed, 693 insertions(+), 160 deletions(-) create mode 100644 tests/test_static_check.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 6af9ee14..8711f8d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,25 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Changed +- `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 + `TMax = 0`, where the range graphs hold the `t = 0` row. A standalone deck without `TMax` that + asks for the march now says so: its error ends "to check a dynamic deck's static start only, + give dtM with TMax = 0". +- Deck waves from a WaterKin elevation history (`WaveKinMod 1`) run two to four times faster. + Below the surface, the velocity and acceleration sums stop once the components still to come, + too short to reach that depth, cannot change them beyond round-off. On a 1024-element lazy-wave + cable over 300 s, a record at `dtWave` 0.25 s (600 components) runs in 103 s instead of 226 s, + and one at 0.1 s in 189 s instead of about 660 s, with output identical to the printed digits. + A `jonswap` sea changes at round-off. +- An elevation record (WaterKin `WaveKinMod 1`) keeps only its Fourier components up to the new + `WvHiCOff` option, in rad/s as in SeaState, by default 0.5 Hz (MoorDyn-C's fixed cut for + `WaveKin 3`, which now follows the option too); `none WvHiCOff` keeps them up to the Nyquist + frequency of `dtWave`, as MoorDyn-F and earlier CableDyn did. A one-hour record at `dtWave` + 0.1 s drops from 18,000 components to 1,800. On the 300 s lazy-wave case both records then run + in 72 s, and every output channel's standard deviation moves by at most 0.002 %. A record with + no component at or below the cut-off is refused by name. - Under a bend stiffener, `BendMomN` (and the `BendMoment` columns of the static profile, range graphs and element file) report the cable's own moment, the line type's EI times the curvature; lines without stiffeners are unchanged. @@ -68,6 +87,12 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- 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`. +- Reading a WaterKin `WaveKinFile` no longer slows with the square of its length: the rows grow + by doubling instead of copying the whole record per row. A 10 s run on a 168,000-row record + took 107 s and now takes 3.5 s. - A weightless or near-neutral taut finite-EI line (a neutrally buoyant cable, a tendon) failed its static solve, even straight along its chord: the convergence test scaled the residual by the line's weight alone, far below the round-off of its axial forces. A taut line's scale now diff --git a/CMakeLists.txt b/CMakeLists.txt index 163a0b51..0409e213 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1613,6 +1613,18 @@ if(Python3_Interpreter_FOUND) message(STATUS "range_graph_tdp: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() + # TMax = 0 checks the static start of a dynamic deck: vesselMotion and motionFile records + # that outlast TMax, RangeStart at TMax = 0, and the hint of a deck without dtM and TMax. + add_test(NAME static_check + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_static_check.py + --exe $ + --examples ${CMAKE_CURRENT_SOURCE_DIR}/examples + --output ${CMAKE_BINARY_DIR}/static_check) + set_tests_properties(static_check PROPERTIES + LABELS "python;driver;integration;static;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). diff --git a/doc/driver_format.md b/doc/driver_format.md index 14bf2e29..3e299aa8 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1182,7 +1182,7 @@ them on `water_grid.txt` and interpolates, so that file is not read. Standalone | Option | File | Meaning | |---|---|---| -| `WaveKin 3` | `wave_elevation.txt` | `time elevation` rows from `t = 0` (no header rows), resampled linearly at `dtWave` to `floor(t_last/dtWave) + 1` samples (the last dropped when the count is odd) and reduced to its Fourier components; components above 0.5 Hz are dropped and the mean is a mean-level offset, as MoorDyn-C does. Waves travel along +x | +| `WaveKin 3` | `wave_elevation.txt` | `time elevation` rows from `t = 0` (no header rows), resampled linearly at `dtWave` to `floor(t_last/dtWave) + 1` samples (the last dropped when the count is odd) and reduced to its Fourier components; components above `WvHiCOff` (default 0.5 Hz, MoorDyn-C's fixed cut) are dropped and the mean is a mean-level offset, as MoorDyn-C does. Waves travel along +x | | `WaveKin 7` | `wave_frequencies.txt` | `omega Re Im [beta]` rows [rad/s, m, m, rad], the first at `omega = 0`: each row is the component `\|c\| sin(omega t - k d + arg c)`, `d = x cos(beta) + y sin(beta)`; the `omega = 0` row is a mean-level offset. All rows must share one `beta` | | `Currents 1` | `current_profile.txt` | `z ux uy uz` rows after its header rows, strictly increasing `z`; linear in `z` and held beyond the end rows | @@ -1208,7 +1208,7 @@ A MoorDyn-F deck may select a WaterKin file (grammar in [Auxiliary file formats] | Mode | Meaning | |---|---| | `WaveKinMod = 0` | no waves | -| `WaveKinMod = 1` | elevation history resampled at `dtWave` over deck `TMax` (host `TMax` for caller-driven decks), truncated or zero-padded, and Fourier-reduced once on one padded DFT time base | +| `WaveKinMod = 1` | elevation history resampled at `dtWave` over deck `TMax` (host `TMax` for caller-driven decks), truncated or zero-padded, and Fourier-reduced once on one padded DFT time base, keeping the components up to `WvHiCOff` (default 0.5 Hz; `none` keeps all, as MoorDyn-F) | | `WaveKinMod = 2` / `SEASTATE` | waves from the coupled host SeaState field | | `CurrentMod = 0` | no current | | `CurrentMod = 1` | N-level WaterKin depth table, interpolated at structural nodes | @@ -1261,7 +1261,8 @@ about the line tangent pointing into the line from that end. Either way it impos (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 `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, …, TMax` grid and `point_id` must be a prescribed point. Each +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 (point, time) pair appears once, every prescribed point needs a row at every grid time, and rows may appear in any order. See also [Auxiliary file formats](file_formats.rst). @@ -1287,8 +1288,8 @@ moment follows the vessel rotation. Rotations use the OrcaFlex vessel convention: `R = Rz(yaw)·Ry(pitch)·Rx(roll)`, right-handed about the vessel x (roll), y (pitch) and z (yaw) axes, applied yaw, then pitch, then roll. -**`vesselMotion` record.** One row per `dtM` grid time from 0 to `TMax`, in any order, in one -of two forms for the whole file: +**`vesselMotion` record.** One row per `dtM` grid time from 0 to `TMax`, in any order (rows on +the grid after `TMax` are read and not used), in one of two forms for the whole file: ```text time x y z roll pitch yaw vx vy vz wx wy wz ax ay az alx aly alz (19 values) diff --git a/doc/file_formats.rst b/doc/file_formats.rst index 4915efae..ce828700 100644 --- a/doc/file_formats.rst +++ b/doc/file_formats.rst @@ -211,10 +211,11 @@ The model grid is ``t_k = k·dtM`` for ``k = 0 … TMax/dtM``, and ``TMax`` must whole multiple of ``dtM``. The file is checked against this grid: * Each ``time`` must match a grid time to within ``100·ε·max(1, TMax)``, where ε is - double-precision machine epsilon. Times off the grid, before ``0``, or after - ``TMax`` are rejected (``time is outside the dtM/TMax grid``). Write times with - enough digits to hit the grid exactly. A file that runs past ``TMax`` must be cut - to length. + double-precision machine epsilon. Times off the grid or before ``0`` are rejected + (``time is outside the dtM/TMax grid``). Write times with enough digits to hit the + grid exactly. A file may run past ``TMax``: its rows after ``TMax`` are checked + (on the ``dtM`` grid, to within ``100·ε·max(1, time)``) and not used, so a long + record serves a shorter run and ``TMax = 0`` checks the static start. * Every eligible point needs exactly one row at every grid time. A repeated point/time pair is rejected (``duplicate row for point at this time``). A missing pair is rejected once the whole file has been read (``motionFile must @@ -563,6 +564,15 @@ two columns: * ``TMax / dtWave`` may be at most 10\ :sup:`6` samples; a longer record is rejected (``WaterKin TMax/dtWave needs more than 1000000 wave samples``) because the one-time reduction grows with the square of the sample count. +* The components above the ``WvHiCOff`` option (default :math:`\pi` rad/s, 0.5 Hz) are + dropped, as SeaState drops those of an elevation series; ``none WvHiCOff`` keeps them up to + the Nyquist frequency of ``dtWave``, as MoorDyn-F does. A record with no component at or + below the cut-off, for example a run shorter than 2 s, is refused by name. +* The record keeps about ``TMax WvHiCOff / (2 pi)`` components (150 for a 300 s run), or + ``TMax / (2 dtWave)`` with ``none`` (600 at ``dtWave`` 0.25 s), against the 200 of a + ``jonswap`` sea. Every node sums all of them for its surface elevation. Below the surface, + the components too short to reach the node's depth are dropped once they cannot change its + velocity and acceleration beyond round-off (:ref:`theory-waves`). Example ~~~~~~~ diff --git a/doc/migrating.rst b/doc/migrating.rst index 53a743d1..39010cfa 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -123,7 +123,9 @@ Keyword map * - ``kBot``, ``cBot``, seabed friction coefficient - ``kBot``, ``cBot``, ``frictionMu`` (alias ``mu``) * - ``WaterKin`` file (``CurrentMod 1``, ``WaveKinMod 1``) - - same file; ``WaveKinMod 2`` and ``SEASTATE`` only when coupled to OpenFAST + - same file; ``WaveKinMod 2`` and ``SEASTATE`` only when coupled to OpenFAST. An + elevation record keeps its components up to ``WvHiCOff`` (default 0.5 Hz); give + ``none WvHiCOff`` to keep all of them, as MoorDyn-F does * - ``FAILURE``, ``CONTROL`` sections - ``FAILURE`` on ``EI = 0`` decks, standalone and in OpenFAST (a deck with a finite-EI cable rejects it); ``CONTROL`` on ``EI = 0`` lines and finite-EI cables in OpenFAST, not diff --git a/doc/modeling.rst b/doc/modeling.rst index 46d7e51a..a7c00699 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -199,7 +199,8 @@ resolves the wave a snap does not trigger them, and at 0.5 ms the cable takes no Begin with the smallest model that should equilibrate: -#. omit ``dtM``/``TMax`` for an ``EI = 0`` static-only checkout; +#. omit ``dtM``/``TMax`` for an ``EI = 0`` static-only checkout, or set ``TMax = 0`` to check + the static start of a dynamic deck with all its other options; #. verify endpoint order, length, submerged weight, and seabed elevation; #. request endpoint tensions and the static along-arc profile; #. inspect contact, touchdown, curvature, and symmetry; then diff --git a/doc/options.rst b/doc/options.rst index 0783b8a3..5c304764 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -269,14 +269,17 @@ Clock and initial condition - real, s - absent (static-only) - finite, ≥ 0 and an integer multiple of ``dtM``. ``TMax = 0`` runs the dynamic - initialisation and writes the ``t = 0`` row + initialisation and writes the ``t = 0`` row: the static start of a dynamic deck, checked + with every other option kept (motion records longer than ``TMax`` and a later + ``RangeStart`` included) - standalone only; OpenFAST uses the host ``TMax``. Do not copy the host duration into a coupled deck - ``600.0 TMax`` * - ``RangeStart`` / ``range_start`` - real, s - ``0`` - - finite, ≥ 0 and ≤ ``TMax``. First output time accumulated into the range graphs + - finite, ≥ 0 and ≤ ``TMax`` (any value at ``TMax = 0``, where the graphs hold the + ``t = 0`` row). First output time accumulated into the range graphs (``.Line.range.out``, ``LINES`` ``Outputs`` flag ``r``), so a start-up transient is left out. Needs ``TMax`` and at least one line with the ``r`` flag - standalone only @@ -743,6 +746,16 @@ Ambient fluid and prescribed motion - the step at which ``WaveKin 3`` resamples ``wave_elevation.txt`` (MoorDyn-C) - standalone - ``0.1 dtWave`` + * - ``WvHiCOff`` + - positive number [rad/s] or ``none`` + - ``3.14159`` (0.5 Hz) + - the high cut-off frequency of an elevation record (WaterKin ``WaveKinMod 1``, + ``WaveKin 3``): its Fourier components above it are dropped, as SeaState's ``WvHiCOff`` + zeroes the spectrum of an elevation series. ``none`` keeps them up to the Nyquist + frequency of ``dtWave``, as MoorDyn-F's ``WaveKinMod 1`` does. A record with no + component at or below the cut-off is refused + - standalone + - ``6.2832 WvHiCOff`` * - ``Currents`` - ``0`` or ``1`` - ``0`` diff --git a/doc/theory.rst b/doc/theory.rst index 11c57108..98295023 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -828,6 +828,8 @@ configuration derivative in the tangent. The Hermite path evaluates the consiste holds it over the step. The spatial gradient of the wave field is omitted from the tangent on both paths; the residual is exact, so the converged state is unaffected. +.. _theory-waves: + Waves ~~~~~ @@ -892,6 +894,18 @@ commensurate, the record does not repeat (an equally spaced comb would repeat af its component table (amplitude, frequency, phase), for example a WaterKin ``WaveKinMod`` 1 elevation history, which is reduced once to its Fourier components on the run time base. +Every point sums every component of the elevation. The velocity, acceleration and dynamic +pressure sums run in order of increasing :math:`k_i`. For :math:`-h \le z' \le 0` both depth +ratios :math:`\cosh k(z' + h)/\sinh kh` and :math:`\sinh k(z' + h)/\sinh kh` fall as +:math:`k` grows, so the cosh ratio of the last summed component times the remaining +:math:`\sum_{j \ge i} a_j\omega_j`, :math:`\sum a_j\omega_j^2` and :math:`\sum a_j\omega_j^2/k_j` +bounds the rest of each sum. The sums stop once those bounds are below half an ulp of the +magnitudes already summed. A deep point therefore skips the short components that have +decayed to nothing there, and the result changes at round-off only. This matters for an +elevation history, which keeps its components up to the ``WvHiCOff`` cut-off (0.5 Hz by +default) or, with ``none``, all :math:`T_{max}/(2\,\Delta t_{wave})` of them up to the Nyquist +frequency of ``dtWave``. + **Regular nonlinear waves.** A ``stream`` wave is Dean's stream-function wave (:ref:`Dean, 1965 `) solved numerically by the Fourier method of :ref:`Rienecker & Fenton (1981) `. In the frame moving with the celerity diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 92b59cfb..5ebb7d05 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -199,8 +199,13 @@ Clock, motion, and environment - a deck that mixes ``EI = 0`` and finite-EI lines writes no modal files. Run the modal analysis on a deck whose lines are all ``EI = 0`` or all finite-EI. * - motionFile ``time is outside the dtM/TMax grid`` - - every row time must be ``k·dtM`` for ``0 ≤ k ≤ TMax/dtM``. Resample the history onto the - ``dtM`` grid. + - every row time must be ``k·dtM`` with ``k ≥ 0`` (rows after ``TMax`` are not used). + Resample the history onto the ``dtM`` grid. + * - ``... requires dtM and TMax; to check a dynamic deck's static start only, give dtM with + TMax = 0`` + - the deck asks for the march (motion, current, waves, bodies, rods, finite-EI sections, + ``RangeStart`` ...) without ``TMax``. Keep the deck and set ``TMax = 0``: the run solves + the static start and writes the ``t = 0`` row. * - ``motionFile must provide every Coupled/Vessel point at every dtM time`` (or ``every eligible prescribed point``) - the file is missing at least one (point, time) pair. Every prescribed point needs a row at diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index dabeaebe..85a57e0a 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -98,6 +98,7 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- 0.1 dtOut - MoorDyn output-cadence compatibility only; accepted and ignored -- 0 Currents - MoorDyn-C current mode {0=none; 1=current_profile.txt} [default: 0] -- 0.25 dtWave - MoorDyn-C WaveKin 3 resampling step (s) [default: 0.25] +-- 3.14159 WvHiCOff - High cut-off of an elevation record, WaveKinMod 1 or WaveKin 3 (rad/s) {value; none} [default: 3.14159] -- Keyword aliases (equivalent spellings, case-insensitive): -- g = gravity; rhoW = WtrDnsty = water_density; WtrDpth = water_depth; kBot = kb; cBot = cb -- bathymetryFile = bathymetry_file = seafloorFile = seafloor_file; frictionMu = mu = frictionCoefficient diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 24fb33c1..5eadc030 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -276,6 +276,7 @@ "bodyscheme", "bodysubstep", "dtwave", + "wvhicoff", "bodywetting", "bodyhydro", "rodhydro", @@ -321,6 +322,10 @@ _DISABLED_MOTION_FILE_VALUES = frozenset({"0", "none"}) # Alternative prescribed-motion sources (native apply_option): only one may be active. _MOTION_SOURCE_KEYWORDS = ("motionfile", "vesselmotion", "vesselrao") +# Native STATIC_CHECK_HINT: appended to the errors that ask a standalone deck without TMax for +# the march (those naming one of the cues). +_STATIC_CHECK_HINT = "; to check a dynamic deck's static start only, give dtM with TMax = 0" +_STATIC_CHECK_CUES = ("dtM and TMax", "requires dtM", "require dtM", "dynamic deck (TMax)") _END_CONNECTION_ENDS = { "a": "a", "enda": "a", @@ -1110,8 +1115,15 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: if not value: return "requires a non-empty path" boolean_values = {"true", "t", "yes", "y", "on", "1", "false", "f", "no", "n", "off", "0"} - # native check_option_row_value rule 'positive' (dtWave is the WaveKin 3 resampling step) - positive = key in {"gravity", "water_density", "water_depth", "dtm"} or raw == "dtwave" + if raw == "wvhicoff" and value.lower() == "none": + # native rule: 'none' keeps every component of an elevation record + return None + # native check_option_row_value rule 'positive' (dtWave is the WaveKin 3 resampling step, + # WvHiCOff the high cut-off frequency of an elevation record) + positive = key in {"gravity", "water_density", "water_depth", "dtm"} or raw in { + "dtwave", + "wvhicoff", + } if positive: lower, upper = 0.0, None elif key in {"kbot", "cbot"}: @@ -1157,7 +1169,16 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "max_strain", "range_start", "viv_rms_window", - } or raw in {"dtic", "tmaxic", "cdscaleic", "threshic", "writelog", "dtout", "dtwave"}: + } or raw in { + "dtic", + "tmaxic", + "cdscaleic", + "threshic", + "writelog", + "dtout", + "dtwave", + "wvhicoff", + }: try: numeric = _native_float(value) except ValueError: @@ -2335,6 +2356,20 @@ def validate(self) -> None: DeckFormatError If the deck violates the native deck contract. """ + try: + self._validate() + except DeckFormatError as exc: + if self.caller_driven or not any(cue in str(exc) for cue in _STATIC_CHECK_CUES): + raise + # native finalize_and_validate: a standalone deck without TMax that asks for the + # march is told how to check its static start + try: + self.option("TMax") + except KeyError: + raise DeckFormatError(f"{exc}{_STATIC_CHECK_HINT}") from None + raise + + def _validate(self) -> None: required = {"LINE TYPES", "POINTS", "LINES"} if not self._rows("LINES") and (self._rows("RODS") or self._rows("BODIES")): # native finalize_and_validate: a deck whose rows declare bodies or rods and @@ -3929,9 +3964,9 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: OPTION RangeStart needs a dynamic deck (TMax)" ) - if _native_float(range_start.values[0]) > _native_float( - option_by_key["tmax"].values[0] - ): + tmax_value = _native_float(option_by_key["tmax"].values[0]) + # at TMax = 0 (a dynamic deck's static start) the range graphs hold the t = 0 row + if _native_float(range_start.values[0]) > tmax_value and tmax_value > 0.0: raise DeckFormatError( f"{self._label}: OPTION RangeStart exceeds TMax: the range window would hold " "no output time" diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index d1452838..1da6a512 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -651,6 +651,8 @@ def test_unknown_scalar_option_keyword_fails_closed(tmp_path): ("implicit", "bodyScheme", "monolithic or staggered"), ("fast", "bodySubstep", "none or accuracy"), ("x", "dtWave", "must be numeric"), + ("0", "WvHiCOff", "must be positive"), + ("off", "WvHiCOff", "must be numeric"), ("2", "Currents", "supports only mode 0 or 1"), ("1.5", "Currents", "supports only mode 0 or 1"), ("4", "WaterKin", "numeric mode 0, 3 or 7"), @@ -713,6 +715,8 @@ def test_zero_e_exponent_waterkin_mode_is_accepted(tmp_path): "none bodySubstep", "accuracy bodySubstep", "0.25 dtWave", + "6.283 WvHiCOff", + "none WvHiCOff", "60 TMax", "motion.dat motionFile", "RK4 tScheme", @@ -1825,7 +1829,7 @@ def test_active_friction_clock_dependency_is_route_aware(tmp_path): path = tmp_path / "route-friction.dat" path.write_text(source, encoding="utf-8") - with pytest.raises(DeckFormatError, match="frictionMu requires dtM and TMax"): + with pytest.raises(DeckFormatError, match=r"frictionMu requires dtM and TMax.*TMax = 0"): DeckFile.read(path) DeckFile.read(path, caller_driven=True) @@ -1862,8 +1866,10 @@ def test_host_route_does_not_relax_deck_owned_kinematics_clock(tmp_path, option_ path.write_text(source, encoding="utf-8") for caller_driven in (False, True): - with pytest.raises(DeckFormatError, match=message): + with pytest.raises(DeckFormatError, match=message) as err: DeckFile.read(path, caller_driven=caller_driven) + # the standalone error says how to check the deck's static start; the host route's not + assert ("give dtM with TMax = 0" in str(err.value)) is not caller_driven def test_current_needs_the_deck_clock_only_on_the_standalone_route(tmp_path): @@ -2470,6 +2476,9 @@ def test_range_flag_and_range_start_follow_native_rules(): DeckFile.from_text(_edit(_DYNAMIC, ("10.0 TMax\n", "10.0 TMax\n2.5 RangeStart\n"))) with pytest.raises(DeckFormatError, match="exceeds TMax"): DeckFile.from_text(_edit(ranged, ("2.5 RangeStart", "12.0 RangeStart"))) + # TMax = 0 checks the static start of the dynamic deck: its range graphs hold the t = 0 row + zero = DeckFile.from_text(_edit(ranged, ("10.0 TMax", "0.0 TMax"))) + assert zero.option("RangeStart").values == ("2.5",) with pytest.raises(DeckFormatError, match="must be >= 0"): DeckFile.from_text(_edit(ranged, ("2.5 RangeStart", "-1.0 RangeStart"))) with pytest.raises(DeckFormatError, match="needs a dynamic deck"): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index a60b4dc4..d6d19fe5 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -318,6 +318,11 @@ MODULE CableDyn_DeckDriver CHARACTER(*), PARAMETER :: ROW_VALUES_FMT = TIME_COLUMN_FMT(1:LEN(TIME_COLUMN_FMT) - 1)//',*(A,ES15.7E3))' ! Largest step count a dtM/TMax (or motion-file) grid may index with default INTEGER. REAL(wp), PARAMETER :: MAX_GRID_STEPS = REAL(HUGE(1) - 1, wp) + ! motion_grid_index of a record row on the dtM grid after TMax (read, then not used) + INTEGER, PARAMETER :: MOTION_PAST_TMAX = -1 + ! appended to the dtM/TMax-required errors of a standalone deck without TMax + CHARACTER(*), PARAMETER :: STATIC_CHECK_HINT = & + '; to check a dynamic deck''s static start only, give dtM with TMax = 0' INTEGER, PARAMETER :: MOTION_POINT_ROWS = 0, MOTION_VESSEL_FILE = 1, MOTION_VESSEL_RAO = 2 ! Largest WaterKin WaveKinMod-1 record (TMax/dtWave samples) reduced to Fourier components. REAL(wp), PARAMETER :: MAX_WAVE_SAMPLES = 1.0e6_wp @@ -576,6 +581,8 @@ MODULE CableDyn_DeckDriver REAL(wp) :: jonswap_k(CD_JONSWAP_COMPONENTS) = CD_ZERO ! exp(-2 jonswap_k wtrdpth), fixed with the table (CD_Component_Wave_Kinematics exp_m2kd) REAL(wp) :: jonswap_e2kd(CD_JONSWAP_COMPONENTS) = CD_ZERO + ! CD_Component_Wave_Kinematics tail_sums of the table (set_component_tail) + REAL(wp), ALLOCATABLE :: jonswap_tail(:, :) REAL(wp) :: jonswap_amplitude(CD_JONSWAP_COMPONENTS) = CD_ZERO ! Random-phase, bin-jittered JONSWAP synthesis (OPTION WaveSeed, a positive integer; ! the same seed always gives the same sea). @@ -610,6 +617,8 @@ MODULE CableDyn_DeckDriver ! irregular seas; wave_eta_mean carries the zero-frequency waterline offset. REAL(wp), ALLOCATABLE :: wave_component_omega(:), wave_component_k(:) REAL(wp), ALLOCATABLE :: wave_component_amplitude(:), wave_component_phase(:) + ! exp(-2 k (wtrdpth + wave_eta_mean)) and the tail_sums of the table (CD_Component_Wave_Kinematics) + REAL(wp), ALLOCATABLE :: wave_component_e2kd(:), wave_component_tail(:, :) REAL(wp) :: wave_eta_mean = CD_ZERO ! N-level vertical current profile (ascending z): from the two-point deck ! OPTION row or a MoorDyn WaterKin file's CurrentMod-1 depth table. @@ -660,6 +669,10 @@ MODULE CableDyn_DeckDriver INTEGER :: mdc_wave_kin = 0 INTEGER :: mdc_currents = 0 REAL(wp) :: mdc_dt_wave = 0.25_wp + ! WvHiCOff: the components of an elevation record (WaterKin WaveKinMod 1, WaveKin 3) above + ! this frequency are dropped (rad/s, as SeaState's WvHiCOff; default 0.5 Hz, MoorDyn-C's + ! WaveKin 3 cut); negative ('none') keeps them up to the Nyquist frequency of dtWave + REAL(wp) :: wv_hi_cutoff = 0.5_wp*TWO_PI LOGICAL :: waterkin_seastate = .FALSE. LOGICAL :: waterkin_host_wave = .FALSE. LOGICAL :: waterkin_host_current = .FALSE. @@ -8222,7 +8235,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) ! reserve-point detach machinery. Every other branch fails closed by name. IF (SIZE(fails) > 0) THEN IF (.NOT. (opts%has_dtm .AND. opts%has_tmax)) THEN - CALL fail(ErrStat, ErrMsg, 'FAILURE requires a dynamic deck (dtM and TMax)'); RETURN + CALL fail(ErrStat, ErrMsg, 'FAILURE requires a dynamic deck (dtM and TMax)'//STATIC_CHECK_HINT); RETURN END IF IF (deck_has_finite_ei(types, sections)) THEN CALL fail(ErrStat, ErrMsg, 'FAILURE is not supported on finite-EI decks'); RETURN @@ -11227,7 +11240,7 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg IF (sections(j)%line_id /= ln%id) CYCLE IF (types(sections(j)%ltype)%is_syrope) THEN CALL fail(ErrStat, ErrMsg, 'a Syrope line has no static output; provide dtM and TMax to run the '// & - 'dynamic working-curve path'); RETURN + 'dynamic working-curve path'//STATIC_CHECK_HINT); RETURN END IF END DO @@ -12411,9 +12424,9 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma INTEGER :: unit, ios, n, n_window, j, k, nc, nraw, bracket, row_status, lineno CHARACTER(DECK_RECLEN) :: line CHARACTER(1024) :: why - REAL(wp) :: te_row(2), tr, dt, tol, angle, ca, sa, scale, frac + REAL(wp) :: te_row(2), tr, dt, tol, angle, ca, sa, scale, frac, window REAL(wp) :: cos_step, sin_step, cos_j, sin_j, cos_next, trig_norm - REAL(wp), ALLOCATABLE :: times(:), eta_rows(:), sample_eta(:) + REAL(wp), ALLOCATABLE :: times(:), eta_rows(:), sample_eta(:), grown(:) LOGICAL :: data_started ErrStat = CD_DECKDRV_OK @@ -12423,8 +12436,8 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma '(double-counting); keep one') RETURN END IF - IF (.NOT. IEEE_IS_FINITE(fft_tmax) .OR. fft_tmax <= CD_ZERO) THEN - CALL fail(ErrStat, ErrMsg, 'WaterKin WaveKinMod 1 requires a finite positive deck or '// & + IF (.NOT. IEEE_IS_FINITE(fft_tmax) .OR. fft_tmax < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'WaterKin WaveKinMod 1 requires a finite non-negative deck or '// & 'host TMax for its FFT window') RETURN END IF @@ -12433,7 +12446,9 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma CALL fail(ErrStat, ErrMsg, 'cannot open the WaterKin WaveKinFile: '//TRIM(path)// & input_open_reason(path, why)); RETURN END IF - ALLOCATE (times(0), eta_rows(0)) + ! the rows grow by doubling (appending one row at a time copies the whole record per row) + ALLOCATE (times(1024), eta_rows(1024)) + nraw = 0 data_started = .FALSE. lineno = 0 DO @@ -12458,11 +12473,21 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma CYCLE END IF data_started = .TRUE. - times = [times, te_row(1)] - eta_rows = [eta_rows, te_row(2)] + nraw = nraw + 1 + IF (nraw > SIZE(times)) THEN + ALLOCATE (grown(2*SIZE(times))) + grown(1:nraw - 1) = times(1:nraw - 1) + CALL MOVE_ALLOC(grown, times) + ALLOCATE (grown(2*SIZE(eta_rows))) + grown(1:nraw - 1) = eta_rows(1:nraw - 1) + CALL MOVE_ALLOC(grown, eta_rows) + END IF + times(nraw) = te_row(1) + eta_rows(nraw) = te_row(2) END DO CLOSE (unit) - nraw = SIZE(times) + times = times(1:nraw) + eta_rows = eta_rows(1:nraw) IF (nraw < 4) THEN CALL fail(ErrStat, ErrMsg, 'WaterKin WaveKinFile needs at least four `time elevation` rows'); RETURN END IF @@ -12481,14 +12506,17 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma ! MoorDyn-F sizes the resampled record from the RUN TMax, not from the input ! file length, then zero-pads to an efficient even FFT size. A longer file is ! truncated to the run window; a shorter file leaves the uncovered tail zero. + ! TMax = 0, a check of the static start, takes the record's own length instead. + window = fft_tmax + IF (.NOT. window > CD_ZERO) window = times(nraw) dt = dt_wave ! Bound the resampled record before sizing it: CEILING of a ratio beyond the ! INTEGER range is undefined, and the one-time DFT setup grows with its square. - IF (.NOT. (fft_tmax/dt <= MAX_WAVE_SAMPLES)) THEN + IF (.NOT. (window/dt <= MAX_WAVE_SAMPLES)) THEN CALL fail(ErrStat, ErrMsg, 'WaterKin TMax/dtWave needs more than '//TRIM(int_to_str(INT(MAX_WAVE_SAMPLES)))// & ' wave samples; increase dtWave or reduce TMax'); RETURN END IF - n_window = CEILING(fft_tmax/dt) + n_window = CEILING(window/dt) n = padded_fft_size(n_window) IF (n > LONG_WAVE_RECORD) WRITE (error_unit, '(A)') ' Note: reducing the WaterKin wave record ('// & TRIM(int_to_str(n))//' samples) to Fourier components; this one-time setup grows with the square '// & @@ -12512,7 +12540,19 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma times = [(REAL(j - 1, wp)*dt, j=1, n)] eta_rows = sample_eta - nc = n/2 + ! the components up to WvHiCOff (all n/2 with 'none') + nc = 0 + DO k = 1, n/2 + IF (opts%wv_hi_cutoff >= CD_ZERO .AND. TWO_PI*REAL(k, wp)/(REAL(n, wp)*dt) > opts%wv_hi_cutoff) EXIT + nc = k + END DO + IF (nc < 1) THEN + CALL fail(ErrStat, ErrMsg, 'WvHiCOff '//TRIM(ADJUSTL(es_to_str(opts%wv_hi_cutoff)))//' rad/s keeps no '// & + 'component of the WaterKin WaveKinFile record, whose lowest frequency is '// & + TRIM(ADJUSTL(es_to_str(TWO_PI/(REAL(n, wp)*dt))))//' rad/s over the '// & + TRIM(ADJUSTL(es_to_str(REAL(n, wp)*dt)))//' s window; lengthen TMax or give none WvHiCOff') + RETURN + END IF IF (ALLOCATED(opts%wave_component_omega)) DEALLOCATE (opts%wave_component_omega) IF (ALLOCATED(opts%wave_component_k)) DEALLOCATE (opts%wave_component_k) IF (ALLOCATED(opts%wave_component_amplitude)) DEALLOCATE (opts%wave_component_amplitude) @@ -12541,7 +12581,7 @@ SUBROUTINE read_wave_elevation_components(path, opts, dt_wave, wave_dir, fft_tma END IF END DO scale = 2.0_wp/REAL(n, wp) - IF (MOD(n, 2) == 0 .AND. k == nc) scale = CD_ONE/REAL(n, wp) + IF (MOD(n, 2) == 0 .AND. k == n/2) scale = CD_ONE/REAL(n, wp) ca = scale*ca sa = scale*sa ! Coefficients and runtime components must share the padded DFT time base. @@ -12670,13 +12710,14 @@ SUBROUTINE read_moordyn_c_kinematics(dir, opts, ErrStat, ErrMsg) frac = MIN(CD_ONE, MAX(CD_ZERO, frac)) eta(j) = tab(2, bracket) + frac*(tab(2, bracket + 1) - tab(2, bracket)) END DO - ! discrete Fourier components on the record's own base (period nt dt); MoorDyn-C zeroes the - ! bins above 0.5 Hz and keeps the mean + ! discrete Fourier components on the record's own base (period nt dt) up to WvHiCOff (by + ! default 0.5 Hz, where MoorDyn-C zeroes the bins); the mean is kept mean_level = SUM(eta)/REAL(nt, wp) - ALLOCATE (comp_w(0), comp_a(0), comp_p(0)) + ALLOCATE (comp_w(nt/2), comp_a(nt/2), comp_p(nt/2)) + nc = 0 DO k = 1, nt/2 angle = TWO_PI*REAL(k, wp)/(REAL(nt, wp)*dt) - IF (angle > 0.5_wp*TWO_PI) EXIT + IF (opts%wv_hi_cutoff >= CD_ZERO .AND. angle > opts%wv_hi_cutoff) EXIT ca = CD_ZERO sa = CD_ZERO DO j = 1, nt @@ -12689,10 +12730,14 @@ SUBROUTINE read_moordyn_c_kinematics(dir, opts, ErrStat, ErrMsg) IF (k == nt/2) scale = CD_ONE/REAL(nt, wp) ca = scale*ca sa = scale*sa - comp_w = [comp_w, angle] - comp_a = [comp_a, SQRT(ca*ca + sa*sa)] - comp_p = [comp_p, ATAN2(sa, ca)] - END DO + nc = k + comp_w(nc) = angle + comp_a(nc) = SQRT(ca*ca + sa*sa) + comp_p(nc) = ATAN2(sa, ca) + END DO + comp_w = comp_w(1:nc) + comp_a = comp_a(1:nc) + comp_p = comp_p(1:nc) CALL install_components() IF (ErrStat /= CD_DECKDRV_OK) RETURN CASE (7) @@ -12768,7 +12813,7 @@ SUBROUTINE install_components() nc = SIZE(comp_w) IF (nc < 1) THEN CALL fail(ErrStat, ErrMsg, 'WaveKin '//TRIM(int_to_str(opts%mdc_wave_kin))//': '//TRIM(fname)// & - ' gives no wave component at or below 0.5 Hz'); RETURN + ' gives no wave component at or below WvHiCOff'); RETURN END IF IF (ALLOCATED(opts%wave_component_omega)) DEALLOCATE (opts%wave_component_omega) IF (ALLOCATED(opts%wave_component_k)) DEALLOCATE (opts%wave_component_k) @@ -14927,6 +14972,12 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CASE ('dtwave') ! MoorDyn-C WaveKin 3: the resampling step of wave_elevation.txt CALL rd(val, opts%mdc_dt_wave, ErrStat, ErrMsg) + CASE ('wvhicoff') + IF (to_lower(TRIM(val)) == 'none') THEN + opts%wv_hi_cutoff = -CD_ONE + ELSE + CALL rd(val, opts%wv_hi_cutoff, ErrStat, ErrMsg) + END IF CASE ('ramptime', 'ramp_time', 'tramp') CALL rd(val, opts%ramp_time, ErrStat, ErrMsg) CASE ('maxstrain', 'max_strain') @@ -15408,6 +15459,9 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) CASE ('frictionmu', 'mu', 'frictioncoefficient') IF (to_lower(TRIM(val)) == 'none') RETURN rule = 'non-negative' + CASE ('wvhicoff') + IF (to_lower(TRIM(val)) == 'none') RETURN + rule = 'positive' CASE ('frictionmuaxial', 'frictionmu_axial', 'mu_axial', 'muaxial', 'frictionmulateral', 'frictionmu_lateral', & 'mu_lateral', 'mulateral', 'frictionmunormal', 'frictionmu_normal') rule = 'non-negative' @@ -15807,6 +15861,11 @@ SUBROUTINE finalize_and_validate(types, bodies, rod_types, rods, points, lines, CALL finalize_checks(types, bodies, rod_types, rods, points, lines, sections, opts, channels, & caller_driven, allow_static_finite_ei, ErrStat, ErrMsg, channel_lines, at_line) + ! a standalone deck without TMax that asks for the march: say how to check its static start + IF (ErrStat /= 0 .AND. .NOT. caller_driven .AND. .NOT. opts%has_tmax) THEN + IF (INDEX(ErrMsg, 'dtM and TMax') > 0 .OR. INDEX(ErrMsg, 'dynamic deck (TMax)') > 0) & + ErrMsg = TRIM(ErrMsg)//STATIC_CHECK_HINT + END IF IF (ErrStat /= 0) CALL add_deck_line(at_line, ErrMsg) END SUBROUTINE finalize_and_validate @@ -15846,7 +15905,8 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio IF (.NOT. opts%has_tmax) THEN CALL fail(ErrStat, ErrMsg, 'OPTION RangeStart needs a dynamic deck (TMax)'); RETURN END IF - IF (opts%range_start > opts%tmax) THEN + ! at TMax = 0 (a dynamic deck's static start) the range graphs hold the t = 0 row + IF (opts%range_start > opts%tmax .AND. opts%tmax > CD_ZERO) THEN CALL fail(ErrStat, ErrMsg, 'OPTION RangeStart exceeds TMax: the range window would hold no output time') RETURN END IF @@ -29090,7 +29150,7 @@ SUBROUTINE deck_wave_kinematics(opts, x, y, z, time, eta, velocity, acceleration opts%jonswap_omega, opts%jonswap_k, opts%jonswap_amplitude, & opts%jonswap_phase, eta, velocity, acceleration, ErrStat, ErrMsg, & inputs_validated=.TRUE., amplitude_scale=ramp, pdyn=pdyn, & - exp_m2kd=opts%jonswap_e2kd) + exp_m2kd=opts%jonswap_e2kd, tail_sums=opts%jonswap_tail) CASE (WAVE_SEA) CALL CD_Sea_Kinematics(opts%sea, x, y, z, time, opts%wtrdpth, ramp, eta, velocity, acceleration, & ErrStat, ErrMsg, pdyn) @@ -29104,14 +29164,16 @@ SUBROUTINE deck_wave_kinematics(opts, x, y, z, time, eta, velocity, acceleration opts%wave_component_omega, opts%wave_component_k, & opts%wave_component_amplitude, opts%wave_component_phase, & eta, velocity, acceleration, ErrStat, ErrMsg, inputs_validated=.TRUE., & - amplitude_scale=ramp, pdyn=pdyn) + amplitude_scale=ramp, pdyn=pdyn, exp_m2kd=opts%wave_component_e2kd, & + tail_sums=opts%wave_component_tail) ELSE CALL CD_Component_Wave_Kinematics(x, y, z - opts%wave_eta_mean, time, & opts%wtrdpth + opts%wave_eta_mean, opts%wave_direction, .TRUE., & opts%wave_component_omega, opts%wave_component_k, & opts%wave_component_amplitude, opts%wave_component_phase, & eta, velocity, acceleration, ErrStat, ErrMsg, inputs_validated=.TRUE., & - pdyn=pdyn) + pdyn=pdyn, exp_m2kd=opts%wave_component_e2kd, & + tail_sums=opts%wave_component_tail) END IF eta = eta + opts%wave_eta_mean CASE DEFAULT @@ -29477,6 +29539,7 @@ SUBROUTINE precompute_deck_wave(opts, ErrStat, ErrMsg) opts%wave_seed, opts%jonswap_omega, opts%jonswap_k, opts%jonswap_amplitude, & opts%jonswap_phase, ErrStat, ErrMsg) opts%jonswap_e2kd = EXP(-2.0_wp*(opts%jonswap_k*opts%wtrdpth)) + CALL set_component_tail(opts%jonswap_omega, opts%jonswap_k, opts%jonswap_amplitude, opts%jonswap_tail) CASE (WAVE_SEA) CALL CD_Sea_Synthesise(opts%sea, opts%wtrdpth, opts%g, opts%wave_seed, ErrStat, ErrMsg) CASE (WAVE_STREAM) @@ -29498,6 +29561,11 @@ SUBROUTINE precompute_deck_wave(opts, ErrStat, ErrMsg) opts%wave_component_k(k), ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) EXIT END DO + IF (ErrStat == CD_DECKDRV_OK) THEN + opts%wave_component_e2kd = EXP(-2.0_wp*(opts%wave_component_k*(opts%wtrdpth + opts%wave_eta_mean))) + CALL set_component_tail(opts%wave_component_omega, opts%wave_component_k, opts%wave_component_amplitude, & + opts%wave_component_tail) + END IF CASE DEFAULT CALL fail(ErrStat, ErrMsg, 'unsupported wave kind during deck wave precompute') RETURN @@ -29509,6 +29577,23 @@ SUBROUTINE precompute_deck_wave(opts, ErrStat, ErrMsg) opts%wave_cache_ready = .TRUE. END SUBROUTINE precompute_deck_wave + SUBROUTINE set_component_tail(omega, k, amplitude, tail) + !! The tail_sums of CD_Component_Wave_Kinematics: tail(:, i) sums a_j omega_j, a_j omega_j^2 + !! and a_j omega_j^2/k_j over j >= i. Left unallocated (every component summed) unless k + !! does not decrease, which the bound needs. + REAL(wp), INTENT(IN) :: omega(:), k(:), amplitude(:) + REAL(wp), ALLOCATABLE, INTENT(OUT) :: tail(:, :) + INTEGER :: i, n + n = SIZE(k) + IF (n < 2) RETURN + IF (ANY(k(2:n) < k(1:n - 1))) RETURN + ALLOCATE (tail(3, n)) + tail(:, n) = amplitude(n)*[omega(n), omega(n)*omega(n), omega(n)*omega(n)/k(n)] + DO i = n - 1, 1, -1 + tail(:, i) = tail(:, i + 1) + amplitude(i)*[omega(i), omega(i)*omega(i), omega(i)*omega(i)/k(i)] + END DO + END SUBROUTINE set_component_tail + SUBROUTINE update_system_point_hydro(system, points, opts, time, work, ErrStat, ErrMsg) !! Update lumped Free/Connect point fluid kinematics for current and deck waves. TYPE(CD_SystemType), INTENT(INOUT) :: system @@ -31980,16 +32065,14 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include CALL add_row_context('motionFile', lineno, line, ErrMsg) RETURN END IF - it = 0 - IF (ABS(trow(1)/opts%dtM) < MAX_GRID_STEPS) it = NINT(trow(1)/opts%dtM) + 1 - grid_ok = it >= 1 .AND. it <= motion%n_time - IF (grid_ok) grid_ok = ABS(motion%time(it) - trow(1)) <= tol - IF (.NOT. grid_ok) THEN + it = motion_grid_index(trow(1), opts%dtM, motion, tol) + IF (it == 0) THEN CLOSE (unit) CALL fail(ErrStat, ErrMsg, 'time is outside the dtM/TMax grid') CALL add_row_context('motionFile', lineno, line, ErrMsg) RETURN END IF + IF (it == MOTION_PAST_TMAX) CYCLE IF (.NOT. ALLOCATED(turb_seen)) THEN ALLOCATE (turb_seen(SIZE(opts%turb_ref, 2), motion%n_time), STAT=ios) IF (ios /= 0) THEN @@ -32053,13 +32136,8 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include CALL add_row_context('motionFile', lineno, line, ErrMsg) RETURN END IF - ! Nested tests: Fortran does not guarantee short-circuit evaluation, so the time - ! index is range-checked before motion%time(it) is referenced. - it = 0 - IF (ABS(t/opts%dtM) < MAX_GRID_STEPS) it = NINT(t/opts%dtM) + 1 - grid_ok = it >= 1 .AND. it <= motion%n_time - IF (grid_ok) grid_ok = ABS(motion%time(it) - t) <= tol - IF (.NOT. grid_ok) THEN + it = motion_grid_index(t, opts%dtM, motion, tol) + IF (it == 0) THEN CLOSE (unit) CALL fail(ErrStat, ErrMsg, 'time is outside the dtM/TMax grid') CALL add_row_context('motionFile', lineno, line, ErrMsg) @@ -32078,6 +32156,7 @@ SUBROUTINE read_motion_file(path, points, opts, motion, ErrStat, ErrMsg, include CALL add_row_context('motionFile', lineno, line, ErrMsg) RETURN END IF + IF (it == MOTION_PAST_TMAX) CYCLE IF (seen(ip, it)) THEN CLOSE (unit) CALL fail(ErrStat, ErrMsg, 'duplicate row for point '//TRIM(int_to_str(pid))// & @@ -32192,7 +32271,6 @@ SUBROUTINE read_vessel_record(path, opts, motion, rref, vref, aref, ErrStat, Err INTEGER :: unit, ios, lineno, ntok, nform, row_status, it, off REAL(wp) :: row(20), tol, qn LOGICAL, ALLOCATABLE :: seen(:) - LOGICAL :: grid_ok ErrStat = CD_DECKDRV_OK; ErrMsg = '' ALLOCATE (seen(motion%n_time)) @@ -32239,16 +32317,14 @@ SUBROUTINE read_vessel_record(path, opts, motion, rref, vref, aref, ErrStat, Err CALL add_row_context('vesselMotion file', lineno, line, ErrMsg) RETURN END IF - it = 0 - IF (ABS(row(1)/opts%dtM) < MAX_GRID_STEPS) it = NINT(row(1)/opts%dtM) + 1 - grid_ok = it >= 1 .AND. it <= motion%n_time - IF (grid_ok) grid_ok = ABS(motion%time(it) - row(1)) <= tol - IF (.NOT. grid_ok) THEN + it = motion_grid_index(row(1), opts%dtM, motion, tol) + IF (it == 0) THEN CLOSE (unit) CALL fail(ErrStat, ErrMsg, 'time is outside the dtM/TMax grid') CALL add_row_context('vesselMotion file', lineno, line, ErrMsg) RETURN END IF + IF (it == MOTION_PAST_TMAX) CYCLE IF (seen(it)) THEN CLOSE (unit) CALL fail(ErrStat, ErrMsg, 'duplicate row at this time') @@ -33809,6 +33885,7 @@ SUBROUTINE range_setup(rset, lines, channels, opts, nnodes, by_id, ErrStat, ErrM LOGICAL, ALLOCATABLE :: want_r(:), want_t(:) INTEGER :: i, k, n, line_id, comp, es CHARACTER(1024) :: em + REAL(wp) :: t_start n = SIZE(nnodes) ALLOCATE (ids(n), want_r(n), want_t(n)) @@ -33831,7 +33908,10 @@ SUBROUTINE range_setup(rset, lines, channels, opts, nnodes, by_id, ErrStat, ErrM IF (.NOT. by_id) k = find_line(lines, line_id) IF (k >= 1 .AND. k <= n) want_t(k) = .TRUE. END DO - CALL CD_Range_Setup(rset, ids, nnodes, want_r, want_t, opts%range_start, opts%has_wtrdpth, -opts%wtrdpth, & + ! TMax = 0 (a static start check) puts the t = 0 row in the range graphs whatever RangeStart says + t_start = opts%range_start + IF (opts%has_tmax) t_start = MIN(t_start, opts%tmax) + CALL CD_Range_Setup(rset, ids, nnodes, want_r, want_t, t_start, opts%has_wtrdpth, -opts%wtrdpth, & es, em, bathymetry=bathymetry) CALL range_status(es, em, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK .OR. .NOT. ALLOCATED(rset%lines)) RETURN @@ -37506,6 +37586,25 @@ SUBROUTINE grid_step_count(tmax, dt, nstep, ok) ok = .TRUE. END SUBROUTINE grid_step_count + INTEGER FUNCTION motion_grid_index(t, dt, motion, tol) RESULT(it) + !! Index of a record row's time t on the dtM grid motion%time (within tol), 0 when t is + !! off the grid or before 0, and MOTION_PAST_TMAX when t lies on the grid after TMax: a + !! record longer than the run is read to TMax, so TMax = 0 checks a dynamic deck's start. + REAL(wp), INTENT(IN) :: t, dt, tol + TYPE(MotionTable), INTENT(IN) :: motion + INTEGER :: k + it = 0 + IF (.NOT. ABS(t/dt) < MAX_GRID_STEPS) RETURN + k = NINT(t/dt) + IF (k < 0) RETURN + ! nested tests: Fortran does not short-circuit, so k is range-checked before motion%time + IF (k < motion%n_time) THEN + IF (ABS(motion%time(k + 1) - t) <= tol) it = k + 1 + ELSE IF (ABS(REAL(k, wp)*dt - t) <= 100.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, ABS(t))) THEN + it = MOTION_PAST_TMAX + END IF + END FUNCTION motion_grid_index + INTEGER FUNCTION scan_comment(buf) RESULT(p) !! First comment char to strip: `#`/`!` anywhere, or `--` only when it starts !! a whitespace-delimited comment. Section-header dash rules (`---`) survive. diff --git a/src/CableDyn_Hydro.f90 b/src/CableDyn_Hydro.f90 index 1f4287b5..52d069f6 100644 --- a/src/CableDyn_Hydro.f90 +++ b/src/CableDyn_Hydro.f90 @@ -1939,7 +1939,7 @@ END SUBROUTINE CD_JONSWAP_Wave_Kinematics_Precomputed SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretch, & omega_comp, k_comp, amplitude, phase, & eta, velocity, acceleration, ErrStat, ErrMsg, inputs_validated, & - amplitude_scale, pdyn, exp_m2kd) + amplitude_scale, pdyn, exp_m2kd, tail_sums) !! Evaluate linear irregular-wave kinematics from a CALLER-SUPPLIED component table: !! the general (arbitrary length, explicit per-component phase) form of the fixed-size !! deterministic-phase JONSWAP evaluator above, sharing its conventions exactly -- @@ -1965,6 +1965,13 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc !! depend on the buffer. exp_m2kd is the caller's table of EXP(-2 k_comp(i) depth) for this !! depth (constant for a fixed table): it replaces the per-call exponential with the same !! value, so the result is bit-identical. + !! tail_sums(:, i) holds the sums over components j >= i of a_j omega_j, a_j omega_j^2 and + !! a_j omega_j^2/k_j, for a table whose k_comp does not decrease. On -depth <= z_eval <= 0 + !! both depth ratios fall as k grows, so the cosh ratio of the last summed component times + !! tail_sums bounds the rest of the velocity, acceleration and pressure sums. The sums stop + !! once that bound is below half an ulp of the magnitude already summed: a deep point drops + !! the short components that have decayed to nothing there, and the result changes at + !! round-off only. The elevation always sums every component. REAL(wp), INTENT(IN) :: x, y, z, t, depth, direction_deg LOGICAL, INTENT(IN) :: stretch REAL(wp), INTENT(IN) :: omega_comp(:), k_comp(:), amplitude(:), phase(:) @@ -1976,14 +1983,17 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc ! the linear dynamic pressure per unit density (sum over the components of ! (omega^2/k) a cosh(k(z+h))/sinh(kh) cos(theta)), as in CD_Airy_Wave_Kinematics_Precomputed REAL(wp), INTENT(OUT), OPTIONAL :: pdyn - REAL(wp), INTENT(IN), OPTIONAL :: exp_m2kd(:) - INTEGER :: i, n, nb, n_small - REAL(wp) :: omega, k, amp - REAL(wp) :: cb, sb, x_along, theta, z_eval, cosh_ratio, sinh_ratio - INTEGER, PARAMETER :: NBUF = 1024 - REAL(wp) :: scl, c_i, s_i, kd, kz, e_kz, e_neg2kd, e_neg, denom - REAL(wp) :: cth(NBUF), sth(NBUF), ch(NBUF), sh(NBUF) - LOGICAL :: trust_inputs, at_bed + REAL(wp), INTENT(IN), OPTIONAL :: exp_m2kd(:), tail_sums(:, :) + INTEGER :: i, n, nb, n_small, i0, j, nk + REAL(wp) :: amp + REAL(wp) :: cb, sb, x_along, theta, z_eval + ! the elevation keeps the cosines of the first NBUF components; the velocity sums run in + ! blocks of NBLK (NBUF a multiple of NBLK, so a block lies wholly inside or past the buffer) + INTEGER, PARAMETER :: NBUF = 1024, NBLK = 32 + REAL(wp), PARAMETER :: HALF_ULP = 0.5_wp*EPSILON(CD_ONE) + REAL(wp) :: scl, e_neg, denom + REAL(wp) :: cth(NBUF), bc(NBLK), bs(NBLK), ch(NBLK), sh(NBLK), mag(3), rest(3) + LOGICAL :: trust_inputs, at_bed, use_tail, small(NBLK) eta = CD_ZERO velocity = CD_ZERO @@ -2004,6 +2014,12 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc RETURN END IF END IF + IF (PRESENT(tail_sums)) THEN + IF (SIZE(tail_sums, 1) /= 3 .OR. SIZE(tail_sums, 2) /= n) THEN + CALL fail(ErrStat, ErrMsg, 'tail_sums must be shaped (3, n) for the component-wave arrays') + RETURN + END IF + END IF ! Fortran does not require short-circuit evaluation: keep the O(n) scans inside a ! separate branch so the setup-validated hot path portably skips them at -O0 too. IF (.NOT. trust_inputs) THEN @@ -2043,14 +2059,10 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc sb = SIN(direction_deg*DEG2RAD) x_along = x*cb + y*sb nb = MIN(n, NBUF) - ! Cosine and sine in separate loops: a compiler fuses COS and SIN of one argument into a - ! sincos call, which in the MinGW runtime costs several times a cos plus a sin. + ! the elevation sums every component (Wheeler stretching needs the total eta) DO i = 1, nb cth(i) = COS(k_comp(i)*x_along - omega_comp(i)*t + phase(i)) END DO - DO i = 1, nb - sth(i) = SIN(k_comp(i)*x_along - omega_comp(i)*t + phase(i)) - END DO DO i = 1, nb eta = eta + (scl*amplitude(i))*cth(i) END DO @@ -2072,78 +2084,91 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc ELSE z_eval = z END IF - ! Depth-profile ratios of the buffered components: the expressions of profile_ratios, - ! with its seabed test (a function of z_eval and depth only) evaluated once. + ! Depth-profile ratios: the expressions of profile_ratios, with its seabed test (a function + ! of z_eval and depth only) evaluated once. at_bed = ABS(z_eval + depth) <= 8.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, depth, ABS(z_eval)) - IF (PRESENT(exp_m2kd)) THEN - DO i = 1, nb - ch(i) = EXP(k_comp(i)*z_eval) - sh(i) = exp_m2kd(i) - END DO - ELSE - DO i = 1, nb - ch(i) = EXP(k_comp(i)*z_eval) - sh(i) = EXP(-2.0_wp*(k_comp(i)*depth)) - END DO - END IF - IF (at_bed) THEN - DO i = 1, nb - denom = CD_ONE - sh(i) - ch(i) = (ch(i) + ch(i))/denom - sh(i) = CD_ZERO - END DO - ELSE - ! an underflowed exponential takes profile_ratios' stable form; those components - ! (rare) are redone one at a time below, the rest stay branch-free here - n_small = COUNT(ch(1:nb) <= TINY(CD_ONE) .OR. sh(1:nb) <= TINY(CD_ONE)) - DO i = 1, nb - e_neg = sh(i)/MAX(ch(i), TINY(CD_ONE)) - denom = CD_ONE - sh(i) - sh(i) = (ch(i) - e_neg)/denom - ch(i) = (ch(i) + e_neg)/denom + use_tail = .FALSE. + IF (PRESENT(tail_sums)) use_tail = z_eval <= CD_ZERO .AND. z_eval >= -depth + mag = CD_ZERO + DO i0 = 1, n, NBLK + nk = MIN(n - i0 + 1, NBLK) + IF (i0 <= nb) THEN + bc(1:nk) = cth(i0:i0 + nk - 1) + ELSE + DO j = 1, nk + bc(j) = COS(k_comp(i0 + j - 1)*x_along - omega_comp(i0 + j - 1)*t + phase(i0 + j - 1)) + END DO + END IF + ! the sine in its own loop: a compiler fuses COS and SIN of one argument into a sincos + ! call, which in the MinGW runtime costs several times a cos plus a sin + DO j = 1, nk + bs(j) = SIN(k_comp(i0 + j - 1)*x_along - omega_comp(i0 + j - 1)*t + phase(i0 + j - 1)) END DO - IF (n_small > 0) THEN - DO i = 1, nb - kd = k_comp(i)*depth - kz = k_comp(i)*z_eval - e_kz = EXP(kz) - e_neg2kd = EXP(-2.0_wp*kd) - IF (e_kz <= TINY(e_kz) .OR. e_neg2kd <= TINY(e_neg2kd)) & - CALL profile_ratios(k_comp(i), depth, z_eval, ch(i), sh(i)) + IF (PRESENT(exp_m2kd)) THEN + DO j = 1, nk + ch(j) = EXP(k_comp(i0 + j - 1)*z_eval) + sh(j) = exp_m2kd(i0 + j - 1) + END DO + ELSE + DO j = 1, nk + ch(j) = EXP(k_comp(i0 + j - 1)*z_eval) + sh(j) = EXP(-2.0_wp*(k_comp(i0 + j - 1)*depth)) END DO END IF - END IF - DO i = 1, nb - amp = (scl*amplitude(i))*omega_comp(i) - velocity(1) = velocity(1) + amp*ch(i)*cth(i)*cb - velocity(2) = velocity(2) + amp*ch(i)*cth(i)*sb - velocity(3) = velocity(3) + amp*sh(i)*sth(i) - amp = (scl*amplitude(i))*omega_comp(i)*omega_comp(i) - acceleration(1) = acceleration(1) + amp*ch(i)*sth(i)*cb - acceleration(2) = acceleration(2) + amp*ch(i)*sth(i)*sb - acceleration(3) = acceleration(3) - amp*sh(i)*cth(i) - END DO - IF (PRESENT(pdyn)) THEN - DO i = 1, nb - pdyn = pdyn + (scl*amplitude(i))*omega_comp(i)*omega_comp(i)/k_comp(i)*ch(i)*cth(i) + IF (at_bed) THEN + DO j = 1, nk + denom = CD_ONE - sh(j) + ch(j) = (ch(j) + ch(j))/denom + sh(j) = CD_ZERO + END DO + ELSE + ! an underflowed exponential (exp(-2kd) of a short component in deep water) takes + ! profile_ratios' stable form; those components are redone one at a time below, the + ! rest stay branch-free here + small(1:nk) = ch(1:nk) <= TINY(CD_ONE) .OR. sh(1:nk) <= TINY(CD_ONE) + n_small = COUNT(small(1:nk)) + DO j = 1, nk + e_neg = sh(j)/MAX(ch(j), TINY(CD_ONE)) + denom = CD_ONE - sh(j) + sh(j) = (ch(j) - e_neg)/denom + ch(j) = (ch(j) + e_neg)/denom + END DO + IF (n_small > 0) THEN + DO j = 1, nk + IF (small(j)) CALL profile_ratios(k_comp(i0 + j - 1), depth, z_eval, ch(j), sh(j)) + END DO + END IF + END IF + DO j = 1, nk + i = i0 + j - 1 + amp = (scl*amplitude(i))*omega_comp(i) + velocity(1) = velocity(1) + amp*ch(j)*bc(j)*cb + velocity(2) = velocity(2) + amp*ch(j)*bc(j)*sb + velocity(3) = velocity(3) + amp*sh(j)*bs(j) + amp = (scl*amplitude(i))*omega_comp(i)*omega_comp(i) + acceleration(1) = acceleration(1) + amp*ch(j)*bs(j)*cb + acceleration(2) = acceleration(2) + amp*ch(j)*bs(j)*sb + acceleration(3) = acceleration(3) - amp*sh(j)*bc(j) END DO - END IF - DO i = nb + 1, n - omega = omega_comp(i) - k = k_comp(i) - theta = k*x_along - omega*t + phase(i) - c_i = COS(theta) - s_i = SIN(theta) - CALL profile_ratios(k, depth, z_eval, cosh_ratio, sinh_ratio) - amp = (scl*amplitude(i))*omega - velocity(1) = velocity(1) + amp*cosh_ratio*c_i*cb - velocity(2) = velocity(2) + amp*cosh_ratio*c_i*sb - velocity(3) = velocity(3) + amp*sinh_ratio*s_i - amp = (scl*amplitude(i))*omega*omega - acceleration(1) = acceleration(1) + amp*cosh_ratio*s_i*cb - acceleration(2) = acceleration(2) + amp*cosh_ratio*s_i*sb - acceleration(3) = acceleration(3) - amp*sinh_ratio*c_i - IF (PRESENT(pdyn)) pdyn = pdyn + amp/k*cosh_ratio*c_i + IF (PRESENT(pdyn)) THEN + DO j = 1, nk + i = i0 + j - 1 + pdyn = pdyn + (scl*amplitude(i))*omega_comp(i)*omega_comp(i)/k_comp(i)*ch(j)*bc(j) + END DO + END IF + IF (use_tail) THEN + DO j = 1, nk + i = i0 + j - 1 + mag(1) = mag(1) + amplitude(i)*omega_comp(i)*ch(j) + mag(2) = mag(2) + amplitude(i)*omega_comp(i)*omega_comp(i)*ch(j) + mag(3) = mag(3) + amplitude(i)*omega_comp(i)*omega_comp(i)/k_comp(i)*ch(j) + END DO + IF (i0 + nk <= n) THEN + rest = ch(nk)*tail_sums(:, i0 + nk) + IF (rest(1) <= HALF_ULP*mag(1) .AND. rest(2) <= HALF_ULP*mag(2) .AND. & + (.NOT. PRESENT(pdyn) .OR. rest(3) <= HALF_ULP*mag(3))) EXIT + END IF + END IF END DO END SUBROUTINE CD_Component_Wave_Kinematics diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index ff565bac..f7a302f1 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -645,10 +645,23 @@ PROGRAM test_deck_driver wave_file='wk_eta_short.dat', dtwave=0.25_wp) CALL write_waterkin_file('wk_wave_padded.dat', wavekinmod='1', deepest_first=.FALSE., & wave_file='wk_eta_padded.dat', dtwave=0.25_wp) - CALL write_dynamic_connect_deck('deck_wk_wave_short.dat', option_row='wk_wave_short.dat WaterKin', & + ! TMax = 0 (a static-start check) reduces the record over its own length: 40 s of a 10 s wave + CALL write_wave_elevation_file('wk_eta_t0.dat', 1.0_wp, 10.0_wp, 0.0_wp, nperiods=4) + CALL write_waterkin_file('wk_wave_t0.dat', wavekinmod='1', deepest_first=.FALSE., & + wave_file='wk_eta_t0.dat', dtwave=0.25_wp) + CALL write_dynamic_connect_deck('deck_wk_wave_t0.dat', option_row='wk_wave_t0.dat WaterKin', run_tmax=0.0_wp) + CALL CD_Run_Deck_Driver('deck_wk_wave_t0.dat', 'deck_wk_wave_t0', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'WaveKinMod 1 record at TMax = 0 checks the static start: '//TRIM(em)) + ! a 1 s window has no component at or below the default 0.5 Hz WvHiCOff: refused by name + CALL write_dynamic_connect_deck('deck_wk_wave_cut.dat', option_row='wk_wave_short.dat WaterKin', & run_tmax=1.0_wp) + CALL CD_Run_Deck_Driver('deck_wk_wave_cut.dat', 'deck_wk_wave_cut', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'none WvHiCOff') > 0, & + 'a record with nothing below WvHiCOff is refused by name: '//TRIM(em)) + CALL write_dynamic_connect_deck('deck_wk_wave_short.dat', option_row='wk_wave_short.dat WaterKin', & + option_row2='none WvHiCOff', run_tmax=1.0_wp) CALL write_dynamic_connect_deck('deck_wk_wave_padded.dat', option_row='wk_wave_padded.dat WaterKin', & - run_tmax=1.0_wp) + option_row2='none WvHiCOff', run_tmax=1.0_wp) CALL CD_Run_Deck_Driver('deck_wk_wave_short.dat', 'deck_wk_wave_short', conv, es, em) CALL require(es == CD_DECKDRV_OK .AND. conv, 'short WaveKinMod 1 record converged: '//TRIM(em)) CALL CD_Run_Deck_Driver('deck_wk_wave_padded.dat', 'deck_wk_wave_padded', conv, es, em) @@ -666,7 +679,7 @@ PROGRAM test_deck_driver CALL write_waterkin_file('wk_sub/wk_wave_sub.dat', wavekinmod='1', deepest_first=.FALSE., & wave_file='wk_eta_short.dat', dtwave=0.25_wp) CALL write_dynamic_connect_deck('deck_wk_wave_sub.dat', option_row='wk_sub/wk_wave_sub.dat WaterKin', & - run_tmax=1.0_wp) + option_row2='none WvHiCOff', run_tmax=1.0_wp) CALL CD_Run_Deck_Driver('deck_wk_wave_sub.dat', 'deck_wk_wave_sub', conv, es, em) CALL require(es == CD_DECKDRV_OK .AND. conv, 'deck-relative WaveKinFile of a nested WaterKin file: '//TRIM(em)) IF (es == CD_DECKDRV_OK) THEN @@ -753,15 +766,17 @@ PROGRAM test_deck_driver ! WaveKinMod 1: reduce a sampled elevation history to Fourier components. A ! pure Airy history must reproduce the equivalent inline wave/current deck. ! The source record is twice the run TMax and its second half is deliberately - ! contaminated. The FFT window must ignore that tail and match one clean period. + ! contaminated. The FFT window must ignore that tail and match one clean period. The 1 Hz wave + ! lies above the 0.5 Hz default WvHiCOff, so these decks keep every component. CALL write_wave_elevation_file('wk_eta.dat', 1.0_wp, 1.0_wp, 0.0_wp, nperiods=2, tail_bias=0.4_wp) CALL write_waterkin_file('wk_wave.dat', wavekinmod='1', deepest_first=.FALSE., & wave_file='wk_eta.dat', dtwave=0.25_wp) - CALL write_dynamic_connect_deck('deck_wk_wave.dat', option_row='wk_wave.dat WaterKin', run_tmax=1.0_wp) + CALL write_dynamic_connect_deck('deck_wk_wave.dat', option_row='wk_wave.dat WaterKin', & + option_row2='none WvHiCOff', run_tmax=1.0_wp) CALL CD_Run_Deck_Driver('deck_wk_wave.dat', 'deck_wk_wave', conv, es, em) CALL require(es == CD_DECKDRV_OK .AND. conv, 'WaveKinMod 1 elevation-history deck converged: '//TRIM(em)) CALL write_dynamic_connect_deck('deck_wk_wave_host_tmax.dat', option_row='wk_wave.dat WaterKin', & - omit_tmax=.TRUE.) + option_row2='none WvHiCOff', omit_tmax=.TRUE.) BLOCK TYPE(CD_DeckAggregateType) :: wkagg CALL CD_Init_Deck_Aggregate('deck_wk_wave_host_tmax.dat', 0.005_wp, wkagg, es, em, & @@ -812,7 +827,8 @@ PROGRAM test_deck_driver END BLOCK CALL write_waterkin_file('wk_mixed_hybrid.dat', wavekinmod='1', deepest_first=.FALSE., & wave_file='wk_eta.dat', currentmod='2', dtwave=0.25_wp) - CALL write_dynamic_connect_deck('deck_wk_mixed_hybrid.dat', option_row='wk_mixed_hybrid.dat WaterKin') + CALL write_dynamic_connect_deck('deck_wk_mixed_hybrid.dat', option_row='wk_mixed_hybrid.dat WaterKin', & + option_row2='none WvHiCOff') CALL CD_Run_Deck_Driver('deck_wk_mixed_hybrid.dat', 'deck_wk_mixed_hybrid', conv, es, em) CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'cannot separate') > 0, & 'WaveKinMod 1 plus CurrentMod 2 fails closed by mixed-source contract') diff --git a/tests/test_hermite_irregular_waves.f90 b/tests/test_hermite_irregular_waves.f90 index 4d5d7165..b6283d46 100644 --- a/tests/test_hermite_irregular_waves.f90 +++ b/tests/test_hermite_irregular_waves.f90 @@ -26,6 +26,10 @@ PROGRAM test_hermite_irregular_waves !! all-zero amplitudes, bad period/phase/depth/gravity, missing hydro config). !! 7. IRREGULAR SMOKE: a 12-component JONSWAP-like table on a hanging cable runs !! bounded with every step converged (waves break the at-rest fixed point). + !! 8. TAIL SUMS: on a 1500-component table of a 600 s record (the components of a WaterKin + !! elevation file), the kernel with tail_sums gives the same elevation bit for bit and + !! velocity, acceleration and dynamic pressure within round-off of the full sums, from + !! the surface to the seabed; above still water (stretching off) it sums every component. USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 USE CableDyn_Precision, ONLY: wp @@ -50,6 +54,7 @@ PROGRAM test_hermite_irregular_waves CALL model_displacement() CALL fail_closed_battery() CALL irregular_smoke() + CALL kernel_tail_sums() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -151,6 +156,67 @@ SUBROUTINE kernel_profile_underflow() CALL require(ABS(a(3)) <= TINY(1.0_wp), 'profile underflow: seabed sinh ratio remains zero') END SUBROUTINE kernel_profile_underflow + SUBROUTINE kernel_tail_sums() + INTEGER, PARAMETER :: N = 1500, NZ = 7 + ! (z, stretch): near the surface, mid-depth, deep, near and at the seabed; above still water + REAL(wp), PARAMETER :: ZS(NZ) = [-0.5_wp, -5.0_wp, -20.0_wp, -45.0_wp, -59.999_wp, -60.0_wp, 0.3_wp] + LOGICAL, PARAMETER :: STRETCH(NZ) = [.TRUE., .TRUE., .TRUE., .FALSE., .TRUE., .FALSE., .FALSE.] + REAL(wp) :: om(N), k(N), amp(N), ph(N), tail(3, N), e2kd(N), w(3) + REAL(wp) :: eta0, u0(3), a0(3), p0, eta1, u1(3), a1(3), p1, mag(3), ratio, ze + INTEGER :: i, iz, es + CHARACTER(200) :: em + ! omega_i = i 2 pi/600 s up to 2 Hz: a peaked sea plus the leakage tail of a finite record + DO i = 1, N + om(i) = REAL(i, wp)*2.0_wp*PI/600.0_wp + amp(i) = 0.3_wp*EXP(-0.5_wp*((om(i) - 0.63_wp)/0.12_wp)**2) + 1.0e-3_wp/REAL(i, wp) + ph(i) = MODULO(2.399963_wp*REAL(i, wp)**2, 2.0_wp*PI) + CALL CD_Solve_Dispersion_Wavenumber(om(i), DEPTH, GRAV, k(i), es, em) + CALL require(es == CD_HYDRO_OK, 'tail sums: dispersion solve: '//TRIM(em)) + e2kd(i) = EXP(-2.0_wp*(k(i)*DEPTH)) + END DO + tail(:, N) = amp(N)*[om(N), om(N)**2, om(N)**2/k(N)] + DO i = N - 1, 1, -1 + tail(:, i) = tail(:, i + 1) + amp(i)*[om(i), om(i)**2, om(i)**2/k(i)] + END DO + DO iz = 1, NZ + CALL CD_Component_Wave_Kinematics(12.0_wp, 3.0_wp, ZS(iz), 333.3_wp, DEPTH, 20.0_wp, STRETCH(iz), & + om, k, amp, ph, eta0, u0, a0, es, em, inputs_validated=.TRUE., & + pdyn=p0, exp_m2kd=e2kd) + CALL require(es == CD_HYDRO_OK, 'tail sums: full sum: '//TRIM(em)) + CALL CD_Component_Wave_Kinematics(12.0_wp, 3.0_wp, ZS(iz), 333.3_wp, DEPTH, 20.0_wp, STRETCH(iz), & + om, k, amp, ph, eta1, u1, a1, es, em, inputs_validated=.TRUE., & + pdyn=p1, exp_m2kd=e2kd, tail_sums=tail) + CALL require(es == CD_HYDRO_OK, 'tail sums: bounded sum: '//TRIM(em)) + CALL require(TRANSFER(eta1, 0_INT64) == TRANSFER(eta0, 0_INT64), 'tail sums: the elevation sums every component') + IF (ZS(iz) > 0.0_wp) THEN + CALL require(ALL(TRANSFER([u1, a1, p1], [0_INT64]) == TRANSFER([u0, a0, p0], [0_INT64])), & + 'tail sums: above still water every component is summed') + CYCLE + END IF + ! the magnitudes summed: a omega, a omega^2 and a omega^2/k times the cosh ratio + ze = ZS(iz) + IF (STRETCH(iz)) ze = (ZS(iz) - eta0)*DEPTH/(DEPTH + eta0) + mag = 0.0_wp + DO i = 1, N + ratio = (EXP(k(i)*ze) + EXP(-k(i)*(ze + 2.0_wp*DEPTH)))/(1.0_wp - e2kd(i)) + w = amp(i)*[om(i), om(i)**2, om(i)**2/k(i)] + mag = mag + w*ratio + END DO + CALL require(MAXVAL(ABS(u1 - u0)) <= 4.0_wp*EPSILON(1.0_wp)*mag(1) .AND. & + MAXVAL(ABS(a1 - a0)) <= 4.0_wp*EPSILON(1.0_wp)*mag(2) .AND. & + ABS(p1 - p0) <= 4.0_wp*EPSILON(1.0_wp)*mag(3), & + 'tail sums: velocity, acceleration and pressure within round-off at z = '//fmt_z(ZS(iz))) + END DO + CALL CD_Component_Wave_Kinematics(12.0_wp, 3.0_wp, -5.0_wp, 333.3_wp, DEPTH, 20.0_wp, .TRUE., & + om, k, amp, ph, eta1, u1, a1, es, em, tail_sums=tail(1:2, :)) + CALL require(es /= CD_HYDRO_OK, 'tail sums: a mis-shaped table fails closed') + END SUBROUTINE kernel_tail_sums + + CHARACTER(16) FUNCTION fmt_z(z) + REAL(wp), INTENT(IN) :: z + WRITE (fmt_z, '(F0.3)') z + END FUNCTION fmt_z + SUBROUTINE kernel_total_eta_wheeler() INTEGER, PARAMETER :: N = 4 REAL(wp) :: amp(N), per(N), phd(N), om(N), k(N), ph(N) diff --git a/tests/test_shared_anchor.f90 b/tests/test_shared_anchor.f90 index f7bda633..badf4880 100644 --- a/tests/test_shared_anchor.f90 +++ b/tests/test_shared_anchor.f90 @@ -210,7 +210,7 @@ END SUBROUTINE check_fixed_anchor SUBROUTINE check_turbines_section() !! Turbine J at FAIR(:, J) - [0, 0, -10] with its fairlead at local (0, 0, -10); turbine 1 !! surges as write_motion's fairlead 1, written as a per-turbine record. - REAL(wp), ALLOCATABLE :: a(:, :), b(:, :) + REAL(wp), ALLOCATABLE :: a(:, :), b(:, :), c(:, :) INTEGER :: u, j LOGICAL :: ok @@ -268,6 +268,13 @@ SUBROUTINE check_turbines_section() CALL write_turbine_motion(0) CALL run('shared_turbines.dat', 'shared_turbines', 8, a, ok) IF (.NOT. ok) RETURN + ! a record that runs 2 s past TMax is read to TMax: the same run, bit for bit + CALL write_turbine_motion(5) + CALL run('shared_turbines.dat', 'shared_turbines_long', 8, c, ok) + IF (.NOT. ok) RETURN + CALL require(SIZE(c, 2) == SIZE(a, 2), 'TURBINES record longer than TMax: the run has TMax''s rows') + IF (SIZE(c, 2) /= SIZE(a, 2)) RETURN + CALL require(.NOT. MAXVAL(ABS(c - a)) > 0.0_wp, 'TURBINES record longer than TMax: rows after TMax unused') CALL write_deck('shared_anchor_all.dat', [.TRUE., .TRUE., .TRUE.], .FALSE., .TRUE., .TRUE.) CALL run('shared_anchor_all.dat', 'shared_anchor_all', 8, b, ok) IF (.NOT. ok) RETURN @@ -281,7 +288,8 @@ END SUBROUTINE check_turbines_section SUBROUTINE write_turbine_motion(variant) !! The per-turbine records; variant 1: J = 1.5 on the first row, 2: J = 4 (no such - !! TURBINES row), 3: q0 = 0.5 (not a unit quaternion), 4: turbine 2's first row twice. + !! TURBINES row), 3: q0 = 0.5 (not a unit quaternion), 4: turbine 2's first row twice, + !! 5: the record runs to 12 s, 2 s past the deck's TMax. INTEGER, INTENT(IN) :: variant CHARACTER(16) :: jtok INTEGER :: u, j, k @@ -289,7 +297,7 @@ SUBROUTINE write_turbine_motion(variant) OPEN (NEWUNIT=u, FILE='shared_turbines.motion', STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') '# time J x y z q0 q1 q2 q3 vx vy vz wx wy wz ax ay az alx aly alz' w = 2.0_wp*3.14159265358979323846_wp/20.0_wp - DO k = 0, 100 + DO k = 0, MERGE(120, 100, variant == 5) t = 0.1_wp*REAL(k, wp) DO j = 1, 3 x = FAIR(1, j) diff --git a/tests/test_static_check.py b/tests/test_static_check.py new file mode 100644 index 00000000..38036bcc --- /dev/null +++ b/tests/test_static_check.py @@ -0,0 +1,142 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""TMax = 0 checks the static start of a dynamic deck, and records may outlast TMax. + +Gates, on the shipped lazy-wave decks driven by a vesselMotion record and by a motionFile +(both 36 s records at dtM 0.05 s): + +* a run to TMax = 1 s on the full record writes the same output, byte for byte, as one on + the record cut to 1 s: rows after TMax are read and not used; +* a row after TMax that is off the dtM grid is still refused; +* TMax = 0 runs either deck, RangeStart 12 s included, and writes the t = 0 row of the + 1 s run, with the range graph of that row; +* RangeStart after a TMax > 0 is still refused; +* without dtM and TMax the deck stops on its first dynamic input, and the message says to + give dtM with TMax = 0. + +usage: test_static_check.py --exe --examples --output

+""" + +from __future__ import annotations + +import argparse +import os +import re +import shutil +import subprocess +import sys +from pathlib import Path + +FAILURES: list[str] = [] +HINT = "to check a dynamic deck's static start only, give dtM with TMax = 0" + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +def set_option(text: str, key: str, value: str | None) -> str: + """Set the value of OPTION ``key`` (``None`` removes the row).""" + pattern = re.compile(r"^\s*\S+\s+" + key + r"\b.*$", re.M | re.I) + assert len(pattern.findall(text)) == 1, key + return pattern.sub("" if value is None else f"{value} {key}", text) + + +def cut_record(src: Path, dst: Path, tmax: float) -> None: + """Copy a motion record keeping its comments and the rows up to tmax.""" + keep = [line for line in src.read_text().splitlines() + if line.lstrip().startswith("#") or not line.strip() or float(line.split()[0]) <= tmax + 1e-9] + dst.write_text("\n".join(keep) + "\n") + + +def run(exe: str, cwd: Path, name: str, text: str) -> subprocess.CompletedProcess: + (cwd / f"{name}.dat").write_text(text, encoding="utf-8", newline="\n") + return subprocess.run([exe, f"{name}.dat", name], cwd=cwd, capture_output=True, text=True, + env=dict(os.environ, OMP_NUM_THREADS="1")) + + +def data_rows(path: Path) -> list[str]: + lines = path.read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.startswith("Time")) + return [line for line in lines[head + 1:] if line.strip() and not line.lstrip().startswith("(")] + + +def case(exe: str, examples: Path, out: Path, deck_name: str, record: str, keyword: str) -> None: + work = out / deck_name + work.mkdir(parents=True) + text = (examples / f"{deck_name}.dat").read_text(encoding="utf-8") + src = examples / record + shutil.copy(src, work / "full.txt") + cut_record(src, work / "cut.txt", 1.0) + text = set_option(text, keyword, "full.txt") + if "RangeStart" not in text: + text = text.replace(f"full.txt {keyword}", f"full.txt {keyword}\n12.0 RangeStart", 1) + # line 1 writes its range graph (LINES ID NodeA NodeB Outputs) + text = re.sub(r"^(1\s+1\s+2\s+)\S+$", r"\1r", text, count=1, flags=re.M) + + one = set_option(set_option(text, "TMax", "1.0"), "RangeStart", "0.5") + p_full = run(exe, work, "full", one) + p_cut = run(exe, work, "cut", one.replace(f"full.txt {keyword}", f"cut.txt {keyword}")) + ok = p_full.returncode == 0 and p_cut.returncode == 0 + check(ok, f"{deck_name}: TMax = 1 s runs on the 36 s record and on the record cut to 1 s " + f"(exit {p_full.returncode}, {p_cut.returncode})") + if not ok: + print(p_full.stderr[-1500:], p_cut.stderr[-1500:]) + return + same = (work / "full.out").read_bytes() == (work / "cut.out").read_bytes() + check(same, f"{deck_name}: the run on the longer record writes the same output byte for byte") + + off = (work / "full.txt").read_text().splitlines() + last = next(line for line in reversed(off) if line.strip() and not line.startswith("#")).split() + last[0] = f"{float(last[0]) + 0.025:.3f}" + (work / "off.txt").write_text("\n".join(off + [" ".join(last)]) + "\n") + p_off = run(exe, work, "off", one.replace(f"full.txt {keyword}", f"off.txt {keyword}")) + check(p_off.returncode != 0 and "time is outside the dtM/TMax grid" in p_off.stderr, + f"{deck_name}: an off-grid row after TMax is refused") + + p_zero = run(exe, work, "zero", set_option(text, "TMax", "0.0")) + check(p_zero.returncode == 0, f"{deck_name}: TMax = 0 with RangeStart 12 s checks the static start " + f"(exit {p_zero.returncode})") + if p_zero.returncode != 0: + print(p_zero.stderr[-1500:]) + return + rows = data_rows(work / "zero.out") + check(len(rows) == 1 and rows[0] == data_rows(work / "full.out")[0], + f"{deck_name}: TMax = 0 writes the t = 0 row of the 1 s run") + graph = (work / "zero.Line1.range.out").read_text().splitlines() + check("1 samples from t =" in graph[0] and any(line[:1].isdigit() for line in graph), + f"{deck_name}: and the range graph of that row") + + p_late = run(exe, work, "late", set_option(one, "RangeStart", "2.0")) + check(p_late.returncode != 0 and "RangeStart exceeds TMax" in p_late.stderr, + f"{deck_name}: RangeStart after a TMax > 0 is still refused") + + p_none = run(exe, work, "none", set_option(set_option(text, "TMax", None), "dtM", None)) + check(p_none.returncode != 0 and HINT in p_none.stderr, + f"{deck_name}: without dtM and TMax the message says to give dtM with TMax = 0") + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--examples", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + out = Path(args.output) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + examples = Path(args.examples) + case(args.exe, examples, out, "lazy_wave_vessel_motion", "data/vessel/vessel_surge_heave_pitch_12s_dt005.txt", + "vesselMotion") + case(args.exe, examples, out, "lozon_gomex80_power_cable_motion", "data/lozon/gomex80_heave_3m_12s_dt005.txt", + "motionFile") + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_wavekin_modes.f90 b/tests/test_wavekin_modes.f90 index 07f64166..d85f2004 100644 --- a/tests/test_wavekin_modes.f90 +++ b/tests/test_wavekin_modes.f90 @@ -14,6 +14,8 @@ !> equals the record's two harmonics to 1e-10 m), and velocity and acceleration, which !> MoorDyn-C interpolates in the stretched depth on its 0.25 m grid, within 1e-3 of their !> scale; +!> - WvHiCOff: 1 rad/s keeps only the record's 8 s harmonic, exactly; none keeps both, as the +!> 0.5 Hz default does (the record has nothing above it); !> - Currents 1: identical to 1e-12 m/s; !> - the MoorDyn-C modes CableDyn does not support fail closed by name. PROGRAM test_wavekin_modes @@ -27,6 +29,7 @@ PROGRAM test_wavekin_modes CALL check_mode('wavekin_mdc/wavekin3.dat', 'wavekin_mdc/mdc_wavekin3.csv', 'WaveKin 3', 1.0e-6_wp, & 1.0e-3_wp, 1.0e-3_wp) CALL check_record() + CALL check_cutoff() CALL check_mode('wavekin_mdc/currents1.dat', 'wavekin_mdc/mdc_currents1.csv', 'Currents 1', 1.0e-12_wp, & 1.0e-12_wp, 1.0e-12_wp, absolute=.TRUE.) CALL check_rejections() @@ -138,6 +141,52 @@ SUBROUTINE check_record() CALL require(err <= 1.0e-10_wp, 'WaveKin 3 reproduces the recorded elevation') END SUBROUTINE check_record + SUBROUTINE check_cutoff() + !! WvHiCOff drops the record's components above it: at 1 rad/s only 0.8 cos(2 pi t/8) of + !! wave_elevation.txt is left; with none the record is reproduced as with the default. + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp) :: pos(3, 5), t(5), eta(5), vel(3, 5), acc(3, 5), err_cut, err_none + CHARACTER(1024) :: line + INTEGER :: es, i, u_in, u_cut, u_none, ios + CHARACTER(512) :: em + OPEN (NEWUNIT=u_in, FILE='wavekin_mdc/wavekin3.dat', STATUS='OLD', ACTION='READ') + OPEN (NEWUNIT=u_cut, FILE='wavekin_mdc/wavekin3_cut.dat', STATUS='REPLACE', ACTION='WRITE') + OPEN (NEWUNIT=u_none, FILE='wavekin_mdc/wavekin3_none.dat', STATUS='REPLACE', ACTION='WRITE') + DO + READ (u_in, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + WRITE (u_cut, '(A)') TRIM(line) + WRITE (u_none, '(A)') TRIM(line) + IF (INDEX(line, 'dtWave') > 0) THEN + WRITE (u_cut, '(A)') '1.0 WvHiCOff' + WRITE (u_none, '(A)') 'none WvHiCOff' + END IF + END DO + CLOSE (u_in); CLOSE (u_cut); CLOSE (u_none) + pos = 0.0_wp + pos(3, :) = -10.0_wp + t = [0.0_wp, 1.23_wp, 5.55_wp, 13.01_wp, 27.7_wp] + CALL CD_Deck_Fluid_Probe('wavekin_mdc/wavekin3_cut.dat', pos, t, eta, vel, acc, es, em) + CALL require(es == CD_DECKDRV_OK, 'WvHiCOff 1 rad/s evaluated: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + err_cut = 0.0_wp + DO i = 1, SIZE(t) + err_cut = MAX(err_cut, ABS(eta(i) - 0.8_wp*COS(2.0_wp*PI*t(i)/8.0_wp))) + END DO + CALL CD_Deck_Fluid_Probe('wavekin_mdc/wavekin3_none.dat', pos, t, eta, vel, acc, es, em) + CALL require(es == CD_DECKDRV_OK, 'none WvHiCOff evaluated: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + err_none = 0.0_wp + DO i = 1, SIZE(t) + err_none = MAX(err_none, ABS(eta(i) - (0.8_wp*COS(2.0_wp*PI*t(i)/8.0_wp) + & + 0.4_wp*SIN(2.0_wp*PI*t(i)/5.0_wp + 0.3_wp)))) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A)') 'WvHiCOff: 1 rad/s vs the 8 s harmonic ', err_cut, ' m; none vs the record ', & + err_none, ' m' + CALL require(err_cut <= 1.0e-10_wp, 'WvHiCOff 1 rad/s keeps only the 8 s harmonic') + CALL require(err_none <= 1.0e-10_wp, 'none WvHiCOff reproduces the record') + END SUBROUTINE check_cutoff + SUBROUTINE write_fail_deck(path, wavekin, currents, extra_option) !! The shared probe deck with the given WaveKin and Currents rows (and an optional extra !! OPTIONS row). From a5154856512b24c8c20863ac6cf68c66aab7c075 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 29 Oct 2026 16:37:45 +0900 Subject: [PATCH 16/51] fix/feat: coupled start in the SeaState current, CurvX/CurvY section curvature, Syrope hydrodynamics (#65) * feat(outputs): CurvX/CurvY, the curvature on a cable's section axes CurvN gives the curvature as a magnitude only. The fatigue of an armour wire or conductor at a fixed point of a power cable's cross section needs its direction in the section, so cross-section analysis (CableXSec) had to rebuild it from node positions. CurvXN and CurvYN resolve the nodal curvature vector, toward the centre of curvature and of length CurvN, on the section axes of a finite-EI line. The vector is the normal part of the recovered section moment over EI on the side that gives the curvature, or the exact trace's (r' x r'') x r'/|r'|^4 where the recovery falls back to it (both now returned by node_values and CD_HermiteCable_Curvature). The section axis x starts at End A normal to the End A -> End B tangent: on a line restrained in torsion along End A's torsion normal; otherwise along the static start's upper normal, kept in the hang-off's axes when End A is clamped (it turns with the vessel) and in global axes at a pinned End A. It is carried to every node by parallel transport (eight smallest rotations between the Hermite tangents per element) and, in torsion, turned about the tangent by the twist from End A. The result is cached per state, so the channels of one output row share one recovery. EI = 0 lines and the two-moving-end route refuse the channels by name, natively and in the Python deck validator. section_curvature: on a planar line CurvY is zero and the norm is Curv; in a cross current both components appear with the same norm; the deck turned 30 degrees about the vertical gives the same components to 8e-9; a clamped hang-off turned 30 degrees about its tangent turns them by -30 degrees to 1e-15; on a line twisted 90 degrees the carried axes reach End B within 3e-6 rad of its own pretwisted normal. Signed-off-by: Jae Hoon Seo * fix(openfast): start a coupled run from the equilibrium in SeaState's current A coupled OpenFAST run solved its static start in still water and let the SeaState current act from t = 0, while a standalone deck starts in the equilibrium of its current OPTION. The twin user's lazy-wave cable then spent the first minutes of every coupled run drifting into the current, and those minutes were discarded. CD_Init_Deck_Aggregate (and CD_AGG_Init_From_Deck) take an optional static_current profile (z, ux, uy, uz by ascending z). With the host fluid field and the host current on, it goes into a copy of the options that only the static builders see: body and rod equilibrium, the EI = 0 system and its points, and the finite-EI cables. The dynamics take the host field alone (the EI = 0 models' fluid field is replaced, the cables' drag carries no deck current), so the current is not counted twice. A deck whose WaterKin CurrentMod 1 file gives its own profile keeps it. The OpenFAST shell builds the profile from SeaState's CurrMod 1 current at the levels of its vertical wave grid (CD_SeaState_Steady_Current) and passes it at the initialisation, the checkpoint rebuild and the linearization probes. CurrMod 2 and InflowWind currents keep the still-water start, with a note. On the mixed deck (EI = 0 chain and finite-EI cable) held in a 0.5 m/s current, the start in that current moves its loads by 2.3e-8 over 1 s, the still-water start by 4.8e-3. On the IEA-15 MW mixed example in a 0.5 m/s cross current the cable starts 29 m across at its deepest monitored node and moves less than 0.6 m in 30 s; from still water it has covered a third of that offset by then. Signed-off-by: Jae Hoon Seo * feat(syrope): hydrodynamics, current, waves, host fluid and VIV on Syrope lines MoorDyn applies its line hydrodynamics to Syrope polyester lines as to any other. CableDyn built a Syrope line on its own path with gravity, buoyancy and a flat seabed only: no drag, no added mass, and current, waves, a host's fluid field, a bathymetryFile and VIV refused. The Syrope builder now keeps its working-curve initial condition (the secant EA iterated to the rest curve, the per-element running maximum and slow strain) but builds each probe and the final line through init_one_model, which takes the secant and the Syrope states as optional arguments: the line gets the seabed, hydrodynamics and fluid fields of any EI = 0 line, its static start includes the current's drag, and its legacy BA is zero (the working curve's BA_s|BA_d carries the rope's damping). Composite and finite-EI Syrope lines stay refused. A taut 88.5 m polyester line in water whose fairlead sways 2 m matches MoorDyn-C v2.7.2's fairlead tension within 10.6 N over a 44.8 kN range (1.03 MN mean; 0.5 N at t = 0); without drag and added mass the range grows 4.8 % (syrope_hydro, with a cross current, VIV and waves). Signed-off-by: Jae Hoon Seo * fix(outputs): key the CurvX/CurvY cache on the torsion state too At a bending-pinned End A restrained in torsion, a host rotation turns the committed torsion end frames and torque without moving q, v, a, the time or the load epoch, and the reference normal stays fixed (no parent end connection). The section-curvature cache then served the components of the frames before the rotation. The key now holds the torsion end frames, Theta, Phi and the torque. section_curvature turns the host 30 degrees about the End A tangent of such a line and requires the next evaluation to equal a fresh one. Signed-off-by: Jae Hoon Seo --------- Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 21 ++ CMakeLists.txt | 14 ++ VALIDATION.md | 2 +- doc/capabilities.rst | 5 +- doc/modeling.rst | 2 +- doc/openfast.rst | 14 +- doc/outputs.rst | 10 + doc/theory.rst | 39 ++- doc/troubleshooting.rst | 8 +- python/cabledyn/deck_file.py | 21 +- python/tests/test_deck_file.py | 32 +++ src/CableDyn_DeckDriver.f90 | 304 ++++++++++++----------- src/CableDyn_HermiteCable.f90 | 9 +- src/CableDyn_HermiteCableDynamic.f90 | 182 +++++++++++++- src/CableDyn_OpenFAST_Aggregate.f90 | 8 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 113 +++++++++ src/openfast/CableDyn_OF.f90 | 81 ++++++- tests/test_deck_driver.f90 | 17 +- tests/test_openfast_aggregate.f90 | 105 ++++++++ tests/test_section_curvature.f90 | 344 +++++++++++++++++++++++++++ tests/test_syrope_hydro.py | 161 +++++++++++++ 21 files changed, 1311 insertions(+), 181 deletions(-) create mode 100644 tests/test_section_curvature.f90 create mode 100644 tests/test_syrope_hydro.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 8711f8d5..0404db5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,14 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- 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 + (the torsion normal, or the static start's upper normal), turn with a clamped hang-off, are + carried along the line by parallel transport and turn with the twist of a line restrained in + torsion; `CurvX^2 + CurvY^2 = Curv^2`. On a line twisted 90 degrees the carried axes reach + End B within 3e-6 rad of its pretwisted normal. `EI = 0` lines and finite-EI lines with two + moving ends refuse the channels. - Cross-flow vortex-induced vibration of `EI = 0` lines in the standalone driver: MoorDyn v2's LINE TYPES columns `Cl` or `Cl dF cF` switch on the synchronisation model of Thorsen et al., with the same phase start and running-RMS window (`VIVrmsWindow`, default 500 steps of @@ -72,6 +80,19 @@ All notable changes to CableDyn are recorded in this file. The format follows 0.1 s drops from 18,000 components to 1,800. On the 300 s lazy-wave case both records then run in 72 s, and every output channel's standard deviation moves by at most 0.002 %. A record with no component at or below the cut-off is refused by name. +- Coupled OpenFAST runs start from the equilibrium in SeaState's steady current (`CurrMod 1`), + as standalone decks start in their `current` option, instead of from the still-water shape. + The current is evaluated at SeaState's vertical grid levels for the static solves only; the + dynamics take the SeaState field alone. On the IEA-15 MW mixed example in a 0.5 m/s cross + current, the lazy-wave cable starts 29 m across at its deepest monitored node and moves less + than 0.6 m over the first 30 s, where the still-water start has reached a third of that offset. + `CurrMod 2` and InflowWind currents keep the still-water start, with a note. +- Syrope polyester lines take the seabed, Morison drag and added mass, deck current and waves, + a coupled host's fluid field, a `bathymetryFile` and VIV, as every `EI = 0` line does and as + MoorDyn's do; before, they ran without hydrodynamics and refused current, waves, host fluid + and bathymetry. The static initial condition includes the current's drag. A taut polyester + line whose fairlead sways 2 m in water matches MoorDyn-C's fairlead tension within 11 N on a + 45 kN range (1.03 MN mean); without drag and added mass the range is 5 % larger. - Under a bend stiffener, `BendMomN` (and the `BendMoment` columns of the static profile, range graphs and element file) report the cable's own moment, the line type's EI times the curvature; lines without stiffeners are unchanged. diff --git a/CMakeLists.txt b/CMakeLists.txt index 0409e213..7f9167d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1661,6 +1661,15 @@ if(Python3_Interpreter_FOUND) PROCESSORS 4 TIMEOUT ${_viv_lockin_timeout} ENVIRONMENT "${_cabledyn_python_test_environment}") + # Syrope polyester with hydrodynamics against MoorDyn-C (a fairlead swaying in water) + add_test(NAME syrope_hydro + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_syrope_hydro.py + --exe $ + --output ${CMAKE_BINARY_DIR}/syrope_hydro) + set_tests_properties(syrope_hydro PROPERTIES + LABELS "python;integration;dynamic;validation" + TIMEOUT ${_viv_lockin_timeout} + ENVIRONMENT "${_cabledyn_python_test_environment}") # MoorDyn-C's VIV test case: the catenary riser of Thorsen et al. in a uniform current add_test(NAME viv_riser COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_viv_riser.py @@ -2062,6 +2071,11 @@ target_link_libraries(test_torsion_deck PRIVATE cabledyn_core) add_test(NAME torsion_deck COMMAND test_torsion_deck) set_tests_properties(torsion_deck PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_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) +set_tests_properties(section_curvature PROPERTIES LABELS "fortran;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}) diff --git a/VALIDATION.md b/VALIDATION.md index 8414bb19..af80d954 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -793,7 +793,7 @@ stop with a named error. | Coupled pinned rods (`Pinned`, `CoupledPinned`/`VesselPinned`) | Pass verified | `openfast_pinned_rod` on the aggregate: a dry rod (10 m, 500 kg) released at 30° swings with the elliptic-integral compound-pendulum period to 1.6e-4 at `dt = T/100`, End A on the pin to 0 m; a held `CoupledPinned` node reproduces the `Pinned` rod to round-off (1e-12), returns zero moment, and its force equals the analytic pin reaction to 2.0e-13 of `mg`; a pin accelerating at 2 m/s² gives the mean angle `atan(a/g)` to 1e-6 rad and the period of `sqrt(g² + a²)` to 1.6e-4; a harmonic pin motion follows the linear base-excitation solution to 1.5e-3 / 3.7e-4 of the amplitude at `T0/100` / `T0/200` (ratio 4.03); a 0.1 s step sub-cycled 7 times reproduces a run at the sub-step size to 1e-14 rad and 4e-10 N for a drifting pin; a 1 m `Pinned` rod that carries no line (dry and hanging, or buoyant and upright under water) at a 0.6 s step (`omega0 dt` 2.29 / 3.42, beyond the explicit limit 2) sub-cycles it 6 / 9 times from its own swing stiffness `|W d_g - B d_b|`, equals the run at the sub-step size bit for bit, stays within its release angle and keeps the elliptic-integral period to 6.0e-3 / 5.9e-3 (taken whole, the step turns the rod over); a `CoupledPinned` pin crossing the free surface within one step at constant velocity (a 1 kg/m rod lifted from submerged to dry in 0.1 s, `omega dt` 2.13 wet; a 33 kg/m rod lowered from dry to submerged in 0.6 s, 2.29 dry) takes at least 6 sub-steps from its step-start wetting (more from the waterplane near the surface) and ends within 5e-5 / 3e-4 rad of a run at a sixtieth of the step, where the end-of-step wetting alone gives one sub-step and an angle error of 0.20 / 0.69 rad; on a stiff seabed (`kBot` 1e7 N/m³) a `Pinned` rod whose far end rests on the bed (0.1 s step) and a `Free` rod lying on it (0.05 s step) sub-cycle their contact mode (34–36 and 26 sub-steps), stay at rest on the bed over 5 s (angle change 3.8e-3 / 4e-15 rad, the undamped static settlement) and end within 1.9e-6 / 8e-8 of a run at a tenth of the step, where the sub-steps of the lines and swing alone (1 and 4) throw them off the bed (4.2 rad, 0.8 m); an output probe returns `-m (I_c/I_p) a_p` within 1e-10 of `mg` (not `-m a_p`), and its pin force moves by 2e-11 N when the held end acceleration of the attached tethers changes their end load by 8 N; snapshot/restore, probe restore and restart overlay are bit-identical, the restored state's loads before the next step included; a step without the staged rods (the step-start pin carried by the rod) is bit-identical to the staged one; a `Free` or `Coupled` rod with an end without a line is refused by name; with `PtfmInit` the static start leaves 1.4e-8 N·m about the pin. OpenFAST (IEA-15 UMaine, JONSWAP Hs 6 m, 60 s, `dtM = DT = 0.025 s`) with line 1 hung from a 4 m `CoupledPinned` rod at its fairlead: `openfast -restart` at 30 s reproduces every later OpenFAST output row bit for bit (`NumCrctn` 0 and 1), `NumCrctn = 1` equals `NumCrctn = 0` bit for bit, and surge/heave/pitch statistics stay within 0.2 % / 0.4 % / 1.7 % (mean) of the deck with line 1 on a `Coupled` point | | Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | -| Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. Composite, hydrodynamic, finite-EI, current, and wave combinations stop with a named error | +| Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. The line takes the seabed, Morison loads, current, waves, host fluid and VIV of any `EI = 0` line: a taut 88.5 m polyester line in water whose fairlead sways 2 m matches MoorDyn-C v2.7.2 within 10.6 N over a 44.8 kN tension range (1.03 MN mean; t = 0 within 0.5 N), and its range grows 4.8 % without drag and added mass (`syrope_hydro`). Composite and finite-EI combinations stop with a named error | | Cross-flow VIV (LINE TYPES `Cl`) | Pass verified | `EI = 0` lines and finite-EI cables on the aggregate with the host's fluid field: an `EI = 0` riser and a cable (EI 1 N m²) in a 0.15 m/s host current lock in at A/D 0.6645 / 0.6646 and 0.292 Hz (MoorDyn-F 0.662 at 0.293 Hz; standalone 0.665); the phases, running mean squares and averaging time ride in the checkpoint state and the correction rewind: a rebuild from the checkpoint continues bit for bit, one without the VIV reload does not (`viv_coupled`). OpenFAST (IEA-15 UMaine mixed deck, `Cl` 0.8 on the lazy-wave cable, SeaState 0.5 m/s current, 60 s): `openfast -restart` at 30 s reproduces every later CableDyn and OpenFAST output row bit for bit | **Standalone mixed aggregate.** `CableDyn_driver.exe` partitions and steps the diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 666b9511..902b8201 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -77,8 +77,9 @@ Line and constitutive capability including load-dependent dynamic stiffness; ``EI = 0`` lines * - Syrope polyester - Supported with limits - - single-section taut dynamic line with OWC and two history states; composite, hydro, - finite-EI, current, and wave combinations fail closed by name + - single-section taut dynamic line with OWC and two history states, with the seabed, + Morison loads, current, waves, host fluid fields and VIV of any ``EI = 0`` line; + composite and finite-EI combinations fail closed by name * - Torsion of finite-EI lines - Supported with limits - condensed isotropic torsion (uniform torque, quasi-static: no torsional inertia) of a diff --git a/doc/modeling.rst b/doc/modeling.rst index a7c00699..b13561a9 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -71,7 +71,7 @@ models: - MoorDyn ``ElasticMod = 3`` behaviour * - Syrope - ``SYROPE:settings|alpha|beta`` and ``BA_s|BA_d`` - - supported single-section taut dynamic polyester use case + - single-section taut dynamic polyester line, with the hydrodynamics of any ``EI = 0`` line Use :doc:`examples` for runnable instances and :doc:`theory` for the state equations (the viscoelastic model is a four-parameter series-Kelvin solid that reduces to a standard linear diff --git a/doc/openfast.rst b/doc/openfast.rst index e21b582e..6ddf88dd 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -129,6 +129,16 @@ WaterKin file can select file waves, a file depth-dependent current, host waves, current independently where the field is separable. Unsupported or double-counted combinations fail during initialisation. The selector matrix is in :doc:`options` and :doc:`driver_format`. +The static start includes the steady SeaState current. With ``CurrMod = 1`` and the host +current in use, CableDyn evaluates that current at the levels of SeaState's vertical wave grid +and solves the equilibrium of every line, cable, point and body in it. A run therefore starts +where a standalone deck with the same ``current`` starts, not from the still-water shape. The +profile is linear in depth between the grid levels, so the start agrees with the first step's +current at the levels and very nearly between them. The dynamics then take the SeaState field +alone, and the current is not counted twice. Waves act from t = 0. A ``CurrMod = 2`` current or +an InflowWind current field is known only through the run's samples: the start is then the +still-water equilibrium, and the console says so. + SeaState grid ~~~~~~~~~~~~~ @@ -213,8 +223,8 @@ Before trusting a run, confirm in the console: (``Note: line ...``, for example a folded ``EI = 0`` layout; see :doc:`troubleshooting`); #. ``Requested CableDyn OUTPUTS at t = 0 s``, the deck's channels in the first output row. With SeaState waves or current the header adds ``SeaState kinematics at t = 0``: the equilibrium is - solved before the kinematics act, so a line-end tension at t = 0 can differ slightly from the - equilibrium value above by the kinematic load on the end node. ``.CD.static.out`` holds + solved in the steady current before the waves act, so a line-end tension at t = 0 can differ + slightly from the equilibrium value above by the kinematic load on the end node. ``.CD.static.out`` holds the equilibrium; and #. ``OpenFAST terminated normally.`` diff --git a/doc/outputs.rst b/doc/outputs.rst index 7da7d638..03e4af94 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -690,6 +690,16 @@ Line-node channels same value; ``CD_HermiteCable_Dyn_Curvature_Exact`` and ``CD_HFMF_Curvature_Exact`` the exact geometric traces - 1/m + * - ``CurvXN``, ``CurvYN`` + - the curvature vector at node ``J`` on the cross-section axes x and y of a finite-EI line + (:ref:`theory-section-curvature`): the vector points to the centre of curvature, its + 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`` + returns them for every node + - 1/m * - ``BendMomN`` - bend moment ``EI × κ`` measured relative to the stress-free reference shape (the cubic-Hermite reference is straight). Finite-EI lines: the component normal to the tangent diff --git a/doc/theory.rst b/doc/theory.rst index 98295023..93b844e5 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -328,6 +328,38 @@ node, the larger one-sided exact curvature, and the midpoint axial resultant as tension. The material-strain checks (``tensile_safety``, the static compression notes) judge :math:`EA\varepsilon` under either setting. +.. _theory-section-curvature: + +Curvature on the section axes +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +``CurvXN`` and ``CurvYN`` resolve the nodal curvature vector +:math:`\kappa\mathbf{n}`, which points to the centre of curvature, on two axes of the cable's +cross section. The vector is the one whose length is ``CurvN``: the normal part of the +recovered section moment over :math:`EI` on the side that gives the curvature, or the exact +trace :math:`(\mathbf{r}' \times \mathbf{r}'') \times \mathbf{r}'/|\mathbf{r}'|^4` where +the recovery falls back to it (:ref:`theory-output-recovery`). + +The section axis :math:`\mathbf{d}_1` (x) starts at End A normal to the End A → End B tangent +:math:`\mathbf{t}`: + +- on a line restrained in torsion, along End A's torsion normal ``Nx``, which turns with the + hang-off; +- otherwise along the static start's upper normal, the projection of global +z normal to the + End A tangent (global +x where the tangent is vertical). It is fixed in the hang-off's axes + when End A is clamped or held by a finite rotational stiffness, so it turns with the vessel, + and fixed in global axes at a pinned End A, where the roll of the section is undefined. + +It is carried to every node by parallel transport along the centreline, eight smallest +rotations between the Hermite tangents per element, which does not twist it about the tangent. +On a line in torsion it is then turned about :math:`\mathbf{t}` by the twist from End A, the +torque times the End A compliance plus :math:`\sum l_0/GJ` from End A, right-handed about +:math:`\mathbf{t}`. With :math:`\mathbf{d}_2 = \mathbf{t} \times \mathbf{d}_1` (y), +``CurvX`` :math:`= \kappa\mathbf{n} \cdot \mathbf{d}_1` and ``CurvY`` +:math:`= \kappa\mathbf{n} \cdot \mathbf{d}_2`. A fibre at :math:`(x, y)` in the section is +strained in bending by :math:`-(\kappa_x x + \kappa_y y)`. On a line twisted 90 degrees from +End A to End B the carried axes reach End B within 3e-6 rad of its own pretwisted normal. + .. _theory-torsion: Condensed torsion @@ -650,7 +682,8 @@ ratchets and regenerates the working curve when the mean tension exceeds it. OWC for a virgin rope, or, with ``SYROPE IC``, the working curve regenerated at :math:`T_\text{max,0}` (zero tension below its zero-tension strain, the OWC above its top strain :math:`\varepsilon_\text{OWC}(T_\text{max,0})`). A single secant axial stiffness of that -curve is iterated to the solved mean strain. Each element then starts with the running maximum +curve is iterated to the solved mean strain, the line otherwise built as any ``EI = 0`` line +(its drag in a deck current included). Each element then starts with the running maximum :math:`\max(T_\text{max,0}, T_e)` (:math:`T_e` for a virgin rope), where :math:`T_e` is its static tension, and with the slow strain whose kernel tension at the static strain and zero strain rate equals :math:`T_e`. The dynamic state therefore starts in the static equilibrium, @@ -675,7 +708,9 @@ the next admissible :math:`T_\text{max}`. An optional ``SYROPE IC`` row supplies the prior history :math:`(T_\text{max,0}, T_\text{mean,0})`; see the initial condition above. The model applies -to single-section ``EI = 0`` taut lines; see :doc:`capabilities` for the supported combinations. +to single-section ``EI = 0`` taut lines, which take the seabed, the Morison loads below, current, +waves, a host's fluid field and VIV as any ``EI = 0`` line does (MoorDyn's line hydrodynamics); see +:doc:`capabilities` for the supported combinations. Hydrodynamic loads ------------------ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 5ebb7d05..14cfbfc4 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -327,11 +327,11 @@ Model data ``EI = 0``. * - ``a LINE TYPES BA entry cannot have more bar-separated values than its EA entry`` - write ``BA`` as one value for a plain EA and at most ``Bs|Bd`` for a viscoelastic EA. - * - ``a Syrope line does not support ...`` / ``a Syrope line must be a single section`` / - ``must be taut at init`` / ``has no static output`` + * - ``a Syrope line does not support finite-EI bending`` / ``a Syrope line must be a single + section`` / ``must be taut at init`` / ``has no static output`` - a Syrope line is one ``EI = 0`` section, taut at initialisation, marched with - ``dtM``/``TMax``, without ``bathymetryFile``, deck current/waves, or host fluid loads (a - flat ``WtrDpth`` is accepted). Adjust the model accordingly. + ``dtM``/``TMax``; it takes the seabed, Morison loads, current, waves and host fluid of any + ``EI = 0`` line. Adjust the model accordingly. * - ``Syrope alpha and beta ... must be positive`` / ``the Syrope BA column needs two parts`` / ``the Syrope settings file needs OWC, WCType, k1, and k2 rows`` - see the Syrope column rules in :doc:`driver_format`: ``EA = SYROPE:|alpha|beta`` diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 5eadc030..ef9bbb5f 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -708,6 +708,8 @@ def _parse_line_node_channel(lowered: str) -> tuple[int, int, int, int]: ("torq", 9), ("twist", 10), ("ten", 3), + ("curvx", 13), + ("curvy", 14), ("curv", 5), ("bendmom", 6), ("stfmom", 12), @@ -2732,11 +2734,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: LINE TYPES VIV synchronisation band needs cF > 0 " "and 0 <= dF < cF" ) - if cl > 0.0 and is_syrope: - raise DeckFormatError( - f"{self._at(row)}: VIV (Cl > 0) does not combine with the Syrope " - "working-curve model" - ) has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) if cl > 0.0: viv_type_names.add(row.tokens[0].lower()) @@ -3649,6 +3646,14 @@ def is_body_kind(kind: str, pinned: bool) -> bool: 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: @@ -4120,6 +4125,12 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._label}: OUTPUT {channel!r}: line {line_id} has no STIFFENERS, " "so no stiffener moment" ) + if kind in (13, 14) and line_id not in finite_line_ids: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: the section curvature components " + f"need a finite-EI line (a section frame); line {line_id} has EI = 0 " + "(CurvN gives its curvature)" + ) continue raise DeckFormatError(f"{self._label}: unsupported OUTPUT channel {channel!r}") diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 1da6a512..0e93c791 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4022,6 +4022,16 @@ def test_syrope_line_needs_the_dynamic_clock(): DeckFile.from_text(static, caller_driven=True) +def test_syrope_line_takes_viv_and_a_current(): + # a Syrope line takes the hydrodynamics of any EI = 0 line, VIV included (MoorDyn's) + source = (ROOT / "examples/syrope_polyester_mooring.dat").read_text(encoding="utf-8") + row = '"SYROPE:data/syrope/syrope_settings.dat|1.53e8|23.12" 5.0e10|1.0e5' + row += " 0.0 1.0 0.0 1.0 0.0" + assert source.count(row) == 1 + text = source.replace(row, row + " 0.8") + DeckFile.from_text(re.sub(r"none(\s+)current", r"uniform 0 0.5 0\1current", text)) + + @pytest.mark.parametrize("column", [6, 7, 8, 9]) def test_negative_drag_or_added_mass_coefficient_is_rejected(column): row = "chainR3 0.2466 373.5 1.607e9 -1.0 0.0 1.37 0.64 1.0 0.0" @@ -4098,6 +4108,28 @@ def test_reserved_windows_device_names_are_refused(monkeypatch, tmp_path): ) +def test_section_curvature_channels_need_a_finite_ei_line(): + # CurvX/CurvYN: the curvature on the section axes of a finite-EI line; distinct from + # CurvN and from each other + with_channels = _edit(_DYNAMIC, ("\nFairTen1\n", "\nFairTen1\nCurvX1N2\nCurvY1N2\nCurv1N2\n")) + deck = DeckFile.from_text(with_channels) + assert {"CurvX1N2", "CurvY1N2", "Curv1N2"} <= set(deck.outputs) + 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 + 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"), + ("1 1 3 -\n2 2 3 -\n", "1 1 2 -\n"), + ("1 chain 380 20\n2 chain 380 20\n", "1 chain 620 30\n"), + ("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) + + def test_viv_and_lift_flag_refused_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 diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index d6d19fe5..56d9903a 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -116,6 +116,7 @@ MODULE CableDyn_DeckDriver CD_Vessel_Point_Kinematics, CD_Vessel_RAO_Set, CD_Vessel_RAO_Eval, & CD_Vessel_RAO_Motion, CD_Vessel_Ramp, CD_VESSEL_OK USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_Init, CD_HFMF_Set_Drag, & + CD_HFMF_Set_Section_Reference, CD_HFMF_Section_Curvature, & CD_HFMF_Set_Axial_Damping, & CD_HFMF_Set_AddedMass, CD_HFMF_Set_ModifiedNewton, & CD_HFMF_Set_Tensile_Monitor, CD_HFMF_Get_Tensile_Diagnostics, & @@ -3268,6 +3269,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF ! OPTIONS OutputRecovery selects the definition of the node tension, curvature and bend moment. CALL CD_HermiteCable_Dyn_Set_Output_Recovery(cable%line, opts%output_element_recovery) + ! the cross-section reference of the CurvX/CurvY channels, at the static start + CALL CD_HFMF_Set_Section_Reference(cable, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable section reference failed: '//TRIM(em)); RETURN + END IF CONTAINS SUBROUTINE torsion_stage(est, emt) @@ -6808,7 +6814,7 @@ END SUBROUTINE CD_Init_Deck_HermiteCable SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation) + range_files, host_orientation, static_current) !! Parse a MIXED deck ONCE and partition its lines into {EI=0 mooring} and !! {finite-EI cable}, returning the raw parts the OpenFAST aggregate facade wraps: !! the EI=0 mooring SYSTEM built from the mooring subset (over ALL deck points, the @@ -6880,6 +6886,14 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! restrained in torsion. Without it (the C API, the standalone mixed route) a deck with ! torsion columns fails closed rather than holding that frame fixed. LOGICAL, INTENT(IN), OPTIONAL :: host_orientation + ! static_current (4, n): the host's steady current as a depth profile, rows z (ascending), + ! ux, uy, uz -- the OpenFAST shell's SeaState CurrMod 1 current at SeaState's grid levels. + ! With external_fluid and the host current on, the static solves (bodies and rods, points, + ! EI = 0 lines, finite-EI cables) take it as a deck current profile, so the coupled start + ! is the equilibrium in that current, as a standalone deck's is in its current OPTION. The + ! dynamics take the host field alone: the profile goes into a copy of the options that + ! only the static builders see. + REAL(wp), INTENT(IN), OPTIONAL :: static_current(:, :) INTEGER :: nturb LOGICAL :: host_turns @@ -6891,6 +6905,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi TYPE(DeckLine), ALLOCATABLE :: lines(:), ei0_lines(:) TYPE(DeckSection), ALLOCATABLE :: sections(:) TYPE(DeckOptions) :: opts + ! opts plus the host's steady current (static_current): the options of the static builders + TYPE(DeckOptions) :: opts_static CHARACTER(NAMELEN), ALLOCATABLE :: channels(:) TYPE(CD_BathymetryType) :: bathymetry TYPE(DeckFailure), ALLOCATABLE :: fails(:) @@ -7355,6 +7371,32 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (ErrStat /= CD_DECKDRV_OK) RETURN END IF + ! The static builders' options: the deck's, plus the host's steady current when the host + ! current drives this deck (a WaterKin CurrentMod 1 file keeps its own profile instead). + opts_static = opts + IF (PRESENT(static_current)) THEN + IF (.NOT. opts%external_fluid) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: static_current needs the host fluid field '// & + '(external_fluid)'); RETURN + END IF + IF (SIZE(static_current, 1) /= 4 .OR. SIZE(static_current, 2) < 2) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: static_current must be shaped (4, n >= 2): '// & + 'z, ux, uy, uz'); RETURN + END IF + IF (.NOT. ALL(IEEE_IS_FINITE(static_current))) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: static_current must be finite'); RETURN + END IF + IF (ANY(static_current(1, 2:) <= static_current(1, :SIZE(static_current, 2) - 1))) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: static_current levels must ascend in z'); RETURN + END IF + IF (agg%host_current_enabled .AND. .NOT. (opts%has_current .OR. opts%has_current_profile)) THEN + opts_static%has_current = .TRUE. + opts_static%has_current_profile = .TRUE. + opts_static%current_profile_z = static_current(1, :) + opts_static%current_profile_velocity = static_current(2:4, :) + END IF + END IF + ! Free Rigid6 bodies and free rods start at their static equilibrium with the host's coupled ! points held at their initial (PtfmInit) pose, as on the standalone route (bodyIC static; ! bodyIC deck keeps the deck pose). The solve moves the bodies' start pose and the rod and @@ -7364,11 +7406,12 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & points=points) IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, ErrMsg, & - bathymetry=bathymetry) + CALL solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, sections, opts_static, ErrStat, & + ErrMsg, bathymetry=bathymetry) CALL CD_End_Bathymetry(bathymetry) ELSE - CALL solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, ErrMsg) + CALL solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, sections, opts_static, ErrStat, & + ErrMsg) END IF IF (ErrStat /= CD_DECKDRV_OK) THEN ErrMsg = 'CD_Init_Deck_Aggregate: '//TRIM(ErrMsg) @@ -7395,12 +7438,12 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL load_bathymetry_file(path_join(deck_dir(deck_path), opts%bathymetry_file), bathymetry, ErrStat, ErrMsg, & points=points) IF (ErrStat /= CD_DECKDRV_OK) RETURN - CALL init_deck_system_from_parsed(types, points, ei0_lines, sections, opts, agg%sys, ErrStat, ErrMsg, & - bathymetry=bathymetry, failures=fails) + CALL init_deck_system_from_parsed(types, points, ei0_lines, sections, opts_static, agg%sys, ErrStat, & + ErrMsg, bathymetry=bathymetry, failures=fails) CALL CD_End_Bathymetry(bathymetry) ELSE - CALL init_deck_system_from_parsed(types, points, ei0_lines, sections, opts, agg%sys, ErrStat, ErrMsg, & - failures=fails) + CALL init_deck_system_from_parsed(types, points, ei0_lines, sections, opts_static, agg%sys, ErrStat, & + ErrMsg, failures=fails) END IF IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_Deck_Aggregate(agg); RETURN @@ -7469,14 +7512,14 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi fairlead_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, dt, agg%cables(c), cn, es, em, & - bathymetry=bathymetry, fairlead_orientation=fairlead_dcm, & + 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))) ELSE - CALL build_one_hermite_cable(lines(i), sections, types, points, opts, dt, agg%cables(c), cn, es, em, & - fairlead_orientation=fairlead_dcm, init_note=agg%cable_note(c), & + 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))) @@ -8187,7 +8230,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) TYPE(CD_BathymetryType) :: bathymetry TYPE(DeckFailure), ALLOCATABLE :: fails(:) TYPE(CD_LineInitSummary), ALLOCATABLE :: init_summaries(:) - INTEGER :: nl, li, es, j, n_finite + INTEGER :: nl, li, es, j, n_finite, node_sc, kind_sc, comp_sc LOGICAL :: line_conv, has_line_outputs, has_finite, has_dyn_points, has_rigid6, hermite_standalone_eligible CHARACTER(1024) :: em @@ -8366,6 +8409,16 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) '(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 (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') + RETURN + END DO END IF IF (hermite_standalone_eligible) THEN ALLOCATE (hermite_models(SIZE(lines))) @@ -8701,8 +8754,12 @@ SUBROUTINE line_static_friction(opts, line_id, lay_az, laid_t) END IF END SUBROUTINE line_static_friction - SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry) - !! Initialize one persistent model from a validated deck LINE. + RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry, & + syrope_secant, syrope_is, syrope_type, syrope_slow0, syrope_tmax0) + !! Initialize one persistent model from a validated deck LINE. A Syrope line is built by + !! init_one_syrope_model, which calls back here with syrope_secant (the secant EA of its + !! static solve) and, for the final build, the per-element Syrope states: the line then + !! takes the same seabed, hydrodynamics and fluid fields as any EI = 0 line. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckLineType), INTENT(IN) :: types(:) @@ -8712,6 +8769,10 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), INTENT(IN), OPTIONAL :: syrope_secant + LOGICAL, INTENT(IN), OPTIONAL :: syrope_is(:) + TYPE(CD_SyropeType), INTENT(IN), OPTIONAL :: syrope_type(:) + REAL(wp), INTENT(IN), OPTIONAL :: syrope_slow0(:), syrope_tmax0(:) TYPE(CD_LineType), ALLOCATABLE :: lts(:) TYPE(CD_LineSection), ALLOCATABLE :: secs(:) @@ -8819,9 +8880,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err hydro_cdt = hydro_cdt(SIZE(hydro_cdt):1:-1) hydro_can = hydro_can(SIZE(hydro_can):1:-1) hydro_cat = hydro_cat(SIZE(hydro_cat):1:-1) - ! Syrope line: a dedicated basic build path (single section, taut, no seabed - ! or hydro). Detected here and handled separately from the hydro variants - ! below, which do not carry the working-curve state. + ! Syrope line: init_one_syrope_model solves its working-curve initial state and builds it + ! back through this routine (syrope_secant present), with the hydro variants below BLOCK INTEGER :: syt, i2 syt = 0 @@ -8829,14 +8889,17 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err IF (types(line_section_type(sections, ln%id, i2))%is_syrope) & syt = line_section_type(sections, ln%id, i2) END DO - IF (syt > 0) THEN - IF (ANY(viv_cl > CD_ZERO)) THEN - CALL fail(ErrStat, ErrMsg, 'VIV (LINE TYPES Cl > 0) does not combine with a Syrope line'); RETURN - END IF - CALL init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0, opts, & - static_cfg, dynamic_cfg, factors, bathymetry, model, ErrStat, ErrMsg) + IF (syt > 0 .AND. .NOT. PRESENT(syrope_secant)) THEN + CALL init_one_syrope_model(types, syt, ln, sections, points, l0, opts, model, ErrStat, ErrMsg, & + bathymetry=bathymetry) RETURN END IF + IF (PRESENT(syrope_secant)) THEN + ! the static solve's single secant EA; the working curve carries the rope's damping + ! (BA_s|BA_d), so the line takes no legacy BA on top of it + lts(secs(1)%line_type)%ea = syrope_secant + ba = CD_ZERO + END IF END BLOCK ! external_fluid: the host prescribes per-node fluid kinematics each step, so the ! model must be built with the full wave-capable hydro configuration (drag + FK + @@ -8883,7 +8946,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err ! MoorDyn's, whose deck dialect this parser reads. CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., & anchor_is_end_b=.TRUE., seabed_kn=kn, bathymetry=bathymetry, seabed_cn=cn, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & @@ -8912,7 +8976,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err cn = kn*(opts%cbot/opts%kbot) CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., & anchor_is_end_b=.TRUE., seabed_kn=kn, bathymetry=bathymetry, seabed_cn=cn, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & @@ -8939,7 +9004,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err cn = kn*(opts%cbot/opts%kbot) CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., & anchor_is_end_b=.TRUE., seabed_kn=kn, bathymetry=bathymetry, seabed_cn=cn, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & @@ -8966,7 +9032,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err cn = kn*(opts%cbot/opts%kbot) CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., & anchor_is_end_b=.TRUE., & seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & @@ -8996,7 +9063,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err cn = kn*(opts%cbot/opts%kbot) CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., & anchor_is_end_b=.TRUE., & seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & @@ -9024,7 +9092,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err cn = kn*(opts%cbot/opts%kbot) CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., & anchor_is_end_b=.TRUE., & seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & @@ -9044,7 +9113,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err ELSE IF (opts%has_current) THEN CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, & @@ -9053,7 +9123,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err ELSE CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & + syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & + syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet) END IF IF (ErrStat /= CD_MODEL_OK) THEN @@ -9095,13 +9166,14 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err END IF END SUBROUTINE init_one_model - SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0, opts, & - static_cfg, dynamic_cfg, factors, bathymetry, model, ErrStat, ErrMsg) - !! Build one Syrope line model. The supported scope is a single-section taut line with - !! no hydro. Builds the working-curve constitutive from the parse-resolved OWC data and - !! solves the static equilibrium on the rest curve of the initial load history (the OWC - !! for a virgin rope; with SYROPE IC, the Tmax0 working curve below its top strain and - !! the OWC above): the secant EA of that curve at the solved mean strain. Each element + RECURSIVE SUBROUTINE init_one_syrope_model(types, syt, ln, sections, points, l0, opts, model, ErrStat, ErrMsg, & + bathymetry) + !! Build one Syrope line model: a single-section line, taut at init, with the seabed, + !! hydrodynamics and fluid fields of any EI = 0 line (init_one_model builds it). Builds the + !! working-curve constitutive from the parse-resolved OWC data and solves the static + !! equilibrium on the rest curve of the initial load history (the OWC for a virgin rope; + !! with SYROPE IC, the Tmax0 working curve below its top strain and the OWC above): the + !! secant EA of that curve at the solved mean strain, current drag included. Each element !! then gets the running maximum of that history and the slow strain whose t = 0 kernel !! force equals its static tension, so the dynamic state starts in the static !! equilibrium. Tmean0 is not a state input (the fixed-end geometry and Tmax0 set the @@ -9109,55 +9181,37 @@ SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0 TYPE(DeckLineType), INTENT(IN) :: types(:) INTEGER, INTENT(IN) :: syt TYPE(DeckLine), INTENT(IN) :: ln - TYPE(CD_LineType), INTENT(INOUT) :: lts(:) - TYPE(CD_LineSection), INTENT(IN) :: secs(:) - REAL(wp), INTENT(IN) :: anchor(3), fairlead(3), l0(:), factors(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckPoint), INTENT(IN) :: points(:) + REAL(wp), INTENT(IN) :: l0(:) TYPE(DeckOptions), INTENT(IN) :: opts - TYPE(CableSolverConfig), INTENT(IN) :: static_cfg - TYPE(GenAlphaConfig), INTENT(IN) :: dynamic_cfg - TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry TYPE(CD_ModelType), INTENT(INOUT) :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry TYPE(CD_SyropeType) :: td TYPE(CD_SyropeType), ALLOCATABLE :: stype(:) LOGICAL, ALLOCATABLE :: sis(:) - REAL(wp), ALLOCATABLE :: sslow(:), stmax(:), kn(:), diam(:), cn(:), t_static(:) - REAL(wp) :: eps0, t_ref, secant, total_l0, t_hist, eps_bar, t_mean_static - INTEGER :: ne, e, es, n_owc, iter + REAL(wp), ALLOCATABLE :: sslow(:), stmax(:), t_static(:) + REAL(wp) :: anchor(3), fairlead(3), eps0, t_ref, secant, total_l0, t_hist, eps_bar, t_mean_static + INTEGER :: ne, e, es, n_owc, iter, nsec CHARACTER(1024) :: em CHARACTER(24) :: s_eps, s_lo, s_hi - ! static seabed friction of this line: lay azimuth override [rad] and as-laid tension - REAL(wp), ALLOCATABLE :: lay_az_opt - REAL(wp) :: laid_t ErrStat = CD_DECKDRV_OK ErrMsg = '' - CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) - IF (SIZE(secs) /= 1) THEN + nsec = COUNT(sections%line_id == ln%id) + IF (nsec /= 1) THEN CALL fail(ErrStat, ErrMsg, 'a Syrope line must be a single section (composite Syrope lines are '// & 'not supported yet)'); RETURN END IF IF (types(syt)%ei > CD_ZERO) THEN CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support finite-EI bending'); RETURN END IF - ! A flat WtrDpth seabed floor IS supported (a taut Syrope mooring clears it, so the - ! penalty contact stays inactive and the OWC-secant taut IC below is unchanged). - ! Structured bathymetry and hydro loads (current/waves/host fluid) are not supported. - IF (PRESENT(bathymetry)) THEN - CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support a structured seabed (bathymetryFile); '// & - 'use WtrDpth'); RETURN - END IF - IF (opts%has_current) THEN - CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support current hydro loads'); RETURN - END IF - IF (opts%has_wave) THEN - CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support wave hydro loads'); RETURN - END IF - IF (opts%external_fluid) THEN - CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support host-driven hydro loads'); RETURN - END IF + ! internal order anchor (End B) -> fairlead (End A), as gather_line_inputs + anchor = points(find_point(points, ln%nodeB))%pos + fairlead = points(find_point(points, ln%nodeA))%pos ! the working-curve constitutive from the parse-resolved OWC data CALL CD_Syrope_Init(td, types(syt)%syrope_owc_strain, types(syt)%syrope_owc_tension, & types(syt)%syrope_wc_mod, types(syt)%syrope_p1, types(syt)%syrope_p2, & @@ -9211,30 +9265,14 @@ SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0 DO e = 1, ne stype(e) = td END DO - IF (opts%has_wtrdpth) THEN - ! flat seabed floor at -WtrDpth: build the nodal penalty stiffness (inactive for a - ! taut line clearing the floor) so a coupled Syrope mooring inits like the EI=0 path - ALLOCATE (diam(ne)) - diam = types(syt)%diam - CALL CD_Nodal_Seabed_Stiffness(opts%kbot, diam, l0, kn, es, em) - IF (es /= CD_LINE_OK) THEN - CALL release_syrope() - CALL fail(ErrStat, ErrMsg, 'Syrope seabed stiffness: '//TRIM(em)); RETURN - END IF - ! carry the SAME contact physics the EI=0 WtrDpth branch does: normal damping cn - ! from cBot and Coulomb friction from frictionMu, so a Syrope node that reaches the - ! floor behaves identically to a plain EI=0 line (not just the spring alone) - ALLOCATE (cn(SIZE(kn))) - cn = kn*(opts%cbot/opts%kbot) - END IF - ! Static solve with a single secant EA (the line-local type's EA: lts is rebuilt - ! line-local by gather_line_inputs; secs(1)%line_type indexes it, NOT the global syt). - ! The secant is iterated to the rest curve at the solved mean strain, so the static - ! line carries the curve tension on average (a chord-strain secant misses it by the sag). + ! Static solve with a single secant EA, the line otherwise built as any EI = 0 line (seabed, + ! drag in the deck current, buoyancy). The secant is iterated to the rest curve at the solved + ! mean strain, so the static line carries the curve tension on average (a chord-strain + ! secant misses it by the sag and the current's deflection). DO iter = 1, 6 - lts(secs(1)%line_type)%ea = secant - CALL build_model(.FALSE.) - IF (ErrStat /= CD_MODEL_OK) EXIT + CALL init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry=bathymetry, & + syrope_secant=secant) + IF (ErrStat /= CD_DECKDRV_OK) EXIT CALL CD_Get_Model_Tension(model, t_static, es, em) CALL CD_End_Model(model, ErrStat, ErrMsg) IF (es /= CD_MODEL_OK) THEN @@ -9277,15 +9315,16 @@ SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0 ln%syrope_tmean0, ' N is superseded (the line starts at the equilibrium)' END IF END IF - CALL build_model(.TRUE.) + CALL init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry=bathymetry, & + syrope_secant=secant, syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, & + syrope_tmax0=stmax) CALL release_syrope() - IF (ErrStat /= CD_MODEL_OK) THEN + IF (ErrStat /= CD_DECKDRV_OK) THEN ErrMsg = 'CableDyn_DeckDriver: Syrope model init failed: '//TRIM(ErrMsg) IF (ErrStat /= CD_DECKDRV_BADINPUT) ErrStat = CD_DECKDRV_SOLVEFAIL END IF CONTAINS - SUBROUTINE rest_tension(eps, tension, es_out, em_out) !! The static curve of the initial load history at strain eps: the OWC for a virgin !! rope (no SYROPE IC), the Tmax0 working curve / OWC (CD_Syrope_Static_Tension) with it. @@ -9302,44 +9341,6 @@ SUBROUTINE rest_tension(eps, tension, es_out, em_out) END IF END SUBROUTINE rest_tension - SUBROUTINE build_model(with_syrope) - !! The line build (static solve + model init) at the current secant EA; with_syrope - !! passes the per-element Syrope states, without it the build is the plain-EA probe - !! whose element tensions are the static solution. - LOGICAL, INTENT(IN) :: with_syrope - IF (opts%has_wtrdpth .AND. with_syrope) THEN - CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & - static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., & - seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & - seabed_cn_over_kn=opts%cbot/opts%kbot, seabed_mu=opts%friction_mu, & - seabed_mu_axial=opts%friction_mu_axial, & - static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & - as_laid_tension=laid_t, & - seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & - syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, syrope_tmax0=stmax) - ELSE IF (opts%has_wtrdpth) THEN - CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & - static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., & - seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, seabed_cn=cn, & - seabed_cn_over_kn=opts%cbot/opts%kbot, seabed_mu=opts%friction_mu, & - seabed_mu_axial=opts%friction_mu_axial, & - static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & - as_laid_tension=laid_t, & - seabed_kbot=opts%kbot, seabed_contact_diameter=diam) - ELSE IF (with_syrope) THEN - CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & - static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., & - syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, syrope_tmax0=stmax) - ELSE - CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & - static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE.) - END IF - END SUBROUTINE build_model - SUBROUTINE release_syrope() !! Free the constitutive copies (the model deep-copies what it keeps). INTEGER :: k @@ -13065,10 +13066,6 @@ SUBROUTINE check_viv_columns(t, ErrStat, ErrMsg) IF (.NOT. (t%viv_cf > CD_ZERO .AND. t%viv_df >= CD_ZERO .AND. t%viv_df < t%viv_cf)) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES VIV synchronisation band needs cF > 0 and 0 <= dF < cF'); RETURN END IF - IF (t%is_syrope) THEN - CALL fail(ErrStat, ErrMsg, 'LINE TYPES "'//TRIM(t%name)//'": VIV (Cl > 0) does not combine with the '// & - 'Syrope working-curve model'); RETURN - END IF END SUBROUTINE check_viv_columns SUBROUTINE parse_stiffness_columns(ea_str, ba_str, t, ErrStat, ErrMsg) @@ -16808,7 +16805,7 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio DO i = 1, SIZE(channels) at_line = 0 IF (i <= SIZE(channel_lines)) at_line = channel_lines(i) - CALL check_channel(channels(i), lines, points, sections, ErrStat, ErrMsg, bodies, rods, opts%zl_rod) + CALL check_channel(channels(i), lines, points, sections, ErrStat, ErrMsg, bodies, rods, opts%zl_rod, types) IF (ErrStat /= 0) RETURN END DO at_line = 0 @@ -32805,7 +32802,7 @@ INTEGER FUNCTION deck_to_internal_node(deck_node, nelem) RESULT(internal_node) internal_node = nelem + 2 - deck_node END FUNCTION deck_to_internal_node - SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, rods, zl_rod) + SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, rods, zl_rod, types) CHARACTER(*), INTENT(IN) :: ch TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckPoint), INTENT(IN) :: points(:) @@ -32816,6 +32813,8 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r TYPE(DeckRod), INTENT(IN), OPTIONAL :: rods(:) ! zero-length rods collapsed to connector points (collapse_zero_length_rods) INTEGER, INTENT(IN), OPTIONAL :: zl_rod(:) + ! the line types, for the channels of finite-EI lines only (CurvX, CurvY) + TYPE(DeckLineType), INTENT(IN), OPTIONAL :: types(:) CHARACTER(NAMELEN) :: lo INTEGER :: pidx, comp, kind, line_id, node, li, nelem LOGICAL :: is_body @@ -32916,12 +32915,20 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' has no '// & 'STIFFENERS, so no stiffener moment'); RETURN END IF + IF ((kind == 13 .OR. kind == 14) .AND. PRESENT(types)) THEN + IF (.NOT. line_is_finite_ei(lines(li), types, sections)) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": the section curvature components need a '// & + 'finite-EI line (a section frame); line '//TRIM(int_to_str(line_id))//' has EI = 0 '// & + '(CurvN gives its curvature)'); RETURN + END IF + END IF ELSE CALL fail(ErrStat, ErrMsg, 'OUTPUT channel "'//TRIM(ch)// & '" not supported (use FairTen, AnchTen, AnchFz, AnchFH, FairIncl, AnchIncl, '// & 'FairDecl, AnchDecl (FairAngle/AnchAngle aliases), FairDefl, AnchDefl, '// & 'Point

p{x,y,z} (alias Con

p{x,y,z}), Point

F{x,y,z,H}, '// & - 'TenN, CurvN, BendMomN, StfMomN, TorqN, TwistN, Twist, '// & + 'TenN, CurvN, CurvXN, CurvYN, BendMomN, StfMomN, '// & + 'TorqN, TwistN, Twist, '// & 'LNp{x,y,z}, LNv{x,y,z}, LNa{x,y,z}, LNDec, LNAzi, '// & 'TDP{s,x,y,z,Lay,Exc,Grd}, or the Body/Rod channels)'); RETURN END IF @@ -33165,6 +33172,8 @@ SUBROUTINE parse_line_node_channel(ch, line_id, node_id, kind, comp) !! Parse supported line-node output channels (kind codes shared with the writers): !! TenN -> kind=3, comp=0 nodal tension [N] !! CurvN -> kind=5, comp=0 curvature [1/m] + !! CurvXN -> kind=13, comp=0 curvature on section axis x [1/m] + !! CurvYN -> kind=14, comp=0 curvature on section axis y [1/m] !! BendMomN -> kind=6, comp=0 cable bend moment [N.m] !! StfMomN -> kind=12, comp=0 stiffener moment [N.m] !! LNp{x,y,z} -> kind=1, comp=1..3 position [m] @@ -33211,6 +33220,10 @@ SUBROUTINE parse_line_node_channel(ch, line_id, node_id, kind, comp) CALL parse_keyword_line_node(lo, 3, last, line_id, node_id) IF (line_id > 0 .AND. node_id > 0) kind = 3 RETURN + ELSE IF (starts_with(lo, 'curvx') .OR. starts_with(lo, 'curvy')) THEN + CALL parse_keyword_line_node(lo, 5, last, line_id, node_id) + IF (line_id > 0 .AND. node_id > 0) kind = MERGE(13, 14, lo(5:5) == 'x') + RETURN ELSE IF (starts_with(lo, 'curv')) THEN CALL parse_keyword_line_node(lo, 4, last, line_id, node_id) IF (line_id > 0 .AND. node_id > 0) kind = 5 @@ -35034,6 +35047,15 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) IF (es /= CD_HCABLE_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF + CASE (13, 14) ! the curvature vector on the section axes x, y (CD_HFMF_Section_Curvature) + BLOCK + REAL(wp) :: kxa(cable%line%nn), kya(cable%line%nn) + CALL CD_HFMF_Section_Curvature(cable, kxa, kya, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN + END IF + val = MERGE(kxa(inode), kya(inode), kind == 13) + END BLOCK CASE (9, 10, 11) ! condensed torsion: torque [N m], twist from End A to node J, total twist [deg] BLOCK REAL(wp) :: th, mt @@ -35408,7 +35430,7 @@ FUNCTION CD_Channel_Unit(ch) RESULT(unit) CALL parse_line_node_channel(ch, line_id, node, kind, comp) SELECT CASE (kind) CASE (3); unit = '(N)' - CASE (5); unit = '(1/m)' + CASE (5, 13, 14); unit = '(1/m)' CASE (6, 12); unit = '(N.m)' CASE (7, 8); unit = '(deg)' CASE (9); unit = '(N.m)' diff --git a/src/CableDyn_HermiteCable.f90 b/src/CableDyn_HermiteCable.f90 index 2dea8258..ea7cef97 100644 --- a/src/CableDyn_HermiteCable.f90 +++ b/src/CableDyn_HermiteCable.f90 @@ -444,18 +444,22 @@ SUBROUTINE CD_HermiteCable_Mass(rho_a, L, M, ErrStat, ErrMsg) END DO END SUBROUTINE CD_HermiteCable_Mass - SUBROUTINE CD_HermiteCable_Curvature(qr, L, u, curvature, ErrStat, ErrMsg) - !! Parametrisation-invariant centreline curvature at station u in [0,1] for output. + SUBROUTINE CD_HermiteCable_Curvature(qr, L, u, curvature, ErrStat, ErrMsg, kvec) + !! Parametrisation-invariant centreline curvature at station u in [0,1] for output. kvec, when + !! asked for, is the curvature vector kappa n, toward the centre of curvature: + !! (r' x r'') x r'/|r'|^4, whose length is the curvature. REAL(wp), INTENT(IN) :: qr(12), L, u REAL(wp), INTENT(OUT) :: curvature INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: kvec(3) REAL(wp) :: H(4), dH(4), ddH(4), rp(3), rpp(3), cr(3), sp INTEGER :: k ErrStat = CD_HCABLE_OK ErrMsg = '' curvature = CD_ZERO + IF (PRESENT(kvec)) kvec = CD_ZERO IF (.NOT. CD_All_Finite(qr) .OR. .NOT. CD_Is_Finite(L) .OR. .NOT. CD_Is_Finite(u)) THEN ErrStat = CD_HCABLE_BADINPUT; ErrMsg = 'CD_HermiteCable_Curvature: inputs must be finite'; RETURN END IF @@ -473,6 +477,7 @@ SUBROUTINE CD_HermiteCable_Curvature(qr, L, u, curvature, ErrStat, ErrMsg) END IF cr = [rp(2)*rpp(3) - rp(3)*rpp(2), rp(3)*rpp(1) - rp(1)*rpp(3), rp(1)*rpp(2) - rp(2)*rpp(1)] curvature = SQRT(cr(1)**2 + cr(2)**2 + cr(3)**2)/sp**3 + IF (PRESENT(kvec)) kvec = [cr(2)*rp(3) - cr(3)*rp(2), cr(3)*rp(1) - cr(1)*rp(3), cr(1)*rp(2) - cr(2)*rp(1)]/sp**4 END SUBROUTINE CD_HermiteCable_Curvature SUBROUTINE CD_HermiteCable_Peak_Curvature(qr, L, curvature_peak, u_peak, ErrStat, ErrMsg) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index b303cb3d..b0a5d1da 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -128,6 +128,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Restore PUBLIC :: CD_HermiteCable_Dyn_Energy PUBLIC :: CD_HermiteCable_Dyn_Curvature + PUBLIC :: CD_HermiteCable_Dyn_Section_Curvature PUBLIC :: CD_HermiteCable_Dyn_Reaction PUBLIC :: CD_HermiteCable_Dyn_Curvature_Exact PUBLIC :: CD_HermiteCable_Dyn_Set_Output_Recovery @@ -5542,6 +5543,145 @@ SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact(model, curv_out, ErrStat, ErrMsg) END DO END SUBROUTINE CD_HermiteCable_Dyn_Curvature_Exact + SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, ErrMsg, frame) + !! The two components of the nodal curvature vector on the cross-section axes (the channels + !! CurvXN, CurvYN), in internal node order (node nn is End A). The curvature + !! vector kappa n points to the centre of curvature and its length is the curvature of + !! CD_HermiteCable_Dyn_Curvature: the recovered section moment over EI on the side that + !! gives it (CD_HermiteCable_Dyn_Node_Recovery), or the larger exact one-sided trace under + !! element output recovery. + !! + !! The section axes: d1 at End A is the reference normal -- the End A torsion normal on a + !! line restrained in torsion, else ref_a (solve frame) -- made normal to the End A tangent. + !! It is carried to every node by parallel transport along the centreline, NSUB smallest + !! rotations per element between the Hermite tangents, and on a line in torsion turned + !! about the tangent by the twist from End A: the torque times the End A compliance plus + !! l0/GJ summed from End A, right-handed about the End A -> End B tangent t. d2 = t x d1, + !! kx = kappa n . d1 and ky = kappa n . d2; frame(:, j), when asked for, is d1 at node j. + !! Read-only. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: ref_a(3) + REAL(wp), INTENT(OUT) :: kx(:), ky(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: frame(:, :) + INTEGER, PARAMETER :: NSUB = 8 + REAL(wp) :: kvec(3, model%nn), qe(12), kv(3), kl, kr, d1(3), d(3), t(3), tp(3), tq(3), H(4), dH(4) + REAL(wp) :: r(3), rn, th, mt, comp, phi + INTEGER :: a, e, k, es + CHARACTER(1024) :: em2 + + ErrStat = CD_HCDYN_OK; ErrMsg = '' + kx = CD_ZERO + ky = CD_ZERO + IF (.NOT. model%initialized) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: model not initialised'; RETURN + END IF + IF (SIZE(kx) /= model%nn .OR. SIZE(ky) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: kx, ky must be nn'; RETURN + END IF + IF (PRESENT(frame)) THEN + IF (SIZE(frame, 1) /= 3 .OR. SIZE(frame, 2) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: frame must be (3, nn)'; RETURN + END IF + frame = CD_ZERO + END IF + IF (model%output_element_recovery) THEN + ! the larger exact one-sided trace and its vector (CD_HermiteCable_Dyn_Curvature_Exact) + DO a = 1, model%nn + kvec(:, a) = CD_ZERO + kl = -CD_ONE + IF (a <= model%ne) THEN + CALL gather_elem(model, a, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(a), CD_ZERO, kr, es, em2, kvec=kv) + IF (es /= CD_HCABLE_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: '//TRIM(em2); RETURN + END IF + kvec(:, a) = kv + kl = kr + END IF + IF (a >= 2) THEN + CALL gather_elem(model, a - 1, qe) + CALL CD_HermiteCable_Curvature(qe, model%l0(a - 1), CD_ONE, kr, es, em2, kvec=kv) + IF (es /= CD_HCABLE_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: '//TRIM(em2); RETURN + END IF + IF (kr > kl) kvec(:, a) = kv + END IF + END DO + ELSE + CALL CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, curvature_vector=kvec) + IF (ErrStat /= CD_HCDYN_OK) RETURN + END IF + ! d1 at End A, normal to the End A -> End B tangent there + IF (model%torsion%active) THEN + r = model%torsion%ends(:, 4) + ELSE + r = ref_a + END IF + t = -unit_tangent(model, model%nn) + d1 = r - DOT_PRODUCT(r, t)*t + rn = NORM2(d1) + IF (.NOT. rn > 1.0e-6_wp*MAX(NORM2(r), TINY(CD_ONE))) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: the section reference lies along the End A tangent'; RETURN + END IF + d1 = d1/rn + mt = CD_ZERO + comp = CD_ZERO + 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) + END IF + DO a = model%nn, 1, -1 + IF (a < model%nn) THEN + ! carry d1 from node a + 1 to node a along element a (xi from 1 to 0) + e = a + CALL gather_elem(model, e, qe) + tp = t + DO k = NSUB - 1, 0, -1 + CALL CD_HermiteCable_Shapes(REAL(k, wp)/REAL(NSUB, wp), model%l0(e), H, dH) + tq = -(dH(1)*qe(1:3) + dH(2)*qe(4:6) + dH(3)*qe(7:9) + dH(4)*qe(10:12)) + rn = NORM2(tq) + IF (.NOT. rn > CD_ZERO) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: degenerate centreline tangent'; RETURN + END IF + tq = tq/rn + d1 = rotate_onto(tp, tq, d1) + tp = tq + END DO + 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) + END IF + phi = mt*comp + d = COS(phi)*d1 + SIN(phi)*cross3_local(t, d1) + IF (PRESENT(frame)) frame(:, a) = d + kx(a) = DOT_PRODUCT(kvec(:, a), d) + ky(a) = DOT_PRODUCT(kvec(:, a), cross3_local(t, d)) + END DO + + CONTAINS + + PURE FUNCTION rotate_onto(u, w, v) RESULT(rv) + !! The smallest rotation taking unit u to unit w, applied to v. + REAL(wp), INTENT(IN) :: u(3), w(3), v(3) + REAL(wp) :: rv(3), c, x(3) + c = DOT_PRODUCT(u, w) + x = cross3_local(u, w) + rv = c*v + cross3_local(x, v) + x*DOT_PRODUCT(x, v)/(CD_ONE + c) + END FUNCTION rotate_onto + + PURE FUNCTION cross3_local(u, w) RESULT(x) + REAL(wp), INTENT(IN) :: u(3), w(3) + REAL(wp) :: x(3) + x = [u(2)*w(3) - u(3)*w(2), u(3)*w(1) - u(1)*w(3), u(1)*w(2) - u(2)*w(1)] + END FUNCTION cross3_local + END SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature + SUBROUTINE CD_HermiteCable_Dyn_Reaction(model, node, freac, ErrStat, ErrMsg, full_assembly) !! Constraint reaction at a fixed/prescribed node: the force the LINE exerts ON its !! support (fairlead/anchor) at the current committed state, in global coordinates. @@ -5962,7 +6102,7 @@ END SUBROUTINE cached_end_residual END SUBROUTINE CD_HermiteCable_Dyn_Node_Values SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, curvature, bend_moment, & - segment_tension) + segment_tension, curvature_vector) !! Effective tension, curvature and bend moment at every node (internal order) recovered !! from nodal equilibrium, in one pass over the elements. !! @@ -5986,8 +6126,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu !! exact geometric trace on an element without bending stiffness, or with EI below ei_resolve, !! where the recovered moment error w L0^2/12 exceeds the elastic moment of a 1 m bend radius). !! segment_tension(e) is the - !! mean of the axial components of element e's own two end forces. Every output is - !! optional (node arrays nn, segment_tension ne); the routine allocates nothing. + !! mean of the axial components of element e's own two end forces. curvature_vector(:, j) + !! is the curvature vector kappa n of node j in the solve frame, toward the centre of + !! curvature, of length curvature(j): the section moment vector over EI on the side that + !! gives curvature(j), or the exact trace's vector. Every output is optional (node arrays nn, + !! curvature_vector (3, nn), segment_tension ne); the routine allocates nothing. !! !! The condensed torque of a line restrained in torsion is not part of g_e: it adds a shear !! normal to the tangent and does no work on bending rotations, so tension and bend moment @@ -5996,6 +6139,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(OUT), OPTIONAL :: tension(:), curvature(:), bend_moment(:), segment_tension(:) + REAL(wp), INTENT(OUT), OPTIONAL :: curvature_vector(:, :) REAL(wp) :: g(12), fm(3), mm(3), fp(3), mp(3), ta(3), tb(3) INTEGER :: e, nn LOGICAL :: want_nodes @@ -6010,7 +6154,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: node arrays must be nn, segment_tension ne'; RETURN END IF - want_nodes = PRESENT(tension) .OR. PRESENT(curvature) .OR. PRESENT(bend_moment) + IF (PRESENT(curvature_vector)) THEN + IF (SIZE(curvature_vector, 1) /= 3 .OR. SIZE(curvature_vector, 2) /= nn) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: curvature_vector must be (3, nn)'; RETURN + END IF + END IF + want_nodes = PRESENT(tension) .OR. PRESENT(curvature) .OR. PRESENT(bend_moment) .OR. PRESENT(curvature_vector) fm = CD_ZERO; mm = CD_ZERO DO e = 1, model%ne CALL element_end_residual(model, e, g, ErrStat, ErrMsg) @@ -6034,8 +6184,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery(model, ErrStat, ErrMsg, tension, cu SUBROUTINE store_node(node) INTEGER, INTENT(IN) :: node - REAL(wp) :: t_n, k_n, b_n - CALL node_values(model, node, fm, mm, fp, mp, t_n, k_n, b_n, ErrStat, ErrMsg) + REAL(wp) :: t_n, k_n, b_n, kv(3) + CALL node_values(model, node, fm, mm, fp, mp, t_n, k_n, b_n, ErrStat, ErrMsg, curvature_vector=kv) + IF (PRESENT(curvature_vector)) curvature_vector(:, node) = kv IF (PRESENT(tension)) tension(node) = t_n IF (PRESENT(curvature)) curvature(node) = k_n IF (PRESENT(bend_moment)) bend_moment(node) = b_n @@ -6050,20 +6201,22 @@ END FUNCTION size_ok END SUBROUTINE CD_HermiteCable_Dyn_Node_Recovery SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_moment, ErrStat, ErrMsg, & - sleeve_moment) + sleeve_moment, curvature_vector) !! Node values from the one-sided section force and moment before (fm, mm) and after !! (fp, mp) the node; a line end uses its only side (see CD_HermiteCable_Dyn_Node_Recovery). !! bend_moment is the cable's own share of the section moment, EI_line kappa on the side of !! the larger value (the whole section moment on a side without a bend stiffener), and - !! sleeve_moment the rest, the share a stiffener sleeve carries. + !! sleeve_moment the rest, the share a stiffener sleeve carries. curvature_vector is the + !! curvature vector kappa n (solve frame, toward the centre of curvature) of the side that + !! gives curvature: the normal part of the section moment over EI, or the exact trace's. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: node REAL(wp), INTENT(IN) :: fm(3), mm(3), fp(3), mp(3) REAL(wp), INTENT(OUT) :: tension, curvature, bend_moment INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment - REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace, section_moment, cable_moment + REAL(wp), INTENT(OUT), OPTIONAL :: sleeve_moment, curvature_vector(3) + REAL(wp) :: t(3), f(3), m(3), fend(3), qe(12), trace, section_moment, cable_moment, m_perp(3), kv(3) INTEGER :: e, side CHARACTER(200) :: em2 @@ -6083,13 +6236,17 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom ELSE tension = DOT_PRODUCT(t, f) END IF - section_moment = NORM2(m - DOT_PRODUCT(m, t)*t) + m_perp = m - DOT_PRODUCT(m, t)*t + section_moment = NORM2(m_perp) curvature = CD_ZERO cable_moment = CD_ZERO + IF (PRESENT(curvature_vector)) curvature_vector = CD_ZERO DO side = 0, 1 e = node - 1 + side IF (e < 1 .OR. e > model%ne) CYCLE IF (model%EI(e) > CD_ZERO .AND. model%EI(e) >= model%ei_resolve) THEN + IF (PRESENT(curvature_vector) .AND. section_moment/model%EI(e) > curvature) & + curvature_vector = m_perp/model%EI(e) curvature = MAX(curvature, section_moment/model%EI(e)) IF (model%EI_line(e) == model%EI(e)) THEN cable_moment = MAX(cable_moment, section_moment) @@ -6098,10 +6255,11 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom END IF ELSE CALL gather_elem(model, e, qe) - CALL CD_HermiteCable_Curvature(qe, model%l0(e), REAL(1 - side, wp), trace, ErrStat, em2) + CALL CD_HermiteCable_Curvature(qe, model%l0(e), REAL(1 - side, wp), trace, ErrStat, em2, kvec=kv) IF (ErrStat /= CD_HCABLE_OK) THEN ErrStat = CD_HCDYN_NOCONVERGE; ErrMsg = 'CD_HermiteCable_Dyn_Node_Recovery: '//TRIM(em2); RETURN END IF + IF (PRESENT(curvature_vector) .AND. trace > curvature) curvature_vector = kv curvature = MAX(curvature, trace) IF (model%EI_line(e) == model%EI(e)) THEN cable_moment = MAX(cable_moment, section_moment) diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index c0d6f785..81fb7426 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -249,7 +249,7 @@ MODULE CableDyn_OpenFAST_Aggregate SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation) + range_files, host_orientation, static_current) !! Build the aggregate from ONE mixed deck: partition its lines into {EI=0 mooring} !! and {finite-EI cable}, wrap the mooring subset into a CD_FMF, and own one CD_HFMF !! per cable. Same signature philosophy as CD_FMF_Init_From_Deck (host environment @@ -288,6 +288,9 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ! host_orientation: the caller passes the moving-point orientations with every update, ! which a finite-EI line restrained in torsion requires (see CD_Init_Deck_Aggregate) LOGICAL, INTENT(IN), OPTIONAL :: host_orientation + ! static_current (4, n): the host's steady current (z, ux, uy, uz by ascending z) for the + ! static solves only (see CD_Init_Deck_Aggregate) + REAL(wp), INTENT(IN), OPTIONAL :: static_current(:, :) ! Both bundles (about 70 KB together) are built on the heap: initialisation runs on the ! thread of the calling host, whose stack size CableDyn does not choose. @@ -326,7 +329,8 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi coupled_positions=coupled_positions, n_turbines=n_turbines, & turbine_ref_pos=turbine_ref_pos, farm_ptfm_init=farm_ptfm_init, & forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & - range_files=range_files, host_orientation=host_orientation) + range_files=range_files, host_orientation=host_orientation, & + static_current=static_current) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 5871b946..c4588703 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -38,6 +38,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF CD_HermiteCable_Dyn_Reaction, & CD_HermiteCable_Dyn_EndConnection_Moment, & CD_HermiteCable_Dyn_Curvature, CD_HermiteCable_Dyn_Curvature_Exact, & + CD_HermiteCable_Dyn_Section_Curvature, & CD_HermiteCable_Dyn_Snapshot, CD_HermiteCable_Dyn_Restore, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK, & CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Set_Torsion_Drive, & @@ -81,6 +82,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_GetCoupledKinematics PUBLIC :: CD_HFMF_CalcOutput PUBLIC :: CD_HFMF_Curvature, CD_HFMF_Curvature_Exact + PUBLIC :: CD_HFMF_Set_Section_Reference, CD_HFMF_Section_Curvature PUBLIC :: CD_HFMF_MinSpanZ PUBLIC :: CD_HFMF_MirrorSize PUBLIC :: CD_HFMF_FrictionMirrorSize @@ -145,6 +147,19 @@ MODULE CableDyn_OpenFAST_HermiteFMF ! total NumSegs of the deck sections, End A first), 0 if no mesh node lies there. Unallocated ! when the mesh is the deck mesh. The node output channels (TenN, ...) read deck nodes. INTEGER, ALLOCATABLE :: deck_node(:) + ! The cross-section reference of the CurvX/CurvY channels (CD_HFMF_Set_Section_Reference): + ! the static start's normal at End A in global axes and, for an End A connected to a parent, + ! in the parent's axes, so it turns with the parent. + LOGICAL :: has_sect_ref = .FALSE. + REAL(wp) :: sect_ref_global(3) = CD_ZERO + REAL(wp) :: sect_ref_parent(3) = CD_ZERO + ! the last CD_HFMF_Section_Curvature result and the state it was evaluated at (time, load + ! epoch, reference, q, v, a and, in torsion, the end frames, Theta, Phi and the torque, which + ! a host rotation turns without moving q): the channels of one output row share one evaluation + LOGICAL :: sc_valid = .FALSE. + INTEGER :: sc_epoch = -1 + REAL(wp) :: sc_t = CD_ZERO, sc_ref(3) = CD_ZERO, sc_tors(15) = CD_ZERO + REAL(wp), ALLOCATABLE :: sc_q(:), sc_v(:), sc_a(:), sc_kx(:), sc_ky(:) LOGICAL :: initialized = .FALSE. END TYPE CD_HFMF_ModuleType @@ -1432,6 +1447,99 @@ SUBROUTINE CD_HFMF_Curvature(self, curv_out, ErrStat, ErrMsg) END IF END SUBROUTINE CD_HFMF_Curvature + SUBROUTINE CD_HFMF_Set_Section_Reference(self, ErrStat, ErrMsg) + !! Freeze the cross-section reference of the CurvX/CurvY channels at the current (static) + !! state: the normal at End A of the End A -> End B tangent t nearest global +z, the section's + !! upper side (global +x where t is vertical). It is kept in global axes and, when End A is + !! connected to a parent (a clamped or finite-stiffness end connection), in the parent's axes, + !! in which it then turns with the parent. A line restrained in torsion takes its End A torsion + !! normal instead (CD_HermiteCable_Dyn_Section_Curvature). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: t(3), r(3), up(3), tn + INTEGER :: nn + ErrStat = CD_HFMF_OK; ErrMsg = '' + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Section_Reference: module not initialised'; RETURN + END IF + nn = self%line%nn + ! End A is the last internal node; its internal tangent points away from End B + t = -frame_to_global(self, self%line%q(6*(nn - 1) + 4:6*(nn - 1) + 6)) + tn = NORM2(t) + IF (.NOT. tn > CD_ZERO) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Section_Reference: degenerate End A tangent'; RETURN + END IF + t = t/tn + up = [CD_ZERO, CD_ZERO, CD_ONE] + IF (ABS(t(3)) > CD_ONE - 1.0e-6_wp) up = [CD_ONE, CD_ZERO, CD_ZERO] + r = up - DOT_PRODUCT(up, t)*t + r = r/NORM2(r) + self%sect_ref_global = r + self%sect_ref_parent = MATMUL(self%parent_dcm, r) + self%has_sect_ref = .TRUE. + self%sc_valid = .FALSE. + END SUBROUTINE CD_HFMF_Set_Section_Reference + + SUBROUTINE CD_HFMF_Section_Curvature(self, kx, ky, ErrStat, ErrMsg) + !! The CurvX/CurvY channels of every node (internal order): the curvature vector on the + !! cross-section axes (CD_HermiteCable_Dyn_Section_Curvature), with the reference of + !! CD_HFMF_Set_Section_Reference, turned with the parent when End A is connected to one. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + REAL(wp), INTENT(OUT) :: kx(:), ky(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: r(3), tors(15) + INTEGER :: es, nn + CHARACTER(1024) :: em + ErrStat = CD_HFMF_OK; ErrMsg = '' + kx = CD_ZERO + ky = CD_ZERO + IF (.NOT. (self%initialized .AND. self%has_sect_ref)) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Section_Curvature: module not initialised or without a section reference'; RETURN + END IF + nn = self%line%nn + IF (SIZE(kx) /= nn .OR. SIZE(ky) /= nn) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Section_Curvature: kx, ky must be nn'; RETURN + END IF + IF (self%has_parent_endconn) THEN + r = MATMUL(TRANSPOSE(self%parent_dcm), self%sect_ref_parent) + ELSE + r = self%sect_ref_global + END IF + r = frame_to_local(self, r) + tors = CD_ZERO + IF (self%line%torsion%active) tors = [RESHAPE(self%line%torsion%ends, [12]), self%line%torsion%theta, & + self%line%torsion%phi, self%line%torsion%torque] + IF (self%sc_valid .AND. self%sc_epoch == self%line%rc_epoch) THEN + ! exact equality (a NaN never matches) + IF (ALL(ABS(self%sc_ref - r) <= CD_ZERO) .AND. ABS(self%sc_t - self%line%t) <= CD_ZERO .AND. & + ALL(ABS(self%sc_tors - tors) <= CD_ZERO) .AND. & + ALL(ABS(self%sc_q - self%line%q) <= CD_ZERO) .AND. ALL(ABS(self%sc_v - self%line%v) <= CD_ZERO) .AND. & + ALL(ABS(self%sc_a - self%line%a) <= CD_ZERO)) THEN + kx = self%sc_kx + ky = self%sc_ky + RETURN + END IF + END IF + self%sc_valid = .FALSE. + CALL CD_HermiteCable_Dyn_Section_Curvature(self%line, r, kx, ky, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Section_Curvature: '//TRIM(em); RETURN + END IF + self%sc_ref = r + self%sc_tors = tors + self%sc_t = self%line%t + self%sc_epoch = self%line%rc_epoch + self%sc_q = self%line%q + self%sc_v = self%line%v + self%sc_a = self%line%a + self%sc_kx = kx + self%sc_ky = ky + self%sc_valid = .TRUE. + END SUBROUTINE CD_HFMF_Section_Curvature + SUBROUTINE CD_HFMF_Curvature_Exact(self, curv_out, ErrStat, ErrMsg) !! Nodal geometric curvature of the cubic-Hermite centreline at the current state, the larger !! one-sided trace at an interior node (CD_HermiteCable_Dyn_Curvature_Exact). @@ -1827,6 +1935,11 @@ SUBROUTINE CD_HFMF_End(self) self%snap_parent_dcm = identity_dcm() self%snap_parent_omega = CD_ZERO self%snap_parent_alpha = CD_ZERO + self%has_sect_ref = .FALSE. + self%sect_ref_global = CD_ZERO + self%sect_ref_parent = CD_ZERO + self%sc_valid = .FALSE. + IF (ALLOCATED(self%sc_q)) DEALLOCATE (self%sc_q, self%sc_v, self%sc_a, self%sc_kx, self%sc_ky) self%tors_parent = .FALSE. self%tors_index = 0 self%tors_frame_parent = CD_ZERO diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index a8a72f8f..9c29dee5 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -521,6 +521,7 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er REAL(wp) :: cval, dtC, deck_dtm, dt_moor REAL(wp) :: fair_ten, fair_force(3), fair_incl, fair_decl, fair_azi, force_incl LOGICAL :: has_dtm, has_ptfm, use_extf + REAL(wp), ALLOCATABLE :: static_cur(:,:) ! the host's steady current for the static start CHARACTER(ChanLen) :: chan_hdr, chan_unt CHARACTER(1024) :: native_root, init_note INTEGER(IntKi) :: note_at, note_end @@ -755,11 +756,21 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er host_orientation=.TRUE. ) END IF ELSE + ! the static start in the host's steady current (seastate_static_current) + IF (use_extf) THEN + CALL seastate_static_current( InitInp%WaveField, static_cur, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + IF (InitInp%WaveField%Current_InitInput%CurrMod /= 0_IntKi .AND. & + InitInp%WaveField%Current_InitInput%CurrMod /= 1_IntKi .OR. InitInp%WaveField%hasCurrField) & + CALL WrScr( ' Note: CableDyn starts from its still-water statics: of the SeaState currents only '// & + 'CurrMod 1 enters the static start; this current acts from t = 0.' ) + END IF CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(InitInp%FileName), dt_moor, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp), ptfm_init=REAL(ptfm6, wp), & external_fluid=use_extf, run_tmax=REAL(InitInp%Tmax, wp), & - host_orientation=.TRUE. ) + host_orientation=.TRUE., static_current=static_cur ) END IF IF (es /= CD_AGG_OK) THEN ! The slot stays inactive (it is activated only after full success, below), so this and @@ -1343,6 +1354,7 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) CHARACTER(2100) :: rst_deck INTEGER(IntKi) :: id, old_id, stale_id, i, es, ncp, nlines, il, ndofl, nin, k, ic, csz, koff LOGICAL :: use_extf, profile_requested, preserve_profile + REAL(wp), ALLOCATABLE :: static_cur(:,:) ! the host's steady current for the static start LOGICAL :: restored ! held fluid fields restored from the checkpoint CHARACTER(ErrMsgLen) :: em INTEGER(IntKi) :: ErrStat2 @@ -1405,11 +1417,18 @@ SUBROUTINE rebuild_from_checkpoint( t, u1, p, x, other, m, ErrStat, ErrMsg ) END IF use_extf = .FALSE. IF (ASSOCIATED(p%WaveField)) use_extf = wavefield_is_ambient( p%WaveField ) + ! the rebuild solves the same static start as the run it continues (the restored state + ! then replaces it; a static-shape-driven mesh refinement must match) + IF (use_extf) THEN + CALL seastate_static_current( p%WaveField, static_cur, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + END IF CALL CD_AGG_Init_From_Deck( Inst(id)%agg, TRIM(rst_deck), REAL(p%dtM0, wp), es, em, & env_gravity=REAL(p%g, wp), env_rho_water=REAL(p%rhoW, wp), & env_wtrdpth=REAL(p%WtrDpth, wp), external_fluid=use_extf, & ptfm_init=REAL(p%PtfmInit, wp), run_tmax=REAL(p%Tmax, wp), & - host_orientation=.TRUE. ) + host_orientation=.TRUE., static_current=static_cur ) CALL delete_file( rst_deck ) IF (es /= CD_AGG_OK) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: checkpoint rebuild: '//TRIM(em), & @@ -2925,6 +2944,7 @@ SUBROUTINE quasistatic_dydu( Vars, u, p, m, dYdu, ErrStat, ErrMsg ) CHARACTER(2100) :: lin_deck REAL(wp), ALLOCATABLE :: op_pos(:,:), prb_pos(:,:) LOGICAL :: use_extf + REAL(wp), ALLOCATABLE :: static_cur(:,:) ! the host's steady current for the static probes ErrStat = ErrID_None ErrMsg = '' @@ -2954,6 +2974,12 @@ SUBROUTINE quasistatic_dydu( Vars, u, p, m, dYdu, ErrStat, ErrMsg ) use_extf = .FALSE. IF (ASSOCIATED(p%WaveField)) use_extf = wavefield_is_ambient( p%WaveField ) + ! each probe is a static solve in the host's steady current, as the operating point is + IF (use_extf) THEN + CALL seastate_static_current( p%WaveField, static_cur, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + END IF DO i = 1, SIZE(Vars%u) IF (Vars%u(i)%Field /= FieldTransDisp) CYCLE ! vel/acc/orientation: zero columns @@ -3011,7 +3037,8 @@ SUBROUTINE probe_loads( pos, PErrStat, PErrMsg ) CALL CD_AGG_Init_From_Deck( agg_p, TRIM(lin_deck), REAL(p%dtM0, wp), es_p, em_p, & env_gravity=REAL(p%g, wp), env_rho_water=REAL(p%rhoW, wp), & env_wtrdpth=REAL(p%WtrDpth, wp), external_fluid=use_extf, & - coupled_positions=pos, run_tmax=REAL(p%Tmax, wp) ) + coupled_positions=pos, run_tmax=REAL(p%Tmax, wp), & + static_current=static_cur ) IF (es_p /= CD_AGG_OK) THEN PErrStat = ErrID_Fatal PErrMsg = 'linearization static probe init failed: '//TRIM(em_p) @@ -4454,6 +4481,54 @@ LOGICAL FUNCTION wavefield_is_ambient( wf ) RESULT(ambient) ambient = wf%WaveMod /= WaveMod_None .OR. wf%Current_InitInput%CurrMod /= 0_IntKi .OR. wf%hasCurrField END FUNCTION wavefield_is_ambient + !> The host's steady current for the static start (CD_AGG_Init_From_Deck static_current): + !> SeaState's CurrMod 1 current (CD_SeaState_Steady_Current) at the levels of its vertical + !> wave grid, z ascending. SeaState interpolates between those levels in its own stretched + !> coordinate, the profile linearly in z: the start takes the run's current at the levels + !> and very nearly between them. Left unallocated -- a still-water start -- without a + !> nonzero CurrMod 1 current; a CurrMod 2 current or an InflowWind current field is known + !> only through the run's samples (CD_Init notes it). + SUBROUTINE seastate_static_current( wf, prof, ErrStat, ErrMsg ) + TYPE(SeaSt_WaveFieldType), INTENT(IN ) :: wf + REAL(wp), ALLOCATABLE, INTENT( OUT) :: prof(:,:) + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg + INTEGER(IntKi) :: k, nz, m, es + REAL(wp) :: zk, v(3) + CHARACTER(1024) :: em + ErrStat = ErrID_None + ErrMsg = '' + IF (wf%Current_InitInput%CurrMod /= 1_IntKi) RETURN + nz = wf%VolGridParams%n(4) + IF (nz < 2) RETURN + ALLOCATE (prof(4, nz)) + m = 0 + DO k = 0, nz - 1 + zk = REAL(wf%GridDepth, wp)*(SIN(REAL(wf%VolGridParams%pZero(4) + k*wf%VolGridParams%delta(4), wp)) - 1.0_wp) + IF (m > 0) THEN + IF (.NOT. zk > prof(1, m)) CYCLE + END IF + CALL CD_SeaState_Steady_Current(zk, REAL(wf%EffWtrDpth, wp), 1, & + REAL(wf%Current_InitInput%CurrSSV0, wp), REAL(wf%Current_InitInput%CurrSSDir, wp), & + REAL(wf%Current_InitInput%CurrNSRef, wp), REAL(wf%Current_InitInput%CurrNSV0, wp), & + REAL(wf%Current_InitInput%CurrNSDir, wp), REAL(wf%Current_InitInput%CurrDIV, wp), & + REAL(wf%Current_InitInput%CurrDIDir, wp), v, es, em) + IF (es /= CD_HYDRO_OK) THEN + ErrStat = ErrID_Fatal + ErrMsg = 'CableDyn mooring module: SeaState current for the static start: '//TRIM(em) + DEALLOCATE (prof) + RETURN + END IF + m = m + 1 + prof(:, m) = [zk, v] + END DO + IF (m < 2 .OR. .NOT. ANY(ABS(prof(2:4, 1:m)) > 0.0_wp)) THEN + DEALLOCATE (prof) + RETURN + END IF + prof = prof(:, 1:m) + END SUBROUTINE seastate_static_current + !> Write the packed deck copy to /, the !> file the checkpoint rebuild and the linearization probes re-parse. In the MooringFile !> folder, deck-relative side files (bathymetry, WaterKin, Syrope tables) resolve as in diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index f7a302f1..c2081107 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -1196,15 +1196,24 @@ PROGRAM test_deck_driver CALL write_syrope_deck('deck_syrope_current.dat', 'SYROPE:syrope.dat|1.53e8|23.12', & '5.0e10|1.0e5', option_row='uniform 1.0 0.0 0.0 current') + ! a Syrope line takes the hydrodynamics of any EI = 0 line (MoorDyn's): current and waves CALL CD_Init_Deck_Models('deck_syrope_current.dat', smodels, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'current hydro') > 0, & - 'current-loaded Syrope fails closed by name: '//TRIM(em)) + CALL require(es == CD_DECKDRV_OK, 'current-loaded Syrope builds: '//TRIM(em)) + IF (es == CD_DECKDRV_OK) THEN + CALL require(smodels(1)%has_syrope .AND. smodels(1)%has_morison_drag, & + 'current-loaded Syrope keeps its working curve and takes the Morison drag') + CALL CD_End_Model(smodels(1), es, em) + END IF CALL write_syrope_deck('deck_syrope_wave.dat', 'SYROPE:syrope.dat|1.53e8|23.12', & '5.0e10|1.0e5', wtrdpth=10.0_wp, option_row='airy 1.0 8.0 0.0 waves') CALL CD_Init_Deck_Models('deck_syrope_wave.dat', smodels, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'wave hydro') > 0, & - 'wave-loaded Syrope fails closed by name: '//TRIM(em)) + CALL require(es == CD_DECKDRV_OK, 'wave-loaded Syrope builds: '//TRIM(em)) + IF (es == CD_DECKDRV_OK) THEN + CALL require(smodels(1)%has_syrope .AND. smodels(1)%has_morison_drag, & + 'wave-loaded Syrope keeps its working curve and takes the Morison drag') + CALL CD_End_Model(smodels(1), es, em) + END IF END BLOCK ! end-to-end Syrope deck build: a single-section taut line (no seabed/hydro) ! builds the DYNAMIC model through the OWC-secant static solve, initializes diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index 7736be0a..4187e938 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -159,6 +159,7 @@ PROGRAM test_openfast_aggregate CALL case_external_fluid() CALL case_still_water_deck_ambient() CALL case_external_fluid_report() + CALL case_static_current() CALL case_coupled_positions_override() CALL case_farm_partition() CALL case_farm_free_clump() @@ -4519,6 +4520,110 @@ SUBROUTINE case_external_fluid_cable() CALL CD_AGG_End(agg_p, es, em) END SUBROUTINE case_external_fluid_cable + SUBROUTINE case_static_current() + !! The coupled start in the host's steady current (static_current, what the OpenFAST shell + !! passes from a SeaState CurrMod 1 current: 0.4 m/s along x and 0.3 m/s across): + !! - a pure EI = 0 deck starts as the same deck with that current as its deck OPTION; + !! - on the mixed deck (EI = 0 line and finite-EI cable), held under the host field of the + !! same current, the start stays at its loads -- the equilibrium in that current, with no + !! second copy of it in the dynamics -- where the still-water start moves away; + !! - static_current needs the host field, and z levels that ascend. + TYPE(CD_AGG_ModuleType) :: agg_w, agg_c, agg_u + REAL(wp), PARAMETER :: DT = 0.05_wp + REAL(wp), PARAMETER :: UC(3) = [0.4_wp, 0.3_wp, 0.0_wp] + REAL(wp) :: prof(4, 2), r0(3, 3), vel(3, 3), acc(3, 3), lu(3, 3), lc3(3, 3), v3(3, 3), a3(3, 3) + REAL(wp) :: drift(2) + INTEGER :: es + CHARACTER(1024) :: em + + prof(:, 1) = [-300.0_wp, UC] + prof(:, 2) = [0.0_wp, UC] + + ! (1) pure EI = 0: the static current is the deck current OPTION's + CALL write_volturnus_deck('agg_sc_still.dat', extra_option='0.05 dtM', extra_option2='60.0 TMax') + CALL write_volturnus_deck('agg_sc_deck.dat', extra_option='uniform 0.4 0.3 0.0 current', & + extra_option2='0.05 dtM', extra_option3='60.0 TMax') + CALL CD_AGG_Init_From_Deck(agg_u, 'agg_sc_deck.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'static-current:deck-current-init: '//TRIM(em)) + CALL CD_AGG_Init_From_Deck(agg_c, 'agg_sc_still.dat', DT, es, em, external_fluid=.TRUE., static_current=prof) + CALL require(es == CD_AGG_OK, 'static-current:ei0-init: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL CD_AGG_CalcOutput(agg_u, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_u, r0, vel, acc, lu, es, em) + CALL CD_AGG_CalcOutput(agg_c, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_c, r0, v3, a3, lc3, es, em) + CALL require(nan_max_abs(lc3 - lu) <= 1.0e-9_wp*nan_max_abs(lu), & + 'static-current:ei0-start-equals-deck-current-start') + END IF + CALL CD_AGG_End(agg_u, es, em) + CALL CD_AGG_End(agg_c, es, em) + + ! (2) mixed deck: held in the host's current, the start in that current stays put + CALL write_mixed_deck('agg_sc_mixed.dat') + CALL CD_AGG_Init_From_Deck(agg_w, 'agg_sc_mixed.dat', DT, es, em, external_fluid=.TRUE.) + CALL require(es == CD_AGG_OK, 'static-current:still-water-start: '//TRIM(em)) + CALL CD_AGG_Init_From_Deck(agg_c, 'agg_sc_mixed.dat', DT, es, em, external_fluid=.TRUE., static_current=prof) + CALL require(es == CD_AGG_OK, 'static-current:current-start: '//TRIM(em)) + IF (es == CD_AGG_OK) THEN + CALL held_drift(agg_w, UC, drift(1)) + CALL held_drift(agg_c, UC, drift(2)) + WRITE (*, '(A,ES10.3,A,ES10.3)') 'static current: load drift over 1 s held in the current, still-water '// & + 'start ', drift(1), ', start in the current ', drift(2) + CALL require(drift(2) <= 1.0e-4_wp, 'static-current:start-in-current-stays-put') + CALL require(drift(1) > 1.0e2_wp*drift(2), 'static-current:still-water-start-moves') + END IF + CALL CD_AGG_End(agg_w, es, em) + CALL CD_AGG_End(agg_c, es, em) + + ! (3) contract + CALL CD_AGG_Init_From_Deck(agg_c, 'agg_sc_mixed.dat', DT, es, em, static_current=prof) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'external_fluid') > 0, & + 'static-current:needs-host-field: '//TRIM(em)) + CALL CD_AGG_End(agg_c, es, em) + prof(1, 2) = -400.0_wp + CALL CD_AGG_Init_From_Deck(agg_c, 'agg_sc_mixed.dat', DT, es, em, external_fluid=.TRUE., static_current=prof) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'ascend') > 0, 'static-current:levels-ascend: '//TRIM(em)) + CALL CD_AGG_End(agg_c, es, em) + END SUBROUTINE case_static_current + + SUBROUTINE held_drift(agg, uc, rel) + !! Largest relative change of the two moving-point loads of the mixed deck over 1 s with the + !! boundary held at its start and the host field the uniform current uc. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(IN) :: uc(3) + REAL(wp), INTENT(OUT) :: rel + REAL(wp), PARAMETER :: DT = 0.05_wp + REAL(wp), ALLOCATABLE :: fu(:, :), fud(:, :), wl(:), r(:, :), v(:, :), a(:, :), l0(:, :), l1(:, :) + INTEGER :: nf, nm, s, ni, k, es + LOGICAL :: cv, st + CHARACTER(1024) :: em + rel = HUGE(1.0_wp) + nf = CD_AGG_NFluidNodes(agg, es, em) + IF (es /= CD_AGG_OK) RETURN + ALLOCATE (fu(3, nf), fud(3, nf), wl(nf)) + DO k = 1, nf + fu(:, k) = uc + END DO + fud = 0.0_wp + wl = 0.0_wp + CALL CD_AGG_SetFluidFields(agg, fu, fud, wl, es, em) + CALL require(es == CD_AGG_OK, 'static-current:set-fields: '//TRIM(em)) + nm = 2 + ALLOCATE (r(3, nm), v(3, nm), a(3, nm), l0(3, nm), l1(3, nm)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, r, v, a, l0, es, em) + v = 0.0_wp + a = 0.0_wp + DO s = 1, 20 + CALL CD_AGG_Step_Moving(agg, DT, r, v, a, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, 'static-current:held-step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END DO + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, r, v, a, l1, es, em) + rel = nan_max_abs(l1 - l0)/nan_max_abs(l0) + END SUBROUTINE held_drift + SUBROUTINE case_restart_line_control() !! CHECKPOINT-RESTART of a controlled EI = 0 deck, bit for bit (the shell rebuild's !! recipe): instance A marches the three VolturnUS chains under a surge drive while diff --git a/tests/test_section_curvature.f90 b/tests/test_section_curvature.f90 new file mode 100644 index 00000000..670102b7 --- /dev/null +++ b/tests/test_section_curvature.f90 @@ -0,0 +1,344 @@ +! File: tests/test_section_curvature.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_section_curvature + !! The section-frame curvature components (CurvXN, CurvYN) of a lazy-wave cable at + !! its static start (CD_HFMF_Section_Curvature): + !! 1. on a planar line (End A clamped, no current) the curvature lies on the section axis x + !! (CurvY is zero) and sqrt(CurvX^2 + CurvY^2) is CurvN; + !! 2. in a cross current the line leaves its plane, both components appear and their norm is + !! still the curvature; + !! 3. the same deck turned 30 degrees about the vertical gives the same components (the + !! section frame turns with the line); + !! 4. turning the hang-off 30 degrees about the End A tangent turns the section axes with it + !! (End A clamped): the components rotate by -30 degrees at every node; + !! 5. on a line restrained in torsion with a 90 degree pretwist at End B, the section axis x + !! leaves End A on its torsion normal Nx and reaches End B turned 90 degrees about the + !! tangent, onto End B's own pretwisted normal; + !! 6. with End A bending-pinned and restrained in torsion, turning the host about the End A + !! tangent turns the torsion frames only; the next evaluation is not the cached one but the + !! same as a fresh evaluation. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_HermiteCable, CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_Curvature, CD_HFMF_Section_Curvature, & + CD_HFMF_SetCoupledKinematics, CD_HFMF_End, CD_HFMF_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Section_Curvature, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + ! the nodes 1, 9, ..., 129 the driver cases write (End A to End B) + INTEGER, PARAMETER :: NSAMPLE = 17 + INTEGER :: nfail = 0 + REAL(wp), ALLOCATABLE :: k1(:), x1(:), y1(:), k2(:), x2(:), y2(:), k3(:), x3(:), y3(:) + + ! 1. planar + CALL static_components('sc_planar.dat', 0.0_wp, [0.0_wp, 0.0_wp, 0.0_wp], .FALSE., 0.0_wp, k1, x1, y1) + IF (ALLOCATED(k1)) THEN + CALL require(MAXVAL(ABS(y1)) <= 1.0e-9_wp*MAXVAL(k1), 'planar line: CurvY is zero') + CALL require(MAXVAL(ABS(SQRT(x1**2 + y1**2) - k1)) <= 1.0e-10_wp*MAXVAL(k1), & + 'planar line: sqrt(CurvX^2 + CurvY^2) = Curv') + END IF + ! 2. cross current (the standalone driver: the single-cable entry takes no deck current) + CALL driver_components('sc_cross', 0.0_wp, [0.0_wp, 0.4_wp, 0.0_wp], k2, x2, y2) + IF (ALLOCATED(k2)) THEN + CALL require(MAXVAL(ABS(y2)) > 1.0e-3_wp*MAXVAL(k2), 'cross current: the line bends out of its plane') + ! the driver prints eight significant digits + CALL require(MAXVAL(ABS(SQRT(x2**2 + y2**2) - k2)) <= 1.0e-7_wp*MAXVAL(k2), & + 'cross current: sqrt(CurvX^2 + CurvY^2) = Curv') + END IF + ! 3. the cross-current deck turned 30 degrees about the vertical + CALL driver_components('sc_turned', 30.0_wp, [0.0_wp, 0.4_wp, 0.0_wp], k3, x3, y3) + IF (ALLOCATED(k2) .AND. ALLOCATED(k3)) THEN + WRITE (*, '(A,2ES10.3)') 'turned deck: largest CurvX, CurvY change / largest curvature ', & + MAXVAL(ABS(x3 - x2))/MAXVAL(k2), MAXVAL(ABS(y3 - y2))/MAXVAL(k2) + CALL require(MAXVAL(ABS(x3 - x2)) <= 1.0e-6_wp*MAXVAL(k2) .AND. MAXVAL(ABS(y3 - y2)) <= 1.0e-6_wp*MAXVAL(k2), & + 'the components do not depend on the heading of the line') + END IF + ! 4. the hang-off turned about its tangent + CALL parent_roll() + ! 5. torsion + CALL torsion_frame() + ! 6. the torsion frames turned by the host, End A pinned in bending + CALL torsion_pinned_rotation() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: section-frame curvature components' + +CONTAINS + + SUBROUTINE static_components(path, heading_deg, current, torsion, pretwist_b, k, kx, ky) + !! Build the deck (write_deck) and return Curv, CurvX and CurvY of every node (internal order). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: heading_deg, current(3), pretwist_b + LOGICAL, INTENT(IN) :: torsion + REAL(wp), ALLOCATABLE, INTENT(OUT) :: k(:), kx(:), ky(:) + TYPE(CD_HFMF_ModuleType) :: cable + INTEGER :: es, cn, nn + CHARACTER(1024) :: em + CALL write_deck(path, heading_deg, current, torsion, pretwist_b) + CALL CD_Init_Deck_HermiteCable(path, 0.1_wp, cable, cn, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, TRIM(path)//': build: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + nn = cable%line%nn + ALLOCATE (k(nn), kx(nn), ky(nn)) + CALL CD_HFMF_Curvature(cable, k, es, em) + CALL require(es == CD_HFMF_OK, TRIM(path)//': curvature: '//TRIM(em)) + CALL CD_HFMF_Section_Curvature(cable, kx, ky, es, em) + CALL require(es == CD_HFMF_OK, TRIM(path)//': section curvature: '//TRIM(em)) + CALL CD_HFMF_End(cable) + END SUBROUTINE static_components + + SUBROUTINE driver_components(root, heading_deg, current, k, kx, ky) + !! Curv, CurvX and CurvY of every eighth node at t = 0 (TMax = 0) from the standalone driver. + CHARACTER(*), INTENT(IN) :: root + REAL(wp), INTENT(IN) :: heading_deg, current(3) + REAL(wp), ALLOCATABLE, INTENT(OUT) :: k(:), kx(:), ky(:) + REAL(wp) :: row(1 + 3*NSAMPLE) + INTEGER :: es, u, ios, j + LOGICAL :: conv + CHARACTER(1024) :: em, line + CALL write_deck(root//'.dat', heading_deg, current, .FALSE., 0.0_wp, node_channels=.TRUE.) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, root//': run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='OLD', ACTION='READ') + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (INDEX(line, 'Time') == 1) EXIT + END DO + READ (u, *, IOSTAT=ios) row + CLOSE (u) + CALL require(ios == 0, root//': read the t = 0 row') + IF (ios /= 0) RETURN + ALLOCATE (k(NSAMPLE), kx(NSAMPLE), ky(NSAMPLE)) + DO j = 1, NSAMPLE + k(j) = row(1 + 3*j - 2) + kx(j) = row(1 + 3*j - 1) + ky(j) = row(1 + 3*j) + END DO + END SUBROUTINE driver_components + + SUBROUTINE parent_roll() + TYPE(CD_HFMF_ModuleType) :: cable + REAL(wp), ALLOCATABLE :: kx0(:), ky0(:), kx1(:), ky1(:) + REAL(wp) :: t(3), r(3, 3), ca, sa, kmax + INTEGER :: es, cn, nn, i, j + CHARACTER(1024) :: em + CALL write_deck('sc_roll.dat', 0.0_wp, [0.0_wp, 0.0_wp, 0.0_wp], .FALSE., 0.0_wp) + CALL CD_Init_Deck_HermiteCable('sc_roll.dat', 0.1_wp, cable, cn, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'roll: build: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL require(cable%has_parent_endconn, 'roll: the clamped End A has a parent frame') + nn = cable%line%nn + ALLOCATE (kx0(nn), ky0(nn), kx1(nn), ky1(nn)) + CALL CD_HFMF_Section_Curvature(cable, kx0, ky0, es, em) + ! turn the parent 30 degrees about the End A -> End B tangent (global = solve frame here): + ! global-to-parent DCM P' = P R^T, R the rotation by +30 degrees about t + t = -cable%line%q(6*(nn - 1) + 4:6*(nn - 1) + 6) + t = t/NORM2(t) + ca = COS(PI/6.0_wp) + sa = SIN(PI/6.0_wp) + DO i = 1, 3 + DO j = 1, 3 + r(i, j) = ca*MERGE(1.0_wp, 0.0_wp, i == j) + (1.0_wp - ca)*t(i)*t(j) + END DO + END DO + r(1, 2) = r(1, 2) - sa*t(3); r(2, 1) = r(2, 1) + sa*t(3) + r(1, 3) = r(1, 3) + sa*t(2); r(3, 1) = r(3, 1) - sa*t(2) + r(2, 3) = r(2, 3) - sa*t(1); r(3, 2) = r(3, 2) + sa*t(1) + cable%parent_dcm = MATMUL(cable%parent_dcm, TRANSPOSE(r)) + CALL CD_HFMF_Section_Curvature(cable, kx1, ky1, es, em) + CALL require(es == CD_HFMF_OK, 'roll: section curvature: '//TRIM(em)) + kmax = MAXVAL(SQRT(kx0**2 + ky0**2)) + WRITE (*, '(A,ES10.3)') 'roll: largest departure from the axes turned by 30 degrees / largest curvature ', & + MAX(MAXVAL(ABS(kx1 - (ca*kx0 + sa*ky0))), MAXVAL(ABS(ky1 - (-sa*kx0 + ca*ky0))))/kmax + CALL require(MAXVAL(ABS(kx1 - (ca*kx0 + sa*ky0))) <= 1.0e-9_wp*kmax .AND. & + MAXVAL(ABS(ky1 - (-sa*kx0 + ca*ky0))) <= 1.0e-9_wp*kmax, & + 'roll: the section axes turn with the clamped hang-off') + CALL CD_HFMF_End(cable) + END SUBROUTINE parent_roll + + SUBROUTINE torsion_pinned_rotation() + TYPE(CD_HFMF_ModuleType) :: cable + REAL(wp), ALLOCATABLE :: kx0(:), ky0(:), kx1(:), ky1(:), kx2(:), ky2(:) + REAL(wp) :: t(3), r(3, 3), ca, sa, pos(3), zero3(3) + INTEGER :: es, cn, nn, i, j + CHARACTER(1024) :: em + CALL write_deck('sc_tpin.dat', 0.0_wp, [0.0_wp, 0.0_wp, 0.0_wp], .TRUE., 90.0_wp, pinned_a=.TRUE.) + CALL CD_Init_Deck_HermiteCable('sc_tpin.dat', 0.1_wp, cable, cn, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'pinned torsion: build: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL require(.NOT. cable%has_parent_endconn, 'pinned torsion: End A carries no bending connection') + nn = cable%line%nn + ALLOCATE (kx0(nn), ky0(nn), kx1(nn), ky1(nn), kx2(nn), ky2(nn)) + CALL CD_HFMF_Section_Curvature(cable, kx0, ky0, es, em) + CALL require(es == CD_HFMF_OK, 'pinned torsion: section curvature: '//TRIM(em)) + ! the host turned 30 degrees about the End A -> End B tangent: global-to-parent DCM R^T + t = -cable%line%q(6*(nn - 1) + 4:6*(nn - 1) + 6) + t = t/NORM2(t) + ca = COS(PI/6.0_wp) + sa = SIN(PI/6.0_wp) + DO i = 1, 3 + DO j = 1, 3 + r(i, j) = ca*MERGE(1.0_wp, 0.0_wp, i == j) + (1.0_wp - ca)*t(i)*t(j) + END DO + END DO + r(1, 2) = r(1, 2) - sa*t(3); r(2, 1) = r(2, 1) + sa*t(3) + r(1, 3) = r(1, 3) + sa*t(2); r(3, 1) = r(3, 1) - sa*t(2) + r(2, 3) = r(2, 3) - sa*t(1); r(3, 2) = r(3, 2) + sa*t(1) + pos = cable%line%q(6*(nn - 1) + 1:6*(nn - 1) + 3) + zero3 = 0.0_wp + CALL CD_HFMF_SetCoupledKinematics(cable, pos, zero3, zero3, es, em, TRANSPOSE(r), zero3, zero3) + CALL require(es == CD_HFMF_OK, 'pinned torsion: host rotation: '//TRIM(em)) + CALL CD_HFMF_Section_Curvature(cable, kx1, ky1, es, em) + cable%sc_valid = .FALSE. + CALL CD_HFMF_Section_Curvature(cable, kx2, ky2, es, em) + CALL require(MAXVAL(ABS(kx1 - kx0)) + MAXVAL(ABS(ky1 - ky0)) > 0.0_wp, & + 'pinned torsion: the turned torsion frames turn the components') + CALL require(MAXVAL(ABS(kx1 - kx2)) <= 0.0_wp .AND. MAXVAL(ABS(ky1 - ky2)) <= 0.0_wp, & + 'pinned torsion: the evaluation after the host rotation is the fresh one, not the cached one') + CALL CD_HFMF_End(cable) + END SUBROUTINE torsion_pinned_rotation + + SUBROUTINE torsion_frame() + TYPE(CD_HFMF_ModuleType) :: cable + REAL(wp), ALLOCATABLE :: kx(:), ky(:), fr(:, :), k(:) + REAL(wp) :: tb(3), ny(3), expect(3), ang_a, ang_b + INTEGER :: es, cn, nn + CHARACTER(1024) :: em + CALL write_deck('sc_torsion.dat', 0.0_wp, [0.0_wp, 0.0_wp, 0.0_wp], .TRUE., 90.0_wp) + CALL CD_Init_Deck_HermiteCable('sc_torsion.dat', 0.1_wp, cable, cn, es, em, host_orientation=.TRUE.) + CALL require(es == CD_DECKDRV_OK, 'torsion: build: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + nn = cable%line%nn + ALLOCATE (kx(nn), ky(nn), fr(3, nn), k(nn)) + CALL CD_HermiteCable_Dyn_Section_Curvature(cable%line, [0.0_wp, 0.0_wp, 1.0_wp], kx, ky, es, em, frame=fr) + CALL require(es == CD_HCDYN_OK, 'torsion: section curvature: '//TRIM(em)) + CALL CD_HFMF_Curvature(cable, k, es, em) + CALL require(MAXVAL(ABS(SQRT(kx**2 + ky**2) - k)) <= 1.0e-10_wp*MAXVAL(k), & + 'torsion: sqrt(CurvX^2 + CurvY^2) = Curv') + ny = [0.0_wp, 1.0_wp, 0.0_wp] + ! End A (the last internal node) starts on its torsion normal Nx = +y + ang_a = ACOS(MAX(-1.0_wp, MIN(1.0_wp, DOT_PRODUCT(fr(:, nn), ny)))) + ! End B (internal node 1): Nx = +y turned 90 degrees about the End A -> End B tangent + tb = -cable%line%q(4:6)/NORM2(cable%line%q(4:6)) + expect = cross(tb, ny) + ang_b = ACOS(MAX(-1.0_wp, MIN(1.0_wp, DOT_PRODUCT(fr(:, 1), expect)))) + WRITE (*, '(A,2ES10.3,A)') 'torsion: section axis x off Nx at End A, off the pretwisted normal at End B ', & + ang_a, ang_b, ' rad' + CALL require(ang_a <= 1.0e-9_wp, 'torsion: the section axis x starts on End A''s Nx') + CALL require(ang_b <= 2.0e-3_wp, 'torsion: the section axis x arrives on End B''s pretwisted normal') + CALL CD_HFMF_End(cable) + END SUBROUTINE torsion_frame + + SUBROUTINE write_deck(path, heading_deg, current, torsion, pretwist_b, node_channels, pinned_a) + !! A 170 m lazy-wave cable from a hang-off at 14 m depth to an anchor at 80 m, clamped at End A, + !! turned by heading_deg about the vertical through the origin, in the uniform current + !! (given before the turn). torsion: both ends restrained in torsion, Nx along +y, Pretwist + !! pretwist_b at End B. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: heading_deg, current(3), pretwist_b + LOGICAL, INTENT(IN) :: torsion + ! node_channels: write Curv, CurvX, CurvY of every eighth node, and run to TMax = 0 + LOGICAL, INTENT(IN), OPTIONAL :: node_channels + ! pinned_a: End A pinned in bending (still restrained in torsion) + LOGICAL, INTENT(IN), OPTIONAL :: pinned_a + CHARACTER(8) :: stiff_a + REAL(wp) :: c, s, pa(3), pb(3), eza(3), ezb(3), nx(3), cu(3) + INTEGER :: u, j + LOGICAL :: nodes + nodes = .FALSE. + IF (PRESENT(node_channels)) nodes = node_channels + c = COS(heading_deg*PI/180.0_wp) + s = SIN(heading_deg*PI/180.0_wp) + pa = turn(c, s, [5.0_wp, 0.0_wp, -14.0_wp]) + pb = turn(c, s, [125.0_wp, 0.0_wp, -80.0_wp]) + eza = turn(c, s, [0.14641_wp, 0.0_wp, -0.98922_wp]) + ezb = turn(c, s, [0.99999_wp, 0.0_wp, 0.00503_wp]) + nx = turn(c, s, [0.0_wp, 1.0_wp, 0.0_wp]) + cu = turn(c, s, current) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'section-frame curvature test cable' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam MassDenInAir EA BA EI GAs GJ Irt Irn '// & + 'Cd_n Cd_t Ca_n Ca_t' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (N-m2) (N) (N-m2) (kg-m) (kg-m) '// & + '(-) (-) (-) (-)' + WRITE (u, '(A)') 'bare 0.160 36.70 4.69e8 0.0 1.99e4 9.02e7 5.0e4 0.0587 0.1174 '// & + '1.2 0.1 1.0 0.0' + WRITE (u, '(A)') 'buoy 0.290 59.53 4.69e8 0.0 1.99e4 9.02e7 5.0e4 0.3129 0.6258 '// & + '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,3F14.8)') '1 Coupled ', pa + WRITE (u, '(A,3F14.8)') '2 Fixed ', pb + 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 68.114 56' + WRITE (u, '(A)') '1 buoy 50.000 40' + WRITE (u, '(A)') '1 bare 52.101 32' + 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)' + stiff_a = 'Rigid' + IF (PRESENT(pinned_a)) THEN + IF (pinned_a) stiff_a = 'Pinned' + END IF + WRITE (u, '(A,3F12.8,A,3F12.8,A)') '1 A '//TRIM(stiff_a)//' ', eza, ' Rigid ', nx, ' 0.0' + WRITE (u, '(A,3F12.8,A,3F12.8,F8.2)') '1 B Rigid ', ezb, ' Rigid ', nx, pretwist_b + ELSE + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A,3F12.8)') '1 A Rigid ', eza + END IF + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + WRITE (u, '(A)') '80.0 WtrDpth' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') MERGE('0.0 TMax', '1.0 TMax', nodes) + IF (NORM2(cu) > 0.0_wp) WRITE (u, '(A,3F12.8,A)') 'uniform ', cu, ' current' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + IF (nodes) THEN + DO j = 1, NSAMPLE + WRITE (u, '(A,I0,A,I0,A,I0)') 'Curv1N', 8*j - 7, ' CurvX1N', 8*j - 7, ' CurvY1N', 8*j - 7 + END DO + ELSE + WRITE (u, '(A)') '"FairTen1"' + END IF + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + END SUBROUTINE write_deck + + PURE FUNCTION turn(c, s, v) RESULT(w) + !! v turned about the vertical by the angle of cosine c and sine s. + REAL(wp), INTENT(IN) :: c, s, v(3) + REAL(wp) :: w(3) + w = [c*v(1) - s*v(2), s*v(1) + c*v(2), v(3)] + END FUNCTION turn + + 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 + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + WRITE (*, '(A,A)') 'MISMATCH: ', label + nfail = nfail + 1 + END IF + END SUBROUTINE require +END PROGRAM test_section_curvature diff --git a/tests/test_syrope_hydro.py b/tests/test_syrope_hydro.py new file mode 100644 index 00000000..a91597a2 --- /dev/null +++ b/tests/test_syrope_hydro.py @@ -0,0 +1,161 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Hydrodynamics of a Syrope polyester line against MoorDyn-C. + +A taut 88.5 m polyester line (D 0.203 m, 40 kg/m, 20 segments, Cd 1.2, Ca 1.0) from an anchor at +60 m depth to a fairlead at 20 m depth, 80 m away, with MoorDyn-C's linear working curve +(k1 1.25e8 N) over an OWC table T = 8.5e7 eps + 1.1e9 eps^2 N, alpha 1.53e8 N, beta 23.12, +BA_s|BA_d 5e10|1e5 N s and a SYROPE IC history (Tmax0 1.2 MN). The fairlead sways +2 sin(2 pi t/8) m across the line. MoorDyn-C v2.7.2 (RK2, dtM 5e-4 s; a driver that prescribes +the coupled point) gives a fairlead tension of 1 009 228.1 N at t = 0 and, over 24-40 s, a mean +of 1 029 671.6 N and a range of 44 782.4 N. Gates, CableDyn at dtM 0.01 s: + +* the fairlead tension at t = 0 and its mean over 24-40 s within 1e-5 of MoorDyn-C's, and its + range within 0.2 %; +* the line's drag and added mass act: without them (Cd = Ca = 0) the range grows by more + than 2 %; +* a cross current deflects the static start (mid-span 0.12 m) and holds the line still; +* VIV (Cl 0.8) in the current lifts the line (LINES Outputs flag V) and moves its tension; +* deck waves move the tension of the line held still. + +usage: test_syrope_hydro.py --exe --output

+""" + +from __future__ import annotations + +import argparse +import math +import os +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +MDC_T0, MDC_MEAN, MDC_RANGE = 1009228.1, 1029671.6, 44782.4 +FAILURES: list[str] = [] + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +def deck(hydro: str = "1.2 1.0 0.0 0.0", flags: str = "-", options: str = "", tmax: float = 40.0, + motion: bool = True) -> str: + return f"""--------------------- CableDyn Input File --- +Syrope polyester line with hydrodynamics +---------------------- LINE TYPES ---------------------------------- +LineType Diam MassDenInAir EA BA/-zeta EI Cd Ca CdAx CaAx +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +poly 0.203 40 SYROPE:syrope.dat|1.53e8|23.12 5.0e10|1.0e5 0.0 {hydro} +---------------------- POINTS -------------------------------------- +Node Type X Y Z M V CdA CA +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0 0 -60 0 0 0 0 +2 Coupled 80 0 -20 0 0 0 0 +---------------------- LINES --------------------------------------- +Line LineType NodeA NodeB UnstrLen NumSegs Outputs +(-) (-) (-) (-) (m) (-) (-) +1 poly 2 1 88.5 20 {flags} +---------------------- SYROPE IC ---------------------------------- +Line(s) Tmax0 Tmean0 +(-) (N) (N) +1 1.2e6 1.0313e6 +---------------------- OPTIONS ----------------------------------- +9.80665 g +1025 rhoW +100 WtrDpth +{options}0.01 dtM +{tmax} TMax +{"motion.txt motionFile" if motion else ""} +---------------------- OUTPUTS ----------------------------------- +FairTen1 +L1N11PY +END +---------------------- need this line ---------------------------- +""" + + +def run(exe: str, out: Path, name: str, text: str) -> tuple[list[str], np.ndarray] | None: + (out / f"{name}.dat").write_text(text, encoding="utf-8", newline="\n") + proc = subprocess.run([exe, f"{name}.dat", name], cwd=out, capture_output=True, text=True, + env=dict(os.environ, OMP_NUM_THREADS="1")) + check(proc.returncode == 0, f"{name}: the run completes (exit {proc.returncode})") + if proc.returncode != 0: + print(proc.stdout[-1500:], proc.stderr[-1500:]) + return None + return table(out / f"{name}.out") + + +def table(path: Path) -> tuple[list[str], np.ndarray]: + lines = path.read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.startswith("Time")) + data = np.array([[float(v) for v in line.split()] for line in lines[head + 1:] + if line.strip() and not line.lstrip().startswith("(")]) + return lines[head].split("\t"), data + + +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) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + eps = np.linspace(0.0, 0.06, 31) + (out / "owc.dat").write_text("Strain Tension\n(-) (N)\n" + "\n".join( + f"{e:.6e} {8.5e7 * e + 1.1e9 * e * e:.6e}" for e in eps)) + (out / "syrope.dat").write_text("owc.dat OWC\nLINEAR WCType\n1.25e8 k1\n0.0 k2\n") + w = 2.0 * math.pi / 8.0 + (out / "motion.txt").write_text("# time point x y z vx vy vz ax ay az\n" + "\n".join( + f"{k * 0.01:.6f} 2 80 {2 * math.sin(w * k * 0.01):.12e} -20 0 {2 * w * math.cos(w * k * 0.01):.12e} 0 " + f"0 {-2 * w * w * math.sin(w * k * 0.01):.12e} 0" for k in range(4001)) + "\n") + + sway = run(args.exe, out, "sway", deck()) + if sway: + t, ten = sway[1][:, 0], sway[1][:, sway[0].index("FairTen1")] + win = ten[(t >= 24.0) & (t <= 40.0)] + t0, mean, span = float(ten[0]), float(win.mean()), float(np.ptp(win)) + check(abs(t0 - MDC_T0) <= 1.0e-5 * MDC_T0, f"fairlead tension at t = 0: {t0:.1f} N, MoorDyn-C {MDC_T0} N") + check(abs(mean - MDC_MEAN) <= 1.0e-5 * MDC_MEAN, + f"mean fairlead tension over 24-40 s: {mean:.1f} N, MoorDyn-C {MDC_MEAN} N") + check(abs(span - MDC_RANGE) <= 2.0e-3 * MDC_RANGE, + f"fairlead tension range over 24-40 s: {span:.1f} N, MoorDyn-C {MDC_RANGE} N") + dry = run(args.exe, out, "sway_dry", deck(hydro="0.0 0.0 0.0 0.0")) + if dry: + td, tend = dry[1][:, 0], dry[1][:, dry[0].index("FairTen1")] + dspan = float(np.ptp(tend[(td >= 24.0) & (td <= 40.0)])) + check(dspan > 1.02 * span, f"without drag and added mass the range grows: {dspan:.1f} N against " + f"{span:.1f} N") + + current = "uniform 0.0 1.0 0.0 current\n" + cur = run(args.exe, out, "current", deck(options=current, tmax=10.0, motion=False)) + if cur: + y = cur[1][:, cur[0].index("L1N11PY")] + ten = cur[1][:, cur[0].index("FairTen1")] + check(y[0] > 0.1 and np.ptp(y) < 1.0e-6 and np.ptp(ten) < 1.0, + f"a 1 m/s cross current deflects the static start (mid-span {y[0]:.3f} m) and holds it") + viv = run(args.exe, out, "viv", deck(hydro="1.2 1.0 0.0 0.0 0.8", flags="V", options=current, tmax=20.0, + motion=False)) + if viv: + ten = viv[1][:, viv[0].index("FairTen1")] + names, lift = table(out / "viv.Line1.V.out") + lz = lift[:, names.index("Node11LiftZ(N)")] + check(lz.std() > 50.0 and ten.std() > 100.0, + f"VIV in the current: mid-span lift std {lz.std():.1f} N, fairlead tension std {ten.std():.1f} N") + waves = run(args.exe, out, "waves", deck(options="airy 4.0 8.0 0.0 waves\n", tmax=16.0, motion=False)) + if waves: + ten = waves[1][:, waves[0].index("FairTen1")] + check(ten.std() > 10.0, f"deck waves move the tension of the held line (std {ten.std():.1f} N)") + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) From acaaa1250e09c4a6bb424e0558d287d9e6d6c80e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 29 Oct 2026 20:22:57 +0900 Subject: [PATCH 17/51] feat(openfast): linearise the line dynamics, as MoorDyn-F (#66) * feat(openfast): linearise the line dynamics, as MoorDyn-F With Linearize = True the module now registers continuous states: the interior-node positions of every EI = 0 line (MoorDyn's names and order) and the free DOFs of every finite-EI cable (node positions and tangents), then their velocities. lin_eval loads a state and an input into the committed mirror, solves the accelerations without a time step and restores the committed state; CD_CalcContStateDeriv, CD_JacobianPContState and the input Jacobian central-difference it for A, B, C and D. This replaces the quasi-static linearisation without states. Positions, tangents and coupled-point displacements are stepped by 1 um: a millimetre step lifted a light cable's grounded nodes out of their 0.3 mm seabed penetration on one side of the difference, and the former 5 cm input step slackened a chain's last element, each halving a stiffness. Velocities take MoorDyn-F's 0.1 m/s, which gives the quadratic drag its equivalent linear damping. On the UMaine twin decks the reduction D - C A^-1 B matches MoorDyn-F's to 0.1 % per fairlead and on the platform 6x6, and the lowest nine line-mode frequencies to 0.3 %; both state matrices are stable. On the mixed deck with a lazy-wave power cable every coupled point matches central differences of the deck's own static solutions to 3.3e-4, also with a hang-off spring. openfast_lin_ab.py gates the frequencies, the stability and (with --cable-deck and --driver) the mixed deck, and solves an ill-conditioned A plainly instead of truncating it. A numeric-stiffness cable end connection now linearises. Free/Connect points and a Rigid cable end connection fail closed with named messages, as bodies, rods, Point3 buoys, torsion and CONTROL already did. Signed-off-by: Jae Hoon Seo * refactor(openfast): drop the quasi-static linearisation path Every Linearize call now takes the line-state branch of the input Jacobian, dXdu included only when the glue asks for it (a deck without line states has none), so quasistatic_dydu and its scratch-aggregate re-solves are unreachable and removed. Outside a linearisation run the input Jacobian is the runtime fixed-state derivative for any state count, and dXdu or a state Jacobian fails with a named message. The module comments no longer describe the zero-state reduction. Signed-off-by: Jae Hoon Seo * fix(openfast): linearise the rope models' constitutive states The viscoelastic slow-branch stretch dl_1 and the Syrope slow strain are dynamic states with their own rate laws, but the linearisation held them, so D - C A^-1 B gave these ropes' instantaneous stiffness instead of their relaxed static one. They are now first-order linearisation states (VF_DerivOrder1, "Line l segment e dl1, m" / "slow strain, -"): lin_eval loads them from x and writes their rates, which the new CD_Get_Model_Internal_Rates evaluates with the instantaneous element laws (the taut series-Kelvin ODE or the slack zero-load relaxation; the Syrope kernel at dt = 0). A viscoelastic variant of the UMaine chains (150 stretches) now matches its static solutions to 7e-5 (held: 0.6 % too stiff); a taut three-leg Syrope spread with a SYROPE IC history (60 slow strains) to 6e-6 (held: 2.9 times too stiff). The Syrope running maximum and the seabed-friction stick anchors stay held: load histories, whose operating-point values are the small-motion tangent. A line or cable with VIV fails closed: it oscillates about a lock-in cycle, not an equilibrium. The A/B script's static reference adds TMax = 0 to a deck that leaves TMax to the host. Signed-off-by: Jae Hoon Seo --------- Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 13 + VALIDATION.md | 37 +- doc/openfast.rst | 50 +- doc/troubleshooting.rst | 15 +- src/CableDyn_Model.f90 | 77 +++ src/CableDyn_System.f90 | 57 +- src/openfast/CableDyn_OF.f90 | 958 ++++++++++++++++++-------- validation/scripts/openfast_lin_ab.py | 221 +++++- 8 files changed, 1114 insertions(+), 314 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0404db5a..2622d9a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,19 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- 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 + velocities, with `A`, `B`, `C` and `D` by central differences of the accelerations solved at the + perturbed state. On the UMaine chains the stiffness `D - C A^-1 B` matches MoorDyn-F's to 0.1 % + and the lowest nine line-mode frequencies to 0.3 %; with a lazy-wave power cable every coupled + point matches the deck's own static solutions to 3e-4, also with a hang-off spring. A cable + end connection with a numeric stiffness now linearises. The viscoelastic slow-branch stretch + and the Syrope slow strain are first-order states, so the reduction gives these ropes' relaxed + static stiffness (each matches its deck's static solutions to 7e-5; held, they would read the + chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end + connection, VIV lines, bodies, rods, buoys, torsion and `CONTROL` fail closed with named + messages. This replaces the quasi-static linearisation without states. - 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/VALIDATION.md b/VALIDATION.md index af80d954..6f4db7d2 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -372,13 +372,32 @@ scripts, results, and source provenance are in ([`validation/scripts/openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)): the twin decks linearise once at t = 0. Each run has platform DOFs only, still water, and HydroDyn `ExctnMod = RdtnMod = 0`. MoorDyn's relaxation runs for `TmaxIC = 400 s`, and both `.lin` files are - written with `OutFmt = ES24.15E3`. CableDyn's quasi-static `dYdu` (no states) is compared with - MoorDyn's zero-frequency reduction `D − C A⁻¹ B` over 882 states. The per-fairlead stiffness agrees - to **0.07–0.10%** (line 1: 49 741 / 49 706 N/m in-plane horizontal) and the transverse `H/X` term - to 0.29%. The platform 6×6 diagonals agree to **≤0.10%** (surge 77 211 / 77 156 N/m, - roll 2.6473e8 / 2.6466e8 N·m/rad), and every entry to ≤1.0e-3 of √(KᵢᵢKⱼⱼ). Standalone CableDyn - static solves reproduce the block by finite differences to 1.5e-5, and its transverse term equals - the analytic `H/X`. Both 50-segment models sit 7–12% above the continuous elastic catenary + written with `OutFmt = ES24.15E3`. Both codes linearise the line dynamics over the same 882 states + (each interior node's position and velocity, in MoorDyn's layout and names), and their + zero-frequency reductions `D − C A⁻¹ B` are compared. The per-fairlead stiffness agrees to + **≤0.10%** (line 1: 49 741 / 49 706 N/m in-plane horizontal) and the transverse `H/X` term to 0.29%. + The platform 6×6 diagonals agree to **≤0.10%** (surge 77 211 / 77 156 N/m, roll 2.6473e8 / + 2.6466e8 N·m/rad), and every entry to ≤1.1e-3 of √(KᵢᵢKⱼⱼ). Standalone CableDyn static solves + reproduce the block by finite differences to 1e-5, and its transverse term equals the analytic + `H/X`. Both state matrices are stable, and the lowest nine line modes agree in frequency to + **0.04–0.30%** (CableDyn's consistent mass against MoorDyn's lumped mass). The damping ratios are + half MoorDyn's: both difference the quadratic drag over ±0.1 m/s, and CableDyn's drag, integrated + over the element, gives half the slope for a one-node perturbation. A mixed deck + (`examples/iea15mw_umaine_mixed_cabledyn.dat`, seabed friction off) adds 2976 states of the + lazy-wave power cable (positions and tangents of its free nodes, and their rates). Every coupled + point's linearised stiffness equals central differences of the deck's own static solutions to + ≤3.3e-4, the cable's 36.0 / 2.62 / 38.5 N/m included, and also with a 5e4 N·m/rad hang-off spring. + Two step sizes had to be small. A millimetre position step lifted the cable's grounded nodes out + of their 0.3 mm seabed penetration on one side of the difference, and a 5 cm coupled-point step + slackened the chain's last element. Each halved a stiffness (the cable's sway stiffness read 242 + instead of 2.6 N/m). States and inputs now take 1 µm. The rope models' constitutive states are + first-order states, checked the same way against each deck's static solutions. A viscoelastic + variant of the UMaine chains (`EA 3.27e9|6.54e9`, 150 slow-branch stretches) matches to 7e-5; + held, the stretches would read the chain 0.6 % too stiff. A taut three-leg Syrope polyester + spread with a `SYROPE IC` history (60 slow strains) matches to 6e-6, where held slow strains + would read it 2.9 times too stiff. With every element on one segment of the working-curve + table, the single-secant static start is exact; legs straddling a table kink differ by 2 %, + because that static start takes one secant for the whole line. Both 50-segment models sit 7–12% above the continuous elastic catenary because of the touchdown discretisation; refining to 800 segments converges to it within 0.1%. MoorDyn's reduction needs the full-precision `OutFmt`. With the usual `ES10.3E2` (4 digits), `D ≈ 1e8 N/m` cancels to a ~1e4 N/m result and the block is 57% asymmetric with sign-flipped @@ -489,7 +508,7 @@ sizes, timing ranges, memory, Newton work, and the OrcaFlex mesh sweep are in remeshing), on the development workstation. Each binary output has exactly 144,001 rows from 600 s to 4200 s with 47 channels. The OpenFAST runtime Jacobian is the fixed-state direct-feedthrough derivative; formal linearisation - uses the re-equilibrated quasi-static stiffness. + differentiates the line dynamics with the line states registered. ### Numerical robustness @@ -780,7 +799,7 @@ stop with a named error. | Correction iterations (`NumCrctn > 0`) | Pass verified | bit-identical to own `NumCrctn = 0` run | | SeaState wave/current kinematics | Pass verified | wave A/B ≤0.16% of range | | Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0; also with supercycling (`dtM` > `DT`, the held SeaState fields and the predictor loads checkpointed): IEA-15 VolturnUS-S, turbulent wind and JONSWAP sea, `openfast -restart` at 50 s reproduces every later OpenFAST and `.CD.out` row of the chain mooring at `dtM` = 4 `DT` (extrapolated and held loads) and `DT`, and of the chain + 248-element power-cable mooring at `dtM` = 2 `DT`. A finite-EI cable also checkpoints its committed boundary (held DOFs, end-connection directions, vessel frame): before, the rebuild took its fairlead from the restored input mesh, which differs in the last bits, and on the IEA-15 mixed deck restarted at 6 s the lazy-wave cable's `.CD.out` channels drifted by up to 9.4e-7 (relative) within 4 s; now all rows to 10 s match bit for bit at `dtM` = `DT` and 2 `DT`, `NumCrctn` 0 and 1, and with a rigid fairlead END CONNECTIONS row | -| Linearisation | Pass verified (quasi-static stiffness) | quasi-static `dYdu` compared entry by entry with stock MoorDyn's zero-frequency reduction `D − C A⁻¹ B` (full-precision `.lin` output): fairlead stiffness 0.07–0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; standalone static FD 1.5e-5; transverse term equals `H/X`. Velocity/acceleration columns are zero by design ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)) | +| Linearisation | Pass verified (line dynamics) | line states as MoorDyn-F's (882 on the UMaine chains); zero-frequency reduction `D − C A⁻¹ B` compared entry by entry with stock MoorDyn's (full-precision `.lin` output): fairlead stiffness ≤0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; lowest nine line-mode frequencies 0.04–0.30%, both state matrices stable; a mixed deck with a lazy-wave power cable (2976 cable states) matches its own static solutions at every coupled point to ≤3.3e-4, also with a hang-off spring ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)) | | FAST.Farm shared moorings + clumps + channel record | Pass verified | 600 s A/B of the r-test `MD_Shared` farm against stock MoorDyn (same deck, analysis from 100 s; [`fastfarm_shared_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/fastfarm_shared_ab.py)): tension means ≤0.02%, minima and maxima ≤0.25%, platform motions within millimetres and 0.001°; shared-line tension std 2.2–2.7% lower, 1.0% at half the mooring step (CableDyn's implicit step at the 0.05 s coupling step against MoorDyn's 1e-4 s explicit step). On the shared lines, which have no Fixed end, `FairTen`/`AnchTen` name the opposite ends from MoorDyn's (see the migration guide). MoorDyn's initial settling does not converge for the anchor legs 6 and 7 (2.4 m excess length at t = 0), a start-up transient over by 100 s that most likely set the 3% end of the earlier 60 s record | | Slack-line tension convention | Pass verified | tension-only dynamics; BA on slack lines matches `MoorDyn_Line.f90` | | Farm + restart / Farm + linearisation | Not applicable | FAST.Farm has no restart and does not call module linearisation; the same applies to stock MoorDyn | diff --git a/doc/openfast.rst b/doc/openfast.rst index 6ddf88dd..abfe73cc 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -326,8 +326,9 @@ hang-off the declared direction is given in platform axes and follows the OpenFA orientation; its angular velocity and acceleration enter the implicit residual and tangent, and the connection moment is returned to OpenFAST. Fixed-end directions are global. A rigid direction reversal of exactly 180° in one host update is rejected, because the shortest rotation -is not unique. Formal linearisation (``Linearize = True``) with a platform-relative end -connection fails during initialisation. Row grammar: :doc:`driver_format`. +is not unique. Formal linearisation (``Linearize = True``) supports pinned and numeric-stiffness +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`. Line torsion ------------ @@ -413,15 +414,48 @@ without an auxiliary process: Each is a separate qualification: a successful ordinary run does not qualify restart, linearisation, control, failure, or farm behaviour for a new model. -Two different Jacobians -~~~~~~~~~~~~~~~~~~~~~~~ +Jacobians +~~~~~~~~~ During time marching, the OpenFAST input–output solver asks for the instantaneous output derivative with the cable state frozen; CableDyn evaluates it by symmetric perturbation of the -coupled input while preserving the committed state. In a ``Linearize = True`` run CableDyn -registers no dynamic states and reports the re-equilibrated quasi-static stiffness instead. -These are different derivatives and must not be interchanged. ``NumCrctn`` controls glue -correction passes; it does not change which derivative is used. +coupled input while preserving the committed state. A ``Linearize = True`` run differentiates the +line dynamics themselves (`Linearisation`_). ``NumCrctn`` controls glue correction passes; it does +not change which derivative is used. + +Linearisation +~~~~~~~~~~~~~ + +With ``Linearize = True`` CableDyn linearises the line dynamics, as MoorDyn-F does. The continuous +states are the positions of every ``EI = 0`` line's interior nodes and of every finite-EI cable's +free degrees of freedom (node positions and tangents ``m = dr/ds``), followed by their velocities. +``EI = 0`` states carry MoorDyn's names and order (``Line 1 node 1 Px, m`` … ``Vz, m/s``); a cable's +are named ``Cable 1 node 2 Px, m``, ``Cable 1 node 2 Tx, -`` (tangent) and ``Cable 1 node 2 dTx, +1/s`` (its rate), with node 1 at End A. The matrices ``A``, ``B``, ``C`` and ``D`` are central +differences: at each perturbed state or input, the accelerations are solved without a time step. +Positions, tangents and coupled-point displacements are stepped by 1 µm, which stays inside the +seabed penetration of a light cable and the stretch of every taut element. Velocities are stepped +by 0.1 m/s, MoorDyn-F's step. + +The zero-frequency reduction ``D − C A⁻¹ B`` is the static mooring stiffness. It agrees with +MoorDyn-F and with CableDyn's own static solutions (:doc:`validation`). Quadratic drag has no +slope at rest, so the 0.1 m/s step gives its equivalent linear damping at that velocity amplitude. +CableDyn integrates the drag over the element, and a one-node step then gives about half of +MoorDyn-F's lumped value. + +The constitutive states of the rope models are first-order states, named ``Line 1 segment 3 dl1, +m`` and ``Line 1 segment 3 slow strain, -`` (elements counted from End B, as the nodes): each +viscoelastic element's slow-branch stretch and each Syrope element's slow strain, differentiated +through their own laws. ``D − C A⁻¹ B`` then gives the relaxed static stiffness of these ropes, +not their instantaneous one. Two load histories are held at their operating-point values: the +Syrope running maximum (small motions below it stay on its working curve) and the seabed-friction +stick anchors (a stuck laid run). Linearise from a settled operating point, such as the still-water +start at ``t = 0``. + +Initialisation fails with a named message for Free and Connect points, Point3 buoys, Rigid6 bodies +and rods, a line restrained in torsion, a line with VIV (``Cl > 0``: it oscillates about a lock-in +cycle, not an equilibrium), a ``CONTROL`` section, a cable with a ``Rigid`` end connection, and +FAST.Farm. Their states are not linearisation states. Time-domain runs support all of them. Performance ----------- diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 14cfbfc4..5125a222 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -403,8 +403,8 @@ Torsion FAST.Farm run, add a body (such a deck runs on the multibody route, which supports torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. * - ``formal OpenFAST linearization of a line restrained in torsion is not supported`` - - linearise the model with ``TorsStiffness Free``; the torque's rotational stiffness is not - part of the quasi-static reduction. + - linearise the model with ``TorsStiffness Free``; the twist and the torque carry no + linearisation state. * - ``torsion: the twist would move more than pi/2 from its committed value`` - the host turned a fairlead by more than 90° about the line's end direction without a step (an output probe or a non-stepping input update). Keep the platform turn per @@ -846,10 +846,13 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com * - a finite-EI cable in the same deck as Rigid6 bodies, rods, or ``Connect``/``Free`` points - model the cable and the body/point system in separate decks or use the supported combinations in :doc:`capabilities` - * - OpenFAST linearisation with a platform-relative cable ``END CONNECTIONS`` row - (``formal OpenFAST linearization with a platform-relative cable end connection is not - supported``) or with a ``CONTROL`` section - - linearise a pinned-hang-off, uncontrolled variant of the deck; time-domain runs support both + * - OpenFAST linearisation of a cable with a ``Rigid`` ``END CONNECTIONS`` row (``formal + OpenFAST linearization of a cable with a rigid end connection is not supported``), of a deck + with ``Free`` or ``Connect`` points or a line with VIV (``Cl > 0``), or with a ``CONTROL`` + section + - linearise a variant with a numeric rotational stiffness at the hang-off, the lines attached to + ``Fixed`` or ``Coupled`` points, ``Cl = 0`` and no ``CONTROL`` section; time-domain runs + 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``) diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 3c864f75..90d7b613 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -98,6 +98,7 @@ MODULE CableDyn_Model PUBLIC :: CD_Latch_Model_VIV_Window PUBLIC :: CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Model_Has_VIV, CD_Get_Model_VIV_Lift PUBLIC :: CD_Get_Model_Tension + PUBLIC :: CD_Get_Model_Internal_Rates PUBLIC :: CD_Get_Model_EndForces PUBLIC :: CD_Get_Model_EndNodeMassDiag PUBLIC :: CD_Get_Model_EndNodeAddedMass @@ -5577,6 +5578,82 @@ SUBROUTINE CD_Get_Model_Tension(model, tension, ErrStat, ErrMsg) CALL model_law_tensions(model, tension, ErrStat, ErrMsg) END SUBROUTINE CD_Get_Model_Tension + SUBROUTINE CD_Get_Model_Internal_Rates(model, ve_rate, syrope_rate, ErrStat, ErrMsg) + !! The rates of the per-element constitutive states at the model's current q, v and states, + !! as the instantaneous (dt = 0) element loads evaluate them: the viscoelastic slow-branch + !! stretch d(dl_1)/dt (its taut ODE, or the zero-load relaxation of a slack element) and the + !! Syrope slow strain d(eps_slow)/dt; zero on the other elements. + TYPE(CD_ModelType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: ve_rate(:), syrope_rate(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + INTEGER :: e, idx(6), es + REAL(wp) :: q2(6), v2(6), chord(3), tang(3), length, lstrd, dl, bsum, ld1, ea_d_eff, ea_1_eff + REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC), f6(6), jq6(6, 6), t_mean, dslow + REAL(wp) :: slow_at + CHARACTER(200) :: em + + ve_rate = CD_ZERO + syrope_rate = CD_ZERO + ErrStat = CD_MODEL_OK + ErrMsg = '' + IF (.NOT. model%initialized) THEN + ErrStat = CD_MODEL_NOT_INITIALIZED + ErrMsg = 'CableDyn_Model: model is not initialized' + RETURN + END IF + IF (SIZE(ve_rate) /= model%n_elem .OR. SIZE(syrope_rate) /= model%n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'internal-rate outputs must have shape (n_elem)') + RETURN + END IF + IF (model%has_viscoelastic) THEN + DO e = 1, model%n_elem + IF (model%ve_mode(e) == 0) CYCLE + CALL model_viscoelastic_coeffs(model, e, ea_d_eff, ea_1_eff, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODEL_OK) RETURN + CALL extract_element_state(model, e, model%q, model%v, idx, q2, v2) + chord = q2(4:6) - q2(1:3) + length = NORM2(chord) + IF (length <= CD_VISCO_TINY_LEN) THEN + CALL fail(ErrStat, ErrMsg, 'viscoelastic element collapsed to zero length') + RETURN + END IF + tang = chord/length + lstrd = DOT_PRODUCT(tang, v2(4:6) - v2(1:3)) + dl = length - model%l0(e) + bsum = model%ve_ba_d(e) + model%ve_ba(e) + ! the taut series-Kelvin ODE; a slack chain (tension max(MagT + MagTd, 0) = 0) + ! relaxes under zero load, BA*ld_1 + EA_1*dl_1 = 0, as the element load's switch + ld1 = (ea_d_eff*dl - (ea_d_eff + ea_1_eff)*model%ve_dl_1(e) + model%ve_ba_d(e)*lstrd)/bsum + IF (ea_1_eff*model%ve_dl_1(e)/model%l0(e) + model%ve_ba(e)*ld1/model%l0(e) < CD_ZERO) THEN + ld1 = CD_ZERO + IF (model%ve_ba(e) > CD_ZERO) ld1 = -ea_1_eff*model%ve_dl_1(e)/model%ve_ba(e) + END IF + ve_rate(e) = ld1 + END DO + END IF + IF (model%has_syrope) THEN + DO e = 1, model%n_elem + IF (.NOT. model%syrope_is(e)) CYCLE + CALL extract_element_state(model, e, model%q, model%v, idx, q2, v2) + CALL CD_Syrope_Working_Curve(model%syrope_type(e), model%syrope_tmax(e), ws, wt, wsl, es, em) + IF (es /= CD_SYROPE_OK) THEN + CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN + END IF + slow_at = CD_Syrope_Branch_Divider(model%syrope_type(e), model%syrope_tmax(e)) + CALL CD_Syrope_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), model%syrope_type(e), & + ws, wt, wsl, model%syrope_slow(e) < slow_at, model%syrope_slow(e), & + model%tension_only, f6, jq6, t_mean, dslow, es, em, dt=CD_ZERO, & + divider=slow_at) + IF (es /= CD_SYROPE_OK) THEN + CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN + END IF + syrope_rate(e) = dslow + END DO + END IF + END SUBROUTINE CD_Get_Model_Internal_Rates + SUBROUTINE model_law_tensions(model, tension, ErrStat, ErrMsg) !! Overwrite the entries of the viscoelastic and Syrope elements of tension (n_elem) with !! their law's tension at the committed state (CD_Get_Model_Tension); the other entries diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index cb3b130a..87760f8a 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -14,7 +14,7 @@ MODULE CableDyn_System USE CableDyn_Model, ONLY: CD_ModelType, CD_Model_Is_Initialized, CD_End_Model, & CD_Model_NCoupledDOF, CD_Model_NDOF, CD_Model_NElem, & CD_Get_Model_CoupledDofs, CD_Get_Model_CoupledMotion, & - CD_Get_Model_State, CD_Get_Model_Tension, & + CD_Get_Model_State, CD_Get_Model_Tension, CD_Get_Model_Internal_Rates, & CD_Model_Has_Viscoelastic, CD_Get_Model_VE_Dl1, CD_Set_Model_VE_Dl1, & CD_Model_Has_Syrope, CD_Get_Model_Syrope_State, CD_Set_Model_Syrope_State, & CD_Model_Has_VIV, CD_Get_Model_VIV_State, CD_Set_Model_VIV_State, CD_Get_Model_VIV_Lift, & @@ -85,6 +85,8 @@ MODULE CableDyn_System PUBLIC :: CD_Get_System_Point_State PUBLIC :: CD_Get_System_Line_State PUBLIC :: CD_Get_System_Line_Tension + PUBLIC :: CD_Get_System_Line_Stretch + PUBLIC :: CD_Get_System_Line_Internal_Rates PUBLIC :: CD_Get_System_CoupledMotion PUBLIC :: CD_Update_System_CoupledMotion PUBLIC :: CD_Update_System_Point_States @@ -1149,6 +1151,59 @@ SUBROUTINE CD_Get_System_Line_Tension(system, line_index, tension, ErrStat, ErrM ErrMsg = '' END SUBROUTINE CD_Get_System_Line_Tension + SUBROUTINE CD_Get_System_Line_Stretch(system, line_index, stretch, ErrStat, ErrMsg) + !! Copy the element stretches of one contained line: each element's current chord length + !! minus its unstretched length (negative on a slack element). + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + REAL(wp), INTENT(OUT) :: stretch(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + INTEGER :: e, na, nb + + stretch = CD_ZERO + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + ASSOCIATE (ln => system%lines(line_index)) + IF (SIZE(stretch) /= ln%n_elem) THEN + CALL fail(ErrStat, ErrMsg, 'stretch output must have shape (n_elem)') + RETURN + END IF + DO e = 1, ln%n_elem + na = ln%elem_conn(1, e) + nb = ln%elem_conn(2, e) + stretch(e) = NORM2(ln%q(3*nb - 2:3*nb) - ln%q(3*na - 2:3*na)) - ln%l0(e) + END DO + END ASSOCIATE + END SUBROUTINE CD_Get_System_Line_Stretch + + SUBROUTINE CD_Get_System_Line_Internal_Rates(system, line_index, ve_rate, syrope_rate, ErrStat, ErrMsg) + !! The per-element constitutive-state rates of one contained line at its current state + !! (CD_Get_Model_Internal_Rates). + TYPE(CD_SystemType), INTENT(IN) :: system + INTEGER, INTENT(IN) :: line_index + REAL(wp), INTENT(OUT) :: ve_rate(:), syrope_rate(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + INTEGER :: es + CHARACTER(1024) :: em + + ve_rate = CD_ZERO + syrope_rate = CD_ZERO + CALL validate_line_index(system, line_index, ErrStat, ErrMsg) + IF (ErrStat /= CD_SYSTEM_OK) RETURN + CALL CD_Get_Model_Internal_Rates(system%lines(line_index), ve_rate, syrope_rate, es, em) + IF (es /= CD_MODEL_OK) THEN + ErrStat = CD_SYSTEM_SOLVEFAIL + ErrMsg = 'CableDyn_System: line internal-rate query failed: '//TRIM(em) + RETURN + END IF + ErrStat = CD_SYSTEM_OK + ErrMsg = '' + END SUBROUTINE CD_Get_System_Line_Internal_Rates + SUBROUTINE CD_Get_System_CoupledMotion(system, q_coupled, v_coupled, a_coupled, ErrStat, ErrMsg) !! Copy aggregate compact coupled motion, concatenated line by line. TYPE(CD_SystemType), INTENT(IN) :: system diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 9c29dee5..14916202 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -52,12 +52,16 @@ MODULE CableDyn !! wave/current kinematics sampled at the line nodes (single-turbine only; see the !! farm scope at the use_extf guard), checkpoint restart (rebuild from the packed !! deck + state mirror, accepted on committed mooring-interval boundaries), - !! linearization (quasi-static dYdu only -- no dynamic state linearization; the - !! module registers zero continuous states and CD_CalcContStateDeriv stays fatal - !! by design), and FAST.Farm farm-level moorings (FarmSize > 0: Turbine decks, + !! linearization with the line dynamics (as MoorDyn-F: the continuous states are the + !! EI=0 lines' interior-node positions and the finite-EI cables' free DOFs, positions + !! and tangents, then their velocities, and the rope models' constitutive states; A, B, C + !! and D by central differences of lin_eval, the accelerations and state rates evaluated + !! at the perturbed state; Free/Connect points, VIV lines, bodies, rods, Point3 buoys, + !! torsion, CONTROL and rigid cable ends fail closed), and + !! FAST.Farm farm-level moorings (FarmSize > 0: Turbine decks, !! per-turbine coupled meshes, shared lines; still-water hydro; farm restart and - !! farm linearization fail closed with named messages). Checkpoint restart and - !! linearization re-parse a temporary copy of the deck, written next to the + !! farm linearization fail closed with named messages). Checkpoint restart re-parses a + !! temporary copy of the deck, written next to the !! MooringFile (so its side files resolve as in the original run) and removed after !! use. !! @@ -94,7 +98,7 @@ MODULE CableDyn USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & CD_HFMF_FrictionMirrorSize, CD_HFMF_BoundaryMirrorSize, & CD_HFMF_ForceMirrorSize, CD_HFMF_TorsionMirrorSize, CD_HFMF_VIVMirrorSize, & - CD_HFMF_OK + CD_HFMF_Refresh_Acceleration, CD_HFMF_OK USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -104,6 +108,8 @@ MODULE CableDyn USE CableDyn_LoadPredictor, ONLY: CD_Predictor_Ready, CD_Predictor_Fraction, CD_Predict_Loads USE CableDyn_Profile, ONLY: CD_Profile_Arm, CD_Profile_Disarm, CD_Profile_Kernels, CD_PROF_K_RESIDUAL, & CD_PROF_K_TANGENT, CD_PROF_K_FACTOR, CD_PROF_K_SOLVE, CD_PROF_NKERNEL + USE CableDyn_System, ONLY: CD_Get_System_Line_Stretch, CD_Get_System_Line_Internal_Rates + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_System_Line_NElem, & CD_Get_System_DynamicPoint_States, CD_Set_System_DynamicPoint_States, & CD_System_NSystemCoupledDOF, CD_Get_System_CoupledMotion, & @@ -126,6 +132,9 @@ MODULE CableDyn PRIVATE + ! the kinds of first-order linearization state (lin_state_map) + INTEGER(IntKi), PARAMETER :: LIN1_VE = 1, LIN1_SYROPE = 2 + TYPE(ProgDesc), PARAMETER :: CableDyn_ProgDesc = ProgDesc( 'CableDyn', 'v0.3.0', '2026-10-23' ) INTERFACE ! 1 when the CableDyn core targets x86-64-v3 (CABLEDYN_TARGET_AVX2) and carries the @@ -192,6 +201,16 @@ END FUNCTION cd_cpu_guard_armed ! restored after (the boundary-only restore recomputes interior accelerations, ! which are gen-alpha COMMITTED values, not (q, v)-derivable) REAL(R8Ki), ALLOCATABLE :: ws_msave(:) + ! Linearization with the line dynamics (lin_state_map): for every state, its position, + ! velocity and acceleration slots in the x%states mirror, and the mirror save/work + ! buffers of lin_eval + LOGICAL :: lin_states = .FALSE. + INTEGER(IntKi), ALLOCATABLE :: lin_pos(:), lin_vel(:), lin_acc(:) + ! the first-order linearization states, the per-element constitutive states of the + ! EI = 0 lines: mirror slot, line, element and kind (LIN1_VE: the viscoelastic slow-branch + ! stretch dl_1; LIN1_SYROPE: the Syrope slow strain) + INTEGER(IntKi), ALLOCATABLE :: lin1_slot(:), lin1_line(:), lin1_elem(:), lin1_kind(:) + REAL(R8Ki), ALLOCATABLE :: ws_lsave(:), ws_lwork(:) ! FAST.Farm: turbine count (0 = plain single-turbine mode), the driving turbine ! per flat aggregate moving slot, that slot's node index within its turbine's ! mesh, the farm-layout reference offsets, and the per-turbine PtfmInit. @@ -562,16 +581,9 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er 'not supported (linearize single-turbine cases).', ErrStat, ErrMsg, RoutineName ) RETURN END IF - ! Linearize is accepted for the established force-only boundary: the module presents - ! the MAP-shaped reduction -- ZERO - ! continuous-state variables (CD_InitVars) and a QUASI-STATIC dYdu whose - ! displacement columns come from scratch-aggregate static re-solves at the - ! perturbed boundary (each init IS a static solve), so the linearized mooring - ! is the re-equilibrated stiffness, not the frozen-interior response - ! (CD_JacobianPInput). Velocity/acceleration/orientation columns are zero: - ! frequency-dependent mooring damping is not representable without states. A - ! platform-relative cable end connection is rejected after deck construction below, - ! because it introduces orientation-dependent force and moment columns. + ! Linearize registers the line states (CD_InitVars, lin_state_map) and differentiates the + ! line dynamics (lin_eval); the objects whose states are not linearization states are + ! rejected after deck construction below. IF (.NOT. InitInp%UsePrimaryInputFile) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: passed-in primary input data is not '// & 'supported; provide the MoorDyn-format deck as a file.', ErrStat, ErrMsg, RoutineName ) @@ -779,46 +791,77 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) RETURN END IF - ! Rigid6 bodies and rods carry their own degrees of freedom, but the quasi-static - ! linearization re-solves only the line and point equilibrium at each perturbed - ! boundary and holds them at their deck pose, so its dYdu would silently omit - ! their compliance. Fail closed until body-state linearization exists. + ! Rigid6 bodies and rods carry their own degrees of freedom, which are not linearization + ! states (the states are the line and cable DOFs): the linearization would hold them + ! where they are and omit their compliance. Fail closed until body-state linearization + ! exists. IF (InitInp%Linearize .AND. (CD_AGG_HasRigid6( Inst(id)%agg ) .OR. CD_AGG_HasRod( Inst(id)%agg ))) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & - 'with Rigid6 bodies or RODs is not supported; the quasi-static reduction '// & - 'holds them at their deck pose instead of re-solving their equilibrium '// & - '(linearize a deck without BODIES/RODS).', ErrStat, ErrMsg, RoutineName ) + 'with Rigid6 bodies or RODs is not supported; their states are not '// & + 'linearization states (linearize a deck without BODIES/RODS).', & + ErrStat, ErrMsg, RoutineName ) RETURN END IF - ! A Point3 buoy steps as a Free point, but the static solve holds it at its deck position: - ! each perturbed re-solve would leave it there and omit its compliance as well. + ! A Point3 buoy steps as a Free point with its own state, which is not a linearization + ! state either. IF (InitInp%Linearize .AND. CD_AGG_HasPoint3( Inst(id)%agg )) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & - 'with Point3 buoys is not supported; the quasi-static reduction holds a '// & - 'Point3 buoy at its deck position instead of re-solving its equilibrium '// & - '(model the buoy as a Free point to linearize).', ErrStat, ErrMsg, RoutineName ) + 'with Point3 buoys is not supported; their states are not linearization '// & + 'states.', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + ! A Free/Connect point steps with its own state through the implicit point-line coupling; + ! the linearization states are the line and cable DOFs only, so the point would be held + ! where it is and its compliance omitted. + ! A line with VIV oscillates about a lock-in limit cycle, not about an equilibrium, and its + ! shedding phase and running mean squares are not linearization states either. + IF (InitInp%Linearize) THEN + DO il = 1, Inst(id)%nlines + IF (CD_System_Line_VIV_MirrorSize( Inst(id)%agg%sys%fast%system, il ) > 0) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'of a line with VIV (LINE TYPES Cl > 0) is not supported; set Cl = 0 to '// & + 'linearize.', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + END DO + DO ic = 1, Inst(id)%agg%ncable + IF (Inst(id)%agg%cables(ic)%line%has_viv) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'of a cable with VIV (LINE TYPES Cl > 0) is not supported; set Cl = 0 to '// & + 'linearize.', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + END DO + END IF + IF (InitInp%Linearize .AND. CD_AGG_NDynamicPoints( Inst(id)%agg ) > 0) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'with Free or Connect points is not supported; their states are not '// & + 'linearization states (attach the lines to Fixed or Coupled points to '// & + 'linearize).', ErrStat, ErrMsg, RoutineName ) RETURN END IF IF (InitInp%Linearize .AND. Inst(id)%agg%ncable > 0) THEN DO ic = 1, Inst(id)%agg%ncable + ! a rigid end connection holds the end tangent on the parent's direction, so only + ! its axial part is a degree of freedom, which the global-component states cannot + ! carry + IF (ANY(Inst(id)%agg%cables(ic)%line%endconn_mode == CD_ENDCONN_RIGID)) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & + 'of a cable with a rigid end connection is not supported (use a '// & + 'finite rotational stiffness in END CONNECTIONS to linearize).', & + ErrStat, ErrMsg, RoutineName ) + RETURN + END IF ! a line restrained in torsion returns a torque moment that turns with the platform ! even at a bending-pinned end: its rotational stiffness a a^T / C has no column in ! the translation-only reduction either IF (Inst(id)%agg%cables(ic)%line%torsion%active) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & - 'of a line restrained in torsion is not supported; the torque''s '// & - 'orientation and moment Jacobian columns are not part of the current '// & - 'quasi-static reduction (set TorsStiffness Free to linearize).', & + 'of a line restrained in torsion is not supported: its condensed torque '// & + 'carries no state of its own (set TorsStiffness Free to linearize).', & ErrStat, ErrMsg, RoutineName ) RETURN END IF - IF (.NOT. Inst(id)%agg%cables(ic)%has_parent_endconn) CYCLE - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & - 'with a platform-relative cable end connection is not supported; '// & - 'the required orientation and connection-moment Jacobian columns '// & - 'are not part of the current quasi-static reduction.', & - ErrStat, ErrMsg, RoutineName ) - RETURN END DO END IF CALL CD_AGG_GetInitMetadata( Inst(id)%agg, nreportlines, npoints, nsections, nei0, nfinite, es, em ) @@ -1215,6 +1258,11 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er CALL CD_InitVars( InitOut%Vars, u, p, x, y, m, Inst(id), InitInp%Linearize, ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN + IF (InitInp%Linearize) THEN + CALL lin_state_map( Inst(id), m, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + END IF ! The time history contains the selected deck channels and is therefore opened only ! when nch > 0. The static profile, unconditional and covering every line node @@ -2645,16 +2693,315 @@ SUBROUTINE CD_CalcContStateDeriv( t, u, p, x, xd, z, other, m, dxdt, ErrStat, Er CHARACTER(*), INTENT( OUT) :: ErrMsg character(*), parameter :: RoutineName = 'CD_CalcContStateDeriv' + INTEGER(IntKi) :: ErrStat2 + CHARACTER(ErrMsgLen) :: ErrMsg2 ErrStat = ErrID_None ErrMsg = '' - ! Only the linearization/GetOP paths reach this routine (the module marches - ! implicitly through UpdateStates). CableDyn exposes no continuous states. - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: continuous-state derivatives are part of '// & - 'the linearization surface; CableDyn exposes no continuous states to OpenFAST.', & - ErrStat, ErrMsg, RoutineName ) + ! Only the linearization/GetOP paths reach this routine (the module marches implicitly + ! through UpdateStates): dx/dt of the linearization states (lin_eval). + IF (.NOT. Inst(m%CDInst)%lin_states) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: continuous-state derivatives exist only '// & + 'for a linearization run (Linearize = True).', ErrStat, ErrMsg, RoutineName ) + RETURN + END IF + CALL lin_eval( m%CDInst, p, m, u, x, ErrStat2, ErrMsg2, dxdt=dxdt ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) END SUBROUTINE CD_CalcContStateDeriv +!---------------------------------------------------------------------------------------------------------------------------------- + SUBROUTINE lin_state_map( inst_e, m, ErrStat, ErrMsg ) + !! The x%states mirror slots of the linearization states (CD_InitVars under Linearize): for + !! every interior DOF of an EI = 0 line and every free DOF of a finite-EI cable, the slot of + !! its position, of its velocity and of its acceleration (lin_pos, lin_vel, lin_acc), and the + !! mirror buffers of lin_eval. + TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_e + TYPE(CD_MiscVarType), INTENT(IN) :: m + INTEGER(IntKi), INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER(IntKi) :: il, ic, ndofl, nin, nf, csz, koff, n, k, j, es, n1, k1, kind + CHARACTER(ErrMsgLen) :: em + LOGICAL, ALLOCATABLE :: mask(:) + + ErrStat = ErrID_None + ErrMsg = '' + n = 0 + DO il = 1, inst_e%nlines + ndofl = CD_System_Line_NDOF( inst_e%agg%sys%fast%system, il, es, em ) + IF (es /= CD_SYSTEM_OK) THEN + CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, 'lin_state_map' ); RETURN + END IF + n = n + ndofl - 6 + END DO + DO ic = 1, inst_e%agg%ncable + IF (CD_HFMF_MirrorSize( inst_e%agg%cables(ic) ) <= 0) CYCLE + n = n + COUNT(inst_e%agg%cables(ic)%line%freemask) + END DO + ! the constitutive states: every viscoelastic and Syrope element, the per-element tail + ! after the line's interior block (as pack_state_mirror) + n1 = 0 + DO il = 1, inst_e%nlines + n1 = n1 + COUNT(lin1_element(il, LIN1_VE)) + COUNT(lin1_element(il, LIN1_SYROPE)) + END DO + IF (ALLOCATED(inst_e%lin1_slot)) DEALLOCATE (inst_e%lin1_slot, inst_e%lin1_line, inst_e%lin1_elem, & + inst_e%lin1_kind) + ALLOCATE (inst_e%lin1_slot(n1), inst_e%lin1_line(n1), inst_e%lin1_elem(n1), inst_e%lin1_kind(n1), STAT=es) + IF (es /= 0) THEN + CALL SetErrStat( ErrID_Fatal, 'Could not allocate the linearization state map.', ErrStat, ErrMsg, & + 'lin_state_map' ); RETURN + END IF + k1 = 0 + DO il = 1, inst_e%nlines + nin = CD_System_Line_NDOF( inst_e%agg%sys%fast%system, il, es, em ) - 6 + DO kind = LIN1_VE, LIN1_SYROPE + mask = lin1_element(il, kind) + DO j = 1, SIZE(mask) + IF (.NOT. mask(j)) CYCLE + k1 = k1 + 1 + inst_e%lin1_slot(k1) = m%LineStateIs1(il) + 3*nin + j - 1 + inst_e%lin1_line(k1) = il + inst_e%lin1_elem(k1) = j + inst_e%lin1_kind(k1) = kind + END DO + END DO + END DO + IF (ALLOCATED(inst_e%lin_pos)) DEALLOCATE (inst_e%lin_pos, inst_e%lin_vel, inst_e%lin_acc) + IF (ALLOCATED(inst_e%ws_lsave)) DEALLOCATE (inst_e%ws_lsave, inst_e%ws_lwork) + ALLOCATE (inst_e%lin_pos(n), inst_e%lin_vel(n), inst_e%lin_acc(n), inst_e%ws_lsave(m%Nx), & + inst_e%ws_lwork(m%Nx), STAT=es) + IF (es /= 0) THEN + CALL SetErrStat( ErrID_Fatal, 'Could not allocate the linearization state map.', ErrStat, ErrMsg, & + 'lin_state_map' ); RETURN + END IF + ! a mooring line's interior block is [v; r; a], 3 (N - 1) each, at LineStateIs1 + k = 0 + DO il = 1, inst_e%nlines + ndofl = CD_System_Line_NDOF( inst_e%agg%sys%fast%system, il, es, em ) + nin = ndofl - 6 + DO j = 0, nin - 1 + k = k + 1 + inst_e%lin_vel(k) = m%LineStateIs1(il) + j + inst_e%lin_pos(k) = m%LineStateIs1(il) + nin + j + inst_e%lin_acc(k) = m%LineStateIs1(il) + 2*nin + j + END DO + END DO + ! a cable's mirror starts [v_free; q_free; a_free], after the mooring block + koff = 0 + IF (inst_e%nlines > 0) koff = m%LineStateIsN(inst_e%nlines) + DO ic = 1, inst_e%agg%ncable + csz = CD_HFMF_MirrorSize( inst_e%agg%cables(ic) ) + IF (csz <= 0) CYCLE + nf = COUNT(inst_e%agg%cables(ic)%line%freemask) + DO j = 1, nf + k = k + 1 + inst_e%lin_vel(k) = koff + j + inst_e%lin_pos(k) = koff + nf + j + inst_e%lin_acc(k) = koff + 2*nf + j + END DO + koff = koff + csz + END DO + inst_e%lin_states = .TRUE. + + CONTAINS + + FUNCTION lin1_element(il_, kind_) RESULT(msk) + !! The elements of line il_ carrying a constitutive state of kind kind_. + INTEGER(IntKi), INTENT(IN) :: il_, kind_ + LOGICAL, ALLOCATABLE :: msk(:) + msk = lin1_mask( inst_e, il_, kind_ ) + END FUNCTION lin1_element + END SUBROUTINE lin_state_map + + FUNCTION lin1_mask( inst_, il, kind ) RESULT(msk) + !! The elements of EI = 0 line il that carry a first-order linearization state of the kind: + !! viscoelastic (ElasticMod 2/3) elements for LIN1_VE, Syrope elements for LIN1_SYROPE. + TYPE(CD_OF_Instance), INTENT(IN) :: inst_ + INTEGER(IntKi), INTENT(IN) :: il, kind + LOGICAL, ALLOCATABLE :: msk(:) + ASSOCIATE (ln => inst_%agg%sys%fast%system%lines(il)) + ALLOCATE (msk(ln%n_elem)) + msk = .FALSE. + IF (kind == LIN1_VE .AND. ln%has_viscoelastic) msk = ln%ve_mode /= 0 + IF (kind == LIN1_SYROPE .AND. ln%has_syrope) msk = ln%syrope_is + END ASSOCIATE + END FUNCTION lin1_mask + + SUBROUTINE lin_disp_step( inst_, dx, ErrStat, ErrMsg ) + !! The coupled-point displacement step of the linearization, as MoorDyn-F's: half the + !! smallest positive element stretch of the EI = 0 lines, at most dx on entry. A larger + !! step would slacken a tension-only element on one side of the central difference (a + !! taut chain stretches about a centimetre per element) and halve its stiffness. + TYPE(CD_OF_Instance), INTENT(IN) :: inst_ + REAL(R8Ki), INTENT(INOUT) :: dx + INTEGER(IntKi), INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + + INTEGER(IntKi) :: il, ne, es + CHARACTER(ErrMsgLen) :: em + REAL(wp), ALLOCATABLE :: stretch(:) + + ErrStat = ErrID_None + ErrMsg = '' + DO il = 1, inst_%nlines + ne = CD_System_Line_NElem( inst_%agg%sys%fast%system, il, es, em ) + IF (es == CD_SYSTEM_OK) THEN + ALLOCATE (stretch(ne)) + CALL CD_Get_System_Line_Stretch( inst_%agg%sys%fast%system, il, stretch, es, em ) + END IF + IF (es /= CD_SYSTEM_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: line '//TRIM(Num2LStr(il))//': '// & + TRIM(em), ErrStat, ErrMsg, 'CableDyn:lin_disp_step' ); RETURN + END IF + IF (ANY(stretch > 0.0_wp)) dx = MIN(dx, 0.5_R8Ki*REAL(MINVAL(stretch, MASK=stretch > 0.0_wp), R8Ki)) + DEALLOCATE (stretch) + END DO + END SUBROUTINE lin_disp_step + +!---------------------------------------------------------------------------------------------------------------------------------- + SUBROUTINE lin_eval( id, p, m, u, x_in, ErrStat, ErrMsg, dxdt, y_out ) + !! The linearization surface at the state x_in and input u: the line interiors and cable + !! free DOFs take x_in's positions and velocities, the coupled points u's kinematics, and the + !! accelerations are solved from them without a time step. dxdt gets dx/dt of the + !! linearization states (each position slot its velocity, each velocity slot its + !! acceleration; the other slots 0); y_out the loads on the coupled points and the deck + !! channels at that state. The committed state is restored on exit. + INTEGER(IntKi), INTENT(IN ) :: id + TYPE(CD_ParameterType), INTENT(IN ) :: p + TYPE(CD_MiscVarType), INTENT(INOUT) :: m + TYPE(CD_InputType), INTENT(IN ) :: u + TYPE(CD_ContinuousStateType), INTENT(IN ) :: x_in + INTEGER(IntKi), INTENT( OUT) :: ErrStat + CHARACTER(*), INTENT( OUT) :: ErrMsg + TYPE(CD_ContinuousStateType), INTENT(INOUT), OPTIONAL :: dxdt + TYPE(CD_OutputType), INTENT(INOUT), OPTIONAL :: y_out + + character(*), parameter :: RoutineName = 'CableDyn:lin_eval' + INTEGER(IntKi) :: ErrStat2, es, i, ic, il, ne, k + REAL(wp), ALLOCATABLE :: ve_rate(:), syr_rate(:) + CHARACTER(ErrMsgLen) :: ErrMsg2, em + REAL(wp) :: cval, t_clock + + ErrStat = ErrID_None + ErrMsg = '' + t_clock = REAL(MAX(Inst(id)%t_commit, 0.0_DbKi), wp) + ! the committed state: the coupled kinematics and the whole mirror + CALL CD_AGG_GetMovingPointMesh( Inst(id)%agg, Inst(id)%sv_pos, Inst(id)%sv_vel, Inst(id)%sv_acc, & + Inst(id)%ws_fld, es, em, orientation=Inst(id)%sv_orient, & + angular_velocity=Inst(id)%sv_omega, angular_acceleration=Inst(id)%sv_alpha, & + cable_loads=.FALSE. ) + IF (es /= CD_AGG_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + CALL pack_state_mirror_ary( Inst(id), m, Inst(id)%ws_lsave, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + ! the state: x_in's positions and velocities in the committed mirror + Inst(id)%ws_lwork = Inst(id)%ws_lsave + Inst(id)%ws_lwork(Inst(id)%lin_pos) = x_in%states(Inst(id)%lin_pos) + Inst(id)%ws_lwork(Inst(id)%lin_vel) = x_in%states(Inst(id)%lin_vel) + Inst(id)%ws_lwork(Inst(id)%lin1_slot) = x_in%states(Inst(id)%lin1_slot) + CALL reload_interiors_ary( Inst(id), m, Inst(id)%ws_lwork, t_clock, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) THEN + CALL restore; RETURN + END IF + ! the input: the coupled points move to u, and the accelerations follow (the EI = 0 lines + ! in the non-probe update, the cables by their refresh) + CALL mesh_to_arrays( u%CoupledKinematics(1), Inst(id)%ncp, Inst(id)%ws_pos, Inst(id)%ws_vel, & + Inst(id)%ws_acc, Inst(id)%ws_orient, Inst(id)%ws_omega, Inst(id)%ws_alpha, & + ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) THEN + CALL restore; RETURN + END IF + CALL CD_AGG_UpdateStates_Moving( Inst(id)%agg, Inst(id)%ws_pos, Inst(id)%ws_vel, Inst(id)%ws_acc, es, em, & + output_probe=.FALSE., orientation=Inst(id)%ws_orient, & + angular_velocity=Inst(id)%ws_omega, angular_acceleration=Inst(id)%ws_alpha ) + IF (es /= CD_AGG_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) + CALL restore; RETURN + END IF + DO ic = 1, Inst(id)%agg%ncable + CALL CD_HFMF_Refresh_Acceleration( Inst(id)%agg%cables(ic), es, em ) + IF (es /= CD_HFMF_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & + ' acceleration: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) + CALL restore; RETURN + END IF + END DO + IF (PRESENT(dxdt)) THEN + CALL pack_state_mirror_ary( Inst(id), m, Inst(id)%ws_lwork, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) THEN + CALL restore; RETURN + END IF + dxdt%states = 0.0_R8Ki + dxdt%states(Inst(id)%lin_pos) = Inst(id)%ws_lwork(Inst(id)%lin_vel) + dxdt%states(Inst(id)%lin_vel) = Inst(id)%ws_lwork(Inst(id)%lin_acc) + ! the constitutive states' rates at this state (the instantaneous element laws) + DO il = 1, Inst(id)%nlines + IF (.NOT. ANY(Inst(id)%lin1_line == il)) CYCLE + ne = CD_System_Line_NElem( Inst(id)%agg%sys%fast%system, il, es, em ) + ALLOCATE (ve_rate(ne), syr_rate(ne)) + CALL CD_Get_System_Line_Internal_Rates( Inst(id)%agg%sys%fast%system, il, ve_rate, syr_rate, es, em ) + IF (es /= CD_SYSTEM_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) + CALL restore; RETURN + END IF + DO k = 1, SIZE(Inst(id)%lin1_slot) + IF (Inst(id)%lin1_line(k) /= il) CYCLE + IF (Inst(id)%lin1_kind(k) == LIN1_VE) THEN + dxdt%states(Inst(id)%lin1_slot(k)) = REAL(ve_rate(Inst(id)%lin1_elem(k)), R8Ki) + ELSE + dxdt%states(Inst(id)%lin1_slot(k)) = REAL(syr_rate(Inst(id)%lin1_elem(k)), R8Ki) + END IF + END DO + DEALLOCATE (ve_rate, syr_rate) + END DO + END IF + IF (PRESENT(y_out)) THEN + CALL CD_AGG_CalcOutput( Inst(id)%agg, es, em ) + IF (es == CD_AGG_OK) CALL CD_AGG_GetMovingPointMesh( Inst(id)%agg, Inst(id)%ws_pos, Inst(id)%ws_vel, & + Inst(id)%ws_acc, Inst(id)%ws_fld, es, em, & + orientation=Inst(id)%ws_orient, & + moment=Inst(id)%ws_moment, & + angular_velocity=Inst(id)%ws_omega, & + angular_acceleration=Inst(id)%ws_alpha ) + IF (es /= CD_AGG_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) + CALL restore; RETURN + END IF + DO i = 1, Inst(id)%ncp + y_out%CoupledLoads(1)%Force(:, i) = REAL(Inst(id)%ws_fld(:, i), ReKi) + y_out%CoupledLoads(1)%Moment(:, i) = REAL(Inst(id)%ws_moment(:, i), ReKi) + END DO + DO i = 1, p%NumOuts + CALL CD_AGG_EvalChannel( Inst(id)%agg, i, cval, es, em ) + IF (es /= CD_AGG_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: output channel evaluation failed: '// & + TRIM(em), ErrStat, ErrMsg, RoutineName ) + CALL restore; RETURN + END IF + y_out%WriteOutput(i) = REAL(cval, ReKi) + END DO + END IF + CALL restore + + CONTAINS + + SUBROUTINE restore() + !! The committed coupled kinematics and mirror back; the held loads are re-evaluated. + CALL CD_AGG_UpdateStates_Moving( Inst(id)%agg, Inst(id)%sv_pos, Inst(id)%sv_vel, Inst(id)%sv_acc, es, em, & + output_probe=.TRUE., orientation=Inst(id)%sv_orient, & + angular_velocity=Inst(id)%sv_omega, angular_acceleration=Inst(id)%sv_alpha ) + IF (es /= CD_AGG_OK) CALL SetErrStat( ErrID_Fatal, 'CableDyn linearization restore failed: '//TRIM(em), & + ErrStat, ErrMsg, RoutineName ) + CALL reload_interiors_ary( Inst(id), m, Inst(id)%ws_lsave, t_clock, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + Inst(id)%loads_cached = .FALSE. + END SUBROUTINE restore + END SUBROUTINE lin_eval + !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 @@ -2838,73 +3185,102 @@ SUBROUTINE CD_JacobianPInput(Vars, t, u, p, x, xd, z, OtherState, y, m, ErrStat, ! Get OP values here (the FD reference point) CALL CD_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat2, ErrMsg2 ); IF (Failed()) RETURN - ! dY/du has TWO distinct contracts. During a normal nonlinear OpenFAST run the - ! registered CableDyn states exist (Nx > 0), and the glue input/output solve needs - ! the PARTIAL derivative g_u at fixed internal state. Re-equilibrating the line for - ! those probes returns a total quasi-static derivative instead; inserting that into - ! the runtime algebraic loop can make its Jacobian rank deficient. For formal - ! linearization CableDyn deliberately registers no states (Nx = 0), so the useful - ! reduction is the re-equilibrated, zero-frequency stiffness. Keep those paths - ! explicit rather than using the linearization reduction in the runtime solve. + ! Linearization with the line dynamics: the partial derivatives at the fixed state x, by + ! central differences of lin_eval, as MoorDyn-F's of its CalcOutput and + ! CalcContStateDeriv (dXdu only when the glue asks for it: a deck without line states + ! has none). + IF (Inst(m%CDInst)%lin_states) THEN + IF (PRESENT(dYdu)) THEN + IF (.NOT. ALLOCATED(dYdu)) THEN + CALL AllocAry( dYdu, m%Jac%Ny, m%Jac%Nu, 'dYdu', ErrStat2, ErrMsg2 ); IF (Failed()) RETURN + END IF + dYdu = 0.0_R8Ki + END IF + IF (PRESENT(dXdu)) THEN + IF (.NOT. ALLOCATED(dXdu)) THEN + CALL AllocAry( dXdu, m%Jac%Nx, m%Jac%Nu, 'dXdu', ErrStat2, ErrMsg2 ); IF (Failed()) RETURN + END IF + dXdu = 0.0_R8Ki + END IF + CALL CD_CopyInput( u, m%u_perturb, MESH_UPDATECOPY, ErrStat2, ErrMsg2 ); IF (Failed()) RETURN + CALL CD_VarsPackInput( Vars, u, m%Jac%u ) + DO i = 1, SIZE(Vars%u) + DO j = 1, Vars%u(i)%Num + iCol = Vars%u(i)%iLoc(1) + j - 1 + CALL MV_Perturb( Vars%u(i), j, 1, m%Jac%u, m%Jac%u_perturb ) + CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) + CALL lin_eval( m%CDInst, p, m, m%u_perturb, x, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) + IF (Failed()) RETURN + CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) + CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_pos ) + CALL MV_Perturb( Vars%u(i), j, -1, m%Jac%u, m%Jac%u_perturb ) + CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) + CALL lin_eval( m%CDInst, p, m, m%u_perturb, x, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) + IF (Failed()) RETURN + CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) + CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_neg ) + IF (PRESENT(dYdu)) CALL MV_ComputeCentralDiff( Vars%y, Vars%u(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, & + dYdu(:, iCol) ) + IF (PRESENT(dXdu)) dXdu(:, iCol) = (m%Jac%x_pos - m%Jac%x_neg)/(2.0_R8Ki*Vars%u(i)%Perturb) + END DO + END DO + ! the outputs at the operating point again (the glue reads y after this call) + CALL CD_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat2, ErrMsg2 ); IF (Failed()) RETURN + IF (PRESENT(dXddu)) THEN + IF (ALLOCATED(dXddu)) DEALLOCATE (dXddu) + END IF + IF (PRESENT(dZdu)) THEN + IF (ALLOCATED(dZdu)) DEALLOCATE (dZdu) + END IF + RETURN + END IF + + ! The runtime input/output solve of a nonlinear run: the PARTIAL derivative g_u at the + ! fixed internal state, as stock MoorDyn's runtime Jacobian. Perturb the current input, + ! evaluate CalcOutput with the same x/xd/z/other, and central-difference the packed + ! outputs; CD_CalcOutput's probe overlay restores the authoritative CableDyn state after + ! every evaluation. (Re-equilibrating the line for these probes would give a total + ! quasi-static derivative instead, which can make the runtime Jacobian rank deficient.) IF (PRESENT(dYdu)) THEN IF (.NOT. ALLOCATED(dYdu)) THEN CALL AllocAry( dYdu, m%Jac%Ny, m%Jac%Nu, 'dYdu', ErrStat2, ErrMsg2 ); IF (Failed()) RETURN END IF dYdu = 0.0_R8Ki - IF (m%Jac%Nx > 0) THEN - ! Match stock MoorDyn's runtime Jacobian contract: perturb the current input, - ! evaluate CalcOutput with the same x/xd/z/other, and central-difference the - ! packed outputs. CD_CalcOutput's probe overlay restores the authoritative - ! CableDyn state after every evaluation. - CALL CD_CopyInput( u, m%u_perturb, MESH_UPDATECOPY, ErrStat2, ErrMsg2 ); IF (Failed()) RETURN - CALL CD_VarsPackInput( Vars, u, m%Jac%u ) - DO i = 1, SIZE(Vars%u) - DO j = 1, Vars%u(i)%Num - iCol = Vars%u(i)%iLoc(1) + j - 1 - CALL MV_Perturb( Vars%u(i), j, 1, m%Jac%u, m%Jac%u_perturb ) - CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) - CALL CD_CalcOutput( t, m%u_perturb, p, x, xd, z, OtherState, m%y_lin, m, ErrStat2, ErrMsg2 ) - IF (Failed()) RETURN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) - - CALL MV_Perturb( Vars%u(i), j, -1, m%Jac%u, m%Jac%u_perturb ) - CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) - CALL CD_CalcOutput( t, m%u_perturb, p, x, xd, z, OtherState, m%y_lin, m, ErrStat2, ErrMsg2 ) - IF (Failed()) RETURN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) - - CALL MV_ComputeCentralDiff( Vars%y, Vars%u(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, & - dYdu(:, iCol) ) - END DO + CALL CD_CopyInput( u, m%u_perturb, MESH_UPDATECOPY, ErrStat2, ErrMsg2 ); IF (Failed()) RETURN + CALL CD_VarsPackInput( Vars, u, m%Jac%u ) + DO i = 1, SIZE(Vars%u) + DO j = 1, Vars%u(i)%Num + iCol = Vars%u(i)%iLoc(1) + j - 1 + CALL MV_Perturb( Vars%u(i), j, 1, m%Jac%u, m%Jac%u_perturb ) + CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) + CALL CD_CalcOutput( t, m%u_perturb, p, x, xd, z, OtherState, m%y_lin, m, ErrStat2, ErrMsg2 ) + IF (Failed()) RETURN + CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) + + CALL MV_Perturb( Vars%u(i), j, -1, m%Jac%u, m%Jac%u_perturb ) + CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) + CALL CD_CalcOutput( t, m%u_perturb, p, x, xd, z, OtherState, m%y_lin, m, ErrStat2, ErrMsg2 ) + IF (Failed()) RETURN + CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) + + CALL MV_ComputeCentralDiff( Vars%y, Vars%u(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, & + dYdu(:, iCol) ) END DO - ! The final negative probe leaves only output/cache workspaces at the - ! perturbed input (the authoritative structural state was already restored). - ! Re-evaluate the operating point so the callback is observationally neutral - ! to the next glue evaluation as well as state neutral. - CALL CD_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat2, ErrMsg2 ) - IF (Failed()) RETURN - ELSE - ! Zero-state formal linearization: each displacement probe re-solves static - ! equilibrium on a scratch aggregate, giving the reduced mooring stiffness. - CALL quasistatic_dydu( Vars, u, p, m, dYdu, ErrStat2, ErrMsg2 ); IF (Failed()) RETURN - END IF + END DO + ! The final negative probe leaves only output/cache workspaces at the perturbed + ! input (the authoritative structural state was already restored). Re-evaluate the + ! operating point so the callback is observationally neutral to the next glue + ! evaluation as well as state neutral. + CALL CD_CalcOutput( t, u, p, x, xd, z, OtherState, y, m, ErrStat2, ErrMsg2 ) + IF (Failed()) RETURN END IF - ! dX/du: the implicit march has no x' = f(x, u) surface. Under linearization the - ! module registers ZERO state variables (see CD_InitVars), so the honest dXdu is - ! the empty (0 x Nu) block; a caller holding a state-registered instance (Nx > 0) - ! is asking for a surface that does not exist -- fail loudly, never zero-fill. + ! dX/du of the implicit march exists only for a linearization run (the line-state + ! branch above): fail loudly, never zero-fill. IF (PRESENT(dXdu)) THEN - IF (m%Jac%Nx > 0) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: dXdu is undefined for the implicit '// & - 'march with registered state variables; linearization must be requested at '// & - 'Init so the module presents its zero-state (dYdu-only) reduction.', & - ErrStat, ErrMsg, RoutineName ) - RETURN - END IF - IF (.NOT. ALLOCATED(dXdu)) THEN - CALL AllocAry( dXdu, m%Jac%Nx, m%Jac%Nu, 'dXdu', ErrStat2, ErrMsg2 ); IF (Failed()) RETURN - END IF + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: dXdu exists only for a linearization '// & + 'run (Linearize = True).', ErrStat, ErrMsg, RoutineName ) + RETURN END IF IF (PRESENT(dXddu)) THEN @@ -2921,155 +3297,6 @@ LOGICAL FUNCTION Failed() END FUNCTION Failed END SUBROUTINE CD_JacobianPInput -!---------------------------------------------------------------------------------------------------------------------------------- - SUBROUTINE quasistatic_dydu( Vars, u, p, m, dYdu, ErrStat, ErrMsg ) - !! The quasi-static dYdu displacement columns: for each coupled-mesh - !! FieldTransDisp perturbation, re-solve the mooring static equilibrium at the - !! perturbed boundary on a SCRATCH aggregate built from the deck copy (each - !! CD_AGG_Init_From_Deck IS a static solve; coupled_positions places the moving - !! points explicitly), read the loads and deck channels, and central-difference. - !! The live instance is never touched -- the probe cannot perturb committed - !! state by construction. All other input fields keep zero columns. - TYPE(ModVarsType), INTENT(IN ) :: Vars - TYPE(CD_InputType), INTENT(IN ) :: u - TYPE(CD_ParameterType), INTENT(IN ) :: p - TYPE(CD_MiscVarType), INTENT(INOUT) :: m - REAL(R8Ki), INTENT(INOUT) :: dYdu(:,:) - INTEGER(IntKi), INTENT( OUT) :: ErrStat - CHARACTER(*), INTENT( OUT) :: ErrMsg - - character(*), parameter :: RoutineName = 'quasistatic_dydu' - INTEGER(IntKi) :: ErrStat2, es, i, j, iCol, node, comp, ncp, k - CHARACTER(ErrMsgLen) :: ErrMsg2 - CHARACTER(2100) :: lin_deck - REAL(wp), ALLOCATABLE :: op_pos(:,:), prb_pos(:,:) - LOGICAL :: use_extf - REAL(wp), ALLOCATABLE :: static_cur(:,:) ! the host's steady current for the static probes - - ErrStat = ErrID_None - ErrMsg = '' - IF (p%DeckCopy%NumLines < 1) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: the linearization probe needs the '// & - 'deck copy in the parameters.', ErrStat, ErrMsg, RoutineName ) - RETURN - END IF - ncp = u%CoupledKinematics(1)%Nnodes - ALLOCATE (op_pos(3, ncp), prb_pos(3, ncp), STAT=ErrStat2) - IF (ErrStat2 /= 0) THEN - CALL SetErrStat( ErrID_Fatal, 'Could not allocate the linearization probe positions.', & - ErrStat, ErrMsg, RoutineName ) - RETURN - END IF - ! the operating-point boundary: the committed mesh positions at the snapshot - DO i = 1, ncp - op_pos(:, i) = REAL(u%CoupledKinematics(1)%Position(:, i), wp) + & - REAL(u%CoupledKinematics(1)%TranslationDisp(:, i), wp) - END DO - - ! the deck copy back to disk once (beside the MooringFile, so its side files - ! resolve); every probe init reuses it and it is removed afterwards - CALL write_deck_copy( p, '.lin.dat', lin_deck, ErrStat2, ErrMsg2 ) - CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) - IF (ErrStat >= AbortErrLev) RETURN - - use_extf = .FALSE. - IF (ASSOCIATED(p%WaveField)) use_extf = wavefield_is_ambient( p%WaveField ) - ! each probe is a static solve in the host's steady current, as the operating point is - IF (use_extf) THEN - CALL seastate_static_current( p%WaveField, static_cur, ErrStat2, ErrMsg2 ) - CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) - IF (ErrStat >= AbortErrLev) RETURN - END IF - - DO i = 1, SIZE(Vars%u) - IF (Vars%u(i)%Field /= FieldTransDisp) CYCLE ! vel/acc/orientation: zero columns - DO j = 1, Vars%u(i)%Num - iCol = Vars%u(i)%iLoc(1) + j - 1 - node = (j - 1)/3 + 1 - comp = MOD(j - 1, 3) + 1 - IF (node > ncp) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: linearization probe node index '// & - 'exceeds the coupled mesh.', ErrStat, ErrMsg, RoutineName ) - CALL delete_file( lin_deck ) - RETURN - END IF - DO k = 1, 2 ! +perturb then -perturb - prb_pos = op_pos - IF (k == 1) THEN - prb_pos(comp, node) = prb_pos(comp, node) + REAL(Vars%u(i)%Perturb, wp) - ELSE - prb_pos(comp, node) = prb_pos(comp, node) - REAL(Vars%u(i)%Perturb, wp) - END IF - CALL probe_loads( prb_pos, ErrStat2, ErrMsg2 ) - CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) - IF (ErrStat >= AbortErrLev) THEN - CALL delete_file( lin_deck ) - RETURN - END IF - IF (k == 1) THEN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) - ELSE - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) - END IF - END DO - CALL MV_ComputeCentralDiff( Vars%y, Vars%u(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, dYdu(:, iCol) ) - END DO - END DO - CALL delete_file( lin_deck ) - - CONTAINS - - SUBROUTINE probe_loads( pos, PErrStat, PErrMsg ) - !! One static probe: scratch-aggregate init at the given boundary (the init - !! IS the static solve), loads + deck channels into m%y_lin, then release. - REAL(wp), INTENT(IN ) :: pos(:,:) - INTEGER(IntKi), INTENT( OUT) :: PErrStat - CHARACTER(*), INTENT( OUT) :: PErrMsg - - TYPE(CD_AGG_ModuleType) :: agg_p - REAL(wp) :: q_p(3, ncp), v_p(3, ncp), a_p(3, ncp), f_p(3, ncp) - REAL(wp) :: cval - INTEGER(IntKi) :: es_p, ich - CHARACTER(ErrMsgLen) :: em_p - - PErrStat = ErrID_None - PErrMsg = '' - CALL CD_AGG_Init_From_Deck( agg_p, TRIM(lin_deck), REAL(p%dtM0, wp), es_p, em_p, & - env_gravity=REAL(p%g, wp), env_rho_water=REAL(p%rhoW, wp), & - env_wtrdpth=REAL(p%WtrDpth, wp), external_fluid=use_extf, & - coupled_positions=pos, run_tmax=REAL(p%Tmax, wp), & - static_current=static_cur ) - IF (es_p /= CD_AGG_OK) THEN - PErrStat = ErrID_Fatal - PErrMsg = 'linearization static probe init failed: '//TRIM(em_p) - RETURN - END IF - CALL CD_AGG_CalcOutput( agg_p, es_p, em_p ) - IF (es_p == CD_AGG_OK) CALL CD_AGG_GetMovingPointMesh( agg_p, q_p, v_p, a_p, f_p, es_p, em_p ) - IF (es_p /= CD_AGG_OK) THEN - CALL CD_AGG_End( agg_p, es_p, em_p ) - PErrStat = ErrID_Fatal - PErrMsg = 'linearization static probe output failed: '//TRIM(em_p) - RETURN - END IF - DO ich = 1, ncp - m%y_lin%CoupledLoads(1)%Force(:, ich) = REAL(f_p(:, ich), ReKi) - m%y_lin%CoupledLoads(1)%Moment(:, ich) = 0.0_ReKi - END DO - DO ich = 1, p%NumOuts - CALL CD_AGG_EvalChannel( agg_p, ich, cval, es_p, em_p ) - IF (es_p /= CD_AGG_OK) THEN - CALL CD_AGG_End( agg_p, es_p, em_p ) - PErrStat = ErrID_Fatal - PErrMsg = 'linearization static probe channel failed: '//TRIM(em_p) - RETURN - END IF - m%y_lin%WriteOutput(ich) = REAL(cval, ReKi) - END DO - CALL CD_AGG_End( agg_p, es_p, em_p ) - END SUBROUTINE probe_loads - - END SUBROUTINE quasistatic_dydu !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE CD_JacobianPContState(Vars, t, u, p, x, xd, z, OtherState, y, m, ErrStat, ErrMsg, dYdx, dXdx, dXddx, dZdx) @@ -3092,22 +3319,71 @@ SUBROUTINE CD_JacobianPContState(Vars, t, u, p, x, xd, z, OtherState, y, m, ErrS character(*), parameter :: RoutineName = 'CD_JacobianPContState' - INTEGER(IntKi) :: ErrStat2 + INTEGER(IntKi) :: ErrStat2, i, j, iCol CHARACTER(ErrMsgLen) :: ErrMsg2 ErrStat = ErrID_None ErrMsg = '' ErrStat2 = ErrID_None ErrMsg2 = '' - ! Under linearization the module registers ZERO state variables (the MAP-shaped - ! dYdu-only reduction; see CD_InitVars), so every state Jacobian is an empty - ! block. A state-registered instance (Nx > 0) has no x' = f(x, u) surface to - ! differentiate -- fail loudly rather than fabricate one. + ! Linearization with the line dynamics: dYdx and dXdx by central differences of lin_eval + ! over the registered states, as MoorDyn-F's + IF (Inst(m%CDInst)%lin_states) THEN + IF (PRESENT(dYdx)) THEN + IF (.NOT. ALLOCATED(dYdx)) THEN + CALL AllocAry( dYdx, m%Jac%Ny, m%Jac%Nx, 'dYdx', ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + END IF + dYdx = 0.0_R8Ki + END IF + IF (PRESENT(dXdx)) THEN + IF (.NOT. ALLOCATED(dXdx)) THEN + CALL AllocAry( dXdx, m%Jac%Nx, m%Jac%Nx, 'dXdx', ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + END IF + dXdx = 0.0_R8Ki + END IF + CALL CD_CopyContState( x, m%x_perturb, MESH_UPDATECOPY, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + CALL CD_VarsPackContState( Vars, x, m%Jac%x ) + DO i = 1, SIZE(Vars%x) + DO j = 1, Vars%x(i)%Num + iCol = Vars%x(i)%iLoc(1) + j - 1 + CALL MV_Perturb( Vars%x(i), j, 1, m%Jac%x, m%Jac%x_perturb ) + CALL CD_VarsUnpackContState( Vars, m%Jac%x_perturb, m%x_perturb ) + CALL lin_eval( m%CDInst, p, m, u, m%x_perturb, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) + CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_pos ) + CALL MV_Perturb( Vars%x(i), j, -1, m%Jac%x, m%Jac%x_perturb ) + CALL CD_VarsUnpackContState( Vars, m%Jac%x_perturb, m%x_perturb ) + CALL lin_eval( m%CDInst, p, m, u, m%x_perturb, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) + CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_neg ) + IF (PRESENT(dYdx)) CALL MV_ComputeCentralDiff( Vars%y, Vars%x(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, & + dYdx(:, iCol) ) + IF (PRESENT(dXdx)) dXdx(:, iCol) = (m%Jac%x_pos - m%Jac%x_neg)/(2.0_R8Ki*Vars%x(i)%Perturb) + END DO + END DO + IF (PRESENT(dXddx)) THEN + IF (ALLOCATED(dXddx)) DEALLOCATE (dXddx) + END IF + IF (PRESENT(dZdx)) THEN + IF (ALLOCATED(dZdx)) DEALLOCATE (dZdx) + END IF + RETURN + END IF + ! Outside a linearization run the implicit march has no x' = f(x, u) surface to + ! differentiate: fail loudly rather than fabricate one. IF (m%Jac%Nx > 0) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: state Jacobians are undefined for the '// & - 'implicit march with registered state variables; linearization must be '// & - 'requested at Init so the module presents its zero-state (dYdu-only) '// & - 'reduction.', ErrStat, ErrMsg, RoutineName ) + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: state Jacobians exist only for a '// & + 'linearization run (Linearize = True).', ErrStat, ErrMsg, RoutineName ) RETURN END IF IF (PRESENT(dYdx)) THEN @@ -3210,25 +3486,167 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) CHARACTER(LinChanLen), ALLOCATABLE :: CblLinVel(:), CblLinPos(:), CblLinAcc(:) character(20), parameter :: TransDispSuffix(*) = [' Px, m', ' Py, m', ' Pz, m'] character(20), parameter :: TransVelSuffix(*) = [' Vx, m/s', ' Vy, m/s', ' Vz, m/s'] + ! a finite-EI cable node's tangent m = dr/ds and its rate (linearization states) + character(20), parameter :: TangentSuffix(*) = [' Tx, -', ' Ty, -', ' Tz, -'] + character(20), parameter :: TangentRateSuffix(*) = [' dTx, 1/s', ' dTy, 1/s', ' dTz, 1/s'] + ! central-difference steps of the linearization states. Positions, tangents and the + ! coupled-point displacements take 1 um (a tangent step moves an element by about its + ! length times the step): far inside the seabed penetration of a light cable (a few + ! tenths of a millimetre) and any element's slack, either of which a millimetre step + ! would cross on one side of the difference, and still some ten digits above round-off. + ! The velocity step is MoorDyn-F's 0.1 m/s: quadratic drag has no slope at rest, so the + ! difference over +-0.1 m/s is the drag's equivalent linear damping at that velocity + ! amplitude (a smaller step leaves the line modes all but undamped); a cable's tangent + ! rate takes the same amplitude over its mean element length. + REAL(R8Ki), PARAMETER :: LIN_DX = 1.0E-6_R8Ki, LIN_DV = 0.1_R8Ki + REAL(R8Ki), PARAMETER :: LIN_DT = 1.0E-6_R8Ki + ! the constitutive states: a viscoelastic slow-branch stretch (m) takes the position step, + ! a Syrope slow strain the strain of a micrometre over a metre + REAL(R8Ki), PARAMETER :: LIN_DSLOW = 1.0E-6_R8Ki + LOGICAL, ALLOCATABLE :: lin1m(:) + INTEGER(IntKi) :: kind1 + INTEGER(IntKi) :: ipass, nnc, inode, ikind, i0, nrun, icomp, k + ! the position step of the line states and the coupled-point displacement step of the + ! inputs under linearization (lin_disp_step), and a cable's tangent-rate step + REAL(R8Ki) :: dx_pos, dx_u, dtr ErrStat = ErrID_None ErrMsg = '' + dx_u = 0.05_R8Ki + IF (Linearize) THEN + dx_u = LIN_DX + CALL lin_disp_step( inst_, dx_u, ErrStat2, ErrMsg2 ) + CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) + IF (ErrStat >= AbortErrLev) RETURN + END IF + dx_pos = dx_u IF (Linearize) THEN - ! Linearization presents the module in the MAP shape: ZERO continuous-state - ! variables. The module marches implicitly (generalised-alpha behind - ! UpdateStates), so there is no x' = f(x, u) surface to expose, and the glue - ! force-flags every registered x variable into the linearization set. With - ! Nx = 0 the linearized mooring is the direct-feedthrough impedance dYdu -- - ! stiffness from the displacement columns, damping from the velocity columns, - ! inertia from the acceleration columns: the quasi-static reduction MAP - ! exposes, and what a FOWT linearization consumes from a mooring. The - ! checkpoint and state-copy machinery is UNAFFECTED: pack_state_mirror and - ! the registry state copies use x%states directly, never Vars%x. + ! Linearization with the line dynamics, as MoorDyn-F: the continuous states are the + ! positions of every EI = 0 line's interior nodes and of every finite-EI cable's free + ! DOFs (node positions r and tangents m = dr/ds), then their velocities, held in the + ! x%states mirror slots (lin_state_map), and the per-element constitutive states of the + ! viscoelastic and Syrope ropes as first-order states. The acceleration and the other + ! mirror blocks are not registered: the glue would take every registered x as a state. ALLOCATE (Vars%x(0), STAT=ErrStat2) IF (ErrStat2 /= 0) THEN CALL SetErrStat( ErrID_Fatal, 'Could not allocate Vars%x.', ErrStat, ErrMsg, RoutineName ); RETURN END IF + DO ipass = 1, 2 ! the positions, then the velocities + DO il = 1, inst_%nlines + ndofl = CD_System_Line_NDOF( inst_%agg%sys%fast%system, il, es, em ) + IF (es /= CD_SYSTEM_OK) THEN + CALL SetErrStat( ErrID_Fatal, TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + N = ndofl/3 - 1 + DO i = 0, N - 2 + LinStr = 'Line '//TRIM(Num2LStr(il))//' node '//TRIM(Num2LStr(i + 1)) + IF (ipass == 1) THEN + CALL MV_AddVar( Vars%x, LinStr, FieldTransDisp, DatLoc(CD_x_states), & + iAry=m%LineStateIs1(il) + 3*(N - 1) + 3*i, Num=3, Flags=VF_DerivOrder2, & + Perturb=dx_pos, LinNames=[(TRIM(LinStr)//TransDispSuffix(j), j=1, 3)] ) + ELSE + CALL MV_AddVar( Vars%x, LinStr, FieldTransVel, DatLoc(CD_x_states), & + iAry=m%LineStateIs1(il) + 3*i, Num=3, Flags=VF_DerivOrder2, & + Perturb=LIN_DV, LinNames=[(TRIM(LinStr)//TransVelSuffix(j), j=1, 3)] ) + END IF + END DO + END DO + koff = 0 + IF (inst_%nlines > 0) koff = m%LineStateIsN(inst_%nlines) + DO ic = 1, inst_%agg%ncable + csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) + IF (csz <= 0) CYCLE + nf = COUNT(inst_%agg%cables(ic)%line%freemask) + ndofl = inst_%agg%cables(ic)%line%ndof + nnc = inst_%agg%cables(ic)%line%nn + dtr = LIN_DV*REAL(inst_%agg%cables(ic)%line%ne, R8Ki)/REAL(SUM(inst_%agg%cables(ic)%line%l0), R8Ki) + k = 0 + i = 1 + DO WHILE (i <= ndofl) + IF (.NOT. inst_%agg%cables(ic)%line%freemask(i)) THEN + i = i + 1 + CYCLE + END IF + ! a run of free DOFs of one node and one kind: the position r (DOFs 1-3 of the + ! node) or the tangent m (4-6); the node is named End A first, as the channels + inode = (i - 1)/6 + 1 + ikind = MERGE(1, 2, MOD(i - 1, 6) < 3) + i0 = i + DO WHILE (i <= ndofl) + IF (.NOT. inst_%agg%cables(ic)%line%freemask(i)) EXIT + IF ((i - 1)/6 + 1 /= inode .OR. MERGE(1, 2, MOD(i - 1, 6) < 3) /= ikind) EXIT + i = i + 1 + END DO + nrun = i - i0 + LinStr = 'Cable '//TRIM(Num2LStr(ic))//' node '//TRIM(Num2LStr(nnc + 1 - inode)) + ALLOCATE (CblLinPos(nrun), STAT=ErrStat2) + IF (ErrStat2 /= 0) THEN + CALL SetErrStat( ErrID_Fatal, 'Could not allocate cable lin-name work array.', & + ErrStat, ErrMsg, RoutineName ); RETURN + END IF + DO j = 1, nrun + icomp = MOD(i0 + j - 2, 3) + 1 + IF (ikind == 1 .AND. ipass == 1) THEN + CblLinPos(j) = TRIM(LinStr)//TransDispSuffix(icomp) + ELSE IF (ikind == 1) THEN + CblLinPos(j) = TRIM(LinStr)//TransVelSuffix(icomp) + ELSE IF (ipass == 1) THEN + CblLinPos(j) = TRIM(LinStr)//TangentSuffix(icomp) + ELSE + CblLinPos(j) = TRIM(LinStr)//TangentRateSuffix(icomp) + END IF + END DO + IF (ipass == 1) THEN + IF (ikind == 1 .AND. nrun == 3) THEN + CALL MV_AddVar( Vars%x, LinStr, FieldTransDisp, DatLoc(CD_x_states), & + iAry=koff + nf + k + 1, Num=nrun, Flags=VF_DerivOrder2, & + Perturb=dx_pos, LinNames=CblLinPos ) + ELSE + CALL MV_AddVar( Vars%x, LinStr, FieldScalar, DatLoc(CD_x_states), & + iAry=koff + nf + k + 1, Num=nrun, Flags=VF_DerivOrder2, DerivOrder=0, & + Perturb=MERGE(dx_pos, LIN_DT, ikind == 1), LinNames=CblLinPos ) + END IF + ELSE + IF (ikind == 1 .AND. nrun == 3) THEN + CALL MV_AddVar( Vars%x, LinStr, FieldTransVel, DatLoc(CD_x_states), & + iAry=koff + k + 1, Num=nrun, Flags=VF_DerivOrder2, & + Perturb=LIN_DV, LinNames=CblLinPos ) + ELSE + CALL MV_AddVar( Vars%x, LinStr, FieldScalar, DatLoc(CD_x_states), & + iAry=koff + k + 1, Num=nrun, Flags=VF_DerivOrder2, DerivOrder=1, & + Perturb=MERGE(LIN_DV, dtr, ikind == 1), LinNames=CblLinPos ) + END IF + END IF + DEALLOCATE (CblLinPos) + k = k + nrun + END DO + koff = koff + csz + END DO + END DO + ! the per-element constitutive states of the EI = 0 lines, first-order states: the + ! viscoelastic slow-branch stretch dl_1 and the Syrope slow strain (the Syrope running + ! maximum is a load history, held as the operating point's) + DO il = 1, inst_%nlines + ndofl = CD_System_Line_NDOF( inst_%agg%sys%fast%system, il, es, em ) + nin = ndofl - 6 + DO kind1 = LIN1_VE, LIN1_SYROPE + lin1m = lin1_mask( inst_, il, kind1 ) + DO j = 1, SIZE(lin1m) + IF (.NOT. lin1m(j)) CYCLE + LinStr = 'Line '//TRIM(Num2LStr(il))//' segment '//TRIM(Num2LStr(j)) + IF (kind1 == LIN1_VE) THEN + CALL MV_AddVar( Vars%x, LinStr, FieldScalar, DatLoc(CD_x_states), & + iAry=m%LineStateIs1(il) + 3*nin + j - 1, Num=1, Flags=VF_DerivOrder1, & + Perturb=LIN_DX, LinNames=[TRIM(LinStr)//' dl1, m'] ) + ELSE + CALL MV_AddVar( Vars%x, LinStr, FieldScalar, DatLoc(CD_x_states), & + iAry=m%LineStateIs1(il) + 3*nin + j - 1, Num=1, Flags=VF_DerivOrder1, & + Perturb=LIN_DSLOW, LinNames=[TRIM(LinStr)//' slow strain, -'] ) + END IF + END DO + END DO + END DO ELSE ! position states (interior line nodes; the mirror layout stores [rd, r] per @@ -3609,7 +4027,7 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) CALL MV_AddMeshVar( Vars%u, "CoupledKinematics", MotionFields, & DatLoc(CD_u_CoupledKinematics, ivT), & Mesh=u%CoupledKinematics(ivT), & - Perturbs=[0.05_R8Ki, & ! FieldTransDisp + Perturbs=[dx_u, & ! FieldTransDisp 0.1_R8Ki, & ! FieldOrientation 0.1_R8Ki, & ! FieldTransVel 0.1_R8Ki, & ! FieldAngularVel diff --git a/validation/scripts/openfast_lin_ab.py b/validation/scripts/openfast_lin_ab.py index c8c72970..82f41a69 100644 --- a/validation/scripts/openfast_lin_ab.py +++ b/validation/scripts/openfast_lin_ab.py @@ -20,12 +20,15 @@ so the dynamic-relaxation initial state is settled, and no `SeaState WaterKin` row (no effect in still water). +Both modules linearize with the line dynamics: the continuous states are the +line nodes' positions and velocities (882 on this deck, in the same layout), and +the zero-frequency stiffness is the reduction K = D - C A^-1 B of each. + WHAT IS GATED 1. CableDyn invariants of a tangent mooring stiffness at equilibrium, on its - quasi-static dYdu (force rows vs translation-displacement columns, matched - by ROW/COLUMN LABELS): symmetry, negative (restoring) displacement - diagonals, and no net sway force under a collective surge of this - y-symmetric spread. + K (force rows vs translation-displacement columns, matched by ROW/COLUMN + LABELS): symmetry, negative (restoring) displacement diagonals, and no net + sway force under a collective surge of this y-symmetric spread. 2. The reference itself: MoorDyn's zero-frequency reduction K_md = D - C A^-1 B must be symmetric (<= 1e-3) and its .lin matrices must carry >= 10 significant digits; otherwise the comparison is refused @@ -39,9 +42,28 @@ operating-point fairlead loads): diagonals within --gate-pct, every entry within --gate-pct of sqrt(K_ii K_jj). Measured on this model (OutFmt ES24.15E3, TmaxIC 400 s, t = 0): the - dominant fairlead entries agree to 0.07-0.10 %, the small transverse - (H/X) entry to 0.29 %, the 6x6 diagonals to <= 0.10 % and every 6x6 - entry to 1.0e-3 of sqrt(K_ii K_jj) or better. + fairlead entries agree to 0.10 % (the small transverse entry to 0.29 %), + the 6x6 diagonals to <= 0.10 % and every 6x6 entry to 1.1e-3 of + sqrt(K_ii K_jj) or better. + 4. The dynamics: both state matrices stable (every eigenvalue in the left + half-plane), and the lowest --n-modes line-mode frequencies of CableDyn's + A within --freq-pct (default 1 %) of MoorDyn's. Measured: 0.04-0.07 % on + the first three modes, 0.3 % on the ninth (CableDyn's consistent mass + against MoorDyn's lumped mass). The damping ratios are printed, not gated: the + quadratic drag has no slope at rest, so both codes difference it over the + same +-0.1 m/s velocity step, and CableDyn's drag, integrated over the + element rather than lumped at the node, gives half the slope for a one-node + perturbation. + 5. With --cable-deck and --driver (optional): every coupled point of a mixed + deck (EI = 0 lines and finite-EI cables) against the deck's own static + solution. The deck is linearized in the same OpenFAST case (seabed + friction off: a stuck laid run is a different static problem), and the + standalone driver solves it at TMax = 0 with one coupled point moved + +-h (--cable-h, default 0.05 m) along each axis; -dF/dx of those solves is + the reference. Per-point 3x3 entries >= 10 % of the block's largest within + --cable-pct (default 1 %), every entry >= 1 % of it within twice that. + Measured on examples/iea15mw_umaine_mixed_cabledyn.dat: the lazy-wave + cable's 36.0 / 2.62 / 38.5 N/m within 3.3e-4, the chains within 7e-5. The 6x6 is the module-level stiffness. A full-system ElastoDyn linearization additionally contains a term of ElastoDyn/glue origin proportional to the @@ -66,6 +88,8 @@ [--ref-cd IEA-15-UMaine_CompMooring5_CableDyn.fst] [--ref-md IEA-15-UMaine_CompMooring3_MoorDyn.fst] [--t-lin 0.0] [--gate-pct 0.5] [--outfmt ES24.15E3] [--md-tmaxic 400] + [--n-modes 9] [--freq-pct 1.0] + [--cable-deck --driver [--cable-h 0.05] [--cable-pct 1.0]] [--skip-run] """ @@ -306,27 +330,151 @@ def op_values(labels: list[str], idx: list[int]) -> np.ndarray: def static_impedance(mod: dict) -> np.ndarray: """K = D - C A^+ B (reduces to D when the module carries no states). - A^+ is the pseudo-inverse when A is numerically singular: a lumped-mass - mooring on a FRICTIONLESS seabed can have neutral horizontal modes on its - grounded nodes (zero restoring force). The minimum-norm solution projects the - neutral modes out -- they stay put under a static boundary displacement, which - is exactly the quasi-static physics. On the settled UMaine deck with full - precision A is regular (the seabed penalty and line tension restrain every - node) and the plain solve is used.""" + A^+ is the pseudo-inverse only when A is singular to working precision (cond > + 1e14): a mooring on a FRICTIONLESS seabed can have neutral horizontal modes on + its grounded nodes (zero restoring force). The minimum-norm solution projects + the neutral modes out -- they stay put under a static boundary displacement, + which is exactly the quasi-static physics. A merely ill-conditioned A is solved + plainly: the soft lateral modes of a long laid cable are physical, and + truncating them corrupts every subsystem's reduction. On the settled UMaine + deck A is regular (the seabed penalty and line tension restrain every node).""" if mod["n_x"] == 0: return mod["D"] A = mod["A"] sv = np.linalg.svd(A, compute_uv=False) cond = sv[0] / max(sv[-1], 1e-300) - print(f"MD state matrix: {A.shape[0]} states, cond ~ {cond:.2e}") - if cond > 1e10: + print(f"state matrix: {A.shape[0]} states, cond ~ {cond:.2e}") + if cond > 1e14: print("note: neutral modes; using the pseudo-inverse zero-frequency reduction") - X = np.linalg.lstsq(A, mod["B"], rcond=1e-8)[0] + X = np.linalg.lstsq(A, mod["B"], rcond=1e-12)[0] else: X = np.linalg.solve(A, mod["B"]) return mod["D"] - mod["C"] @ X +def line_modes(A: np.ndarray) -> tuple[np.ndarray, np.ndarray, float]: + """Natural frequencies (Hz) and damping ratios of the oscillatory modes of a + state matrix, ascending in frequency, and its largest eigenvalue real part.""" + ev = np.linalg.eigvals(A) + osc = ev[ev.imag > 1e-9 * max(np.abs(ev).max(), 1.0)] + wn = np.abs(osc) + order = np.argsort(wn) + return wn[order] / (2.0 * np.pi), -osc.real[order] / wn[order], float(ev.real.max()) + + +def deck_points(deck: Path) -> list[tuple[int, str, list[float], int]]: + """(id, type, xyz, line index) of every row of a deck's POINTS section.""" + out = [] + in_points = False + for k, ln in enumerate(deck.read_text().splitlines()): + if ln.lstrip().startswith("-"): + in_points = "POINTS" in ln.upper() + continue + tok = ln.split() + if in_points and len(tok) >= 5 and tok[0].isdigit(): + out.append((int(tok[0]), tok[1].lower(), [float(v) for v in tok[2:5]], k)) + return out + + +def driver_point_loads(driver: Path, deck: Path, work: Path, pid: int, xyz: list[float], + coupled: list[int]) -> np.ndarray: + """The static loads Point

F{x,y,z} on every coupled point with point pid moved + to xyz: the deck solved by the standalone driver at TMax = 0.""" + lines = deck.read_text().splitlines() + row = {p[0]: p[3] for p in deck_points(deck)}[pid] + tok = lines[row].split() + lines[row] = " ".join(tok[:2] + [f"{v:.10f}" for v in xyz] + tok[5:]) + out: list[str] = [] + in_outputs = False + has_tmax = any(re.match(r"^\s*\S+\s+TMax\b", ln) for ln in lines) + for ln in lines: + up = ln.strip().upper() + if ln.lstrip().startswith("-") and "OUTPUTS" in up: + if not has_tmax: + # a coupled deck leaves TMax to the host: the static start alone + out.append("0.0 TMax - Standalone duration (s); 0 solves the static start") + in_outputs = True + out.append(ln) + out.extend(f'"Point{p}F{c}"' for p in coupled for c in "xyz") + continue + if in_outputs: + if up.startswith("END"): + in_outputs = False + out.append(ln) + continue + if re.match(r"^\s*\S+\s+TMax\b", ln): + ln = re.sub(r"^\s*\S+", "0.0", ln, count=1) + out.append(ln) + work.mkdir(parents=True, exist_ok=True) + (work / "trial.dat").write_text("\n".join(out) + "\n") + proc = subprocess.run([str(driver), "trial.dat", "trial"], cwd=work, capture_output=True, + text=True, timeout=3600) + if proc.returncode != 0: + tail = "\n".join((proc.stdout + proc.stderr).splitlines()[-15:]) + die(f"driver failed on {deck.name} with point {pid} at {xyz}:\n{tail}") + rows = [r for r in (work / "trial.out").read_text().splitlines() if r.strip() and not r.startswith("#")] + head = rows[0].split() + vals = [float(v) for v in rows[1].split()] + return np.array([[vals[head.index(f"Point{p}F{c}")] for c in "xyz"] for p in coupled]) + + +def cable_gate(args: argparse.Namespace, case: Path, cd_fst: Path) -> list[str]: + """Gate 5: a mixed deck's coupled-point stiffness against its static solution.""" + src = args.cable_deck.resolve() + if not src.is_file(): + die(f"cable deck not found: {src}") + if not args.driver.is_file(): + die(f"driver not found: {args.driver}") + deck = case / "CableDyn_cable_lin.dat" + text, n_mu = re.subn(r"^(\s*)\S+(\s+frictionMu\b)", r"\1none\2", src.read_text(), flags=re.M) + deck.write_text(text) + fst = case / "Main_lin_cable.fst" + fst_text = cd_fst.read_text() + name = file_entry(fst_text, "MooringFile", cd_fst.name) + fst.write_text(fst_text.replace(f'"{name}"', f'"{deck.name}"')) + if not args.skip_run: + print(f"running {fst.name} ...") + run_case(args.exe, fst) + mod = parse_module_lin(case / "Main_lin_cable.1.CD.lin") + kb, _ = block(mod, -static_impedance(mod), ["force"], ["translation displacement"], + "cable-deck stiffness") + pts = [p for p in deck_points(deck) if p[1] in ("coupled", "vessel", "cpld", "ves")] + ids = [p[0] for p in pts] + if kb.shape != (3 * len(ids), 3 * len(ids)): + die(f"cable-deck stiffness block {kb.shape} does not match {len(ids)} coupled points") + h = args.cable_h + tol = args.cable_pct / 100.0 + worst_dom = worst_all = 0.0 + print(f"cable deck {src.name} (frictionMu rows set to none: {n_mu}), coupled points {ids}, " + f"static reference from +-{h} m driver solves; K lin / K static / rel. diff (N/m):") + for ip, (pid, _, xyz, _) in enumerate(pts): + kref = np.zeros((3, 3)) + for k in range(3): + xp, xm = list(xyz), list(xyz) + xp[k] += h + xm[k] -= h + fp = driver_point_loads(args.driver, deck, case / "cable_lin_work", pid, xp, ids) + fm = driver_point_loads(args.driver, deck, case / "cable_lin_work", pid, xm, ids) + kref[:, k] = -(fp[ip] - fm[ip]) / (2.0 * h) + b = kb[3 * ip:3 * ip + 3, 3 * ip:3 * ip + 3] + big = np.abs(kref).max() + for i in range(3): + cells = [] + for j in range(3): + rel = (b[i, j] - kref[i, j]) / kref[i, j] if abs(kref[i, j]) > 1e-2 * big else 0.0 + if abs(kref[i, j]) >= 0.1 * big: + worst_dom = max(worst_dom, abs(rel)) + if abs(kref[i, j]) >= 1e-2 * big: + worst_all = max(worst_all, abs(rel)) + cells.append(f"{b[i, j]:11.5g} / {kref[i, j]:11.5g} / {rel:+.2e}") + print(f" point {pid} {'xyz'[i]}: " + " | ".join(cells)) + print(f"cable deck: dominant entries max rel. diff {worst_dom:.2e} (gate {tol:.1e}); " + f"all entries >= 1% of block max {worst_all:.2e} (gate {2 * tol:.1e})") + if worst_dom > tol or worst_all > 2 * tol: + return ["the cable deck's linearized point stiffness differs from its static solution"] + return [] + + def block(mod: dict, K: np.ndarray, row_must: list[str], col_must: list[str], what: str) -> tuple: rows = match_indices(mod["y_labels"], row_must) cols = match_indices(mod["u_labels"], col_must) @@ -372,8 +520,20 @@ def main() -> None: help="OutFmt written into both decks; the .lin matrices use it") ap.add_argument("--md-tmaxic", type=float, default=400.0, help="MoorDyn dynamic-relaxation time TmaxIC (s)") + ap.add_argument("--n-modes", type=int, default=9, + help="lowest line modes whose frequencies are gated") + ap.add_argument("--freq-pct", type=float, default=1.0, + help="CableDyn vs MoorDyn line-mode frequency tolerance in %%") + ap.add_argument("--cable-deck", type=Path, + help="a mixed EI = 0 + finite-EI deck for gate 5 (needs --driver)") + ap.add_argument("--driver", type=Path, help="the standalone CableDyn driver (gate 5)") + ap.add_argument("--cable-h", type=float, default=0.05, + help="coupled-point displacement of the gate-5 static solves (m)") + ap.add_argument("--cable-pct", type=float, default=1.0, help="gate-5 tolerance in %%") ap.add_argument("--skip-run", action="store_true") args = ap.parse_args() + if (args.cable_deck is None) != (args.driver is None): + die("--cable-deck and --driver go together") case = args.case_dir cd_fst = case / "Main_lin_cd5.fst" @@ -390,9 +550,9 @@ def main() -> None: md = parse_module_lin(case / "Main_lin_md3.1.MD.lin") print(f"CD: n_x={cd['n_x']} n_u={len(cd['u_labels'])} n_y={len(cd['y_labels'])}") print(f"MD: n_x={md['n_x']} n_u={len(md['u_labels'])} n_y={len(md['y_labels'])}") - if cd["n_x"] != 0: - die("CableDyn module reported continuous states under linearization " - "(the dYdu-only reduction must register Nx = 0)") + if cd["n_x"] == 0: + die("CableDyn module reported no continuous states under linearization " + "(the line positions and velocities must be states)") r_cd = coupled_points(cd_fst) r_md = coupled_points(md_fst) @@ -484,6 +644,27 @@ def main() -> None: if np.abs(rel_d).max() > tol or norm.max() > tol: failures.append("platform 6x6 stiffness differs from MoorDyn beyond the gate") + # 4. The dynamics: stability and the lowest line-mode frequencies. + f_cd, z_cd, re_cd = line_modes(cd["A"]) + f_md, z_md, re_md = line_modes(md["A"]) + nm = args.n_modes + if len(f_cd) < nm or len(f_md) < nm: + die(f"fewer than {nm} oscillatory modes (CD {len(f_cd)}, MD {len(f_md)})") + rel_f = f_cd[:nm] / f_md[:nm] - 1.0 + print(f"state matrices: max Re(lambda) CD {re_cd:.3e}, MD {re_md:.3e} (gate < 0)") + print(f"lowest {nm} line modes, f [Hz] CD / MD / rel. diff, damping ratio CD / MD (not gated):") + for i in range(nm): + print(f" {i + 1:2d} {f_cd[i]:.6f} / {f_md[i]:.6f} / {rel_f[i]:+.2e} {z_cd[i]:.4f} / {z_md[i]:.4f}") + print(f"line modes: max |rel. diff| {np.abs(rel_f).max():.2e} (gate {args.freq_pct / 100.0:.1e})") + if not (re_cd < 0.0 and re_md < 0.0): + failures.append("a state matrix has an eigenvalue in the right half-plane") + if np.abs(rel_f).max() > args.freq_pct / 100.0: + failures.append("the line-mode frequencies differ from MoorDyn beyond the gate") + + # 5. Optional: a mixed deck's coupled points against its own static solution. + if args.cable_deck is not None: + failures += cable_gate(args, case, cd_fst) + if failures: die("; ".join(failures)) print("PASS") From 287e3a9c654b77d1e57b68d587f8c2216a9466c1 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 01:58:56 +0900 Subject: [PATCH 18/51] feat(syrope): composite lines, a Syrope section between chains (#67) A Syrope line had to be a single taut section. A LINE can now carry Syrope sections between plain EI = 0 sections, such as the chain-polyester-chain mooring of a floating platform. init_one_syrope_model builds each Syrope section's working curve and solves the static start through init_one_model with a secant EA per element. On a composite line the tension varies along a sagging Syrope section, so each Syrope element takes the secant of its rest curve at its own tension: every element starts on its curve, its slow strain at rest. One secant per section left the elements away from the mean off the curve, and their slow strains moved the fairlead tension by 1.4e-5 within 2 s; now a still run keeps it to the printed digits. The tension update stays a contraction where the chains' weight and the geometry set the tension. The line's sections split into runs of one secant for the model build (the mesh is unchanged), the chains keep their BA damping, and a converged tension above the OWC table or a slack Syrope element stops with a named error. An iterate whose trial tension (the first solve at the working curve's alpha) overshoots the table takes the curve's secant at the table's top row and the update continues. Where the tension update contracts slowly (a lightly loaded rope near a working curve's zero-tension strain), the last two solves' response at each element, crossed with its rest curve, gives a safeguarded secant step. A single-section line keeps its secant from the mean strain: all 52 example decks are bit-identical. SYROPE IC applies to every Syrope section of a line; the Python deck reader accepts it on any line with a Syrope section. New test syrope_composite (every polyester element on its OWC to 2e-11, the equilibrium start, the Tmax0 working curve, the named refusals) and example composite_chain_syrope_chain.dat on a moving vessel. The driver format, the rope guide and the tutorial no longer describe the current, waves and bathymetry the Syrope hydrodynamics now carry as refused. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 7 + CMakeLists.txt | 8 +- VALIDATION.md | 2 +- doc/capabilities.rst | 7 +- doc/driver_format.md | 18 +- doc/examples.rst | 5 + doc/modeling.rst | 2 +- doc/tutorial_ropes.rst | 4 +- examples/README.md | 4 +- examples/SYNTHETIC_ROPES.md | 7 +- examples/composite_chain_syrope_chain.dat | 59 +++ python/cabledyn/builder.py | 2 +- python/cabledyn/deck_file.py | 6 +- python/tests/test_deck_file.py | 8 +- src/CableDyn_DeckDriver.f90 | 579 +++++++++++++++++----- tests/test_deck_driver.f90 | 26 +- tests/test_syrope_composite.f90 | 394 +++++++++++++++ 17 files changed, 989 insertions(+), 149 deletions(-) create mode 100644 examples/composite_chain_syrope_chain.dat create mode 100644 tests/test_syrope_composite.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 2622d9a1..5424649a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,13 @@ All notable changes to CableDyn are recorded in this file. The format follows chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end connection, VIV lines, bodies, rods, buoys, torsion and `CONTROL` fail closed with named messages. This replaces the quasi-static linearisation without states. +- Composite Syrope lines: a Syrope polyester section between plain `EI = 0` sections, such as a + chain-polyester-chain mooring, in one LINE. The static start puts every Syrope element on the + rest curve of its load history with its own secant EA (the tension varies along a sagging + section), so the dynamics start in the static equilibrium; the chains keep their `BA` damping, + 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. - 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 7f9167d2..b5bd24c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2076,6 +2076,11 @@ target_link_libraries(test_section_curvature PRIVATE cabledyn_core) add_test(NAME section_curvature COMMAND test_section_curvature) set_tests_properties(section_curvature PROPERTIES LABELS "fortran;driver;integration;static") +add_executable(test_syrope_composite tests/test_syrope_composite.f90) +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_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}) @@ -2882,7 +2887,8 @@ foreach(_floor_case IN ITEMS held_start_gomex80_power_cable held_start_humboldt8 set_tests_properties(${_floor_case} PROPERTIES LABELS "fortran;driver;integration;dynamic") endforeach() foreach(_dyn_example IN ITEMS dynamic_chain_held dynamic_chain_current dynamic_chain_waves - ve_polyester_dynamic_waves syrope_polyester_mooring clump_weight_free_point connect_weighted_point) + ve_polyester_dynamic_waves syrope_polyester_mooring composite_chain_syrope_chain clump_weight_free_point + connect_weighted_point) add_test(NAME example_${_dyn_example} COMMAND cabledyn "${CMAKE_CURRENT_SOURCE_DIR}/examples/${_dyn_example}.dat" "${CMAKE_CURRENT_BINARY_DIR}/example_${_dyn_example}") diff --git a/VALIDATION.md b/VALIDATION.md index 6f4db7d2..10f1362e 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -812,7 +812,7 @@ stop with a named error. | Coupled pinned rods (`Pinned`, `CoupledPinned`/`VesselPinned`) | Pass verified | `openfast_pinned_rod` on the aggregate: a dry rod (10 m, 500 kg) released at 30° swings with the elliptic-integral compound-pendulum period to 1.6e-4 at `dt = T/100`, End A on the pin to 0 m; a held `CoupledPinned` node reproduces the `Pinned` rod to round-off (1e-12), returns zero moment, and its force equals the analytic pin reaction to 2.0e-13 of `mg`; a pin accelerating at 2 m/s² gives the mean angle `atan(a/g)` to 1e-6 rad and the period of `sqrt(g² + a²)` to 1.6e-4; a harmonic pin motion follows the linear base-excitation solution to 1.5e-3 / 3.7e-4 of the amplitude at `T0/100` / `T0/200` (ratio 4.03); a 0.1 s step sub-cycled 7 times reproduces a run at the sub-step size to 1e-14 rad and 4e-10 N for a drifting pin; a 1 m `Pinned` rod that carries no line (dry and hanging, or buoyant and upright under water) at a 0.6 s step (`omega0 dt` 2.29 / 3.42, beyond the explicit limit 2) sub-cycles it 6 / 9 times from its own swing stiffness `|W d_g - B d_b|`, equals the run at the sub-step size bit for bit, stays within its release angle and keeps the elliptic-integral period to 6.0e-3 / 5.9e-3 (taken whole, the step turns the rod over); a `CoupledPinned` pin crossing the free surface within one step at constant velocity (a 1 kg/m rod lifted from submerged to dry in 0.1 s, `omega dt` 2.13 wet; a 33 kg/m rod lowered from dry to submerged in 0.6 s, 2.29 dry) takes at least 6 sub-steps from its step-start wetting (more from the waterplane near the surface) and ends within 5e-5 / 3e-4 rad of a run at a sixtieth of the step, where the end-of-step wetting alone gives one sub-step and an angle error of 0.20 / 0.69 rad; on a stiff seabed (`kBot` 1e7 N/m³) a `Pinned` rod whose far end rests on the bed (0.1 s step) and a `Free` rod lying on it (0.05 s step) sub-cycle their contact mode (34–36 and 26 sub-steps), stay at rest on the bed over 5 s (angle change 3.8e-3 / 4e-15 rad, the undamped static settlement) and end within 1.9e-6 / 8e-8 of a run at a tenth of the step, where the sub-steps of the lines and swing alone (1 and 4) throw them off the bed (4.2 rad, 0.8 m); an output probe returns `-m (I_c/I_p) a_p` within 1e-10 of `mg` (not `-m a_p`), and its pin force moves by 2e-11 N when the held end acceleration of the attached tethers changes their end load by 8 N; snapshot/restore, probe restore and restart overlay are bit-identical, the restored state's loads before the next step included; a step without the staged rods (the step-start pin carried by the rod) is bit-identical to the staged one; a `Free` or `Coupled` rod with an end without a line is refused by name; with `PtfmInit` the static start leaves 1.4e-8 N·m about the pin. OpenFAST (IEA-15 UMaine, JONSWAP Hs 6 m, 60 s, `dtM = DT = 0.025 s`) with line 1 hung from a 4 m `CoupledPinned` rod at its fairlead: `openfast -restart` at 30 s reproduces every later OpenFAST output row bit for bit (`NumCrctn` 0 and 1), `NumCrctn = 1` equals `NumCrctn = 0` bit for bit, and surge/heave/pitch statistics stay within 0.2 % / 0.4 % / 1.7 % (mean) of the deck with line 1 on a `Coupled` point | | Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | -| Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. The line takes the seabed, Morison loads, current, waves, host fluid and VIV of any `EI = 0` line: a taut 88.5 m polyester line in water whose fairlead sways 2 m matches MoorDyn-C v2.7.2 within 10.6 N over a 44.8 kN tension range (1.03 MN mean; t = 0 within 0.5 N), and its range grows 4.8 % without drag and added mass (`syrope_hydro`). Composite and finite-EI combinations stop with a named error | +| Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. The line takes the seabed, Morison loads, current, waves, host fluid and VIV of any `EI = 0` line: a taut 88.5 m polyester line in water whose fairlead sways 2 m matches MoorDyn-C v2.7.2 within 10.6 N over a 44.8 kN tension range (1.03 MN mean; t = 0 within 0.5 N), and its range grows 4.8 % without drag and added mass (`syrope_hydro`). Composite lines (a 400 m Syrope polyester section between chains, `syrope_composite`): every polyester element starts on its OWC to 2e-11 across its 1.005–1.012 MN tension range, a still run keeps the fairlead tension to the printed digits (one secant per section moved it by 1.4e-5 within 2 s), the chains keep their `BA` damping, a `SYROPE IC` history puts the section on the `Tmax0` working curve, a line split into two Syrope sections reaches the single section's tensions to 1e-8, and a tension above the OWC table stops with a named error. Finite-EI combinations stop with a named error | | Cross-flow VIV (LINE TYPES `Cl`) | Pass verified | `EI = 0` lines and finite-EI cables on the aggregate with the host's fluid field: an `EI = 0` riser and a cable (EI 1 N m²) in a 0.15 m/s host current lock in at A/D 0.6645 / 0.6646 and 0.292 Hz (MoorDyn-F 0.662 at 0.293 Hz; standalone 0.665); the phases, running mean squares and averaging time ride in the checkpoint state and the correction rewind: a rebuild from the checkpoint continues bit for bit, one without the VIV reload does not (`viv_coupled`). OpenFAST (IEA-15 UMaine mixed deck, `Cl` 0.8 on the lazy-wave cable, SeaState 0.5 m/s current, 60 s): `openfast -restart` at 30 s reproduces every later CableDyn and OpenFAST output row bit for bit | **Standalone mixed aggregate.** `CableDyn_driver.exe` partitions and steps the diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 902b8201..257140f9 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -77,9 +77,10 @@ Line and constitutive capability including load-dependent dynamic stiffness; ``EI = 0`` lines * - Syrope polyester - Supported with limits - - single-section taut dynamic line with OWC and two history states, with the seabed, - Morison loads, current, waves, host fluid fields and VIV of any ``EI = 0`` line; - composite and finite-EI combinations fail closed by name + - dynamic line with OWC and two history states, single-section and taut or between + linear-elastic ``EI = 0`` sections (chain–polyester–chain), with the seabed, Morison loads, + current, waves, host fluid fields and VIV of any ``EI = 0`` line; finite-EI combinations + fail closed by name * - Torsion of finite-EI lines - Supported with limits - condensed isotropic torsion (uniform torque, quasi-static: no torsional inertia) of a diff --git a/doc/driver_format.md b/doc/driver_format.md index 3e299aa8..550d19d1 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -286,9 +286,16 @@ and `BA = BA_s|BA_d`: or `EXP`), `k1`, and `k2` rows as `value name`. `OWC` names the original-working-curve table, resolved relative to the settings file: a `strain tension` table of at least two numeric rows. - `BA_d` enters the slow-state rate; the physical damping contribution is `BA_s*d(eps_slow)/dt`. -- A Syrope type requires `EI = 0`. A Syrope line must be a single section, taut at - initialisation, and run on a dynamic deck (`dtM`/`TMax`). It does not support `bathymetryFile`, - deck current or waves, or host-driven fluid loads. A flat `WtrDpth` seabed is accepted. +- A Syrope type requires `EI = 0`. A Syrope line is either a single section, taut at + initialisation, or a composite line whose other sections are linear-elastic `EI = 0` sections (a + chain–polyester–chain mooring), with every Syrope element in tension at initialisation. It runs + on a dynamic deck (`dtM`/`TMax`) and takes the seabed, `bathymetryFile`, Morison loads, current, + waves, host fluid fields and VIV of any `EI = 0` line. +- The static start solves each Syrope element on the rest curve of its load history (the OWC, or + the `Tmax0` working curve under `SYROPE IC`). A single-section line takes one secant EA from the + curve at its mean strain; on a composite line, where the tension varies along a sagging Syrope + section, every Syrope element takes its own secant at its own tension, so every element starts + on its curve and the dynamics start in the static equilibrium. The settings-file grammar is in [Auxiliary file formats](file_formats.rst). @@ -718,8 +725,9 @@ Line(s) Tmax0 Tmean0 The last two tokens are `Tmax0 Tmean0`; the tokens before them form the line list. Line ids are comma-separated (`1,2` or `1, 2`); ids separated only by spaces are rejected. Values must satisfy -`Tmax0 >= Tmean0 >= 0` and `Tmax0 > 0`, and be finite. Every referenced line must be a -single-section Syrope line, named in only one row. +`Tmax0 >= Tmean0 >= 0` and `Tmax0 > 0`, and be finite. Every referenced line must have a +Syrope section, and be named in only one row. On a composite line the history applies to every +Syrope section. `Tmax0` is the rope's running maximum tension. The static initial condition is solved on its rest curve, the working curve regenerated at `Tmax0` (the OWC beyond that curve's top strain). diff --git a/doc/examples.rst b/doc/examples.rst index 342e0d79..cb8abf50 100644 --- a/doc/examples.rst +++ b/doc/examples.rst @@ -158,6 +158,11 @@ for the equations, the viscoelastic (series-Kelvin) and Syrope sections of :doc: ``data/syrope/syrope_settings.dat`` and ``data/syrope/syrope_owc.dat`` - cable, dynamic - < 1 s + * - ``composite_chain_syrope_chain.dat`` + - chain–Syrope polyester–chain mooring on a vessel in a 12 s surge, heave and pitch record; + needs ``data/syrope/`` and ``data/vessel/vessel_surge_heave_pitch_12s_dt005.txt`` + - cable, dynamic + - < 1 s Dynamic environment ------------------- diff --git a/doc/modeling.rst b/doc/modeling.rst index b13561a9..0bf65947 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -308,7 +308,7 @@ Use-case map - ``ve_polyester_dynamic_waves.dat`` - slow/dynamic state, relaxation time, cyclic tension * - Syrope polyester - - ``syrope_polyester_mooring.dat`` + - ``syrope_polyester_mooring.dat`` / ``composite_chain_syrope_chain.dat`` - OWC/settings files, initial history, supported-combination limits * - Current/wave-loaded mooring - ``dynamic_chain_current.dat`` / ``dynamic_chain_waves.dat`` diff --git a/doc/tutorial_ropes.rst b/doc/tutorial_ropes.rst index f5e613ff..51527568 100644 --- a/doc/tutorial_ropes.rst +++ b/doc/tutorial_ropes.rst @@ -121,7 +121,9 @@ The static initial condition is solved on the ``Tmax0`` working curve, and the l that equilibrium: ``FairTen1`` is 972.8 kN at t = 0 and stays there over the 2 s run (the fairlead is held). With both ends fixed, the geometry and ``Tmax0`` set the mean tension, so ``Tmean0`` does not enter the state. The driver prints a note because this deck's 1.5 MN differs from the -972.8 kN equilibrium. Syrope lines are single-section and run dynamically (``dtM``/``TMax``). +972.8 kN equilibrium. Syrope lines run dynamically (``dtM``/``TMax``). A Syrope section can also +sit between chains: ``composite_chain_syrope_chain.dat`` is a chain–polyester–chain mooring on a +moving vessel, every polyester element starting on its working curve. .. important:: diff --git a/examples/README.md b/examples/README.md index 416de1b3..f2acc80e 100644 --- a/examples/README.md +++ b/examples/README.md @@ -43,9 +43,9 @@ Copy a deck under a new name and keep every file it references at the same relat | --- | --- | | `*.dat` | Standalone decks. `iea15mw_umaine_openfast_cabledyn.dat` is an OpenFAST-only `MooringFile`; `iea15mw_umaine_mixed_cabledyn.dat` runs both standalone and coupled. | | `openfast/` | IEA-15MW VolturnUS-S `.fst` pair (`CompMooring = 5` and `3`) with their mooring decks; see [openfast/README.md](openfast/README.md). | -| `data/syrope/` | Syrope settings and original working-curve table used by `syrope_polyester_mooring.dat`. | +| `data/syrope/` | Syrope settings and original working-curve table used by `syrope_polyester_mooring.dat` and `composite_chain_syrope_chain.dat`. | | `data/lozon/` | Prescribed hang-off heave history for `lozon_gomex80_power_cable_motion.dat` and the script that generates it. | -| `data/vessel/` | 6-DOF vessel-motion record for `lazy_wave_vessel_motion.dat`, the script that generates it, and the illustrative RAO table for `lazy_wave_vessel_rao.dat` and `lazy_wave_bend_stiffener.dat`. | +| `data/vessel/` | 6-DOF vessel-motion record for `lazy_wave_vessel_motion.dat` and `composite_chain_syrope_chain.dat`, the script that generates it, and the illustrative RAO table for `lazy_wave_vessel_rao.dat` and `lazy_wave_bend_stiffener.dat`. | | `data/torsion/` | Hang-off roll history (motionFile roll column) for `torsion_lazy_wave_hangoff_twist.dat` and the script that generates it. | | `data/range_tdp/` | Fairlead surge history for `chain_range_tdp.dat` and the script that generates it. | | `moordynC_wavekin/` | A deck with the MoorDyn-C `wave_frequencies.txt` and `current_profile.txt` files it reads from its own folder. | diff --git a/examples/SYNTHETIC_ROPES.md b/examples/SYNTHETIC_ROPES.md index 556e6fb5..d9dfcfb0 100644 --- a/examples/SYNTHETIC_ROPES.md +++ b/examples/SYNTHETIC_ROPES.md @@ -54,9 +54,10 @@ rope 0.1438 22.42 "SYROPE:data/syrope/syrope_settings.dat|1.53e8|23.12" initialisation with the offending tension and the next admissible `Tmax`. `EXP` requires `k2 > 0`. - Viscoelastic and Syrope line types require `EI = 0`; a finite-EI type is rejected. -- A Syrope line must be a single section and taut at initialisation, and the deck must set - `dtM` and `TMax` (there is no static-only output). Current, waves, bathymetry and host-driven - hydrodynamic loads on a Syrope line are rejected with an error naming the feature. +- A Syrope line is a single section, taut at initialisation, or a composite line whose other + sections are linear-elastic `EI = 0` sections (`composite_chain_syrope_chain.dat`), and the deck + must set `dtM` and `TMax` (there is no static-only output). It takes the seabed, bathymetry, + Morison loads, current, waves, host fluid fields and VIV of any `EI = 0` line. ## Run the Syrope example diff --git a/examples/composite_chain_syrope_chain.dat b/examples/composite_chain_syrope_chain.dat new file mode 100644 index 00000000..8aca158a --- /dev/null +++ b/examples/composite_chain_syrope_chain.dat @@ -0,0 +1,59 @@ +--------------------- CableDyn Input File ------------------------------------ +CableDyn driver deck -- composite chain + SYROPE polyester + chain mooring on a moving vessel +-- One LINE of three SECTIONS in End-A(fairlead)->End-B(anchor) order: a 100 m studless chain +-- at the fairlead, a 400 m polyester section with the Syrope working-curve model, and a 250 m +-- chain at the anchor, in 200 m of water. The line of composite_chain_poly_chain.dat with its +-- anchor 30 m further out, so the polyester carries about 1 MN. The polyester's EA and BA +-- columns, its settings and OWC files, are those of syrope_polyester_mooring.dat. The static +-- start puts every polyester element on its rest curve (here the OWC: the rope is virgin), so +-- the dynamics start in that equilibrium. The vessel then surges, heaves and pitches in the +-- 12 s record of lazy_wave_vessel_motion.dat, with its 12 s smooth start. +-- chain 155 mm R4 studless: volume-equivalent diam 0.2791 m, dry mass 480.93 kg/m, EA 2.058e9 N. +-- polyester 181.8 mm: diam 0.1438 m, dry mass 22.42 kg/m. +--------------------- LINE TYPES --------------------------------------- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (-) (N-s|N-s) (N-m^2) (-) (-) (-) (-) +chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0 +polyester 0.1438 22.42 "SYROPE:data/syrope/syrope_settings.dat|1.53e8|23.12" 5.0e10|1.0e5 0.0 1.2 0.2 1.0 0.0 +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 780.0 0.0 -200.0 0 0 0 0 +2 Coupled 58.0 0.0 -14.0 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 2 1 - +--------------------- SECTIONS ----------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 100.0 12 +1 polyester 400.0 40 +1 chain 250.0 25 +--------------------- OPTIONS ------------------------------------------ +9.80665 g - Gravitational acceleration (m/s^2) [default: 9.80665] +1025.0 rhoW - Water density (kg/m^3) [default: 1025] +200.0 WtrDpth - Water depth (m) [default: absent standalone; host-owned OpenFAST] +3.0e6 kBot - Seabed penalty stiffness base (Pa/m) [default: 1.0e5] +1.0e4 cBot - Seabed normal damping base (Pa-s/m) [default: 1.0e4] +0.05 dtM - CableDyn internal time step (s) [default: omitted standalone; the glue DT in OpenFAST] +36.0 TMax - Standalone simulation duration (s), including the 12 s smooth start +data/vessel/vessel_surge_heave_pitch_12s_dt005.txt vesselMotion - 6-DOF vessel record moving every Coupled point rigidly +0.0|0.0|0.0 vesselRef - Vessel reference point, rotation centre and RAO origin (m) [default: 0|0|0] +0.4 rhoInf - Generalised-alpha spectral radius {0<=rhoInf<=1} [default: 0.4] +False modified_newton - Tangent-reuse mode {False=full Newton; True=guarded reuse} [default: False] +False adaptive_mesh - Automatic finite-EI refinement {False; True} [default: False] +dynamic_solver 1.0e-8 1.0e-14 30 12 - Relative tolerance, absolute tolerance, max iterations, backtracks [defaults shown] +none frictionMu - Seabed friction coefficient {none; value>=0} [default: none] +none current - Current model and velocity (m/s) {none; uniform; profile} [default: none] +none waves - Wave model, height, period, and direction (m, s, deg) {none; airy; jonswap} [default: none] +0 WaterKin - Water-kinematics source {0/none; file; SEASTATE coupled only} [default: no policy] +-- Complete option/default reference: cabledyn_options_reference.dat and doc/options.rst. +--------------------- OUTPUTS ------------------------------------------ +"FairTen1" +"AnchTen1" +"FairIncl1" +"AnchIncl1" +"Point2px" +"Point2pz" +--------------------- need this line ----------------------------------- diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 17d8e717..13f6cabc 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -669,7 +669,7 @@ class SyropeIC: Attributes ---------- lines : list[Line] - The single-section Syrope lines. + The lines with a Syrope section (alone or in a composite line). tmax0 : float Running maximum tension, in N. tmean0 : float diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index ef9bbb5f..2963c432 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3896,12 +3896,10 @@ def is_body_kind(kind: str, pinned: bool) -> bool: f"{self._at(row)}: SYROPE IC must follow its referenced LINE definitions" ) if any( - len(section_types_by_line[value]) != 1 - or section_types_by_line[value][0] not in syrope_types - for value in ids + not any(t in syrope_types for t in section_types_by_line[value]) for value in ids ): raise DeckFormatError( - f"{self._at(row)}: SYROPE IC can reference only a single-section Syrope line" + f"{self._at(row)}: SYROPE IC can reference only a line with a Syrope section" ) if assigned_syrope.intersection(ids): raise DeckFormatError(f"{self._label}: duplicate SYROPE IC line assignment") diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 0e93c791..37f0bec3 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -1362,7 +1362,7 @@ def test_syrope_ic_accepts_spaces_after_id_commas(tmp_path): assert deck.text() == path.read_bytes().decode("utf-8") -def test_syrope_ic_requires_a_single_syrope_section(tmp_path): +def test_syrope_ic_requires_a_syrope_section(tmp_path): chain = (ROOT / "examples/chain_catenary_r3_100m.dat").read_text(encoding="utf-8") chain = chain.replace( "--------------------- SECTIONS -----------------------------------------", @@ -1372,9 +1372,10 @@ def test_syrope_ic_requires_a_single_syrope_section(tmp_path): ) non_syrope = tmp_path / "non-syrope-ic.dat" non_syrope.write_text(chain, encoding="utf-8") - with pytest.raises(DeckFormatError, match="single-section Syrope line"): + with pytest.raises(DeckFormatError, match="line with a Syrope section"): DeckFile.read(non_syrope) + # a composite line with a Syrope section takes the history (every Syrope section's) syrope = (ROOT / "examples/syrope_polyester_mooring.dat").read_text(encoding="utf-8") syrope = syrope.replace( "1 rope 20.0 8", @@ -1382,8 +1383,7 @@ def test_syrope_ic_requires_a_single_syrope_section(tmp_path): ) composite = tmp_path / "composite-syrope-ic.dat" composite.write_text(syrope, encoding="utf-8") - with pytest.raises(DeckFormatError, match="single-section Syrope line"): - DeckFile.read(composite) + DeckFile.read(composite) DeckFile.read(ROOT / "examples/syrope_polyester_mooring.dat") diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 56d9903a..f4cf1b08 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -50,7 +50,8 @@ MODULE CableDyn_DeckDriver USE CableDyn_Damping, ONLY: CD_Resolve_Legacy_BA, CD_DAMP_OK USE CableDyn_Syrope, ONLY: CD_SYROPE_WC_LINEAR, CD_SYROPE_WC_QUADRATIC, CD_SYROPE_WC_EXP, & CD_SyropeType, CD_Syrope_Init, CD_Syrope_End, & - CD_Syrope_Static_Tension, CD_Syrope_Slow_For_Tension, CD_SYROPE_OK + CD_Syrope_Static_Tension, CD_Syrope_Slow_For_Tension, CD_SYROPE_OK, & + CD_SYROPE_BADINPUT USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_DYN_OK, CD_EI0_SUBSTEPS_OFF, CD_EI0_SUBSTEPS_AUTO USE CableDyn_Model, ONLY: CD_ModelType, CD_Init_Line_Model, CD_End_Model, CD_Model_NCoupledDOF, CD_Model_NDOF, & CD_Get_Model_CoupledDofs, CD_Get_Model_State, CD_Get_Model_Tension, & @@ -8756,10 +8757,11 @@ END SUBROUTINE line_static_friction RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry, & syrope_secant, syrope_is, syrope_type, syrope_slow0, syrope_tmax0) - !! Initialize one persistent model from a validated deck LINE. A Syrope line is built by - !! init_one_syrope_model, which calls back here with syrope_secant (the secant EA of its - !! static solve) and, for the final build, the per-element Syrope states: the line then - !! takes the same seabed, hydrodynamics and fluid fields as any EI = 0 line. + !! Initialize one persistent model from a validated deck LINE. A line with a Syrope section is + !! built by init_one_syrope_model, which calls back here with syrope_secant (per element, + !! anchor first: the static secant EA of each Syrope element; other elements ignored) and, for + !! the final build, the per-element Syrope states: the line then takes the same seabed, + !! hydrodynamics and fluid fields as any EI = 0 line. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckLineType), INTENT(IN) :: types(:) @@ -8769,7 +8771,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - REAL(wp), INTENT(IN), OPTIONAL :: syrope_secant + REAL(wp), INTENT(IN), OPTIONAL :: syrope_secant(:) LOGICAL, INTENT(IN), OPTIONAL :: syrope_is(:) TYPE(CD_SyropeType), INTENT(IN), OPTIONAL :: syrope_type(:) REAL(wp), INTENT(IN), OPTIONAL :: syrope_slow0(:), syrope_tmax0(:) @@ -8784,6 +8786,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er REAL(wp), ALLOCATABLE :: hydro_diam(:), hydro_cdn(:), hydro_cdt(:), hydro_can(:), hydro_cat(:) REAL(wp), ALLOCATABLE :: ve_ead(:), ve_bas(:), ve_bad(:), ve_ambl(:), ve_vbet(:) REAL(wp), ALLOCATABLE :: viv_cl(:), viv_cf(:), viv_df(:) + LOGICAL, ALLOCATABLE :: syr_el(:) REAL(wp) :: anchor(3), fairlead(3) REAL(wp), PARAMETER :: factors(4) = [0.25_wp, 0.5_wp, 0.75_wp, CD_ONE] INTEGER :: j, i, e, es @@ -8821,7 +8824,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er ALLOCATE (ba(SIZE(l0)), hydro_diam(SIZE(l0)), hydro_cdn(SIZE(l0)), hydro_cdt(SIZE(l0)), & hydro_can(SIZE(l0)), hydro_cat(SIZE(l0)), ve_ead(SIZE(l0)), ve_bas(SIZE(l0)), & ve_bad(SIZE(l0)), ve_ambl(SIZE(l0)), ve_vbet(SIZE(l0)), viv_cl(SIZE(l0)), viv_cf(SIZE(l0)), & - viv_df(SIZE(l0))) + viv_df(SIZE(l0)), syr_el(SIZE(l0))) viv_cl = CD_ZERO viv_cf = CD_ZERO viv_df = CD_ZERO @@ -8864,8 +8867,10 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er viv_cl(e) = types(line_section_type(sections, ln%id, i))%cl viv_cf(e) = types(line_section_type(sections, ln%id, i))%viv_cf viv_df(e) = types(line_section_type(sections, ln%id, i))%viv_df + syr_el(e) = types(line_section_type(sections, ln%id, i))%is_syrope END DO END DO + syr_el = syr_el(SIZE(syr_el):1:-1) viv_cl = viv_cl(SIZE(viv_cl):1:-1) viv_cf = viv_cf(SIZE(viv_cf):1:-1) viv_df = viv_df(SIZE(viv_df):1:-1) @@ -8890,15 +8895,20 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er syt = line_section_type(sections, ln%id, i2) END DO IF (syt > 0 .AND. .NOT. PRESENT(syrope_secant)) THEN - CALL init_one_syrope_model(types, syt, ln, sections, points, l0, opts, model, ErrStat, ErrMsg, & + CALL init_one_syrope_model(types, ln, sections, points, l0, opts, model, ErrStat, ErrMsg, & bathymetry=bathymetry) RETURN END IF IF (PRESENT(syrope_secant)) THEN - ! the static solve's single secant EA; the working curve carries the rope's damping - ! (BA_s|BA_d), so the line takes no legacy BA on top of it - lts(secs(1)%line_type)%ea = syrope_secant - ba = CD_ZERO + ! each Syrope element's static secant EA; the working curve carries the rope's damping + ! (BA_s|BA_d), so its elements take no legacy BA on top of it (the other sections keep + ! theirs) + IF (SIZE(syrope_secant) /= SIZE(l0)) THEN + CALL fail(ErrStat, ErrMsg, 'internal: one Syrope secant per element expected'); RETURN + END IF + CALL syrope_secant_sections(syrope_secant, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + WHERE (syr_el) ba = CD_ZERO END IF END BLOCK ! external_fluid: the host prescribes per-node fluid kinematics each step, so the @@ -9164,22 +9174,96 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er END IF END BLOCK END IF + + CONTAINS + + SUBROUTINE syrope_secant_sections(sec_el, es_out, em_out) + !! The line's sections and types with the Syrope elements' secant EAs: a Syrope section + !! splits into runs of elements of one secant, each its own section and type (the mesh is + !! unchanged); a section whose elements share one secant, and every other section, stays + !! whole. + REAL(wp), INTENT(IN) :: sec_el(:) + INTEGER, INTENT(OUT) :: es_out + CHARACTER(*), INTENT(OUT) :: em_out + TYPE(CD_LineType), ALLOCATABLE :: lts_n(:) + TYPE(CD_LineSection), ALLOCATABLE :: secs_n(:) + INTEGER :: is, je, d, n, ne_l, j0 + REAL(wp) :: seg + es_out = CD_DECKDRV_OK + em_out = '' + ne_l = SIZE(sec_el) + ALLOCATE (lts_n(ne_l + SIZE(secs)), secs_n(ne_l + SIZE(secs))) + n = 0 + d = 0 ! deck-order element index (End A first); internal index ne_l + 1 - d + DO is = 1, SIZE(secs) + IF (.NOT. types(line_section_type(sections, ln%id, is))%is_syrope) THEN + n = n + 1 + lts_n(n) = lts(secs(is)%line_type) + secs_n(n) = secs(is) + secs_n(n)%line_type = n + d = d + secs(is)%n_segments + CYCLE + END IF + seg = secs(is)%length/REAL(secs(is)%n_segments, wp) + j0 = 1 + DO je = 1, secs(is)%n_segments + IF (je < secs(is)%n_segments) THEN + IF (bits_same(sec_el(ne_l + 1 - (d + je)), sec_el(ne_l - (d + je)))) CYCLE + END IF + ! the run j0..je of this section, one secant + n = n + 1 + lts_n(n) = lts(secs(is)%line_type) + lts_n(n)%ea = sec_el(ne_l + 1 - (d + je)) + secs_n(n)%line_type = n + secs_n(n)%n_segments = je - j0 + 1 + IF (j0 == 1 .AND. je == secs(is)%n_segments) THEN + secs_n(n)%length = secs(is)%length + ELSE + secs_n(n)%length = seg*REAL(je - j0 + 1, wp) + END IF + j0 = je + 1 + END DO + d = d + secs(is)%n_segments + END DO + IF (d /= ne_l) THEN + es_out = CD_DECKDRV_BADINPUT + em_out = 'internal: the Syrope secants do not match the line mesh' + RETURN + END IF + CALL MOVE_ALLOC(lts_n, lts) + CALL MOVE_ALLOC(secs_n, secs) + lts = lts(1:n) + secs = secs(1:n) + END SUBROUTINE syrope_secant_sections + + PURE LOGICAL FUNCTION bits_same(a, b) + REAL(wp), INTENT(IN) :: a, b + bits_same = .NOT. (a < b .OR. a > b) + END FUNCTION bits_same END SUBROUTINE init_one_model - RECURSIVE SUBROUTINE init_one_syrope_model(types, syt, ln, sections, points, l0, opts, model, ErrStat, ErrMsg, & + RECURSIVE SUBROUTINE init_one_syrope_model(types, ln, sections, points, l0, opts, model, ErrStat, ErrMsg, & bathymetry) - !! Build one Syrope line model: a single-section line, taut at init, with the seabed, - !! hydrodynamics and fluid fields of any EI = 0 line (init_one_model builds it). Builds the - !! working-curve constitutive from the parse-resolved OWC data and solves the static - !! equilibrium on the rest curve of the initial load history (the OWC for a virgin rope; - !! with SYROPE IC, the Tmax0 working curve below its top strain and the OWC above): the - !! secant EA of that curve at the solved mean strain, current drag included. Each element - !! then gets the running maximum of that history and the slow strain whose t = 0 kernel - !! force equals its static tension, so the dynamic state starts in the static - !! equilibrium. Tmean0 is not a state input (the fixed-end geometry and Tmax0 set the - !! mean tension); a disagreement beyond 1 % is reported on the console. + !! Build one Syrope line model: a line of one or more Syrope sections, alone (taut at init) or + !! between plain EI = 0 sections (a chain-polyester-chain mooring), with the seabed, + !! hydrodynamics and fluid fields of any EI = 0 line (init_one_model builds it). Builds each + !! Syrope section's working-curve constitutive from the parse-resolved OWC data and solves the + !! static equilibrium on the rest curve of the initial load history (the OWC for a virgin rope; + !! with SYROPE IC, the Tmax0 working curve below its top strain and the OWC above), current drag + !! included. Each Syrope element then gets the running maximum of that history and the slow + !! strain whose t = 0 kernel force equals its static tension, so the dynamic state starts in + !! the static equilibrium. Tmean0 is not a state input (the fixed-end geometry and Tmax0 set + !! the mean tension); a disagreement beyond 1 % is reported on the console. + !! The static solve uses secant EAs, iterated to the rest curve. A single-section line, taut + !! and of nearly uniform tension, takes one secant from the curve at its mean strain (the + !! strain the taut geometry fixes). On a composite line the tension varies along a sagging + !! Syrope section, so each Syrope element takes its own secant, from the curve's strain at the + !! element's tension: every element then starts on its rest curve, its slow strain at rest + !! (one secant per section would leave the elements away from the mean off the curve, and + !! their slow strains would settle the line after the start). The tension, which the chains' + !! weight and the geometry largely fix, keeps this update a contraction where a strain update + !! can overshoot. TYPE(DeckLineType), INTENT(IN) :: types(:) - INTEGER, INTENT(IN) :: syt TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckPoint), INTENT(IN) :: points(:) @@ -9190,88 +9274,144 @@ RECURSIVE SUBROUTINE init_one_syrope_model(types, syt, ln, sections, points, l0, CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - TYPE(CD_SyropeType) :: td - TYPE(CD_SyropeType), ALLOCATABLE :: stype(:) - LOGICAL, ALLOCATABLE :: sis(:) - REAL(wp), ALLOCATABLE :: sslow(:), stmax(:), t_static(:) - REAL(wp) :: anchor(3), fairlead(3), eps0, t_ref, secant, total_l0, t_hist, eps_bar, t_mean_static - INTEGER :: ne, e, es, n_owc, iter, nsec + INTEGER, PARAMETER :: MAX_ITER_COMPOSITE = 50 + ! per section in deck order (End A first): its line type, element count and, for a Syrope + ! section, its constitutive data; per element (internal order, anchor first): its section, + ! whether it is a Syrope element and its static secant EA + TYPE(CD_SyropeType), ALLOCATABLE :: tds(:), stype(:) + INTEGER, ALLOCATABLE :: sec_type(:), sec_nseg(:), el_sec(:) + LOGICAL, ALLOCATABLE :: sec_syr(:), sis(:) + REAL(wp), ALLOCATABLE :: sec_el(:), cand_el(:), sslow(:), stmax(:), t_static(:), eps_prev(:), t_prev(:) + REAL(wp) :: anchor(3), fairlead(3), eps0, t_ref, total_l0, t_hist, eps_bar, t_mean_static + REAL(wp) :: eps_e, change, secant, cand, eps_now, d_eps, d_t, eps_r, t_r, acc + INTEGER :: ne, e, es, n_owc, iter, nsec, j, k, isec, st + LOGICAL :: composite, converged CHARACTER(1024) :: em CHARACTER(24) :: s_eps, s_lo, s_hi ErrStat = CD_DECKDRV_OK ErrMsg = '' nsec = COUNT(sections%line_id == ln%id) - IF (nsec /= 1) THEN - CALL fail(ErrStat, ErrMsg, 'a Syrope line must be a single section (composite Syrope lines are '// & - 'not supported yet)'); RETURN - END IF - IF (types(syt)%ei > CD_ZERO) THEN - CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support finite-EI bending'); RETURN + ALLOCATE (sec_type(nsec), sec_nseg(nsec), sec_syr(nsec), tds(nsec)) + k = 0 + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= ln%id) CYCLE + k = k + 1 + sec_type(k) = sections(j)%ltype + sec_nseg(k) = sections(j)%nsegs + sec_syr(k) = types(sections(j)%ltype)%is_syrope + END DO + composite = nsec > 1 + ne = SIZE(l0) + IF (SUM(sec_nseg) /= ne) THEN + CALL fail(ErrStat, ErrMsg, 'internal: the Syrope line''s section element counts do not match its mesh') + RETURN END IF - ! internal order anchor (End B) -> fairlead (End A), as gather_line_inputs + DO k = 1, nsec + st = sec_type(k) + IF (types(st)%ei > CD_ZERO) THEN + IF (sec_syr(k)) THEN + CALL fail(ErrStat, ErrMsg, 'a Syrope line does not support finite-EI bending') + ELSE + CALL fail(ErrStat, ErrMsg, 'a composite Syrope line''s other sections must have EI = 0 (section '// & + TRIM(int_to_str(k))//' of LINE '//TRIM(int_to_str(ln%id))//')') + END IF + RETURN + END IF + IF (.NOT. sec_syr(k) .AND. types(st)%elastic_mod > 1) THEN + CALL fail(ErrStat, ErrMsg, 'a composite Syrope line''s other sections must be linear-elastic '// & + '(ElasticMod 1; section '//TRIM(int_to_str(k))//' of LINE '//TRIM(int_to_str(ln%id))//')') + RETURN + END IF + END DO + ! internal element order anchor (End B) -> fairlead (End A), as gather_line_inputs: element e + ! belongs to deck section el_sec(e) + ALLOCATE (el_sec(ne)) + e = ne + DO k = 1, nsec + DO j = 1, sec_nseg(k) + el_sec(e) = k + e = e - 1 + END DO + END DO anchor = points(find_point(points, ln%nodeB))%pos fairlead = points(find_point(points, ln%nodeA))%pos - ! the working-curve constitutive from the parse-resolved OWC data - CALL CD_Syrope_Init(td, types(syt)%syrope_owc_strain, types(syt)%syrope_owc_tension, & - types(syt)%syrope_wc_mod, types(syt)%syrope_p1, types(syt)%syrope_p2, & - types(syt)%syrope_alpha, types(syt)%syrope_beta, & - types(syt)%syrope_c1, types(syt)%syrope_c2, es, em) - IF (es /= CD_SYROPE_OK) THEN - CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN - END IF - ! geometric strain of the taut line; the working-curve tension there and the - ! OWC secant EA that makes the static solve land at that strain - total_l0 = SUM(l0) - eps0 = NORM2(fairlead - anchor)/total_l0 - CD_ONE - IF (.NOT. (eps0 > CD_ZERO)) THEN - CALL CD_Syrope_End(td) - CALL fail(ErrStat, ErrMsg, 'a Syrope line must be taut at init (stretched length > unstretched)'); RETURN - END IF - ! the OWC table must cover the initial strain: the interpolation would clamp at - ! the end rows and the line would start silently mis-tensioned - n_owc = SIZE(types(syt)%syrope_owc_strain) - IF (eps0 < types(syt)%syrope_owc_strain(1) .OR. eps0 > types(syt)%syrope_owc_strain(n_owc)) THEN - WRITE (s_eps, '(ES10.3)') eps0 - WRITE (s_lo, '(ES10.3)') types(syt)%syrope_owc_strain(1) - WRITE (s_hi, '(ES10.3)') types(syt)%syrope_owc_strain(n_owc) - CALL CD_Syrope_End(td) - CALL fail(ErrStat, ErrMsg, 'the Syrope line''s initial strain '//TRIM(ADJUSTL(s_eps))// & - ' lies outside its OWC table strain range ['//TRIM(ADJUSTL(s_lo))//', '// & - TRIM(ADJUSTL(s_hi))//']; extend the table or reduce the pretension'); RETURN - END IF + ! each Syrope section's working-curve constitutive from the parse-resolved OWC data + DO k = 1, nsec + IF (.NOT. sec_syr(k)) CYCLE + st = sec_type(k) + CALL CD_Syrope_Init(tds(k), types(st)%syrope_owc_strain, types(st)%syrope_owc_tension, & + types(st)%syrope_wc_mod, types(st)%syrope_p1, types(st)%syrope_p2, & + types(st)%syrope_alpha, types(st)%syrope_beta, & + types(st)%syrope_c1, types(st)%syrope_c2, es, em) + IF (es /= CD_SYROPE_OK) THEN + CALL release_syrope(.FALSE.) + CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN + END IF + END DO ! The load history: SYROPE IC Tmax0, or (no IC) a virgin rope loaded along the OWC. ! The static solve uses that history's rest curve (CD_Syrope_Static_Tension: the ! Tmax0 working curve below its top strain, the OWC above), so the equilibrium it ! finds is the rest state of the SAME constitutive state the dynamics start from. t_hist = CD_ZERO IF (ln%has_syrope_ic) t_hist = ln%syrope_tmax0 - CALL rest_tension(eps0, t_ref, es, em) - IF (es /= CD_SYROPE_OK) THEN - CALL CD_Syrope_End(td) - CALL fail(ErrStat, ErrMsg, 'SYROPE IC working curve: '//TRIM(em)); RETURN - END IF - IF (.NOT. (t_ref > CD_ZERO)) THEN - WRITE (s_eps, '(ES10.3)') eps0 - CALL CD_Syrope_End(td) - CALL fail(ErrStat, ErrMsg, 'the Syrope line is slack on its SYROPE IC working curve: the initial '// & - 'strain '//TRIM(ADJUSTL(s_eps))//' is below the zero-tension strain of the Tmax0 curve; '// & - 'lower Tmax0 or shorten the line'); RETURN - END IF - secant = t_ref/eps0 - ne = SIZE(l0) - ALLOCATE (stype(ne), sis(ne), sslow(ne), stmax(ne), t_static(ne)) - sis = .TRUE. + ALLOCATE (sec_el(ne), cand_el(ne), stype(ne), sis(ne), sslow(ne), stmax(ne), t_static(ne), eps_prev(ne), & + t_prev(ne)) + sis = .FALSE. + sslow = CD_ZERO + stmax = CD_ZERO + sec_el = CD_ZERO DO e = 1, ne - stype(e) = td - END DO - ! Static solve with a single secant EA, the line otherwise built as any EI = 0 line (seabed, - ! drag in the deck current, buoyancy). The secant is iterated to the rest curve at the solved - ! mean strain, so the static line carries the curve tension on average (a chord-strain - ! secant misses it by the sag and the current's deflection). - DO iter = 1, 6 + IF (.NOT. sec_syr(el_sec(e))) CYCLE + sis(e) = .TRUE. + stype(e) = tds(el_sec(e)) + END DO + secant = CD_ZERO + IF (.NOT. composite) THEN + ! geometric strain of the taut line; the working-curve tension there and the + ! OWC secant EA that makes the static solve land at that strain + total_l0 = SUM(l0) + eps0 = NORM2(fairlead - anchor)/total_l0 - CD_ONE + IF (.NOT. (eps0 > CD_ZERO)) THEN + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'a Syrope line must be taut at init (stretched length > unstretched)'); RETURN + END IF + ! the OWC table must cover the initial strain: the interpolation would clamp at + ! the end rows and the line would start silently mis-tensioned + IF (.NOT. strain_in_table(1, eps0)) THEN + CALL release_syrope(.TRUE.) + RETURN + END IF + CALL rest_tension(1, eps0, t_ref, es, em) + IF (es /= CD_SYROPE_OK) THEN + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'SYROPE IC working curve: '//TRIM(em)); RETURN + END IF + IF (.NOT. (t_ref > CD_ZERO)) THEN + WRITE (s_eps, '(ES10.3)') eps0 + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'the Syrope line is slack on its SYROPE IC working curve: the initial '// & + 'strain '//TRIM(ADJUSTL(s_eps))//' is below the zero-tension strain of the Tmax0 curve; '// & + 'lower Tmax0 or shorten the line'); RETURN + END IF + secant = t_ref/eps0 + sec_el = secant + ELSE + ! a first solve with each Syrope element at its placeholder stiffness (the working curve's + ! alpha); the tension update below takes it to the curve + DO e = 1, ne + IF (sis(e)) sec_el(e) = types(sec_type(el_sec(e)))%syrope_alpha + END DO + END IF + ! Static solve with the secant EAs, the line otherwise built as any EI = 0 line (seabed, drag + ! in the deck current, buoyancy). The secants are iterated to the rest curves, so the Syrope + ! elements carry their curve tensions (a chord-strain secant misses them by the sag and the + ! current's deflection). The solve just made belongs to the current secants, which are kept + ! once the candidates agree with them. + converged = .FALSE. + DO iter = 1, MERGE(MAX_ITER_COMPOSITE, 6, composite) CALL init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry=bathymetry, & - syrope_secant=secant) + syrope_secant=sec_el) IF (ErrStat /= CD_DECKDRV_OK) EXIT CALL CD_Get_Model_Tension(model, t_static, es, em) CALL CD_End_Model(model, ErrStat, ErrMsg) @@ -9280,35 +9420,130 @@ RECURSIVE SUBROUTINE init_one_syrope_model(types, syt, ln, sections, points, l0, ErrMsg = em END IF IF (ErrStat /= CD_MODEL_OK) EXIT - eps_bar = SUM(l0*t_static)/(secant*SUM(l0)) - CALL rest_tension(eps_bar, t_ref, es, em) - IF (es /= CD_SYROPE_OK .OR. .NOT. (t_ref > CD_ZERO .AND. eps_bar > CD_ZERO)) EXIT - IF (ABS(t_ref/eps_bar - secant) <= 1.0e-10_wp*secant) EXIT - secant = t_ref/eps_bar + IF (composite) THEN + ! each Syrope element: the curve's strain at its tension + change = CD_ZERO + cand_el = sec_el + DO e = 1, ne + IF (.NOT. sis(e)) CYCLE + isec = el_sec(e) + IF (.NOT. (t_static(e) > CD_ZERO)) THEN + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'Syrope section '//TRIM(int_to_str(isec))//' of LINE '// & + TRIM(int_to_str(ln%id))//' is slack at init; shorten the line or raise the pretension') + RETURN + END IF + ! an iterate's tension above the top of the table (the placeholder alpha can overshoot + ! the curve) takes the curve's secant at the table's top row, where the curve's secant + ! is continuous, so the update goes on; the converged tensions are checked against the + ! table below + eps_e = types(sec_type(isec))%syrope_owc_strain(SIZE(types(sec_type(isec))%syrope_owc_strain)) + CALL rest_tension(isec, eps_e, t_ref, es, em) + IF (es == CD_SYROPE_OK .AND. .NOT. (t_static(e) > t_ref)) & + CALL rest_strain(isec, t_static(e), eps_e, es, em) + IF (es /= CD_SYROPE_OK) THEN + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'Syrope section '//TRIM(int_to_str(isec))//' of LINE '// & + TRIM(int_to_str(ln%id))//': '//TRIM(em)); RETURN + END IF + IF (t_static(e) > t_ref) THEN + cand_el(e) = t_ref/eps_e + ELSE + cand_el(e) = t_static(e)/eps_e + END IF + ! the residual: how far the element's (strain, tension) sits off its curve + change = MAX(change, ABS(cand_el(e) - sec_el(e))/sec_el(e)) + ! The tension update contracts by 1 - (secant / tangent) of the curve, slowly where the + ! secant is far below the tangent (near a working curve's zero-tension strain). The + ! last two solves give the line's response at the element, a straight line in + ! (strain, tension) that falls as the secant stiffens (the tension rises, the strain + ! drops); its crossing with the rising curve is the next secant, a secant step on the + ! equilibrium. It is taken only beyond the tension update in the same direction and + ! at most 100 times as far, else the tension update stands. + eps_now = t_static(e)/sec_el(e) + IF (iter > 1) THEN + d_eps = eps_now - eps_prev(e) + d_t = t_static(e) - t_prev(e) + IF (d_eps*d_t < CD_ZERO) THEN + CALL response_root(isec, eps_now, t_static(e), d_eps, d_t, eps_r, t_r) + IF (eps_r > CD_ZERO .AND. t_r > CD_ZERO) THEN + acc = t_r/eps_r + IF ((acc - sec_el(e))*(cand_el(e) - sec_el(e)) > CD_ZERO .AND. & + ABS(acc - sec_el(e)) >= ABS(cand_el(e) - sec_el(e)) .AND. & + ABS(acc - sec_el(e)) <= 100.0_wp*ABS(cand_el(e) - sec_el(e))) cand_el(e) = acc + END IF + END IF + END IF + eps_prev(e) = eps_now + t_prev(e) = t_static(e) + END DO + IF (change <= 1.0e-10_wp) THEN + converged = .TRUE. + EXIT + END IF + sec_el = cand_el + ELSE + eps_bar = SUM(l0*t_static)/(secant*SUM(l0)) + CALL rest_tension(1, eps_bar, t_ref, es, em) + IF (es /= CD_SYROPE_OK .OR. .NOT. (t_ref > CD_ZERO .AND. eps_bar > CD_ZERO)) EXIT + cand = t_ref/eps_bar + IF (ABS(cand - secant) <= 1.0e-10_wp*secant) EXIT + secant = cand + sec_el = secant + END IF END DO IF (ErrStat /= CD_MODEL_OK) THEN - CALL release_syrope() + CALL release_syrope(.TRUE.) ErrMsg = 'CableDyn_DeckDriver: Syrope static solve failed: '//TRIM(ErrMsg) IF (ErrStat /= CD_DECKDRV_BADINPUT) ErrStat = CD_DECKDRV_SOLVEFAIL RETURN END IF - ! Per element: the running maximum is the history's (raised to the element's static + IF (composite) THEN + ! a composite line starts only from converged secants, every Syrope element on its + ! curve's table + IF (.NOT. converged) THEN + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'the static secant EA of the Syrope elements of LINE '// & + TRIM(int_to_str(ln%id))//' did not converge in '//TRIM(int_to_str(MAX_ITER_COMPOSITE))// & + ' iterations') + RETURN + END IF + DO e = 1, ne + IF (.NOT. sis(e)) CYCLE + ! a converged tension above the table's top (the secant held at the top row's) is refused + ! by name + CALL rest_strain(el_sec(e), t_static(e), eps_e, es, em) + IF (es /= CD_SYROPE_OK) THEN + CALL release_syrope(.TRUE.) + CALL fail(ErrStat, ErrMsg, 'Syrope section '//TRIM(int_to_str(el_sec(e)))//' of LINE '// & + TRIM(int_to_str(ln%id))//': '//TRIM(em)); RETURN + END IF + IF (.NOT. strain_in_table(el_sec(e), t_static(e)/sec_el(e))) THEN + CALL release_syrope(.TRUE.) + RETURN + END IF + END DO + END IF + ! Per Syrope element: the running maximum is the history's (raised to the element's static ! tension where that exceeds it, i.e. the element sits on the OWC; without SYROPE IC ! every element is a virgin rope at its own static tension), and the slow strain ! is the state whose t = 0 kernel force at the static strain equals the static element ! tension exactly, so t = 0 is the static equilibrium (zero initial transient). DO e = 1, ne + IF (.NOT. sis(e)) CYCLE + isec = el_sec(e) stmax(e) = MAX(t_hist, t_static(e)) - CALL CD_Syrope_Slow_For_Tension(td, stmax(e), t_static(e)/secant, t_static(e), sslow(e), es, em) + CALL CD_Syrope_Slow_For_Tension(tds(isec), stmax(e), t_static(e)/sec_el(e), t_static(e), sslow(e), & + es, em) IF (es /= CD_SYROPE_OK) THEN - CALL release_syrope() + CALL release_syrope(.TRUE.) CALL fail(ErrStat, ErrMsg, 'Syrope initial state: '//TRIM(em)); RETURN END IF END DO IF (ln%has_syrope_ic) THEN ! Tmean0 does not enter the state: with fixed ends the mean tension follows from the ! geometry and the Tmax0 history. Name a disagreement rather than ignore it silently. - t_mean_static = SUM(l0*t_static)/SUM(l0) + t_mean_static = SUM(l0*t_static, MASK=sis)/SUM(l0, MASK=sis) IF (ABS(t_mean_static - ln%syrope_tmean0) > 0.01_wp*MAX(t_mean_static, ln%syrope_tmean0)) THEN WRITE (*, '(A,I0,A,ES11.4,A,ES11.4,A)') 'CableDyn: SYROPE IC line ', ln%id, & ': static equilibrium mean tension ', t_mean_static, ' N on the Tmax0 working curve; Tmean0 ', & @@ -9316,18 +9551,20 @@ RECURSIVE SUBROUTINE init_one_syrope_model(types, syt, ln, sections, points, l0, END IF END IF CALL init_one_model(ln, sections, types, points, opts, model, ErrStat, ErrMsg, bathymetry=bathymetry, & - syrope_secant=secant, syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, & + syrope_secant=sec_el, syrope_is=sis, syrope_type=stype, syrope_slow0=sslow, & syrope_tmax0=stmax) - CALL release_syrope() + CALL release_syrope(.TRUE.) IF (ErrStat /= CD_DECKDRV_OK) THEN ErrMsg = 'CableDyn_DeckDriver: Syrope model init failed: '//TRIM(ErrMsg) IF (ErrStat /= CD_DECKDRV_BADINPUT) ErrStat = CD_DECKDRV_SOLVEFAIL END IF CONTAINS - SUBROUTINE rest_tension(eps, tension, es_out, em_out) - !! The static curve of the initial load history at strain eps: the OWC for a virgin - !! rope (no SYROPE IC), the Tmax0 working curve / OWC (CD_Syrope_Static_Tension) with it. + SUBROUTINE rest_tension(isec_, eps, tension, es_out, em_out) + !! The static curve of the initial load history of Syrope section isec_ at strain eps: the + !! OWC for a virgin rope (no SYROPE IC), the Tmax0 working curve / OWC + !! (CD_Syrope_Static_Tension) with it. + INTEGER, INTENT(IN) :: isec_ REAL(wp), INTENT(IN) :: eps REAL(wp), INTENT(OUT) :: tension INTEGER, INTENT(OUT) :: es_out @@ -9335,18 +9572,127 @@ SUBROUTINE rest_tension(eps, tension, es_out, em_out) es_out = CD_SYROPE_OK em_out = '' IF (ln%has_syrope_ic) THEN - CALL CD_Syrope_Static_Tension(td, t_hist, eps, tension, es_out, em_out) + CALL CD_Syrope_Static_Tension(tds(isec_), t_hist, eps, tension, es_out, em_out) ELSE - tension = owc_table_interp(types(syt)%syrope_owc_strain, types(syt)%syrope_owc_tension, eps) + tension = owc_table_interp(types(sec_type(isec_))%syrope_owc_strain, & + types(sec_type(isec_))%syrope_owc_tension, eps) END IF END SUBROUTINE rest_tension - SUBROUTINE release_syrope() + SUBROUTINE rest_strain(isec_, tension, eps, es_out, em_out) + !! The strain of section isec_'s rest curve at a tension, by bisection over its OWC table + !! (the curve rises monotonically with strain). + INTEGER, INTENT(IN) :: isec_ + REAL(wp), INTENT(IN) :: tension + REAL(wp), INTENT(OUT) :: eps + INTEGER, INTENT(OUT) :: es_out + CHARACTER(*), INTENT(OUT) :: em_out + REAL(wp) :: lo, hi, t_lo, t_hi, t_mid + INTEGER :: it, n + CHARACTER(24) :: s_t, s_top + n = SIZE(types(sec_type(isec_))%syrope_owc_strain) + lo = types(sec_type(isec_))%syrope_owc_strain(1) + hi = types(sec_type(isec_))%syrope_owc_strain(n) + eps = lo + CALL rest_tension(isec_, lo, t_lo, es_out, em_out) + IF (es_out /= CD_SYROPE_OK) RETURN + CALL rest_tension(isec_, hi, t_hi, es_out, em_out) + IF (es_out /= CD_SYROPE_OK) RETURN + IF (tension > t_hi) THEN + WRITE (s_t, '(ES10.3)') tension + WRITE (s_top, '(ES10.3)') t_hi + es_out = CD_SYROPE_BADINPUT + em_out = 'a tension of '//TRIM(ADJUSTL(s_t))//' N lies above the top of its OWC table ('// & + TRIM(ADJUSTL(s_top))//' N); extend the table or reduce the pretension' + RETURN + END IF + IF (.NOT. (tension > t_lo)) RETURN + DO it = 1, 200 + eps = 0.5_wp*(lo + hi) + CALL rest_tension(isec_, eps, t_mid, es_out, em_out) + IF (es_out /= CD_SYROPE_OK) RETURN + IF (t_mid < tension) THEN + lo = eps + ELSE + hi = eps + END IF + IF (hi - lo <= 4.0_wp*EPSILON(hi)*hi) EXIT + END DO + eps = 0.5_wp*(lo + hi) + END SUBROUTINE rest_strain + + SUBROUTINE response_root(isec_, eps_k, t_k, d_eps_, d_t_, eps_out, t_out) + !! The crossing of section isec_'s rest curve with the response line through (eps_k, t_k) + !! of direction (d_eps_, d_t_), d_eps_*d_t_ < 0: h(eps) = (T(eps) - t_k) d_eps_ - + !! (eps - eps_k) d_t_ is monotone over the table (the curve rises, the line falls), so + !! bisection over the table finds it. eps_out = -1 where the crossing lies outside the + !! table or the curve fails. + INTEGER, INTENT(IN) :: isec_ + REAL(wp), INTENT(IN) :: eps_k, t_k, d_eps_, d_t_ + REAL(wp), INTENT(OUT) :: eps_out, t_out + REAL(wp) :: lo, hi, h_lo, h_hi, h_mid, t_c + INTEGER :: it, n, es_c + CHARACTER(256) :: em_c + eps_out = -CD_ONE + t_out = CD_ZERO + n = SIZE(types(sec_type(isec_))%syrope_owc_strain) + lo = types(sec_type(isec_))%syrope_owc_strain(1) + hi = types(sec_type(isec_))%syrope_owc_strain(n) + CALL rest_tension(isec_, lo, t_c, es_c, em_c) + IF (es_c /= CD_SYROPE_OK) RETURN + h_lo = (t_c - t_k)*d_eps_ - (lo - eps_k)*d_t_ + CALL rest_tension(isec_, hi, t_c, es_c, em_c) + IF (es_c /= CD_SYROPE_OK) RETURN + h_hi = (t_c - t_k)*d_eps_ - (hi - eps_k)*d_t_ + IF (.NOT. (h_lo*h_hi <= CD_ZERO)) RETURN + DO it = 1, 200 + eps_out = 0.5_wp*(lo + hi) + CALL rest_tension(isec_, eps_out, t_c, es_c, em_c) + IF (es_c /= CD_SYROPE_OK) THEN + eps_out = -CD_ONE + RETURN + END IF + h_mid = (t_c - t_k)*d_eps_ - (eps_out - eps_k)*d_t_ + IF (h_mid*h_lo > CD_ZERO) THEN + lo = eps_out + h_lo = h_mid + ELSE + hi = eps_out + END IF + IF (hi - lo <= 4.0_wp*EPSILON(hi)*hi) EXIT + END DO + eps_out = 0.5_wp*(lo + hi) + CALL rest_tension(isec_, eps_out, t_out, es_c, em_c) + IF (es_c /= CD_SYROPE_OK) eps_out = -CD_ONE + END SUBROUTINE response_root + + LOGICAL FUNCTION strain_in_table(isec_, eps) RESULT(ok) + !! Whether strain eps lies in section isec_'s OWC table (the interpolation clamps at its end + !! rows, so a strain outside would start the line silently mis-tensioned); fails otherwise. + INTEGER, INTENT(IN) :: isec_ + REAL(wp), INTENT(IN) :: eps + n_owc = SIZE(types(sec_type(isec_))%syrope_owc_strain) + ok = .NOT. (eps < types(sec_type(isec_))%syrope_owc_strain(1) .OR. & + eps > types(sec_type(isec_))%syrope_owc_strain(n_owc)) + IF (ok) RETURN + WRITE (s_eps, '(ES10.3)') eps + WRITE (s_lo, '(ES10.3)') types(sec_type(isec_))%syrope_owc_strain(1) + WRITE (s_hi, '(ES10.3)') types(sec_type(isec_))%syrope_owc_strain(n_owc) + CALL fail(ErrStat, ErrMsg, 'the Syrope line''s initial strain '//TRIM(ADJUSTL(s_eps))// & + ' lies outside its OWC table strain range ['//TRIM(ADJUSTL(s_lo))//', '// & + TRIM(ADJUSTL(s_hi))//']; extend the table or reduce the pretension') + END FUNCTION strain_in_table + + SUBROUTINE release_syrope(with_elements) !! Free the constitutive copies (the model deep-copies what it keeps). - INTEGER :: k - CALL CD_Syrope_End(td) - DO k = 1, ne - CALL CD_Syrope_End(stype(k)) + LOGICAL, INTENT(IN) :: with_elements + INTEGER :: kk + DO kk = 1, nsec + IF (sec_syr(kk)) CALL CD_Syrope_End(tds(kk)) + END DO + IF (.NOT. with_elements) RETURN + DO kk = 1, ne + IF (sis(kk)) CALL CD_Syrope_End(stype(kk)) END DO END SUBROUTINE release_syrope END SUBROUTINE init_one_syrope_model @@ -16783,21 +17129,18 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END IF END DO - ! A history row is meaningful only for a line whose constitutive type is - ! Syrope. The current production surface is single-section, so this also - ! prevents an IC from being silently attached to a plain/composite line. + ! A history row is meaningful only for a line with a Syrope section (alone or in a + ! composite line); it sets the load history of every Syrope section of the line. DO i = 1, SIZE(lines) at_line = lines(i)%deck_line IF (.NOT. lines(i)%has_syrope_ic) CYCLE - nsec_for_line = 0 idx = 0 DO j = 1, SIZE(sections) IF (sections(j)%line_id /= lines(i)%id) CYCLE - nsec_for_line = nsec_for_line + 1 IF (types(sections(j)%ltype)%is_syrope) idx = idx + 1 END DO - IF (nsec_for_line /= 1 .OR. idx /= 1) THEN - CALL fail(ErrStat, ErrMsg, 'SYROPE IC can reference only a single-section Syrope LINE') + IF (idx < 1) THEN + CALL fail(ErrStat, ErrMsg, 'SYROPE IC can reference only a LINE with a Syrope section') RETURN END IF END DO diff --git a/tests/test_deck_driver.f90 b/tests/test_deck_driver.f90 index c2081107..25787d3c 100644 --- a/tests/test_deck_driver.f90 +++ b/tests/test_deck_driver.f90 @@ -1182,11 +1182,27 @@ PROGRAM test_deck_driver ! the placeholder linear EA or to a load path that carries no Syrope state. BLOCK TYPE(CD_ModelType), ALLOCATABLE :: smodels(:) - CALL write_syrope_deck('deck_syrope_composite.dat', 'SYROPE:syrope.dat|1.53e8|23.12', & - '5.0e10|1.0e5', nsections=2) - CALL CD_Init_Deck_Models('deck_syrope_composite.dat', smodels, es, em) - CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'composite Syrope') > 0, & - 'composite Syrope fails closed by name') + ! a Syrope line split into two Syrope sections (the same mesh) is the same line: the + ! composite build's mean-tension secant iteration lands on the single section's equilibrium + BLOCK + TYPE(CD_ModelType), ALLOCATABLE :: one(:) + REAL(wp) :: t1(4), t2(4) + CALL write_syrope_deck('deck_syrope_one.dat', 'SYROPE:syrope.dat|1.53e8|23.12', '5.0e10|1.0e5') + CALL CD_Init_Deck_Models('deck_syrope_one.dat', one, es, em) + CALL require(es == CD_DECKDRV_OK, 'single-section Syrope line builds: '//TRIM(em)) + CALL write_syrope_deck('deck_syrope_composite.dat', 'SYROPE:syrope.dat|1.53e8|23.12', & + '5.0e10|1.0e5', nsections=2) + CALL CD_Init_Deck_Models('deck_syrope_composite.dat', smodels, es, em) + CALL require(es == CD_DECKDRV_OK, 'a Syrope line of two Syrope sections builds: '//TRIM(em)) + IF (ALLOCATED(one) .AND. ALLOCATED(smodels)) THEN + CALL CD_Get_Model_Tension(one(1), t1, es, em) + CALL CD_Get_Model_Tension(smodels(1), t2, es, em) + CALL require(MAXVAL(ABS(t2 - t1)) <= 1.0e-8_wp*MAXVAL(t1), & + 'two Syrope sections reach the single section''s static tensions') + CALL CD_End_Model(one(1), es, em) + CALL CD_End_Model(smodels(1), es, em) + END IF + END BLOCK CALL write_syrope_deck('deck_syrope_finite_ei.dat', 'SYROPE:syrope.dat|1.53e8|23.12', & '5.0e10|1.0e5', ei=5.0e3_wp) diff --git a/tests/test_syrope_composite.f90 b/tests/test_syrope_composite.f90 new file mode 100644 index 00000000..92ded4e3 --- /dev/null +++ b/tests/test_syrope_composite.f90 @@ -0,0 +1,394 @@ +! File: tests/test_syrope_composite.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_syrope_composite + !! Composite Syrope lines: a chain-polyester-chain mooring whose polyester section follows the + !! Syrope working-curve model, in 200 m of water (the line of + !! examples/composite_chain_poly_chain.dat with its anchor 30 m further out, so the polyester + !! carries about 1 MN, where the working curve of these constants is admissible for a virgin + !! rope). + !! 1. The line builds; the Syrope flags sit on the 40 polyester elements only, the chains keep + !! their BA damping and the polyester takes none (its working curve carries the rope's). + !! 2. The static polyester sits on its rest curve: every element's geometric strain gives its + !! tension on the OWC (each element takes its own secant EA), and so does the section's mean. + !! 3. The same line with a linear-EA polyester of the mean secant EA has the static tensions to + !! the spread of the elements' own secants: the chains are built as any EI = 0 line. + !! 4. The dynamics start in the static equilibrium: a still run keeps the fairlead tension + !! (one secant per section left the elements away from the mean off the curve, and their + !! slow strains moved the fairlead tension by 1.4e-5 within 2 s). + !! 5. A SYROPE IC history (Tmax0 above the static tension) puts the section on the Tmax0 + !! working curve instead. + !! 6. A pretension above the top of the OWC table fails closed by name. + !! 7. A taut line of two Syrope sections whose first solve, at the placeholder alpha, overshoots + !! the top of the table: the update continues from the table's top secant and every + !! element lands on its OWC. + !! 8. A lightly loaded SYROPE IC rope near its working curve's zero-tension strain, where the + !! plain secant update contracts slowly: the accelerated update lands every element on the + !! Tmax0 working curve. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_Models, CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_Model, ONLY: CD_ModelType, CD_End_Model, CD_Get_Model_Tension + USE CableDyn_Syrope, ONLY: CD_SyropeType, CD_Syrope_Init, CD_Syrope_End, CD_Syrope_Static_Tension, & + CD_SYROPE_WC_EXP, CD_SYROPE_OK + IMPLICIT NONE + + INTEGER, PARAMETER :: NOWC = 30, NE_A = 25, NE_P = 40, NE_F = 12 + ! the shipped data/syrope/syrope_owc.dat table + REAL(wp), PARAMETER :: OWC_EPS(NOWC) = [ & + 0.00000e+00_wp, 2.06897e-03_wp, 4.13793e-03_wp, 6.20690e-03_wp, 8.27586e-03_wp, & + 1.03448e-02_wp, 1.24138e-02_wp, 1.44828e-02_wp, 1.65517e-02_wp, 1.86207e-02_wp, & + 2.06897e-02_wp, 2.27586e-02_wp, 2.48276e-02_wp, 2.68966e-02_wp, 2.89655e-02_wp, & + 3.10345e-02_wp, 3.31034e-02_wp, 3.51724e-02_wp, 3.72414e-02_wp, 3.93103e-02_wp, & + 4.13793e-02_wp, 4.34483e-02_wp, 4.55172e-02_wp, 4.75862e-02_wp, 4.96552e-02_wp, & + 5.17241e-02_wp, 5.37931e-02_wp, 5.58621e-02_wp, 5.79310e-02_wp, 6.00000e-02_wp] + REAL(wp), PARAMETER :: OWC_TEN(NOWC) = [ & + 0.00000e+00_wp, 1.71768e+05_wp, 3.30952e+05_wp, 4.78788e+05_wp, 6.16510e+05_wp, & + 7.45355e+05_wp, 8.66556e+05_wp, 9.81351e+05_wp, 1.09097e+06_wp, 1.19666e+06_wp, & + 1.29964e+06_wp, 1.40116e+06_wp, 1.50245e+06_wp, 1.60474e+06_wp, 1.70927e+06_wp, & + 1.81728e+06_wp, 1.93000e+06_wp, 2.04866e+06_wp, 2.17450e+06_wp, 2.30876e+06_wp, & + 2.45267e+06_wp, 2.60747e+06_wp, 2.77439e+06_wp, 2.95467e+06_wp, 3.14954e+06_wp, & + 3.36024e+06_wp, 3.58800e+06_wp, 3.83406e+06_wp, 4.09965e+06_wp, 4.38601e+06_wp] + INTEGER :: nfail = 0, es, e + CHARACTER(1024) :: em + TYPE(CD_ModelType), ALLOCATABLE :: models(:), lin(:) + REAL(wp) :: t_syr(NE_A + NE_P + NE_F), t_lin(NE_A + NE_P + NE_F), eps_bar, t_bar, secant, eps_e, worst + CHARACTER(32) :: ea_text + + CALL write_owc('csyr_owc.dat', NOWC) + CALL write_settings('csyr_settings.dat', 'csyr_owc.dat') + + ! 1. the composite line builds, with its Syrope elements and damping where they belong + CALL write_deck('csyr.dat', '"SYROPE:csyr_settings.dat|1.53e8|23.12"', '5.0e10|1.0e5') + CALL CD_Init_Deck_Models('csyr.dat', models, es, em) + CALL require(es == CD_DECKDRV_OK, 'chain-Syrope-chain line builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) CALL finish() + ASSOCIATE (md => models(1)) + ! internal element order anchor -> fairlead: the anchor chain, the polyester, the fairlead chain + CALL require(md%n_elem == NE_A + NE_P + NE_F, 'the composite mesh has the three sections'' elements') + CALL require(COUNT(md%syrope_is) == NE_P .AND. ALL(md%syrope_is(NE_A + 1:NE_A + NE_P)), & + 'the Syrope flags sit on the polyester elements only') + CALL require(ALL(md%ba_dyn(1:NE_A) > 0.0_wp) .AND. ALL(md%ba_dyn(NE_A + NE_P + 1:) > 0.0_wp), & + 'the chain sections keep their BA damping') + CALL require(ALL(.NOT. (md%ba_dyn(NE_A + 1:NE_A + NE_P) > 0.0_wp)), & + 'the polyester takes no legacy BA (its working curve carries the damping)') + CALL CD_Get_Model_Tension(md, t_syr, es, em) + ! 2. on the rest curve (a virgin rope: the OWC) at the section's mean strain + eps_bar = 0.0_wp + DO e = NE_A + 1, NE_A + NE_P + eps_bar = eps_bar + (NORM2(md%q(3*md%elem_conn(2, e) - 2:3*md%elem_conn(2, e)) - & + md%q(3*md%elem_conn(1, e) - 2:3*md%elem_conn(1, e))) - md%l0(e)) + END DO + eps_bar = eps_bar/SUM(md%l0(NE_A + 1:NE_A + NE_P)) + t_bar = SUM(md%l0(NE_A + 1:NE_A + NE_P)*t_syr(NE_A + 1:NE_A + NE_P))/SUM(md%l0(NE_A + 1:NE_A + NE_P)) + PRINT '(A,ES12.5,A,ES12.5,A,ES12.5,A,ES12.5)', ' polyester mean strain ', eps_bar, ', mean tension ', & + t_bar, ' N, OWC there ', owc(eps_bar), ' N; fairlead tension ', t_syr(NE_A + NE_P + NE_F) + CALL require(ABS(owc(eps_bar) - t_bar) <= 1.0e-6_wp*t_bar, & + 'the static polyester section sits on its OWC at its mean strain') + ! and every polyester element on its own OWC (each takes its own secant) + worst = 0.0_wp + DO e = NE_A + 1, NE_A + NE_P + eps_e = NORM2(md%q(3*md%elem_conn(2, e) - 2:3*md%elem_conn(2, e)) - & + md%q(3*md%elem_conn(1, e) - 2:3*md%elem_conn(1, e)))/md%l0(e) - 1.0_wp + worst = MAX(worst, ABS(owc(eps_e) - t_syr(e))/t_syr(e)) + END DO + PRINT '(A,ES10.3,A,ES12.5,A,ES12.5,A)', ' polyester elements off their OWC by at most ', worst, & + ' (tensions ', MINVAL(t_syr(NE_A + 1:NE_A + NE_P)), ' to ', MAXVAL(t_syr(NE_A + 1:NE_A + NE_P)), ' N)' + CALL require(worst <= 1.0e-8_wp, 'every static polyester element sits on its OWC') + secant = t_bar/eps_bar + END ASSOCIATE + CALL CD_End_Model(models(1), es, em) + + ! 3. the same line with a linear-EA polyester of the converged secant EA + WRITE (ea_text, '(ES23.16)') secant + CALL write_deck('csyr_lin.dat', TRIM(ADJUSTL(ea_text)), '0.0') + CALL CD_Init_Deck_Models('csyr_lin.dat', lin, es, em) + CALL require(es == CD_DECKDRV_OK, 'the linear-EA twin builds: '//TRIM(em)) + IF (es == CD_DECKDRV_OK) THEN + CALL CD_Get_Model_Tension(lin(1), t_lin, es, em) + PRINT '(A,ES10.3)', ' Syrope vs linear-EA twin: max element-tension difference / max tension ', & + MAXVAL(ABS(t_syr - t_lin))/MAXVAL(t_lin) + CALL require(MAXVAL(ABS(t_syr - t_lin)) <= 1.0e-6_wp*MAXVAL(t_lin), & + 'the linear-EA twin of the mean secant EA has the static tensions (to the spread of '// & + 'the elements'' own secants)') + CALL CD_End_Model(lin(1), es, em) + END IF + + ! 4. the dynamics start in the static equilibrium + CALL still_run() + + ! 5. a SYROPE IC history above the static tension: the Tmax0 working curve + CALL tmax0_curve() + + ! 6. a pretension above the top of the OWC table + CALL write_owc('csyr_owc_short.dat', 6) + CALL write_settings('csyr_settings_short.dat', 'csyr_owc_short.dat') + CALL write_deck('csyr_short.dat', '"SYROPE:csyr_settings_short.dat|1.53e8|23.12"', '5.0e10|1.0e5') + CALL CD_Init_Deck_Models('csyr_short.dat', models, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'above the top of its OWC table') > 0, & + 'a pretension above the OWC table fails closed by name: '//TRIM(em)) + + ! 7. an overshooting first solve on a taut two-section rope: alpha (1.53e8 N) at the 3.5 % chord + ! strain gives 5.4 MN, above the table's 4.4 MN top, while the OWC there is about 2 MN + CALL taut_rope(20.7_wp, '22.42', 'a taut rope whose first solve overshoots the OWC table') + ! 8. a lightly loaded, nearly neutrally buoyant rope on the Tmax0 = 2.5 MN working curve, near its + ! zero-tension strain (about 53 kN), where the plain secant update contracts slowly + CALL taut_rope(20.2_wp, '16.70', 'a lightly loaded preconditioned rope', tmax0=2.5e6_wp) + + CALL finish() + +CONTAINS + + SUBROUTINE still_run() + !! The composite line run still for 2 s: the fairlead tension stays at its static value. + INTEGER :: u, ios, n + CHARACTER(4096) :: row + REAL(wp) :: t, ft, ft0, dev + LOGICAL :: conv + CALL write_deck('csyr_dyn.dat', '"SYROPE:csyr_settings.dat|1.53e8|23.12"', '5.0e10|1.0e5', dynamic=.TRUE.) + CALL CD_Run_Deck_Driver('csyr_dyn.dat', 'csyr_dyn', conv, es, em) + CALL require(es == CD_DECKDRV_OK, 'the composite line runs: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='csyr_dyn.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + n = 0 + dev = 0.0_wp + ft0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) row + IF (ios /= 0) EXIT + IF (row(1:1) == '#' .OR. INDEX(row, 'Time') > 0) CYCLE + READ (row, *, IOSTAT=ios) t, ft + IF (ios /= 0) CYCLE + n = n + 1 + IF (n == 1) ft0 = ft + dev = MAX(dev, ABS(ft - ft0)) + END DO + CLOSE (u) + PRINT '(A,I0,A,ES10.3)', ' still run: ', n, ' rows, max |FairTen - FairTen(0)| / FairTen(0) ', dev/ft0 + CALL require(n > 100 .AND. dev <= 1.0e-7_wp*ft0, 'the dynamics start in the static equilibrium') + END SUBROUTINE still_run + + SUBROUTINE taut_rope(span, mass, what, tmax0) + !! 20 m of rope in two 10 m Syrope sections between fixed points span apart, of the given mass + !! per length, a virgin rope or (tmax0 present) a SYROPE IC history: every element must land on + !! its rest curve (the OWC, or the Tmax0 working curve), inside the table. + REAL(wp), INTENT(IN) :: span + CHARACTER(*), INTENT(IN) :: mass, what + REAL(wp), INTENT(IN), OPTIONAL :: tmax0 + TYPE(CD_ModelType), ALLOCATABLE :: mt(:) + TYPE(CD_SyropeType) :: td + REAL(wp) :: ten(10), eps_k, wst, tcurve + INTEGER :: u, k + CHARACTER(32) :: s_span, s_tmax0 + WRITE (s_span, '(F8.3)') span + OPEN (NEWUNIT=u, FILE='csyr_taut.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'taut two-section Syrope test deck' + 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.1438 '//mass//' "SYROPE:csyr_settings.dat|1.53e8|23.12" 5.0e10|1.0e5 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Fixed '//TRIM(ADJUSTL(s_span))//' 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '2 Vessel 0.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 2 1 -' + IF (PRESENT(tmax0)) THEN + WRITE (s_tmax0, '(ES23.16)') tmax0 + WRITE (u, '(A)') '--- SYROPE IC ---' + WRITE (u, '(A)') 'Line(s) Tmax0 Tmean0' + WRITE (u, '(A)') '(-) (N) (N)' + WRITE (u, '(A)') '1 '//TRIM(ADJUSTL(s_tmax0))//' 1.0e5' + END IF + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 10.0 5' + WRITE (u, '(A)') '1 poly 10.0 5' + 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)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + CALL CD_Init_Deck_Models('csyr_taut.dat', mt, es, em) + CALL require(es == CD_DECKDRV_OK, what//' builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + IF (PRESENT(tmax0)) THEN + CALL CD_Syrope_Init(td, OWC_EPS, OWC_TEN, CD_SYROPE_WC_EXP, 0.20_wp, 1.50_wp, 1.53e8_wp, 23.12_wp, & + 5.0e10_wp, 1.0e5_wp, es, em) + CALL require(es == CD_SYROPE_OK, 'reference working curve: '//TRIM(em)) + END IF + ASSOCIATE (md => mt(1)) + CALL CD_Get_Model_Tension(md, ten, es, em) + wst = 0.0_wp + DO k = 1, md%n_elem + eps_k = NORM2(md%q(3*md%elem_conn(2, k) - 2:3*md%elem_conn(2, k)) - & + md%q(3*md%elem_conn(1, k) - 2:3*md%elem_conn(1, k)))/md%l0(k) - 1.0_wp + IF (PRESENT(tmax0)) THEN + CALL CD_Syrope_Static_Tension(td, tmax0, eps_k, tcurve, es, em) + ELSE + tcurve = owc(eps_k) + END IF + wst = MAX(wst, ABS(tcurve - ten(k))/ten(k)) + END DO + PRINT '(A,ES12.5,A,ES12.5,A,ES10.3)', ' taut rope: tensions ', MINVAL(ten), ' to ', MAXVAL(ten), & + ' N, elements off their rest curve by at most ', wst + CALL require(wst <= 1.0e-8_wp .AND. MAXVAL(ten) < OWC_TEN(NOWC), & + 'every element of '//what//' sits on its rest curve, inside the table') + END ASSOCIATE + CALL CD_End_Model(mt(1), es, em) + IF (PRESENT(tmax0)) CALL CD_Syrope_End(td) + END SUBROUTINE taut_rope + + SUBROUTINE tmax0_curve() + !! SYROPE IC Tmax0 = 2.5 MN: the polyester's mean tension is the Tmax0 working curve's at its + !! mean strain. + TYPE(CD_ModelType), ALLOCATABLE :: mic(:) + TYPE(CD_SyropeType) :: td + REAL(wp) :: ten(NE_A + NE_P + NE_F), eb, tb, tcurve + INTEGER :: k + CALL write_deck('csyr_ic.dat', '"SYROPE:csyr_settings.dat|1.53e8|23.12"', '5.0e10|1.0e5', & + ic_row='1 2.5e6 1.0e6') + CALL CD_Init_Deck_Models('csyr_ic.dat', mic, es, em) + CALL require(es == CD_DECKDRV_OK, 'the composite line with SYROPE IC builds: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + CALL CD_Syrope_Init(td, OWC_EPS, OWC_TEN, CD_SYROPE_WC_EXP, 0.20_wp, 1.50_wp, 1.53e8_wp, 23.12_wp, & + 5.0e10_wp, 1.0e5_wp, es, em) + CALL require(es == CD_SYROPE_OK, 'reference working curve: '//TRIM(em)) + ASSOCIATE (md => mic(1)) + CALL CD_Get_Model_Tension(md, ten, es, em) + eb = 0.0_wp + DO k = NE_A + 1, NE_A + NE_P + eb = eb + (NORM2(md%q(3*md%elem_conn(2, k) - 2:3*md%elem_conn(2, k)) - & + md%q(3*md%elem_conn(1, k) - 2:3*md%elem_conn(1, k))) - md%l0(k)) + END DO + eb = eb/SUM(md%l0(NE_A + 1:NE_A + NE_P)) + tb = SUM(md%l0(NE_A + 1:NE_A + NE_P)*ten(NE_A + 1:NE_A + NE_P))/SUM(md%l0(NE_A + 1:NE_A + NE_P)) + CALL CD_Syrope_Static_Tension(td, 2.5e6_wp, eb, tcurve, es, em) + PRINT '(A,ES12.5,A,ES12.5,A,ES12.5,A)', ' SYROPE IC: polyester mean strain ', eb, ', mean tension ', tb, & + ' N, Tmax0 working curve there ', tcurve, ' N' + CALL require(es == CD_SYROPE_OK .AND. ABS(tcurve - tb) <= 1.0e-6_wp*tb, & + 'with SYROPE IC the polyester sits on the Tmax0 working curve') + CALL require(ALL(md%syrope_tmax(NE_A + 1:NE_A + NE_P) >= 2.5e6_wp), & + 'every polyester element carries the Tmax0 history') + END ASSOCIATE + CALL CD_End_Model(mic(1), es, em) + CALL CD_Syrope_End(td) + END SUBROUTINE tmax0_curve + + REAL(wp) FUNCTION owc(eps) RESULT(t) + !! The OWC table, interpolated linearly. + REAL(wp), INTENT(IN) :: eps + INTEGER :: k + t = OWC_TEN(NOWC) + DO k = 2, NOWC + IF (eps <= OWC_EPS(k)) THEN + t = OWC_TEN(k - 1) + (OWC_TEN(k) - OWC_TEN(k - 1))*(eps - OWC_EPS(k - 1))/(OWC_EPS(k) - OWC_EPS(k - 1)) + RETURN + END IF + END DO + END FUNCTION owc + + SUBROUTINE write_owc(path, nrow) + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: nrow + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Strain Tension' + WRITE (u, '(A)') '(-) (N)' + DO k = 1, nrow + WRITE (u, '(ES14.6,1X,ES14.6)') OWC_EPS(k), OWC_TEN(k) + END DO + CLOSE (u) + END SUBROUTINE write_owc + + SUBROUTINE write_settings(path, owc_path) + CHARACTER(*), INTENT(IN) :: path, owc_path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') owc_path//' OWC - Original working-curve table file' + WRITE (u, '(A)') 'EXP WCType - Working-curve formulation' + WRITE (u, '(A)') '0.20 k1 - First working-curve shape parameter' + WRITE (u, '(A)') '1.50 k2 - Second working-curve shape parameter' + CLOSE (u) + END SUBROUTINE write_settings + + SUBROUTINE write_deck(path, poly_ea, poly_ba, dynamic, ic_row) + !! The chain-polyester-chain line (anchor at 780 m), the polyester with the given EA and BA + !! columns. + CHARACTER(*), INTENT(IN) :: path, poly_ea, poly_ba + LOGICAL, INTENT(IN), OPTIONAL :: dynamic + CHARACTER(*), INTENT(IN), OPTIONAL :: ic_row + INTEGER :: u + LOGICAL :: dyn + dyn = .FALSE. + IF (PRESENT(dynamic)) dyn = dynamic + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'composite Syrope test deck' + 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)') 'chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') 'poly 0.1438 22.42 '//poly_ea//' '//poly_ba//' 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Fixed 780.0 0.0 -200.0 0 0 0 0' + WRITE (u, '(A)') '2 Vessel 58.0 0.0 -14.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 2 1 -' + IF (PRESENT(ic_row)) THEN + WRITE (u, '(A)') '--- SYROPE IC ---' + WRITE (u, '(A)') 'Line(s) Tmax0 Tmean0' + WRITE (u, '(A)') '(-) (N) (N)' + WRITE (u, '(A)') ic_row + END IF + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 chain 100.0 12' + WRITE (u, '(A)') '1 poly 400.0 40' + WRITE (u, '(A)') '1 chain 250.0 25' + 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)') '3.0e6 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + IF (dyn) THEN + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '2.0 TMax' + END IF + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_deck + + 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 + + SUBROUTINE finish() + IF (nfail > 0) THEN + PRINT '(I0,A)', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + PRINT '(A)', 'all composite Syrope checks passed' + STOP + END SUBROUTINE finish +END PROGRAM test_syrope_composite From 2ef4453520a2137e3521705c7e8a975d5e8b1c9a Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 06:00:20 +0900 Subject: [PATCH 19/51] feat(torsion): torque-tension coupling of finite-EI cables (#68) The helical armour of a power cable or a wire rope couples stretch and twist: T = EA eps + K tau, M = GJ tau + K eps. The 14-column LINE TYPES row's GJ column now takes GJ|K (finite-EI, linear-elastic, K^2 < EA GJ). With the torque still uniform along a line, tau = (M - K eps)/GJ follows the strain pointwise and the condensed torsion stays exact. Two changes carry the coupling: - the cable takes the axial stiffness EA - K^2/GJ of a section free to twist (build_finite_section_mesh); - a line restrained in torsion twists by Theta_eff = Theta - sum (K/GJ)(l_e - L_e). CD_HermiteTorsion_Line gains an optional per-element couple = K/GJ and adds the stretched element length's value, gradient and Hessian, so the statics, the dynamics, the rank-one tangent, the stability test, the host loads and the body equilibrium all take it. The coupling twist has no 2 pi ambiguity, so a first static evaluation unwraps the holonomy alone about its hint. The node and segment tensions add the element's (K/GJ) M, which the kernel's EA - K^2/GJ leaves out. The twist channels, the range rows and CurvX/CurvY sum the element twists M L/GJ - (K/GJ)(l - L) (new CD_HermiteCable_Dyn_Element_Twist). The two-moving-end compatibility route refuses the coupling. Every reader of the kernel's axial resultant on a line restrained in torsion adds the coupling force (K/GJ) M_t (new public CD_HermiteCable_Dyn_Coupling_Tension): the dynamic tensile_safety audit at the converged torque, the final static mesh-safety diagnosis (CD_HermiteCable_Resolution_Metrics axial_offset), the element recovery and the static element profile. The OpenFAST aggregate preflight evaluates the twist with the coupling, as the step does. test_torsion_coupling: - the kernel's effective-twist gradient and Hessian match finite differences (1.7e-10, 9.8e-11); - a stretched straight cable gives T = EA eps, M = K eps between rigid ends, T = (EA - K^2/GJ) eps with a free end, and T = EA eps + K Phi/L, M = GJ Phi/L + K eps with a 90 deg pretwist, to the printed digits; - a 20 s stretch-and-roll march ends on the static values to 1e-7; - GJ|0 is the uncoupled cable bit for bit; - K^2 >= EA GJ stops by name; - the element recovery and the element profile read EA eps between rigid ends; - a cable stretched by 1e-4 and twisted by -45 deg (T = -2.14 kN, the kernel's resultant +680 N) is refused by tensile_safety True in the statics and in a march rolled there, the opposite march passes; - the coupled aggregate accepts an update at the unchanged boundary. The full suite passes and all 53 example decks are bit-identical. The Python deck reader mirrors the grammar and checks, and the builder takes gj=(GJ, K). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 11 + CMakeLists.txt | 8 +- VALIDATION.md | 14 +- doc/capabilities.rst | 2 +- doc/driver_format.md | 4 + doc/outputs.rst | 8 +- doc/theory.rst | 33 +- python/cabledyn/builder.py | 16 +- python/cabledyn/deck_file.py | 38 ++- python/tests/test_builder.py | 48 +++ src/CableDyn_DeckDriver.f90 | 153 +++++++-- src/CableDyn_HermiteCableDynamic.f90 | 154 ++++++++-- src/CableDyn_HermiteCableStatic.f90 | 45 ++- src/CableDyn_HermiteTorsion.f90 | 120 +++++++- src/CableDyn_OpenFAST_HermiteFMF.f90 | 1 + tests/test_torsion_coupling.f90 | 444 +++++++++++++++++++++++++++ 16 files changed, 1011 insertions(+), 88 deletions(-) create mode 100644 tests/test_torsion_coupling.f90 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 From 66e3e83b4d8cc332a4bc120ad4fece15486bb95f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 12:06:51 +0900 Subject: [PATCH 20/51] feat(torsion): torsional inertia and damping, a twist angle at every node (#69) In the dynamics a finite-EI line restrained in torsion now carries a twist angle phi at every node, against reference directors that follow the node tangents by the smallest rotation over each step (time-parallel transport), so the axial angular velocity of a section is phi_dot. The statics stay condensed and set the angles from the uniform static torque. - Element twist phi_{e+1} - phi_e + beta_e - h_e: beta_e advances by the solid angles of the quadrilateral of committed and present tangents (CD_HermiteTwist_Reference, local to the element's 12 DOFs, with gradient and Hessian), so the turns live in the angles and no 2 pi branch is tracked. A rigid end takes its frame's normal carried to the node as the node's director and holds the angle; an elastic end adds its spring. - Torque M_e = (GJ/l0)(tw + (K/GJ) dl) + (Bt/l0) d/dt(...), with the polar inertia Irn (LINE TYPES column, now used) lumped at the nodes and the new torsional damping Bt of the GJ column (GJ|K|Bt, negative: -zeta of an element's critical l0 sqrt(GJ Irn)). A rigid end's element twists through rho as its end frame turns; its damping rate adds d rho/dw . omega of the frames over the step. The support reaction of a rigid end adds the held end section's polar inertia, turned by the frame's angular acceleration and the held angle; the polar kinetic energy takes that section's spin with its frame. - The angles join the generalised-alpha step; the step factors one band of [r, m, phi] per node (half-width 13). Their rows converge on the nodal torque balance, scaled by the nodal loads as the force rows are. The committed reference advances with the step's own solid angles, so the committed state reproduces the converged iterate bit for bit; the twist state joins the snapshot, the recovering step and the OpenFAST mirror. - TorqN is the node's torque (mean of its elements); end force, end moment, energy, element twist and section curvature read the nodal state. - Under torque-tension coupling each element's coupling force (K/GJ) M_e takes its own torque: in the dynamic tensile_safety audit (the converged evaluation's), the element recovery and the node tensions. Gates: the kernel against direct transports (1e-13) and FD; nodal_twist_dynamic: the condensed torsion in the limit of no inertia (<= 6e-7, clamped, bending-pinned, elastic ends), the continuum torsional wave (0.07 %) and its zero driven-end torque at kL = pi/2 (0.13 %), the damping decrement (6 %), a parent rolling the end frame at a steady rate loading the line with (GJ theta + Bt Omega)/L (4e-13) and spinning it with the continuum's kinetic energy (7e-4), energy band 4.9e-4, snapshot and mirror restart bit-identical; a zero-allocation step gate. The old quasi-static gates run at Irn 1e-9/1e-12; a non-stepping coupled write twists the end element against the frozen interior. Full suite passes; 52 of 53 examples bit-identical, the torsion example within 7e-5 of the torque. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 11 + CMakeLists.txt | 15 + VALIDATION.md | 30 +- doc/capabilities.rst | 12 +- doc/driver_format.md | 14 +- doc/outputs.rst | 16 +- doc/theory.rst | 77 +- python/cabledyn/builder.py | 12 +- python/cabledyn/deck_file.py | 18 +- python/tests/test_builder.py | 25 +- src/CableDyn_DeckDriver.f90 | 106 +- src/CableDyn_HermiteCableDynamic.f90 | 1530 +++++++++++++++++++++++++- src/CableDyn_HermiteTorsion.f90 | 282 +++++ src/CableDyn_OpenFAST_HermiteFMF.f90 | 43 +- tests/test_coupled_torsion.f90 | 22 +- tests/test_hermite_twist_kernel.f90 | 284 +++++ tests/test_nodal_twist_dynamic.f90 | 631 +++++++++++ tests/test_step_allocations.f90 | 29 +- tests/test_torsion_coupling.f90 | 75 +- tests/test_torsion_deck.f90 | 9 +- 20 files changed, 3125 insertions(+), 116 deletions(-) create mode 100644 tests/test_hermite_twist_kernel.f90 create mode 100644 tests/test_nodal_twist_dynamic.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 96b44608..57797afa 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. +- Torsional inertia and damping of finite-EI lines: in the dynamics a line restrained in torsion + carries a twist angle at every node, against directors that follow the node tangents by the + smallest rotation over each step, with the polar rotary inertia `Irn` of its LINE TYPES row and + the torsional damping `Bt` of a new third part of the `GJ` column (`GJ|K|Bt`, negative for a + damping ratio). The torque now varies along the line (`TorqN` is the node's) and + travels as a torsional wave; the statics stay condensed, and in the limit of a negligible + inertia the dynamics reproduce the condensed torsion. The step solves the angles with the + cable in one band of half-width 13; the twist state joins the snapshot, the recovering step + and the OpenFAST checkpoint mirror. Decks with torsion whose `Irn` was a placeholder (the + column was unused before) need the section's real value. The Python deck reader and builder + take `GJ|K|Bt` (builder `gj=(GJ, K, Bt)`). - 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. diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e19ea88..ad31d2c0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -632,6 +632,16 @@ add_test(NAME hermite_torsion_kernel COMMAND test_hermite_torsion_kernel ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/torsion_oracle_reference.txt) set_tests_properties(hermite_torsion_kernel PROPERTIES LABELS "fortran;unit;static") +add_executable(test_hermite_twist_kernel tests/test_hermite_twist_kernel.f90) +target_link_libraries(test_hermite_twist_kernel PRIVATE cabledyn_core) +add_test(NAME hermite_twist_kernel COMMAND test_hermite_twist_kernel) +set_tests_properties(hermite_twist_kernel PROPERTIES LABELS "fortran;unit") + +add_executable(test_nodal_twist_dynamic tests/test_nodal_twist_dynamic.f90) +target_link_libraries(test_nodal_twist_dynamic PRIVATE cabledyn_core) +add_test(NAME nodal_twist_dynamic COMMAND test_nodal_twist_dynamic) +set_tests_properties(nodal_twist_dynamic PROPERTIES LABELS "fortran;unit;dynamic;openfast") + add_executable(test_hermite_torsion_static tests/test_hermite_torsion_static.f90) target_link_libraries(test_hermite_torsion_static PRIVATE cabledyn_core) add_test(NAME hermite_torsion_static @@ -1394,6 +1404,9 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN # The same gate on a finite-EI cable with condensed torsion (a turning parent and a changing twist). add_test(NAME step_allocations_torsion COMMAND test_step_allocations torsion) set_tests_properties(step_allocations_torsion PROPERTIES LABELS "fortran;dynamic;memory") + # And with the nodal twist (polar inertia, torsional damping, the 7-DOF-per-node band). + add_test(NAME step_allocations_nodal_twist COMMAND test_step_allocations nodal) + set_tests_properties(step_allocations_nodal_twist PROPERTIES LABELS "fortran;dynamic;memory") endif() add_executable(test_snap_load tests/test_snap_load.f90) @@ -2789,6 +2802,8 @@ if(CABLEDYN_ENABLE_COVERAGE) test_line test_hermite_cable test_hermite_torsion_kernel + test_hermite_twist_kernel + test_nodal_twist_dynamic test_hermite_torsion_static test_hermite_torsion_dynamic test_hermite_cable_static diff --git a/VALIDATION.md b/VALIDATION.md index 530965a0..c1eb64a6 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-13** | Nodal twist (torsional inertia and damping) | condensed torsion in the limit of no inertia; continuum torsional wave; `ζ = ω Bt/(2 GJ)`; energy; restart | ≤6e-7 against the condensed torsion; wave torque 0.07 %; decrement 6 %; energy band 4.9e-4; restart bit-identical | see [Torsion](#torsion) | Pass | | **T-12** | Torque–tension coupling | `T = EA ε + K τ`, `M = GJ τ + K ε` closed forms; kernel FD; march | ≤1e-7 against every closed form; kernel gradient 1.7e-10, Hessian 9.8e-11 | see [Torsion](#torsion) | Pass | | **T-11** | Torsion on the coupled OpenFAST / FAST.Farm route | `GJ (−roll)/L`; single coupled cable; uninterrupted run | twist ≤1.8e-15°, torque ≤1.7e-13 N·m; aggregate = single cable bit for bit; restart bit-identical (aggregate and `openfast -restart`) | see [Torsion](#torsion) | Pass | @@ -999,6 +1000,30 @@ in parentheses). 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. +- **T-13 nodal twist** (`nodal_twist_dynamic`, `hermite_twist_kernel`). The reference twist of the + time-parallel-transported directors equals the direct composition of the smallest rotations + to 1e-13 (interior element, rigid End A, rigid End B, one element rigid at both ends, an + elastic end's spring), equals the fine transport along the element with the holonomy to + 1e-6, and has the gradient and Hessian of its finite differences. On the 10 m line + (EA 1e5 N, EI 100 N·m², GJ 80 N·m², 20 elements): + - with `Irn = 1e-9 kg·m` it reproduces the condensed torsion through 300 steps of sway, a + roll of more than a turn and an imposed twist, for clamped, bending-pinned and elastic + ends: centreline to 1.3e-10 m, mean torque 1.7e-12, node torques 5.9e-7, end force 9.9e-8 + and end moment 5.5e-7 relative; + - with `Irn = 0.5 kg·m`, rolled at half its first torsional frequency, the held end carries + the continuum torque `GJ A k/sin(kL)` to 0.07 %; + - with `Bt` for `ζ_1 = 0.05`, the first torsional mode rings down with the logarithmic + decrement 0.334 against 0.315 (6 %, the faster higher modes not yet gone); + - in free vibration at `ρ∞ = 1` the energy stays in a band of 4.9e-4 of the vibration energy + (3.8e-4 without torsion), and a run restored from a snapshot or rebuilt from the checkpoint + mirror continues bit-identically. + + The torsion gates of `torsion_deck`, `coupled_torsion` and `torsion_coupling` run in the + limit of a negligible polar inertia (`Irn = 1e-12` and `1e-9 kg·m`), whose closed forms they + check; at a direct non-stepping write of the coupled end, the end element alone takes the + roll (`GJ (−roll)/l_e`) against the frozen interior. The example + `torsion_lazy_wave_hangoff_twist.dat` (Irn of the section) moves by at most 7e-5 of the + torque against the condensed torsion. - **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"` @@ -1008,8 +1033,9 @@ in parentheses). (the C API) and a standalone mixed `EI = 0` + finite-EI deck without a body stop with named errors. -Limits. The torsion model is quasi-static (no torsional inertia), takes no seabed friction -against twist, and does not resolve self-contact. The torque–tension coupling is checked against +Limits. The torsion model takes no seabed friction against twist and does not resolve +self-contact; its statics are condensed (uniform torque). The nodal twist's inertia and damping +are checked against the continuum and modal closed forms only. 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 25943f26..0568936b 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -83,9 +83,11 @@ Line and constitutive capability fail closed by name * - Torsion of finite-EI lines - 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``), with torque–tension coupling (``GJ|K``), in statics with a stability check and buckling descent, and in dynamics + - isotropic torsion of a finite-EI line restrained in torsion at both ends + (``END CONNECTIONS`` torsion columns, explicit ``GJ``), with torque–tension coupling + (``GJ|K``): condensed (uniform torque) in statics with a stability check and buckling + descent, and a twist angle at every node in dynamics, with the polar inertia ``Irn`` and + torsional damping (``GJ|K|Bt``), with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm runs (torque returned to the platform, ``PtfmInit``, checkpoints; see @@ -93,8 +95,8 @@ Line and constitutive capability name: the standalone mixed ``EI = 0`` + finite-EI aggregate and the C API (which move the line ends by translation only), OpenFAST linearisation of a line restrained in torsion, rod ends, bodies other than Rigid6, lines with ``ATTACHMENTS``, modal analysis, and - ``False alpha_force_blend``. Not modelled: seabed friction against twist, torque–tension - coupling, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) + ``False alpha_force_blend``. Not modelled: seabed friction against twist, anisotropic + sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws - Not provided - the buckling onset and the post-buckled shape are computed, but a loop that closes on diff --git a/doc/driver_format.md b/doc/driver_format.md index 0be83193..905f9d4e 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -256,18 +256,26 @@ row decides: A stock-order header applies only to the 10-column row. **Optional finite-EI columns.** A 14-column row adds `GAs`, `GJ`, `Irt`, `Irn` (shear stiffness, -torsional stiffness, transverse and axial rotary inertia per length): +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 ([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. +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] +(`m r²/2` for a solid round section; see [Nodal twist](theory.rst)): give the section's real +value, as a placeholder `Irn` gives the line a wrong torsional inertia. `GAs` and `Irt` 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`. +`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 +`l0 √(GJ Irn)` on the final mesh, as `BA` is for the axial damping. It needs a finite-EI type; +`GJ|0|Bt` is damping without coupling. **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 52c64afd..31dc068e 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -733,22 +733,26 @@ Line-node channels - deg * - ``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_{\text{eff}})/C` (:math:`\Theta_{\text{eff}} = \Theta` - without torque–tension coupling); positive for a right-handed twist of End B relative + (``END CONNECTIONS`` ``TorsStiffness``, see :doc:`driver_format`). In the statics it is + uniform along the line, :math:`M = (\Phi - \Theta_{\text{eff}})/C` + (:math:`\Theta_{\text{eff}} = \Theta` without torque–tension coupling); in the dynamics it + is the nodal twist's torque at the node, the mean of its two elements' (an end node's + element; :ref:`nodal twist `). 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``, 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 + twists :math:`M L_e/GJ_e` (less :math:`(K/GJ)(l_e - L_e)` under torque–tension coupling; + in the dynamics the nodal twist's element twists) 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 * - ``Twist`` - total twist of the line, :math:`\Phi - \Theta = M C`, including the windup of torsional end springs: the imposed twist :math:`\Phi` less the geometric twist - :math:`\Theta` the line takes up by writhing out of its plane + :math:`\Theta` the line takes up by writhing out of its plane (in the dynamics the + element twists plus the end springs' windup) - deg Touchdown channels diff --git a/doc/theory.rst b/doc/theory.rst index 37f91c5f..76bab7a5 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -138,7 +138,8 @@ element, with a 2 % criterion relative to the largest local magnitude (at least The element follows the geometrically exact Kirchhoff-rod formulation of :ref:`Boyer et al. (2011) ` with the :math:`C^1` Hermite centreline interpolation of :ref:`Meier, Popp & Wall (2015) `, reduced to a torsion-free -cable. Torsion enters only through the condensed line term below. +cable. Torsion enters through the condensed line term of the statics and the nodal twist of the +dynamics below. .. _theory-bend-stiffeners: @@ -354,7 +355,8 @@ It is carried to every node by parallel transport along the centreline, eight sm rotations between the Hermite tangents per element, which does not twist it about the tangent. On a line in torsion it is then turned about :math:`\mathbf{t}` by the twist from End A, the torque times the End A compliance plus :math:`\sum l_0/GJ` from End A, right-handed about -:math:`\mathbf{t}`. With :math:`\mathbf{d}_2 = \mathbf{t} \times \mathbf{d}_1` (y), +:math:`\mathbf{t}`. In the dynamics, with the :ref:`nodal twist `, +it is the material director of each node, on the same convention. With :math:`\mathbf{d}_2 = \mathbf{t} \times \mathbf{d}_1` (y), ``CurvX`` :math:`= \kappa\mathbf{n} \cdot \mathbf{d}_1` and ``CurvY`` :math:`= \kappa\mathbf{n} \cdot \mathbf{d}_2`. A fibre at :math:`(x, y)` in the section is strained in bending by :math:`-(\kappa_x x + \kappa_y y)`. On a line twisted 90 degrees from @@ -459,13 +461,12 @@ constant-velocity joint), for which :math:`\tan x = -x/3` and :math:`M_{cr} = 4. zero tension, not the :math:`2\pi EI/L` of Greenhill's axial-torque hinge. OrcaFlex's bending-free end with a twisting spring gives the same value (see :doc:`validation`). -**Dynamics and loads.** The torsion force enters the force-blended residual like the internal -force, so a dynamic deck with torsion requires ``True alpha_force_blend`` (the default). Torsion -carries no inertia: the torque follows the imposed twist within the step, without a torsional -wave. This is accurate while the first torsional frequency of the line, -:math:`\sqrt{GJ/I_p}/(2L)` with :math:`I_p` the polar mass moment per length, is well above the -excitation; it is not for very long or torsionally soft lines. The moment of the torque on the -object at End A is :math:`M\,\partial\Theta/\partial\boldsymbol{\omega}_A`, the derivative with +**Dynamics and loads.** A deck line carries the nodal twist below in the dynamics, with the +condensed torsion as its limit of a negligible polar inertia; a line built through the API +without the polar inertia keeps the condensed torsion, whose torque follows the imposed twist +within the step, without a torsional wave. Either enters the force-blended residual like the +internal force, so a dynamic deck with torsion requires ``True alpha_force_blend`` (the +default). In the condensed torsion, the moment of the torque on the object at End A is :math:`M\,\partial\Theta/\partial\boldsymbol{\omega}_A`, the derivative with respect to a rotation :math:`\boldsymbol{\omega}_A` of that object (for a clamped end, of its frame and the end tangent together), so the virtual work of the body moment is exact; for a straight line it is the torque along the line axis. The static body equilibrium uses the same moment and @@ -499,6 +500,64 @@ cannot twist, so it carries :math:`T = EA\,\varepsilon` and :math:`M = K\varepsi 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)`. +.. _theory-nodal-twist: + +**Nodal twist (dynamics).** The dynamics give every node :math:`k` a twist angle +:math:`\varphi_k`: the angle about the unit node tangent :math:`\mathbf{t}_k` from a reference +director :math:`\mathbf{u}_k` to the material director. Over each step the reference directors +follow their tangents by the smallest rotation (time-parallel transport), so the axial angular +velocity of the section is :math:`\dot\varphi_k`. The material twist of element :math:`e` +between nodes :math:`k` and :math:`k+1` is :math:`\varphi_{k+1} - \varphi_k + m_e`, with the +reference twist :math:`m_e = \beta_e - h_e`: :math:`\beta_e` the angle from :math:`\mathbf{u}_k`, +carried to node :math:`k+1` by the smallest rotation, to :math:`\mathbf{u}_{k+1}`, and :math:`h_e` +the element holonomy above. Transport around the geodesic quadrilateral of the committed and +present tangents gives + +.. math:: + + \beta_e = \beta_e^n - \Omega(\mathbf{t}_k^n, \mathbf{t}_k, \mathbf{t}_{k+1}) + - \Omega(\mathbf{t}_k^n, \mathbf{t}_{k+1}, \mathbf{t}_{k+1}^n) , + +local to the element's 12 DOFs, with the closed-form gradient and Hessian of the solid angles. +The turns of the line live in the angles, so no :math:`2\pi` branch is tracked. This is the +time-parallel reference frame of discrete elastic rods (:ref:`Bergou et al., 2008 +`) on the Hermite centreline. The element carries the torque + +.. math:: + + M_e = \frac{GJ_e}{L_{0,e}}\,\hat\tau_e + \frac{B_{t,e}}{L_{0,e}}\,\dot{\hat\tau}_e, \qquad + \hat\tau_e = \varphi_{k+1} - \varphi_k + m_e + \frac{K_e}{GJ_e}\,(l_e - L_{0,e}) , + +the elastic torque of the energy :math:`\tfrac12 (GJ/L_0)\,\hat\tau^2`, which with the cable's +axial stiffness :math:`EA - K^2/GJ` is the section energy of the torque–tension coupling, and +the Kelvin–Voigt torsional damping :math:`B_t` (``GJ|K|Bt``), whose rate takes the nodal rates +and :math:`\nabla\hat\tau\cdot\dot{\mathbf{q}}`. The damping is stiffness-proportional: the +torsional mode of frequency :math:`\omega` has the damping ratio :math:`\omega B_t/(2GJ)`. The +polar rotary inertia :math:`I_{rn}` (``Irn``) is lumped at the nodes. An elastic end adds its +spring between the end node and the end frame's normal carried to the node; a rigid end takes +that normal as its node's director and holds the node's angle (0 at the first node of the solve +order, End B, and :math:`\Phi` at End A), so a turn of the frame enters the end element's +reference twist through the same solid angles. A turn of an end frame by more than +:math:`\pi/2` about the line within one step is refused, and the step is cut. + +In the limit of a negligible inertia the element torques are uniform and equal the condensed +torque; the test suite holds the two models to 1e-6 on a rolling, swaying, bowed line with +clamped, bending-pinned and elastic ends, and checks the torque of a driven torsional wave +against the continuum, the decay of the first torsional mode under :math:`B_t`, and the energy +of a free vibration (see :doc:`validation`). + +The angles join the generalised-α step with the same Newmark scheme. The tangent couples them +to the tangent DOFs of their elements: the step factorises one band in the order +:math:`[\mathbf{r}, \mathbf{m}, \varphi]` per node (half-bandwidth 13 instead of 11), into which +the cable's tangent, the angle rows and columns, the lumped inertia and the damping are +assembled; the angle rows converge on the nodal torque balance, scaled as the force rows are by +the nodal loads. The committed reference twists are advanced with the step's own solid angles, so +the committed state reproduces the converged iterate bit for bit, and the twist state is part of +the snapshot, the recovering step and the checkpoint mirror. A host write of the coupled end +between steps (the direct feedthrough) twists the end element against the frozen interior, as +the end's translation stretches it. The node torque (``TorqN``) is the mean of its two +elements', and the material twists of the elements sum to the twist channels. + **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 anisotropic or pre-twisted section, and no self-contact: a loop that diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index cb8cda73..56f485e3 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -193,7 +193,9 @@ class LineType: 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. ``gj`` may be ``(GJ, K)``, with ``K`` the - torque-tension coupling in N m (written ``GJ|K``). + torque-tension coupling in N m (written ``GJ|K``), or ``(GJ, K, Bt)``, + with ``Bt`` the torsional damping in N m^2 s, negative for a damping + ratio (written ``GJ|K|Bt``). 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 @@ -212,7 +214,7 @@ class LineType: can: float = 0.0 cat: float = 0.0 gas: float | None = None - gj: float | tuple[float, float] | None = None + gj: float | tuple[float, ...] | None = None irt: float | None = None irn: float | None = None cl: float | None = None @@ -1628,7 +1630,7 @@ def add_line_type( can: float = 0.0, cat: float = 0.0, gas: float | None = None, - gj: float | tuple[float, float] | None = None, + gj: float | tuple[float, ...] | None = None, irt: float | None = None, irn: float | None = None, cl: float | None = None, @@ -2659,8 +2661,8 @@ 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 - if isinstance(item.gj, tuple) and len(item.gj) != 2: - raise ValueError(f"{what}: gj is GJ or (GJ, K)") + if isinstance(item.gj, tuple) and len(item.gj) not in (2, 3): + raise ValueError(f"{what}: gj is GJ, (GJ, K) or (GJ, K, Bt)") row += [ _multi(value, what) if index == 1 else _num(value, what) for index, value in enumerate(extra) diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 3fe4a0c7..c72dd9db 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2655,7 +2655,7 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: 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 + continue # the GJ column, GJ, GJ|K or GJ|K|Bt, 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("|") @@ -2744,14 +2744,17 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: 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) + # the GJ column is GJ, GJ|K or GJ|K|Bt (K the torque-tension coupling, N m; + # Bt the torsional damping, N m^2 s, negative: -zeta) gj_parts = row.tokens[7].split("|") - if len(gj_parts) > 2: + if len(gj_parts) > 3: raise DeckFormatError( - f'{self._at(row)}: LINE TYPES GJ column "{row.tokens[7]}" takes GJ or GJ|K' + f'{self._at(row)}: LINE TYPES GJ column "{row.tokens[7]}" takes GJ, GJ|K ' + "or GJ|K|Bt" ) 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 + ktt = numeric(gj_parts[1], row, "GJ|K coupling") if len(gj_parts) >= 2 else 0.0 + btor = numeric(gj_parts[2], row, "GJ|K|Bt damping") if len(gj_parts) == 3 else 0.0 finite_ei = [ numeric(row.tokens[6], row, "LINE TYPES column 7"), gj_value, @@ -2781,6 +2784,11 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: LINE TYPES {name}: torque-tension coupling needs " "GJ > 0 and K^2 < EA GJ" ) + if btor != 0.0 and not (ei > 0.0 and gj_value > 0.0 and finite_ei[3] > 0.0): + raise DeckFormatError( + f"{self._at(row)}: LINE TYPES {row.tokens[0]}: torsional damping (GJ|K|Bt) " + "needs a finite-EI cable with GJ > 0 and Irn > 0" + ) line_type_meta[row.tokens[0].lower()] = ( numeric(row.tokens[1], row, "Diam"), numeric(row.tokens[2], row, "Mass"), diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index c0996a74..d3d28f19 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -962,12 +962,35 @@ def test_torque_tension_coupling_round_trips_in_the_gj_column(tmp_path: Path) -> assert next(t for t in loaded.line_types if t.name == "cable").gj == (1.0e4, 2.0e5) +def test_torsional_damping_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, 0.0, -0.02), + irt=0.1, + irn=0.05, + ) + assert cable.gj == (1.0e4, 0.0, -0.02) + target = model.save(tmp_path / "damped.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, 0.0, -0.02] + loaded = DeckModel.load(target) + assert next(t for t in loaded.line_types if t.name == "cable").gj == (1.0e4, 0.0, -0.02) + + @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"), + ("1.0e4|1.0e3|5.0|1.0", "1.0e4", r"takes GJ, GJ\|K or GJ\|K\|Bt"), + ("1.0e4|0|5.0", "0.0", "torsional damping"), ], ) def test_torque_tension_coupling_refusals(tmp_path: Path, gj: str, ei: str, message: str) -> None: diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 67f916cd..035060bf 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -110,7 +110,8 @@ MODULE CableDyn_DeckDriver 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_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension + CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension, & + CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & CD_HTORS_MAX_TWIST USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID @@ -366,6 +367,10 @@ MODULE CableDyn_DeckDriver ! 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 + ! torsional damping Bt [N m^2 s] of the GJ column's third part (GJ|K|Bt), the torque Bt dtau/dt + ! of the nodal twist; negative: -zeta, the fraction of an element's critical torsional + ! damping l0 sqrt(GJ Irn), resolved on the final mesh + REAL(wp) :: bt = 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 @@ -1736,7 +1741,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 :: ktt_in(:), bt_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(:) @@ -1983,7 +1988,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, ktt=ktt_in) + gas_in, gj_in, i_rt_in, i_rn_in, ErrStat, ErrMsg, ktt=ktt_in, bt=bt_in) IF (ErrStat /= CD_DECKDRV_OK) RETURN IF (ALLOCATED(ln%stf)) THEN ALLOCATE (ei_cable(SIZE(l0))) @@ -3325,6 +3330,19 @@ SUBROUTINE torsion_stage(est, emt) 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 + ! the polar rotary inertia Irn per element: the dynamics then carries a twist angle at + ! every node (CD_HermiteCable_Dyn_Set_Torsion) + tors%irn = i_rn_in + IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%irn, l0, l0_am) + ! torsional damping (GJ|K|Bt): a negative value is -zeta of an element's critical torsional + ! damping l0 sqrt(GJ Irn), on the final mesh + IF (ANY(ABS(bt_in) > CD_ZERO)) THEN + tors%bt = bt_in + IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%bt, l0, l0_am) + DO k = 1, SIZE(tors%bt) + IF (tors%bt(k) < CD_ZERO) tors%bt(k) = -tors%bt(k)*l0_am(k)*SQRT(tors%gj(k)*tors%irn(k)) + END DO + END IF DO k = 1, 2 dvec = endconn_d0_local(:, k)/NORM2(endconn_d0_local(:, k)) IF (k == 1) THEN @@ -9859,12 +9877,13 @@ 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, ktt) + ErrStat, ErrMsg, ktt, bt) !! 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. 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. + !! cable; a line restrained in torsion adds the rest through its torque) and, with ktt, its K; + !! bt returns the deck's torsional damping (unresolved: -zeta stays negative). TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckLineType), INTENT(IN) :: types(:) @@ -9873,10 +9892,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(:) + REAL(wp), ALLOCATABLE, INTENT(OUT), OPTIONAL :: ktt(:), bt(:) INTEGER :: n_elem, i, j, e, tidx - REAL(wp), ALLOCATABLE :: kc(:) + REAL(wp), ALLOCATABLE :: kc(:), bc(:) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -9889,7 +9908,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), kc(n_elem)) + ALLOCATE (gas(n_elem), gj(n_elem), i_rt(n_elem), i_rn(n_elem), kc(n_elem), bc(n_elem)) e = 0 DO i = 1, SIZE(sections) IF (sections(i)%line_id /= ln%id) CYCLE @@ -9907,6 +9926,7 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia i_rt(e) = types(tidx)%i_rt i_rn(e) = types(tidx)%i_rn kc(e) = types(tidx)%ktt + bc(e) = types(tidx)%bt IF (ABS(kc(e)) > CD_ZERO) ea(e) = ea(e) - kc(e)**2/gj(e) END DO END DO @@ -9921,6 +9941,7 @@ SUBROUTINE build_finite_section_mesh(ln, sections, types, conn, l0, ea, mpl, dia 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) + IF (PRESENT(bt)) bt = bc(n_elem:1:-1) END SUBROUTINE build_finite_section_mesh SUBROUTINE finite_raw_ba_array(ln, sections, types, ba_raw) @@ -13358,30 +13379,40 @@ SUBROUTINE sniff_types_header(line, stock_cols) 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] + !! The 14-column row's GJ column: GJ, 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). + !! sense its positive torque turns), or GJ|K|Bt with Bt the torsional damping (DeckLineType). CHARACTER(*), INTENT(IN) :: gj_str TYPE(DeckLineType), INTENT(INOUT) :: t INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: bar, ios + INTEGER :: bar, bar2, ios ErrStat = 0; ErrMsg = '' t%ktt = CD_ZERO + t%bt = 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 + bar2 = INDEX(gj_str(bar + 1:), '|') + IF (bar2 > 0) THEN + bar2 = bar + bar2 + IF (INDEX(gj_str(bar2 + 1:), '|') > 0) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" takes GJ, GJ|K or GJ|K|Bt'); RETURN + END IF END IF READ (gj_str(1:bar - 1), *, IOSTAT=ios) t%gj - IF (ios == 0) READ (gj_str(bar + 1:), *, IOSTAT=ios) t%ktt + IF (bar2 > 0) THEN + IF (ios == 0) READ (gj_str(bar + 1:bar2 - 1), *, IOSTAT=ios) t%ktt + IF (ios == 0) READ (gj_str(bar2 + 1:), *, IOSTAT=ios) t%bt + ELSE + IF (ios == 0) READ (gj_str(bar + 1:), *, IOSTAT=ios) t%ktt + END IF END IF IF (ios /= 0) THEN - CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" is not GJ or GJ|K'); RETURN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" is not GJ, GJ|K or GJ|K|Bt'); RETURN END IF - IF (.NOT. (IEEE_IS_FINITE(t%gj) .AND. IEEE_IS_FINITE(t%ktt))) THEN + IF (.NOT. (IEEE_IS_FINITE(t%gj) .AND. IEEE_IS_FINITE(t%ktt) .AND. IEEE_IS_FINITE(t%bt))) THEN CALL fail(ErrStat, ErrMsg, 'LINE TYPES GJ column "'//TRIM(gj_str)//'" must be finite'); RETURN END IF END SUBROUTINE parse_gj_column @@ -13475,6 +13506,12 @@ SUBROUTINE append_type(line, types, nt, stock_cols, ErrStat, ErrMsg) 'K^2 < EA GJ'); RETURN END IF END IF + IF (ABS(t%bt) > CD_ZERO) THEN + IF (.NOT. (t%ei > CD_ZERO .AND. t%gj > CD_ZERO .AND. t%i_rn > CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'LINE TYPES '//TRIM(t%name)//': torsional damping (GJ|K|Bt) needs a '// & + 'finite-EI cable with GJ > 0 and Irn > 0'); RETURN + END IF + END IF CALL grow_types(types, nt) nt = nt + 1; types(nt) = t END SUBROUTINE append_type @@ -34597,7 +34634,19 @@ SUBROUTINE range_sample_cable(cable, rl, ErrStat, ErrMsg) IF (rl%has_torsion .AND. cable%line%torsion%active) THEN ! condensed torsion: the committed torque (uniform) and the cable's own twist from End A ! (public node 1, the last internal node), as the TorqN and TwistN channels - rl%val(CD_RQ_TORQUE, :) = cable%line%torsion%torque + IF (cable%line%tw_active) THEN + ! nodal twist: the node torques (public node j is internal node nn + 1 - j) + BLOCK + REAL(wp) :: ntq(nn) + CALL CD_HermiteCable_Dyn_Node_Torque(cable%line, ntq, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'range-graph torque recovery failed: '//TRIM(em)); RETURN + END IF + rl%val(CD_RQ_TORQUE, 1:nn) = ntq(nn:1:-1) + END BLOCK + ELSE + rl%val(CD_RQ_TORQUE, :) = cable%line%torsion%torque + END IF rl%val(CD_RQ_TWIST, 1) = CD_ZERO BLOCK REAL(wp) :: etw(cable%line%ne) @@ -35500,7 +35549,17 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) IF (es /= CD_HCDYN_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF - IF (kind == 9) THEN + IF (kind == 9 .AND. cable%line%tw_active) THEN + ! nodal twist: the torque at the node (its elements' mean; an end node's element) + BLOCK + REAL(wp) :: ntq(cable%line%nn) + CALL CD_HermiteCable_Dyn_Node_Torque(cable%line, ntq, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN + END IF + val = ntq(inode) + END BLOCK + ELSE IF (kind == 9) THEN val = mt ELSE IF (cable%line%torsion%active) THEN ! the element twists (M_t l0/GJ, less the stretch's under torque-tension coupling); @@ -35512,7 +35571,16 @@ SUBROUTINE eval_cable_channel(cable, ch, val, ErrStat, ErrMsg, mesh_node) IF (es /= CD_HCDYN_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN END IF - IF (kind == 11) THEN + IF (kind == 11 .AND. cable%line%tw_active) THEN + BLOCK + REAL(wp) :: etw2(2) + CALL CD_HermiteCable_Dyn_End_Twist(cable%line, etw2, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": '//TRIM(em)); RETURN + END IF + val = (SUM(etw2) + SUM(etw))*45.0_wp/QUARTER_PI + END BLOCK + ELSE 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 diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index cd696c9a..03757502 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -51,6 +51,7 @@ MODULE CableDyn_HermiteCableDynamic !! + (1-alpha_f) gamma/(beta dt) Kv(q_alpha, v_alpha), !! where Kv = dR/dv is the drag velocity Jacobian and gamma/(beta dt) = d v_{n+1}/d q_{n+1}. USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_All_Finite, CD_Is_Finite + USE CableDyn_SO3, ONLY: CD_Log_SO3 USE CableDyn_FatalReport, ONLY: CD_Fatal_Thread_Init USE CableDyn_EndConnection, ONLY: CD_EndConn_Spring, CD_EndConn_Energy, & CD_EndConn_Reaction_Moment, CD_EndConn_Basis, & @@ -79,7 +80,10 @@ MODULE CableDyn_HermiteCableDynamic 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_Element_Stretch + CD_HermiteTorsion_Element_Stretch, CD_HermiteTorsion_Element, & + CD_HermiteTorsion_Stretch_Derivatives, CD_HermiteTwist_Reference, & + CD_HermiteTwist_Carry, CD_HermiteTwist_Angle, CD_HermiteTwist_Omega, & + CD_HermiteTwist_Omega_Gradient, CD_HTORS_PI USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 !$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_in_parallel IMPLICIT NONE @@ -94,6 +98,9 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Torsion_State PUBLIC :: CD_HermiteCable_Dyn_Element_Twist PUBLIC :: CD_HermiteCable_Dyn_Coupling_Tension + PUBLIC :: CD_HermiteCable_Dyn_Element_Torque, CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist + PUBLIC :: CD_HermiteCable_Dyn_Twist_Mirror_Size, CD_HermiteCable_Dyn_Twist_Pack, CD_HermiteCable_Dyn_Twist_Unpack + PUBLIC :: CD_HermiteCable_Dyn_Twist_Check PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion_Drive PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion_Frames PUBLIC :: CD_HermiteCable_Dyn_EndConnection_Moment @@ -167,6 +174,8 @@ MODULE CableDyn_HermiteCableDynamic ! general-band storage (DGBSV layout: entry (i, j) at ab(KL_D + KU_D + 1 + i - j, j), with ! KL_D extra top rows for the factorization fill) -- no dense matrices, no bandwidth scan. INTEGER, PARAMETER :: KL_D = 11, KU_D = 11 + ! Half-bandwidth of the nodal-twist tangent in 7-DOF-per-node order ([r, m, phi] per node). + INTEGER, PARAMETER :: KB7 = 13 INTEGER, PARAMETER :: LDAB_D = 2*KL_D + KU_D + 1 ! Profiling is OFF by default: SYSTEM_CLOCK in the step/residual hot path is measurable @@ -444,6 +453,52 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp) :: tors_c_ends(3, 4) = CD_ZERO, tors_c_prev = CD_ZERO, tors_c_theta = CD_ZERO REAL(wp) :: tors_c_eg(6) = CD_ZERO, tors_c_gend(3, 2) = CD_ZERO LOGICAL :: tors_c_valid = .FALSE. + ! Nodal twist (the torsion carries the polar inertia irn; CD_HermiteCable_Dyn_Set_Torsion): + ! a twist angle phi per node, the angle about the node tangent from the reference director + ! u to the material director, replaces the condensed torque in the dynamics. The directors + ! follow the node tangents by the smallest rotation over each step (time-parallel + ! transport), so the axial angular velocity of a section is phi_dot. Element e twists by + ! phi_{e+1} - phi_e + rho_e(q), rho_e = beta_e - h_e + (K/GJ)(l_e - l0) (beta_e the angle + ! from u_e carried to node e + 1 to u_{e+1}, h_e the element holonomy), and carries the + ! torque M_e = (GJ/l0)(phi_{e+1} - phi_e + rho_e) + (Bt/l0) d/dt(...). An elastic end adds a + ! spring k (twist of the end node against its end frame); a rigid end takes the end frame's + ! normal carried to the node as its director and holds phi (0 at end 1, Phi at end 2). + ! Committed state: tw_phi/tw_w/tw_al (angle, rate, acceleration; nn), tw_u and tw_tn + ! (directors and unit tangents; 3 x nn), tw_beta (ne), tw_psi (the end-frame reference of + ! an elastic end) and tw_mt (element torques, ne). tw_mass is the lumped polar inertia. + ! Step scratch: tw_pn/wn/an (step start), tw_pk/wk/ak (iterate), tw_ptrial, tw_dp, tw_G, + ! tw_Gt, tw_Rk, tw_Rt, tw_R (phi residual of the last assembly), tw_fcR (the force cache's + ! phi part), tw_pe/tw_we (the angles and rates the assembly reads in a step), the element + ! and end-link tangent data of the last tangent assembly (tw_eg, tw_ehv, tw_ek, tw_ed, + ! tw_lg, tw_lk), the element torques of the last assembly (tw_me), and the 7-DOF-per-node + ! effective tangent tw_K7 with its pivots and solve vector (KL = KU = 13). + LOGICAL :: tw_active = .FALSE. + LOGICAL :: tw_rigid(2) = .FALSE. + REAL(wp), ALLOCATABLE :: tw_phi(:), tw_w(:), tw_al(:), tw_mass(:), tw_u(:, :), tw_tn(:, :) + REAL(wp), ALLOCATABLE :: tw_beta(:), tw_mt(:) + REAL(wp) :: tw_psi(2) = CD_ZERO + LOGICAL, ALLOCATABLE :: tw_free(:) + REAL(wp), ALLOCATABLE :: tw_pn(:), tw_wn(:), tw_an(:), tw_pk(:), tw_wk(:), tw_ak(:), tw_ptrial(:), tw_dp(:) + REAL(wp), ALLOCATABLE :: tw_G(:), tw_Gt(:), tw_Rk(:), tw_Rt(:), tw_R(:), tw_fcR(:), tw_pe(:), tw_we(:) + REAL(wp), ALLOCATABLE :: tw_eg(:, :), tw_ehv(:, :), tw_ek(:), tw_ed(:), tw_me(:) + REAL(wp) :: tw_lg(3, 2) = CD_ZERO, tw_lk(2) = CD_ZERO + REAL(wp), ALLOCATABLE :: tw_K7(:, :), tw_x7(:) + INTEGER, ALLOCATABLE :: tw_ipiv(:) + ! tw_tsum: the summed element and end-link twists (Phi less the condensed Theta_eff in a + ! quasi-static state) of the last assembly; tw_su/tw_stn/tw_sbeta/tw_spsi: the reference + ! state at q_{n+1} (tw_advance_reference) awaiting the commit; tw_tscale: the torque scale of + ! the step's residual norm. + REAL(wp) :: tw_tsum = CD_ZERO, tw_spsi(2) = CD_ZERO, tw_tscale = CD_ONE + REAL(wp), ALLOCATABLE :: tw_su(:, :), tw_stn(:, :), tw_sbeta(:) + ! tw_som(:, k): the angular velocity of end frame k over the running step, log(R_{n+1} + ! R_n^T)/dt (R = [d n d x n]); tw_om: that of the committed step. A turning frame twists + ! the element at a rigid end through rho, and the torsional damping takes that rate. + ! tw_oal: the frames' angular acceleration at the committed state, (tw_om - its value one + ! step earlier)/dt, which turns the held end section's polar inertia (the support reaction). + REAL(wp) :: tw_som(3, 2) = CD_ZERO, tw_om(3, 2) = CD_ZERO, tw_oal(3, 2) = CD_ZERO + ! Packed twist state (tw_pack) of the recovering step's interval start and of the snapshot, + ! and the snapshot's tw_fcR. + REAL(wp), ALLOCATABLE :: ws_recovery_tw(:), snap_tw(:), snap_tw_fcR(:) LOGICAL :: snap_valid = .FALSE. ! Adaptive-Newton warmup counters are step-history too: a staged step (aggregate ! stage-then-commit) that advances them and is then rolled back must restore them, or the @@ -1927,6 +1982,8 @@ SUBROUTINE rebuild_length_caches(model, l0_new, ErrStat, ErrMsg) CALL MOVE_ALLOC(cn_new, model%contact_cn) IF (model%fr_active) model%fr_k = model%contact_kn END IF + ! the lumped polar inertia of the nodal twist follows the lengths + IF (model%tw_active) CALL tw_set_derived(model, model%torsion) END SUBROUTINE rebuild_length_caches SUBROUTINE enter_committed_lengths(model, aside, ErrStat, ErrMsg) @@ -3343,6 +3400,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step(model, dt, max_iter, tol, ErrStat, ErrMsg, i !! consistent). Theta is unwrapped against the committed value and may change by at most pi/2 !! in a step (a larger change fails the evaluation, and the line search or the recovering step !! cuts it). It needs the force-blended generalised-alpha. + !! + !! NODAL TWIST (the torsion carries irn; see the type note): the twist angles join the step + !! with the same Newmark scheme and are solved with the cable in one band of [r, m, phi] per + !! node; an end frame may turn by at most pi/2 about the line in a step. TYPE(CD_HermiteCableDynType), INTENT(INOUT), TARGET :: model REAL(wp), INTENT(IN) :: dt, tol INTEGER, INTENT(IN) :: max_iter @@ -3462,6 +3523,44 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion_Frames(model, ends, ErrStat, ErrMsg, model%tors_drive_ends = drive_ends model%tors_drive_phi = drive_phi IF (ErrStat /= CD_HCDYN_OK) RETURN + IF (model%tw_active) THEN + ! Nodal twist: the reference re-based at the committed (or checked) configuration with the + ! new frames (tw_advance_reference: a rigid end's element takes the frame's turn, an + ! elastic end's spring its psi), then the committed torques and Theta_eff. + IF (PRESENT(q_check)) THEN + IF (SIZE(q_check) /= model%ndof) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion_Frames: q_check must have ndof entries' + RETURN + END IF + CALL tw_advance_reference(model, q_check, ends, ErrStat, ErrMsg) + ELSE + CALL tw_advance_reference(model, model%q, ends, ErrStat, ErrMsg) + END IF + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion_Frames: '//TRIM(ErrMsg) + RETURN + END IF + IF (PRESENT(q_check)) RETURN + ! a frame turn within one step of the end-frame constants (the wrapped change is unique) + model%tors_drive_set = .FALSE. + CALL tw_commit_reference(model) + model%torsion%ends = ends + model%tors_use_step = .FALSE. + CALL assemble_twist(model, model%q, model%v, .TRUE., .FALSE., model%ws_R, model%ws_Kb, model%ws_Kvb, & + ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion_Frames: '//TRIM(ErrMsg) + RETURN + END IF + model%tw_mt = model%tw_me + model%torsion%theta = model%torsion%phi - model%tw_tsum + model%torsion%torque = model%tw_tsum/CD_HermiteTorsion_Compliance(model%torsion, model%l0) + model%fc_valid = .FALSE. + model%fc_clears = model%fc_clears + 1 + model%tr_valid = .FALSE. + RETURN + END IF IF (PRESENT(q_check)) THEN IF (SIZE(q_check) /= model%ndof) THEN ErrStat = CD_HCDYN_BADINPUT @@ -3693,6 +3792,13 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%ws_vn(iv) = model%v(iv) model%ws_an(iv) = model%a(iv) END DO + IF (model%tw_active) THEN + DO iv = 1, model%nn + model%tw_pn(iv) = model%tw_phi(iv) + model%tw_wn(iv) = model%tw_w(iv) + model%tw_an(iv) = model%tw_al(iv) + END DO + END IF CALL rigid_tangent_scalar_state(model, model%endconn_d0, model%ws_qn, model%ws_vn, model%ws_an, & step_n0, step_ndot0, step_nddot0) ! Total mass for this step: structural + added mass FROZEN at the beginning-of-step @@ -3751,6 +3857,11 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r DO iv = 1, SIZE(model%fc_R) model%fc_R(iv) = model%ws_R(iv) END DO + IF (model%tw_active) THEN + DO iv = 1, model%nn + model%tw_fcR(iv) = model%tw_R(iv) + END DO + END IF ! Key the recomputed force on the state it describes. model%fc_q = model%q model%fc_v = model%v @@ -3768,6 +3879,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! Condensed torsion: F_n above used the committed end frames and Phi; every evaluation of the ! step from here on uses the step's target (set by CD_HermiteCable_Dyn_Step). model%tors_use_step = model%torsion%active + IF (model%tw_active) CALL tw_frame_rates(model, dt) ! Newton predictor. The standard Newmark guess q_n + dt v_n + dt^2 (1/2 - beta) a_n (the ! acceleration map's base a_{n+1} = 0) is a far better start than q_n when the state is ! moving. When the committed acceleration is the physical one, the constant-acceleration @@ -3848,6 +3960,18 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%ws_qk(pres_dofs(ip)) = pres_q(ip) END DO END IF + ! Nodal twist: the same predictor for the angles; a rigid end holds 0 (end 1) or Phi (end 2). + IF (model%tw_active) THEN + DO iv = 1, model%nn + IF (use_ca) THEN + model%tw_pk(iv) = model%tw_pn(iv) + dt*model%tw_wn(iv) + 0.5_wp*dt*dt*model%tw_an(iv) + ELSE + model%tw_pk(iv) = model%tw_pn(iv) + dt*model%tw_wn(iv) + (0.5_wp - bt)*dt*dt*model%tw_an(iv) + END IF + END DO + IF (model%tw_rigid(1)) model%tw_pk(1) = CD_ZERO + IF (model%tw_rigid(2)) model%tw_pk(model%nn) = model%tors_step_phi + END IF CALL project_rigid_tangents(model, step_endconn_target, model%ws_qk, es, em2) IF (es /= CD_HCDYN_OK) THEN ErrStat = es @@ -3962,7 +4086,18 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! Factor with the model-owned pivot workspace (DGBTRF -- exactly what DGBSV runs ! internally, without its per-call pivot allocation). IF (prof_enabled) CALL SYSTEM_CLOCK(pc0) - CALL CD_Factor_Banded(model%ws_Keffb, KL_D, KU_D, model%ws_ipiv, es, em2, matrix_validated=.TRUE.) + IF (model%tw_active) THEN + ! nodal twist: the cable's band with the angles interleaved ([r, m, phi] per node) + CALL tw_build_K7(model, (CD_ONE - am)*c_a, CD_ONE - af, cw, step_rigid_basis, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2) + IF (attempt < n_attempt) CYCLE predict + RETURN + END IF + CALL CD_Factor_Banded(model%tw_K7, KB7, KB7, model%tw_ipiv, es, em2, matrix_validated=.TRUE.) + ELSE + CALL CD_Factor_Banded(model%ws_Keffb, KL_D, KU_D, model%ws_ipiv, es, em2, matrix_validated=.TRUE.) + END IF IF (prof_enabled) THEN CALL SYSTEM_CLOCK(pc1) prof_n_factor = prof_n_factor + 1 @@ -3973,7 +4108,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r IF (attempt < n_attempt) CYCLE predict RETURN END IF - IF (model%torsion%active) THEN + IF (model%torsion%active .AND. .NOT. model%tw_active) THEN ! Rank-one torsion term (1 - af) g g^T / C of the effective tangent: g in the solve ! coordinates (as the residual), its K^-1 image and the Sherman-Morrison denominator, ! all kept with this factor. @@ -4002,8 +4137,15 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r IF (.NOT. model%solve_mask(i)) model%ws_dq(i) = CD_ZERO END DO IF (prof_enabled) CALL SYSTEM_CLOCK(pc0) - CALL CD_Solve_Factored_Banded(model%ws_Keffb, KL_D, KU_D, model%ws_ipiv, model%ws_dq, es, em2, & - factor_validated=.TRUE.) + IF (model%tw_active) THEN + DO i = 1, model%nn + model%tw_dp(i) = MERGE(-model%tw_G(i), CD_ZERO, model%tw_free(i)) + END DO + CALL tw_solve(model, es, em2) + ELSE + CALL CD_Solve_Factored_Banded(model%ws_Keffb, KL_D, KU_D, model%ws_ipiv, model%ws_dq, es, em2, & + factor_validated=.TRUE.) + END IF IF (prof_enabled) THEN CALL SYSTEM_CLOCK(pc1) prof_n_solve = prof_n_solve + 1 @@ -4014,7 +4156,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r IF (attempt < n_attempt) CYCLE predict RETURN END IF - IF (model%torsion%active) CALL torsion_sm_correct() + IF (model%torsion%active .AND. .NOT. model%tw_active) CALL torsion_sm_correct() CALL transform_rigid_vector_to_global(model, step_rigid_basis, model%ws_dq) nsolve_step = nsolve_step + 1 IF (PRESENT(iters_out)) iters_out = nsolve_step @@ -4027,7 +4169,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r lambda = CD_ONE ! Condensed torsion: the linearised twist change of a trial stays within pi/4 (the ! post-trial unwrap against the committed Theta cannot tell 3 pi/2 from -pi/2) - IF (model%torsion%active) THEN + IF (model%torsion%active .AND. .NOT. model%tw_active) THEN dth_lin = ABS(DOT_PRODUCT(model%tors_g, model%ws_dq)) IF (dth_lin > 0.5_wp*CD_HTORS_MAX_STEP) lambda = 0.5_wp*CD_HTORS_MAX_STEP/dth_lin END IF @@ -4035,6 +4177,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r DO iv = 1, SIZE(model%ws_qtrial) model%ws_qtrial(iv) = model%ws_qk(iv) + lambda*model%ws_dq(iv) END DO + IF (model%tw_active) CALL tw_trial(lambda) CALL eval_res(model%ws_qtrial, .TRUE., rnt, es, em2) IF (es == CD_HCDYN_OK) THEN lam_ok = lambda ! loop shrinks lambda, so this ends smallest @@ -4127,6 +4270,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r DO iv = 1, SIZE(model%ws_qtrial) model%ws_qtrial(iv) = model%ws_qk(iv) + lambda*model%ws_dq(iv) END DO + IF (model%tw_active) CALL tw_trial(lambda) CALL eval_res(model%ws_qtrial, .TRUE., rnt, es, em2) IF (es == CD_HCDYN_OK) THEN ! The fallback step rarely improves the residual, so under modified Newton the @@ -4181,6 +4325,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r DO iv = 1, SIZE(model%ws_Rk) model%ws_Rk(iv) = model%ws_Rt(iv) END DO + IF (model%tw_active) CALL tw_accept() rnorm = rnt END DO EXIT predict @@ -4198,19 +4343,27 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r IF (.NOT. model%solve_mask(i)) model%ws_dq(i) = CD_ZERO END DO IF (prof_enabled) CALL SYSTEM_CLOCK(pc0) - CALL CD_Solve_Factored_Banded(model%ws_Keffb, KL_D, KU_D, model%ws_ipiv, model%ws_dq, es, em2, & - factor_validated=.TRUE.) + IF (model%tw_active) THEN + DO i = 1, model%nn + model%tw_dp(i) = MERGE(-model%tw_G(i), CD_ZERO, model%tw_free(i)) + END DO + CALL tw_solve(model, es, em2) + ELSE + CALL CD_Solve_Factored_Banded(model%ws_Keffb, KL_D, KU_D, model%ws_ipiv, model%ws_dq, es, em2, & + factor_validated=.TRUE.) + END IF IF (prof_enabled) THEN CALL SYSTEM_CLOCK(pc1) prof_n_correct = prof_n_correct + 1 prof_t_solve = prof_t_solve + REAL(pc1 - pc0, wp)/REAL(pcr, wp) END IF IF (es == CD_LINALG_OK) THEN - IF (model%torsion%active) CALL torsion_sm_correct() + IF (model%torsion%active .AND. .NOT. model%tw_active) CALL torsion_sm_correct() CALL transform_rigid_vector_to_global(model, step_rigid_basis, model%ws_dq) DO iv = 1, SIZE(model%ws_qtrial) model%ws_qtrial(iv) = model%ws_qk(iv) + model%ws_dq(iv) END DO + IF (model%tw_active) CALL tw_trial(CD_ONE) CALL eval_res(model%ws_qtrial, .TRUE., rnt, es, em2) IF (es == CD_HCDYN_OK .AND. rnt < rnorm) THEN DO iv = 1, SIZE(model%ws_qk) @@ -4222,6 +4375,7 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r DO iv = 1, SIZE(model%ws_Rk) model%ws_Rk(iv) = model%ws_Rt(iv) END DO + IF (model%tw_active) CALL tw_accept() rnorm = rnt IF (PRESENT(res_out)) res_out = rnorm ELSE @@ -4240,7 +4394,15 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r ! audit under torque-tension coupling. tors_theta_new = model%torsion%theta tors_mt_new = CD_ZERO - IF (model%torsion%active) THEN + IF (model%tw_active) THEN + ! nodal twist: the reference state at q_{n+1}, and Theta_eff = Phi less the summed twist + ! of the converged evaluation, whose element torques (tw_me) enter the audit + CALL tw_advance_reference(model, model%ws_qk, model%tors_step_ends, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_Step: '//TRIM(em2); RETURN + END IF + tors_theta_new = model%tors_step_phi - model%tw_tsum + ELSE 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 @@ -4380,6 +4542,20 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r IF (model%has_viv) CALL viv_step_end(model, dt) model%t = model%t + dt IF (has_endconn_motion) model%endconn_d0 = step_endconn_target + IF (model%tw_active) THEN + DO iv = 1, model%nn + model%tw_ak(iv) = c_a*(model%tw_pk(iv) - model%tw_pn(iv)) - c_v*model%tw_wn(iv) - c_a2*model%tw_an(iv) + model%tw_phi(iv) = model%tw_pk(iv) + model%tw_al(iv) = model%tw_ak(iv) + model%tw_w(iv) = model%tw_wn(iv) + dt*((CD_ONE - gm)*model%tw_an(iv) + gm*model%tw_ak(iv)) + END DO + CALL tw_commit_reference(model) + model%tw_oal = (model%tw_som - model%tw_om)/dt + model%tw_om = model%tw_som + DO iv = 1, model%ne + model%tw_mt(iv) = model%tw_me(iv) + END DO + END IF IF (model%torsion%active) THEN model%torsion%ends = model%tors_step_ends model%torsion%phi = model%tors_step_phi @@ -4387,12 +4563,15 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r model%torsion%torque = (model%torsion%phi - tors_theta_new)/ & CD_HermiteTorsion_Compliance(model%torsion, model%l0) ! the read-only queries of the committed state (end loads, energy, channels) from the - ! cache; a failure here only leaves it invalid (a query then evaluates and reports it) - BLOCK - INTEGER :: es_tc - CHARACTER(1024) :: em_tc - CALL torsion_cache_fill(model, es_tc, em_tc) - END BLOCK + ! cache; a failure here only leaves it invalid (a query then evaluates and reports it). + ! The nodal twist answers its queries from its own committed state. + IF (.NOT. model%tw_active) THEN + BLOCK + INTEGER :: es_tc + CHARACTER(1024) :: em_tc + CALL torsion_cache_fill(model, es_tc, em_tc) + END BLOCK + END IF END IF ! Carry the factor of this step's last iteration to the next step. model%tr_valid = model%tangent_reuse .AND. factor_ok @@ -4417,6 +4596,11 @@ SUBROUTINE dyn_step_core(model, dt, max_iter, tol, ErrStat, ErrMsg, iters_out, r DO iv = 1, SIZE(model%fc_R) model%fc_R(iv) = model%ws_Rk(iv) END DO + IF (model%tw_active) THEN + DO iv = 1, model%nn + model%tw_fcR(iv) = model%tw_Rk(iv) + END DO + END IF model%fc_q = model%q model%fc_v = model%v model%fc_t = model%t @@ -4462,12 +4646,17 @@ SUBROUTINE window_load(slot, e) 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. + !! The torque-tension coupling force (K/GJ) M_t of element e at the converged torque (the + !! nodal twist's own element torque, else the condensed uniform one). 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 + IF (model%tw_active) THEN + tc = model%torsion%couple(e)*model%tw_me(e) + ELSE + tc = model%torsion%couple(e)*tors_mt_new + END IF END FUNCTION audit_coupling SUBROUTINE window_mean(slot, esx) @@ -4537,7 +4726,7 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) REAL(wp), POINTER :: Gout(:) INTEGER :: ii, nd INTEGER(INT64) :: ec0, ec1 - REAL(wp) :: xref + REAL(wp) :: xref, xd REAL(wp), PARAMETER :: RESID_ROUNDOFF = 16.0_wp REAL(wp), PARAMETER :: STATE_DIVERGED = 1.0e12_wp ec0 = 0_INT64 ! defined even with profiling off (see the step-entry note) @@ -4590,6 +4779,7 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) END DO END IF IF (has_endconn_motion) CALL impose_step_rigid_kinematics(qcur, model%ws_vk, model%ws_ak) + IF (model%tw_active) CALL tw_stage(use_trial) ! Force blend: the configuration the force (and the loop-top tangent) is evaluated at is ! the iterate itself; only the inertia uses the alpha_m blend. Configuration blend: the ! forces are evaluated at the alpha_f-blended state. @@ -4616,6 +4806,7 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) ELSE CALL vector_copy(model%ws_R, model%ws_Rk) END IF + IF (model%tw_active) CALL tw_residual(use_trial) ! total (structural + frozen added) mass inertia via the band matvec CALL band_matvec(model%ws_Msumb, model%ws_aa, model%ws_inert) IF (model%force_blend) THEN @@ -4655,6 +4846,25 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) IF (MOD(ii - 1, 6) < 3) xref = MAX(xref, ABS(qcur(ii))) END DO fscale = MAX(fscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*MAXVAL(model%EA/model%l0)*xref/tol) + ! Nodal twist: the torque scale of the angle rows, frozen with fscale and formed like it + ! from the nodal loads (a node's torque imbalance, not the torque the line carries, + ! which accumulates the imbalances along the line as the tension does the force's): the + ! inertial torques and the predictor's imbalance, at least 1 N m, and the round-off + ! floor of an element twist, (GJ/l0 + Bt/l0 gamma/(beta dt)) eps (max|phi| + max|x|/l0) + ! (the damping takes the twist rate, whose Newmark rate amplifies the rounding). + IF (model%tw_active) THEN + model%tw_tscale = CD_ONE + DO ii = 1, model%nn + IF (.NOT. model%tw_free(ii)) CYCLE + model%tw_tscale = MAX(model%tw_tscale, & + ABS(model%tw_mass(ii)*((CD_ONE - am)*model%tw_ak(ii) + am*model%tw_an(ii))), & + ABS(model%tw_R(ii))) + END DO + xd = MAXVAL(model%torsion%gj/model%l0) + IF (ALLOCATED(model%torsion%bt)) xd = xd + MAXVAL(model%torsion%bt/model%l0)*gm/(bt*dt) + model%tw_tscale = MAX(model%tw_tscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*xd* & + (MAX(CD_ONE, MAXVAL(ABS(model%tw_pe))) + xref/MINVAL(model%l0))/tol) + END IF scale_set = .TRUE. END IF rn = CD_ZERO @@ -4667,6 +4877,16 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) rn = MAX(rn, ABS(Gout(ii))/fscale) END IF END DO + IF (model%tw_active) THEN + DO ii = 1, model%nn + IF (.NOT. model%tw_free(ii)) CYCLE + IF (use_trial) THEN + rn = MAX(rn, ABS(model%tw_Gt(ii))/model%tw_tscale) + ELSE + rn = MAX(rn, ABS(model%tw_G(ii))/model%tw_tscale) + END IF + END DO + END IF IF (.NOT. CD_Is_Finite(rn)) THEN esx = CD_HCDYN_NOCONVERGE; emx = 'non-finite residual' END IF @@ -4786,6 +5006,65 @@ SUBROUTINE torsion_sm_correct() END DO END SUBROUTINE torsion_sm_correct + SUBROUTINE tw_stage(use_trial) + !! Nodal twist: the Newmark rates and accelerations of the iterate's (or the trial's) + !! angles, staged in tw_pe/tw_we for the assembly. + LOGICAL, INTENT(IN) :: use_trial + INTEGER :: ii + REAL(wp) :: p + DO ii = 1, model%nn + IF (use_trial) THEN + p = model%tw_ptrial(ii) + ELSE + p = model%tw_pk(ii) + END IF + model%tw_ak(ii) = c_a*(p - model%tw_pn(ii)) - c_v*model%tw_wn(ii) - c_a2*model%tw_an(ii) + model%tw_wk(ii) = model%tw_wn(ii) + dt*((CD_ONE - gm)*model%tw_an(ii) + gm*model%tw_ak(ii)) + model%tw_pe(ii) = p + model%tw_we(ii) = model%tw_wk(ii) + END DO + END SUBROUTINE tw_stage + + SUBROUTINE tw_residual(use_trial) + !! Nodal twist: the angle rows of the generalised-alpha residual, I ((1 - am) a_{n+1} + + !! am a_n) + (1 - af) R_phi(n+1) + af R_phi(n) (zero at a held angle), and the + !! unblended R_phi of the evaluation. + LOGICAL, INTENT(IN) :: use_trial + INTEGER :: ii + REAL(wp) :: gv + DO ii = 1, model%nn + gv = CD_ZERO + IF (model%tw_free(ii)) gv = model%tw_mass(ii)*((CD_ONE - am)*model%tw_ak(ii) + am*model%tw_an(ii)) + & + (CD_ONE - af)*model%tw_R(ii) + af*model%tw_fcR(ii) + IF (use_trial) THEN + model%tw_Gt(ii) = gv + model%tw_Rt(ii) = model%tw_R(ii) + ELSE + model%tw_G(ii) = gv + model%tw_Rk(ii) = model%tw_R(ii) + END IF + END DO + END SUBROUTINE tw_residual + + SUBROUTINE tw_trial(lam) + !! Nodal twist: the line-search trial angles tw_pk + lam tw_dp. + REAL(wp), INTENT(IN) :: lam + INTEGER :: ii + DO ii = 1, model%nn + model%tw_ptrial(ii) = model%tw_pk(ii) + lam*model%tw_dp(ii) + END DO + END SUBROUTINE tw_trial + + SUBROUTINE tw_accept() + !! Nodal twist: the accepted trial becomes the iterate. + INTEGER :: ii + DO ii = 1, model%nn + model%tw_pk(ii) = model%tw_ptrial(ii) + model%tw_G(ii) = model%tw_Gt(ii) + model%tw_Rk(ii) = model%tw_Rt(ii) + END DO + END SUBROUTINE tw_accept + END SUBROUTINE dyn_step_core SUBROUTINE torsion_theta_at(model, q_cfg, ends, theta, ErrStat, ErrMsg) @@ -4992,6 +5271,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat tors_theta0 = model%torsion%theta tors_phi0 = model%torsion%phi tors_ends0 = model%torsion%ends + IF (model%tw_active) CALL tw_pack(model, model%ws_recovery_tw) tors_phi1 = tors_phi0 tors_ends1 = tors_ends0 IF (model%torsion%active .AND. model%tors_drive_set) THEN @@ -5236,6 +5516,7 @@ SUBROUTINE restore_torsion() model%torsion%theta = tors_theta0 model%torsion%phi = tors_phi0 model%torsion%ends = tors_ends0 + IF (model%tw_active) CALL tw_unpack(model, model%ws_recovery_tw) model%torsion%torque = (tors_phi0 - tors_theta0)/CD_HermiteTorsion_Compliance(model%torsion, model%l0) model%tors_drive_set = .FALSE. END SUBROUTINE restore_torsion @@ -5487,7 +5768,51 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c END IF strain = strain + connection_energy END IF - IF (model%torsion%active) THEN + IF (model%tw_active) THEN + ! nodal twist: the element and end-spring energies and the polar kinetic energy, a held + ! end section's spin chi_dot = -+drho/dw . omega + phi_dot (End 1, End 2) as in its + ! reaction (CD_HermiteCable_Dyn_EndConnection_Moment) + BLOCK + REAL(wp) :: rho, beta, g(12), h(12, 12), tau, psi, gl(3), hl(3, 3), tw, ew(3, 2), ewe(3, 2), spin(2) + INTEGER :: iend + ew = CD_ZERO + DO e = 1, model%ne + IF (e == 1 .OR. e == model%ne) THEN + CALL twist_reference(model, e, model%q, model%torsion%ends, .FALSE., rho, beta, g, h, ErrStat, em2, & + end_w=ewe) + IF (e == 1) ew(:, 1) = ewe(:, 1) + IF (e == model%ne) ew(:, 2) = ewe(:, 2) + ELSE + CALL twist_reference(model, e, model%q, model%torsion%ends, .FALSE., rho, beta, g, h, ErrStat, em2) + END IF + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Energy: '//TRIM(em2) + RETURN + END IF + tau = model%tw_phi(e + 1) - model%tw_phi(e) + rho + strain = strain + 0.5_wp*model%torsion%gj(e)/model%l0(e)*tau*tau + END DO + DO iend = 1, 2 + IF (model%tw_rigid(iend)) CYCLE + CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, ErrStat, em2) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Energy: '//TRIM(em2) + RETURN + END IF + IF (iend == 1) THEN + tw = model%tw_phi(1) - psi + ELSE + tw = psi + model%torsion%phi - model%tw_phi(model%nn) + END IF + strain = strain + 0.5_wp*tw*tw/model%torsion%end_compliance(iend) + END DO + spin = [model%tw_w(1), model%tw_w(model%nn)] + IF (model%tw_rigid(1)) spin(1) = spin(1) - DOT_PRODUCT(ew(:, 1), model%tw_om(:, 1)) + IF (model%tw_rigid(2)) spin(2) = spin(2) + DOT_PRODUCT(ew(:, 2), model%tw_om(:, 2)) + kinetic = kinetic + 0.5_wp*SUM(model%tw_mass(2:model%nn - 1)*model%tw_w(2:model%nn - 1)**2) & + + 0.5_wp*(model%tw_mass(1)*spin(1)**2 + model%tw_mass(model%nn)*spin(2)**2) + END BLOCK + ELSE IF (model%torsion%active) THEN BLOCK REAL(wp) :: th, mt CALL CD_HermiteCable_Dyn_Torsion_State(model, th, mt, ErrStat, em2) @@ -5650,6 +5975,20 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: the section reference lies along the End A tangent'; RETURN END IF d1 = d1/rn + IF (model%tw_active) THEN + ! Nodal twist: the material director Rot(t_k, phi - Phi) u of every node (t_k the solve + ! tangent, End 1 -> End 2), on the frame convention above: End A (node nn) takes the + ! reference normal turned by the End A spring twist only. + DO a = 1, model%nn + t = -unit_tangent(model, a) + phi = model%tw_phi(a) - model%torsion%phi + d = COS(phi)*model%tw_u(:, a) - SIN(phi)*cross3_local(t, model%tw_u(:, a)) + IF (PRESENT(frame)) frame(:, a) = d + kx(a) = DOT_PRODUCT(kvec(:, a), d) + ky(a) = DOT_PRODUCT(kvec(:, a), cross3_local(t, d)) + END DO + RETURN + END IF mt = CD_ZERO comp = CD_ZERO IF (model%torsion%active) THEN @@ -5999,8 +6338,18 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Force(model, node, force, ErrStat, ErrMsg) END DO END IF force = -r3 - ! Condensed torsion: R carries -M_t dTheta/dq, so the end force gains +M_t dTheta/dr_end. - IF (model%torsion%active) THEN + ! Nodal twist: R carries M_e drho_e/dq of the end element (the committed torque M_e). + IF (model%tw_active) THEN + BLOCK + REAL(wp) :: rho, beta, g(12), h(12, 12) + CALL twist_reference(model, e, model%q, model%torsion%ends, .FALSE., rho, beta, g, h, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = 'CD_HermiteCable_Dyn_End_Force: '//TRIM(em2); RETURN + END IF + force = force - model%tw_mt(e)*g(i0 + 1:i0 + 3) + END BLOCK + ! Condensed torsion: R carries -M_t dTheta/dq, so the end force gains +M_t dTheta/dr_end. + ELSE IF (model%torsion%active) THEN BLOCK REAL(wp) :: th, mt, gend(3, 2) CALL CD_HermiteCable_Dyn_Torsion_State(model, th, mt, es, em2, end_dr=gend) @@ -6235,7 +6584,11 @@ PURE REAL(wp) FUNCTION coupling_tension(model, e) RESULT(tc) 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 + IF (model%tw_active) THEN + tc = model%torsion%couple(e)*model%tw_mt(e) + ELSE + tc = model%torsion%couple(e)*model%torsion%torque + END IF END FUNCTION coupling_tension PURE REAL(wp) FUNCTION CD_HermiteCable_Dyn_Coupling_Tension(model, e) RESULT(tc) @@ -6280,6 +6633,25 @@ SUBROUTINE CD_HermiteCable_Dyn_Element_Twist(model, twist, ErrStat, ErrMsg) ErrMsg = 'CD_HermiteCable_Dyn_Element_Twist: twist must have one entry per element'; RETURN END IF IF (.NOT. model%torsion%active) RETURN + IF (model%tw_active) THEN + ! nodal twist: phi_{e+1} - phi_e + beta_e - h_e at the committed state + BLOCK + REAL(wp) :: rho, beta, g(12), h(12, 12), qe(12), ls + DO e = 1, model%ne + CALL twist_reference(model, e, model%q, model%torsion%ends, .FALSE., rho, beta, g, h, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + twist(e) = model%tw_phi(e + 1) - model%tw_phi(e) + rho + IF (ALLOCATED(model%torsion%couple)) THEN + IF (ABS(model%torsion%couple(e)) > CD_ZERO) THEN + CALL gather_elem(model, e, qe) + ls = CD_HermiteTorsion_Element_Stretch(qe, model%l0(e), model%torsion%quadrature_order) + twist(e) = twist(e) - model%torsion%couple(e)*(ls - model%l0(e)) + END IF + END IF + END DO + END BLOCK + RETURN + END IF CALL CD_HermiteCable_Dyn_Torsion_State(model, th, mt, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) RETURN DO e = 1, model%ne @@ -6287,6 +6659,182 @@ SUBROUTINE CD_HermiteCable_Dyn_Element_Twist(model, twist, ErrStat, ErrMsg) END DO END SUBROUTINE CD_HermiteCable_Dyn_Element_Twist + SUBROUTINE CD_HermiteCable_Dyn_Element_Torque(model, torque, ErrStat, ErrMsg) + !! The torque of every element at the committed state [N m], positive for a right-handed + !! twist about the solve tangent (End 1 -> End 2): with the nodal twist the element torques + !! (elastic plus torsional damping), with the condensed torsion the uniform torque, and zero + !! for a line without torsion. Element order is the model's (End B first). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: torque(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + torque = CD_ZERO + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (SIZE(torque) /= model%ne) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Element_Torque: torque must have one entry per element'; RETURN + END IF + IF (.NOT. model%torsion%active) RETURN + IF (model%tw_active) THEN + torque = model%tw_mt + ELSE + torque = model%torsion%torque + END IF + END SUBROUTINE CD_HermiteCable_Dyn_Element_Torque + + SUBROUTINE CD_HermiteCable_Dyn_Node_Torque(model, torque, ErrStat, ErrMsg) + !! The torque at every node at the committed state [N m] (the TorqN channels): an end + !! node takes its element's torque and an interior node the mean of its two elements' (the + !! uniform torque of the condensed torsion everywhere; zero without torsion). Node order is + !! the model's (End B first). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: torque(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: k + torque = CD_ZERO + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (SIZE(torque) /= model%nn) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Node_Torque: torque must have one entry per node'; RETURN + END IF + IF (.NOT. model%torsion%active) RETURN + IF (.NOT. model%tw_active) THEN + torque = model%torsion%torque + RETURN + END IF + torque(1) = model%tw_mt(1) + torque(model%nn) = model%tw_mt(model%ne) + DO k = 2, model%nn - 1 + torque(k) = 0.5_wp*(model%tw_mt(k - 1) + model%tw_mt(k)) + END DO + END SUBROUTINE CD_HermiteCable_Dyn_Node_Torque + + SUBROUTINE CD_HermiteCable_Dyn_End_Twist(model, twist, ErrStat, ErrMsg) + !! The twist of the two torsional end springs at the committed state [rad] (internal ends 1 + !! and 2; zero at a rigid end): with the nodal twist the end node's against its end frame, + !! with the condensed torsion the torque times the end compliance. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: twist(2) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: psi, gl(3), hl(3, 3) + INTEGER :: iend + twist = CD_ZERO + ErrStat = CD_HCDYN_OK; ErrMsg = '' + IF (.NOT. model%torsion%active) RETURN + IF (.NOT. model%tw_active) THEN + twist = model%torsion%torque*model%torsion%end_compliance + RETURN + END IF + DO iend = 1, 2 + IF (model%tw_rigid(iend)) CYCLE + CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_End_Twist: '//TRIM(ErrMsg) + RETURN + END IF + IF (iend == 1) THEN + twist(1) = model%tw_phi(1) - psi + ELSE + twist(2) = psi + model%torsion%phi - model%tw_phi(model%nn) + END IF + END DO + END SUBROUTINE CD_HermiteCable_Dyn_End_Twist + + SUBROUTINE CD_HermiteCable_Dyn_Twist_Check(model, q_check, ends, ErrStat, ErrMsg) + !! Read-only check that the nodal twist accepts the configuration q_check with the end + !! frames ends (a host about to write them): every element's reference twist and every + !! elastic end's spring evaluate (fold guard, an end frame within pi/2 of its committed + !! turn). Without the nodal twist it accepts. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: q_check(:), ends(3, 4) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: rho, beta, g(12), h(12, 12), psi, gl(3), hl(3, 3) + INTEGER :: e, iend + ErrStat = CD_HCDYN_OK + ErrMsg = '' + IF (.NOT. model%tw_active) RETURN + IF (SIZE(q_check) /= model%ndof) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Check: q_check must have ndof entries'; RETURN + END IF + DO e = 1, model%ne + CALL twist_reference(model, e, q_check, ends, .FALSE., rho, beta, g, h, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Check: '//TRIM(ErrMsg); RETURN + END IF + END DO + DO iend = 1, 2 + IF (model%tw_rigid(iend)) CYCLE + CALL twist_link(model, iend, q_check, ends, .FALSE., psi, gl, hl, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Check: '//TRIM(ErrMsg); RETURN + END IF + END DO + END SUBROUTINE CD_HermiteCable_Dyn_Twist_Check + + PURE INTEGER FUNCTION CD_HermiteCable_Dyn_Twist_Mirror_Size(model) RESULT(n) + !! Reals of the nodal-twist checkpoint mirror (CD_HermiteCable_Dyn_Twist_Pack): the + !! committed angles, rates and accelerations, directors, reference tangents, reference + !! twists, element torques, end-frame references and rates, and the force cache's angle + !! part; 0 without the nodal twist. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + n = 0 + IF (model%tw_active) n = tw_pack_size(model) + model%nn + END FUNCTION CD_HermiteCable_Dyn_Twist_Mirror_Size + + SUBROUTINE CD_HermiteCable_Dyn_Twist_Pack(model, buf) + !! Write the nodal-twist checkpoint mirror (CD_HermiteCable_Dyn_Twist_Mirror_Size reals). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: buf(:) + INTEGER :: n + IF (.NOT. model%tw_active) RETURN + n = tw_pack_size(model) + CALL tw_pack(model, buf(1:n)) + buf(n + 1:n + model%nn) = model%tw_fcR + END SUBROUTINE CD_HermiteCable_Dyn_Twist_Pack + + SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack(model, buf, ErrStat, ErrMsg, check_only) + !! Reload the nodal twist from a mirror of CD_HermiteCable_Dyn_Twist_Pack written by a + !! model built from the same input (the caller restores q, v, a and the force cache with + !! it). Fails closed on a size mismatch, a non-finite value or a non-unit director; with + !! check_only it only checks. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: buf(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: check_only + INTEGER :: n, i + ErrStat = CD_HCDYN_BADINPUT + IF (.NOT. model%tw_active) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Unpack: the model has no nodal twist'; RETURN + END IF + n = tw_pack_size(model) + IF (SIZE(buf) /= n + model%nn) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Unpack: the mirror does not match this line'; RETURN + END IF + IF (.NOT. CD_All_Finite(buf)) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Unpack: non-finite twist state'; RETURN + END IF + DO i = 1, model%nn + IF (ABS(NORM2(buf(3*model%nn + 3*i - 2:3*model%nn + 3*i)) - CD_ONE) > 1.0e-8_wp .OR. & + ABS(NORM2(buf(6*model%nn + 3*i - 2:6*model%nn + 3*i)) - CD_ONE) > 1.0e-8_wp) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Unpack: a director or reference tangent is not a unit vector'; RETURN + END IF + END DO + ErrStat = CD_HCDYN_OK + ErrMsg = '' + IF (PRESENT(check_only)) THEN + IF (check_only) RETURN + END IF + CALL tw_unpack(model, buf(1:n)) + model%tw_fcR = buf(n + 1:n + model%nn) + ErrStat = CD_HCDYN_OK + ErrMsg = '' + END SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack + 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 @@ -6759,7 +7307,47 @@ SUBROUTINE CD_HermiteCable_Dyn_EndConnection_Moment(model, node, moment, ErrStat ErrMsg = 'CD_HermiteCable_Dyn_EndConnection_Moment: node must be a cable endpoint' RETURN END IF - IF (model%torsion%active) THEN + IF (model%tw_active) THEN + ! Nodal twist: -dE/dw of the end frame. A rigid end's element twists by rho(w) through + ! the frame (its normal carried to the end node is the node's director): -M_e drho/dw. An + ! elastic end's spring twists by -+psi(w): +-k tw dpsi/dw. With f(w) = angle(G(d' -> x) n' + ! -> u) of the frame turned by exp(w), G(d' -> x) n' = Rot(x, w . d + Omega(d, d', x)) + ! G(d -> x) n to first order, so df/dw = -d - d x dOmega/dy(d, d, x), and the frame's + ! director in a transport triangle adds d x dOmega/dd. The slaved tangent of a rigid + ! bending end adds its share through the constraint reaction below. The held end section + ! turns with the frame and its held angle, chi_dot = -+drho/dw . omega + phi_dot (End 1, + ! End 2): its polar inertia I adds -I chi_ddot dchi/dw. + BLOCK + REAL(wp) :: rho, beta, g(12), h(12, 12), ew(3, 2), psi, gl(3), hl(3, 3), lw(3), tw, sg, chi_dd + IF (model%tw_rigid(iend)) THEN + CALL twist_reference(model, MERGE(1, model%ne, iend == 1), model%q, model%torsion%ends, .FALSE., rho, & + beta, g, h, es, em, end_w=ew) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es + ErrMsg = 'CD_HermiteCable_Dyn_EndConnection_Moment: '//TRIM(em) + RETURN + END IF + moment = -model%tw_mt(MERGE(1, model%ne, iend == 1))*ew(:, iend) + sg = MERGE(-CD_ONE, CD_ONE, iend == 1) + chi_dd = sg*DOT_PRODUCT(ew(:, iend), model%tw_oal(:, iend)) + model%tw_al(node) + moment = moment - model%tw_mass(node)*chi_dd*sg*ew(:, iend) + ELSE + CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, es, em, end_w=lw) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es + ErrMsg = 'CD_HermiteCable_Dyn_EndConnection_Moment: '//TRIM(em) + RETURN + END IF + IF (iend == 1) THEN + tw = model%tw_phi(1) - psi + moment = tw/model%torsion%end_compliance(1)*lw + ELSE + tw = psi + model%torsion%phi - model%tw_phi(model%nn) + moment = -tw/model%torsion%end_compliance(2)*lw + END IF + END IF + END BLOCK + ELSE IF (model%torsion%active) THEN ! Torque of the condensed torsion on the support: the generalised moment ! -dE_t/dw = M_t dTheta/dw of the end frame (its axial part is -+M_t d); the slaved ! tangent of a rigid end adds its share through the constraint reaction below. @@ -6845,7 +7433,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) !! the torsion. The time step then carries the torsion (see CD_HermiteCable_Dyn_Step); its !! scratch is sized here, so a step allocates nothing. Like a new end connection, a change !! of the load set invalidates the step snapshot (CD_HermiteCable_Dyn_Restore then fails - !! closed); a failed call leaves the model, its snapshot included, as it was. + !! closed); a failed call leaves the model, its snapshot included, as it was. A description + !! with the polar inertia irn installs the nodal twist instead of the condensed torsion in + !! the dynamics (tw_init): the static uniform torque sets the angles, which then carry the + !! torsional inertia and the damping bt. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model TYPE(CD_HermiteTorsionType), INTENT(IN) :: torsion INTEGER, INTENT(OUT) :: ErrStat @@ -6854,7 +7445,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) REAL(wp) :: th, mt REAL(wp) :: saved_step_ends(3, 4), saved_step_phi, saved_snap_theta, saved_snap_phi, saved_snap_ends(3, 4) REAL(wp) :: saved_drive_ends(3, 4), saved_drive_phi - LOGICAL :: saved_snap_valid, saved_drive_set + LOGICAL :: saved_snap_valid, saved_drive_set, saved_tw_active + REAL(wp), ALLOCATABLE :: saved_tw(:) INTEGER :: es, iend CHARACTER(1024) :: em ErrStat = CD_HCDYN_OK @@ -6865,8 +7457,14 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) RETURN END IF saved = model%torsion + saved_tw_active = model%tw_active + IF (saved_tw_active) THEN + ALLOCATE (saved_tw(tw_pack_size(model))) + CALL tw_pack(model, saved_tw) + END IF model%tors_c_valid = .FALSE. IF (.NOT. torsion%active) THEN + model%tw_active = .FALSE. model%torsion = CD_HermiteTorsionType() ELSE CALL CD_HermiteTorsion_Validate(torsion, model%l0, es, em) @@ -6908,10 +7506,12 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) model%tors_gk = CD_ZERO model%tors_zk = CD_ZERO model%tors_den = CD_ONE + model%tw_active = .FALSE. model%torsion = torsion model%tors_c_valid = .FALSE. CALL CD_HermiteCable_Dyn_Torsion_State(model, th, mt, es, em) IF (es /= CD_HCDYN_OK) THEN + CALL restore_twist() model%torsion = saved ErrStat = es ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion: '//TRIM(em) @@ -6919,6 +7519,17 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) END IF model%torsion%theta = th model%torsion%torque = mt + ! nodal twist dynamics when the torsion carries the polar rotary inertia + IF (ALLOCATED(torsion%irn)) THEN + CALL tw_init(model, mt, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL restore_twist() + model%torsion = saved + ErrStat = es + ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion: '//TRIM(em) + RETURN + END IF + END IF END IF saved_step_ends = model%tors_step_ends saved_step_phi = model%tors_step_phi @@ -6943,6 +7554,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) model%tr_valid = .FALSE. CALL CD_HermiteCable_Dyn_Recompute_Acceleration(model, es, em) IF (es /= CD_HCDYN_OK) THEN + CALL restore_twist() model%torsion = saved model%tors_c_valid = .FALSE. model%tors_step_ends = saved_step_ends @@ -6957,6 +7569,17 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) ErrStat = es ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion: '//TRIM(em) END IF + + CONTAINS + + SUBROUTINE restore_twist() + !! The nodal twist as it was before the call (with the torsion description restored + !! after it, from which the derived rigid ends, held angles and inertia follow). + model%tw_active = saved_tw_active + IF (.NOT. saved_tw_active) RETURN + CALL tw_unpack(model, saved_tw) + CALL tw_set_derived(model, saved) + END SUBROUTINE restore_twist END SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion SUBROUTINE CD_HermiteCable_Dyn_Torsion_State(model, theta, torque, ErrStat, ErrMsg, grad, end_grad, q_eval, & @@ -6986,6 +7609,14 @@ SUBROUTINE CD_HermiteCable_Dyn_Torsion_State(model, theta, torque, ErrStat, ErrM ErrStat = CD_HCDYN_OK ErrMsg = '' IF (.NOT. model%torsion%active) RETURN + ! Nodal twist: the committed Theta_eff and mean torque (the condensed kernel answers the + ! derivative queries, the quasi-static stiffness a static caller takes) + IF (model%tw_active .AND. .NOT. (PRESENT(grad) .OR. PRESENT(end_grad) .OR. PRESENT(q_eval) .OR. & + PRESENT(end_dr))) THEN + theta = model%torsion%theta + torque = model%torsion%torque + RETURN + END IF IF (.NOT. (PRESENT(grad) .OR. PRESENT(q_eval))) THEN IF (torsion_cache_matches(model)) THEN theta = model%tors_c_theta @@ -7131,6 +7762,11 @@ SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) model%snap_torsion_theta = model%torsion%theta model%snap_torsion_phi = model%torsion%phi model%snap_torsion_ends = model%torsion%ends + IF (model%tw_active) THEN + IF (.NOT. ALLOCATED(model%snap_tw)) ALLOCATE (model%snap_tw(tw_pack_size(model)), model%snap_tw_fcR(model%nn)) + CALL tw_pack(model, model%snap_tw) + model%snap_tw_fcR = model%tw_fcR + END IF IF (model%fr_active) model%snap_fr_anchor = model%fr_anchor IF (model%has_viv) THEN model%snap_viv_phi = model%viv_phi @@ -7212,6 +7848,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) CD_HermiteTorsion_Compliance(model%torsion, model%l0) model%tors_drive_set = .FALSE. model%tors_use_step = .FALSE. + IF (model%tw_active) CALL tw_unpack(model, model%snap_tw) IF (model%fr_active) model%fr_anchor = model%snap_fr_anchor IF (model%has_viv) THEN model%viv_phi = model%snap_viv_phi; model%viv_ms = model%snap_viv_ms @@ -7234,6 +7871,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) ! the snapshot (the cache differs from a fresh evaluation in the last bits where a ! friction anchor slid). Otherwise the next step evaluates it afresh. IF (model%snap_fc_valid .AND. model%snap_fc_clears == model%fc_clears) THEN + IF (model%tw_active) model%tw_fcR = model%snap_tw_fcR model%fc_R = model%snap_fc_R model%fc_q = model%snap_fc_q model%fc_v = model%snap_fc_v @@ -7354,6 +7992,17 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) model%snap_torsion_theta = CD_ZERO model%snap_torsion_phi = CD_ZERO model%snap_torsion_ends = CD_ZERO + CALL tw_release(model) + model%tw_rigid = .FALSE. + model%tw_psi = CD_ZERO + model%tw_lg = CD_ZERO + model%tw_lk = CD_ZERO + model%tw_tsum = CD_ZERO + model%tw_spsi = CD_ZERO + model%tw_som = CD_ZERO + model%tw_om = CD_ZERO + model%tw_oal = CD_ZERO + model%tw_tscale = CD_ONE model%snap_valid = .FALSE. model%require_tensile = .FALSE. model%tensile_mode = CD_HCDYN_TENSILE_OFF @@ -7913,8 +8562,14 @@ SUBROUTINE assemble_residual(model, q_cfg, v_cfg, t_eval, want_residual, want_ta CALL asm_mark(HC_ASM_HELD, asm_t) ! Condensed torsion: R <- R - M_t dTheta/dq and Kb <- Kb - M_t d2Theta/dq2 at q_cfg (the - ! rank-one g g^T / C joins the solve by Sherman-Morrison; g is kept in tors_g). - IF (model%torsion%active .AND. (want_residual .OR. want_tangent)) THEN + ! rank-one g g^T / C joins the solve by Sherman-Morrison; g is kept in tors_g). Nodal + ! twist: the element torques and end springs (assemble_twist). + IF (model%tw_active .AND. (want_residual .OR. want_tangent)) THEN + CALL assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, Kb, Kvb, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es; ErrMsg = TRIM(em2); RETURN + END IF + ELSE IF (model%torsion%active .AND. (want_residual .OR. want_tangent)) THEN CALL assemble_torsion(model, q_cfg, want_residual, want_tangent, es, em2) IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = TRIM(em2); RETURN @@ -7984,6 +8639,813 @@ SUBROUTINE assemble_torsion(model, q_cfg, want_residual, want_tangent, ErrStat, END IF END SUBROUTINE assemble_torsion + ! ------------------------------------------------------------------------------------------ + ! nodal twist (see the type note) + ! ------------------------------------------------------------------------------------------ + + PURE INTEGER FUNCTION tw_pack_size(model) RESULT(n) + !! Reals of the packed twist state of tw_pack: the angles, rates and accelerations, the + !! directors and unit tangents, the reference twists, the element torques, the two + !! end-frame references and the end frames' angular velocities and accelerations of the + !! committed step. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + n = 9*model%nn + 2*model%ne + 14 + END FUNCTION tw_pack_size + + PURE SUBROUTINE tw_pack(model, buf) + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: buf(:) + INTEGER :: nn, ne + nn = model%nn + ne = model%ne + buf(1:nn) = model%tw_phi + buf(nn + 1:2*nn) = model%tw_w + buf(2*nn + 1:3*nn) = model%tw_al + buf(3*nn + 1:6*nn) = RESHAPE(model%tw_u, [3*nn]) + buf(6*nn + 1:9*nn) = RESHAPE(model%tw_tn, [3*nn]) + buf(9*nn + 1:9*nn + ne) = model%tw_beta + buf(9*nn + ne + 1:9*nn + 2*ne) = model%tw_mt + buf(9*nn + 2*ne + 1:9*nn + 2*ne + 2) = model%tw_psi + buf(9*nn + 2*ne + 3:9*nn + 2*ne + 8) = RESHAPE(model%tw_om, [6]) + buf(9*nn + 2*ne + 9:9*nn + 2*ne + 14) = RESHAPE(model%tw_oal, [6]) + END SUBROUTINE tw_pack + + PURE SUBROUTINE tw_unpack(model, buf) + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: buf(:) + INTEGER :: nn, ne + nn = model%nn + ne = model%ne + model%tw_phi = buf(1:nn) + model%tw_w = buf(nn + 1:2*nn) + model%tw_al = buf(2*nn + 1:3*nn) + model%tw_u = RESHAPE(buf(3*nn + 1:6*nn), [3, nn]) + model%tw_tn = RESHAPE(buf(6*nn + 1:9*nn), [3, nn]) + model%tw_beta = buf(9*nn + 1:9*nn + ne) + model%tw_mt = buf(9*nn + ne + 1:9*nn + 2*ne) + model%tw_psi = buf(9*nn + 2*ne + 1:9*nn + 2*ne + 2) + model%tw_om = RESHAPE(buf(9*nn + 2*ne + 3:9*nn + 2*ne + 8), [3, 2]) + model%tw_oal = RESHAPE(buf(9*nn + 2*ne + 9:9*nn + 2*ne + 14), [3, 2]) + END SUBROUTINE tw_unpack + + ELEMENTAL REAL(wp) FUNCTION tw_wrap(x) RESULT(y) + !! x on (-pi, pi] (an angle change over one step; 0 stays exactly 0). + REAL(wp), INTENT(IN) :: x + y = x - 2.0_wp*CD_HTORS_PI*ANINT(x/(2.0_wp*CD_HTORS_PI)) + END FUNCTION tw_wrap + + PURE FUNCTION tw_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 tw_cross + + PURE SUBROUTINE tw_frames(model, ends, phi_end) + !! The end frames and Phi an evaluation takes: the running step's target, or the committed. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: ends(3, 4), phi_end + IF (model%tors_use_step) THEN + ends = model%tors_step_ends + phi_end = model%tors_step_phi + ELSE + ends = model%torsion%ends + phi_end = model%torsion%phi + END IF + END SUBROUTINE tw_frames + + SUBROUTINE twist_reference(model, e, q_cfg, ends, want_hess, rho, beta, g, h, ErrStat, ErrMsg, end_w) + !! rho_e(q) of element e (the material twist is phi_{e+1} - phi_e + rho_e less the coupling + !! term), its gradient g and, with want_hess, Hessian h over the element's 12 DOFs, at q_cfg + !! with the end frames ends. beta is the reference-twist part: the committed tw_beta(e) plus + !! the change of the end-frame constant and of the transport solid angles since the + !! committed state, each formed as a difference so that the committed state and frames give + !! tw_beta(e) bit for bit. Interior element: beta = beta^n - Omega(a, b, c) - Omega(a, c, d), + !! a, d the committed and b, c the present unit node tangents. An element at a rigid end + !! takes the end frame's normal carried to its end node as that node's director (see + !! CD_HermiteTwist_Reference). end_w(:, k), when asked for, is d rho/d w_k for an incremental + !! rotation w_k of the end frame k (zero unless the element reaches a rigid end). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + REAL(wp), INTENT(IN) :: q_cfg(:), ends(3, 4) + LOGICAL, INTENT(IN) :: want_hess + REAL(wp), INTENT(OUT) :: rho, beta, g(12), h(12, 12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: end_w(3, 2) + REAL(wp) :: qe(12), tri(3, 3, 2), sg(2), fg(3, 3, 2), z(3), a(3), d(3), val, oref, cnow, cref + REAL(wp) :: he, ge(12), hk(12, 12), ls, gs(12), hs(12, 12), om, g9(9), cpl + REAL(wp) :: dA(3), nA(3), dB(3), nB(3), dAc(3), nAc(3), dBc(3), nBc(3) + INTEGER :: slot(3, 2), owner(3, 2), kind, es, k, j + CHARACTER(200) :: em + + rho = CD_ZERO + beta = CD_ZERO + g = CD_ZERO + h = CD_ZERO + IF (PRESENT(end_w)) end_w = CD_ZERO + ErrStat = CD_HCDYN_OK + ErrMsg = '' + qe = q_cfg(6*e - 5:6*e + 6) + a = model%tw_tn(:, e) + d = model%tw_tn(:, e + 1) + z = CD_ZERO + dA = ends(:, 1) + nA = ends(:, 2) + dB = ends(:, 3) + nB = ends(:, 4) + dAc = model%torsion%ends(:, 1) + nAc = model%torsion%ends(:, 2) + dBc = model%torsion%ends(:, 3) + nBc = model%torsion%ends(:, 4) + kind = 0 + IF (e == 1 .AND. model%tw_rigid(1)) kind = 1 + IF (e == model%ne .AND. model%tw_rigid(2)) kind = kind + 2 + cnow = CD_ZERO + cref = CD_ZERO + owner = 0 + sg = -CD_ONE + oref = CD_ZERO + SELECT CASE (kind) + CASE (0) + tri(:, :, 1) = RESHAPE([a, z, z], [3, 3]) + slot(:, 1) = [0, 1, 2] + tri(:, :, 2) = RESHAPE([a, z, d], [3, 3]) + slot(:, 2) = [0, 2, 0] + oref = oref + sg(1)*CD_HermiteTwist_Omega(a, a, d) + oref = oref + sg(2)*CD_HermiteTwist_Omega(a, d, d) + CASE (1) + ! node 1 director G(d_A -> t_1) n_A + tri(:, :, 1) = RESHAPE([dA, z, z], [3, 3]) + slot(:, 1) = [0, 1, 2] + owner(1, 1) = 1 + tri(:, :, 2) = RESHAPE([dA, z, d], [3, 3]) + slot(:, 2) = [0, 2, 0] + owner(1, 2) = 1 + oref = oref + sg(1)*CD_HermiteTwist_Omega(dAc, a, d) + oref = oref + sg(2)*CD_HermiteTwist_Omega(dAc, d, d) + cnow = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(dA, d, nA), model%tw_u(:, e + 1), d) + cref = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(dAc, d, nAc), model%tw_u(:, e + 1), d) + CASE (2) + ! last-node director G(d_B -> t_N) n_B + sg = [CD_ONE, -CD_ONE] + tri(:, :, 1) = RESHAPE([dB, z, a], [3, 3]) + slot(:, 1) = [0, 2, 0] + owner(1, 1) = 2 + tri(:, :, 2) = RESHAPE([a, z, z], [3, 3]) + slot(:, 2) = [0, 1, 2] + oref = oref + sg(1)*CD_HermiteTwist_Omega(dBc, d, a) + oref = oref + sg(2)*CD_HermiteTwist_Omega(a, a, d) + cnow = CD_HermiteTwist_Angle(model%tw_u(:, e), CD_HermiteTwist_Carry(dB, a, nB), a) + cref = CD_HermiteTwist_Angle(model%tw_u(:, e), CD_HermiteTwist_Carry(dBc, a, nBc), a) + CASE (3) + ! one element, rigid at both ends + sg = [CD_ONE, -CD_ONE] + tri(:, :, 1) = RESHAPE([dB, z, dA], [3, 3]) + slot(:, 1) = [0, 2, 0] + owner(1, 1) = 2 + owner(3, 1) = 1 + tri(:, :, 2) = RESHAPE([dA, z, z], [3, 3]) + slot(:, 2) = [0, 1, 2] + owner(1, 2) = 1 + oref = oref + sg(1)*CD_HermiteTwist_Omega(dBc, d, dAc) + oref = oref + sg(2)*CD_HermiteTwist_Omega(dAc, a, d) + cnow = CD_HermiteTwist_Angle(nA, CD_HermiteTwist_Carry(dB, dA, nB), dA) + cref = CD_HermiteTwist_Angle(nAc, CD_HermiteTwist_Carry(dBc, dAc, nBc), dAc) + END SELECT + IF (want_hess) THEN + CALL CD_HermiteTwist_Reference(qe, model%l0(e), tri, slot, sg, val, g, es, em, hess=h, holonomy=.FALSE., & + fixed_grad=fg) + ELSE + CALL CD_HermiteTwist_Reference(qe, model%l0(e), tri, slot, sg, val, g, es, em, holonomy=.FALSE., fixed_grad=fg) + END IF + IF (es /= CD_HTORS_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'twist: '//TRIM(em) + RETURN + END IF + ! the wrapped change of the end-frame constant is unique while the frame turns by less than + ! pi between two committed states; pi/2 keeps the margin of the condensed torsion + IF (ABS(tw_wrap(cnow - cref)) > CD_HTORS_MAX_STEP) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'twist: an end frame turned by more than pi/2 about the line from its committed state' + RETURN + END IF + beta = model%tw_beta(e) + tw_wrap(cnow - cref) + (val - oref) + IF (want_hess) THEN + CALL CD_HermiteTorsion_Element(qe, model%l0(e), he, ge, es, em, hess=hk, & + quadrature_order=model%torsion%quadrature_order) + ELSE + CALL CD_HermiteTorsion_Element(qe, model%l0(e), he, ge, es, em, quadrature_order=model%torsion%quadrature_order) + END IF + IF (es /= CD_HTORS_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'twist: '//TRIM(em) + RETURN + END IF + rho = beta - he + g = g - ge + IF (want_hess) h = h - hk + cpl = CD_ZERO + IF (ALLOCATED(model%torsion%couple)) cpl = model%torsion%couple(e) + IF (ABS(cpl) > CD_ZERO) THEN + CALL CD_HermiteTorsion_Stretch_Derivatives(qe, model%l0(e), ls, gs, hs, model%torsion%quadrature_order) + rho = rho + cpl*(ls - model%l0(e)) + g = g + cpl*gs + IF (want_hess) h = h + cpl*hs + END IF + IF (PRESENT(end_w) .AND. kind > 0) THEN + ! fixed frame vertices turn with their frame: d Omega/d w = d x dOmega/dd + DO k = 1, 2 + DO j = 1, 3 + IF (owner(j, k) == 0) CYCLE + end_w(:, owner(j, k)) = end_w(:, owner(j, k)) + tw_cross(tri(:, j, k), fg(:, j, k)) + END DO + END DO + ! the end-frame constants (see the derivation in CD_HermiteCable_Dyn_EndConnection_Moment) + SELECT CASE (kind) + CASE (1) + CALL CD_HermiteTwist_Omega_Gradient(dA, dA, d, om, g9) + end_w(:, 1) = end_w(:, 1) - dA - tw_cross(dA, g9(4:6)) + CASE (2) + CALL CD_HermiteTwist_Omega_Gradient(dB, dB, a, om, g9) + end_w(:, 2) = end_w(:, 2) + dB + tw_cross(dB, g9(4:6)) + CASE (3) + CALL CD_HermiteTwist_Omega_Gradient(dB, dB, dA, om, g9) + end_w(:, 2) = end_w(:, 2) + dB + tw_cross(dB, g9(4:6)) + CALL CD_HermiteTwist_Omega_Gradient(dB, dA, dA, om, g9) + end_w(:, 1) = end_w(:, 1) - dA + tw_cross(dA, g9(4:6)) + END SELECT + END IF + END SUBROUTINE twist_reference + + SUBROUTINE twist_link(model, iend, q_cfg, ends, want_hess, psi, gl, hl, ErrStat, ErrMsg, end_w) + !! The end-frame reference psi of the elastic end iend: the angle about the end node's + !! tangent from its director to the end frame's normal carried to the node, psi = psi^n + + !! (change of angle(u^n -> G(d -> t^n) n)) + Omega(d, t, t^n) - Omega(d^n, t^n, t^n), with its + !! gradient gl and Hessian hl in the end node's tangent handle m, and, when asked for, + !! end_w = d psi/d w of an incremental rotation of the end frame. The end spring twists by + !! phi_1 - psi at end 1 and by psi + Phi - phi_N at end 2. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: iend + REAL(wp), INTENT(IN) :: q_cfg(:), ends(3, 4) + LOGICAL, INTENT(IN) :: want_hess + REAL(wp), INTENT(OUT) :: psi, gl(3), hl(3, 3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: end_w(3) + REAL(wp) :: qe(12), tri(3, 3, 1), fg(3, 3, 1), g12(12), h12(12, 12), z(3), a(3), u(3), dd(3), nd(3) + REAL(wp) :: dc(3), nc(3), val, oref, cnow, cref, om, g9(9) + INTEGER :: node, slot(3, 1), es + CHARACTER(200) :: em + psi = CD_ZERO + gl = CD_ZERO + hl = CD_ZERO + IF (PRESENT(end_w)) end_w = CD_ZERO + ErrStat = CD_HCDYN_OK + ErrMsg = '' + node = MERGE(1, model%nn, iend == 1) + qe = CD_ZERO + qe(4:6) = q_cfg(6*node - 2:6*node) + a = model%tw_tn(:, node) + u = model%tw_u(:, node) + z = CD_ZERO + dd = ends(:, 2*iend - 1) + nd = ends(:, 2*iend) + dc = model%torsion%ends(:, 2*iend - 1) + nc = model%torsion%ends(:, 2*iend) + tri(:, :, 1) = RESHAPE([dd, z, a], [3, 3]) + slot(:, 1) = [0, 1, 0] + oref = CD_ZERO + oref = oref + CD_ONE*CD_HermiteTwist_Omega(dc, a, a) + cnow = CD_HermiteTwist_Angle(u, CD_HermiteTwist_Carry(dd, a, nd), a) + cref = CD_HermiteTwist_Angle(u, CD_HermiteTwist_Carry(dc, a, nc), a) + IF (want_hess) THEN + CALL CD_HermiteTwist_Reference(qe, model%l0(1), tri, slot, [CD_ONE], val, g12, es, em, hess=h12, & + holonomy=.FALSE., fixed_grad=fg) + ELSE + CALL CD_HermiteTwist_Reference(qe, model%l0(1), tri, slot, [CD_ONE], val, g12, es, em, holonomy=.FALSE., & + fixed_grad=fg) + END IF + IF (es /= CD_HTORS_OK) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'twist end link: '//TRIM(em) + RETURN + END IF + IF (ABS(tw_wrap(cnow - cref)) > CD_HTORS_MAX_STEP) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'twist end link: the end frame turned by more than pi/2 about the line from its committed state' + RETURN + END IF + psi = model%tw_psi(iend) + tw_wrap(cnow - cref) + (val - oref) + gl = g12(4:6) + IF (want_hess) hl = h12(4:6, 4:6) + IF (PRESENT(end_w)) THEN + CALL CD_HermiteTwist_Omega_Gradient(dd, dd, a, om, g9) + end_w = dd + tw_cross(dd, g9(4:6)) + tw_cross(dd, fg(:, 1, 1)) + END IF + END SUBROUTINE twist_link + + SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, Kb, Kvb, ErrStat, ErrMsg) + !! Nodal-twist part of assemble_residual: every element's torque M_e = (GJ/l0) tw_e + (Bt/l0) + !! d tw_e/dt (tw_e = phi_{e+1} - phi_e + rho_e(q), d/dt from the nodal rates and g . q_dot) + !! and every elastic end's spring, at q_cfg, v_cfg and the angles and rates of the running + !! step (tw_pe, tw_we) or of the committed state. R gains M_e drho_e/dq and tw_R the nodal + !! torques (want_residual); Kb gains M_e d2rho_e/dq2 + (GJ/l0) g g^T (+ the damping's + !! g (H q_dot)^T) and Kvb (Bt/l0) g g^T, and the coupling to the angles is kept per element + !! for the solve (tw_eg, tw_ehv, tw_ek, tw_ed, tw_lg, tw_lk; want_tangent). tw_me holds the + !! element torques and tw_tsum the summed twist. + TYPE(CD_HermiteCableDynType), INTENT(INOUT), TARGET :: model + REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) + LOGICAL, INTENT(IN) :: want_residual, want_tangent + REAL(wp), INTENT(INOUT) :: R(:), Kb(:, :), Kvb(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), POINTER :: phi(:), w(:) + REAL(wp) :: ends(3, 4), phi_end, rho, beta, g(12), h(12, 12), ve(12), hv(12), ke(12, 12), kel, kd + REAL(wp) :: om(3, 2), ew(3, 2) + LOGICAL :: turning + REAL(wp) :: tau, rate, mt, psi, gl(3), hl(3, 3), k, tw + INTEGER :: e, iend, node, b, i, j, es + CHARACTER(1024) :: em + + ErrStat = CD_HCDYN_OK + ErrMsg = '' + CALL tw_frames(model, ends, phi_end) + IF (model%tors_use_step) THEN + phi => model%tw_pe + w => model%tw_we + ELSE + phi => model%tw_phi + w => model%tw_w + END IF + IF (want_residual) model%tw_R = CD_ZERO + model%tw_tsum = CD_ZERO + om = MERGE(model%tw_som, model%tw_om, model%tors_use_step) + turning = ANY(om /= CD_ZERO) .AND. ALLOCATED(model%torsion%bt) + DO e = 1, model%ne + kd = CD_ZERO + IF (ALLOCATED(model%torsion%bt)) kd = model%torsion%bt(e)/model%l0(e) + ! an element at a rigid end twists through rho as its end frame turns: its damping rate + ! takes d rho/dw . omega of the frames (the tangent keeps the rate's q-dependence through + ! g only, as the frame's share of it is of order omega dt) + IF (turning .AND. kd > CD_ZERO .AND. (e == 1 .OR. e == model%ne)) THEN + CALL twist_reference(model, e, q_cfg, ends, want_tangent, rho, beta, g, h, es, em, end_w=ew) + ELSE + CALL twist_reference(model, e, q_cfg, ends, want_tangent, rho, beta, g, h, es, em) + ew = CD_ZERO + END IF + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es + ErrMsg = TRIM(em) + RETURN + END IF + ve = v_cfg(6*e - 5:6*e + 6) + kel = model%torsion%gj(e)/model%l0(e) + tau = phi(e + 1) - phi(e) + rho + rate = w(e + 1) - w(e) + DOT_PRODUCT(g, ve) + IF (turning .AND. kd > CD_ZERO) rate = rate + DOT_PRODUCT(ew(:, 1), om(:, 1)) + DOT_PRODUCT(ew(:, 2), om(:, 2)) + mt = kel*tau + kd*rate + model%tw_me(e) = mt + model%tw_tsum = model%tw_tsum + tau + IF (want_residual) THEN + R(6*e - 5:6*e + 6) = R(6*e - 5:6*e + 6) + mt*g + model%tw_R(e) = model%tw_R(e) - mt + model%tw_R(e + 1) = model%tw_R(e + 1) + mt + END IF + IF (want_tangent) THEN + hv = CD_ZERO + IF (kd > CD_ZERO) hv = MATMUL(h, ve) + DO j = 1, 12 + DO i = 1, 12 + ke(i, j) = mt*h(i, j) + kel*g(i)*g(j) + kd*g(i)*hv(j) + END DO + END DO + CALL scatter12_band(Kb, ke, e) + IF (kd > CD_ZERO) THEN + DO j = 1, 12 + DO i = 1, 12 + ke(i, j) = kd*g(i)*g(j) + END DO + END DO + CALL scatter12_band(Kvb, ke, e) + END IF + model%tw_eg(:, e) = g + model%tw_ehv(:, e) = hv + model%tw_ek(e) = kel + model%tw_ed(e) = kd + END IF + END DO + IF (want_tangent) THEN + model%tw_lg = CD_ZERO + model%tw_lk = CD_ZERO + END IF + DO iend = 1, 2 + IF (model%tw_rigid(iend)) CYCLE + CALL twist_link(model, iend, q_cfg, ends, want_tangent, psi, gl, hl, es, em) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = es + ErrMsg = TRIM(em) + RETURN + END IF + k = CD_ONE/model%torsion%end_compliance(iend) + node = MERGE(1, model%nn, iend == 1) + b = 6*node - 3 + IF (iend == 1) THEN + tw = phi(1) - psi + ELSE + tw = psi + phi_end - phi(model%nn) + END IF + mt = k*tw + model%tw_tsum = model%tw_tsum + tw + IF (want_residual) THEN + IF (iend == 1) THEN + R(b + 1:b + 3) = R(b + 1:b + 3) - mt*gl + model%tw_R(1) = model%tw_R(1) + mt + ELSE + R(b + 1:b + 3) = R(b + 1:b + 3) + mt*gl + model%tw_R(model%nn) = model%tw_R(model%nn) - mt + END IF + END IF + IF (want_tangent) THEN + DO j = 1, 3 + DO i = 1, 3 + Kb(KL_D + KU_D + 1 + i - j, b + j) = Kb(KL_D + KU_D + 1 + i - j, b + j) + k*gl(i)*gl(j) + & + MERGE(-mt, mt, iend == 1)*hl(i, j) + END DO + END DO + model%tw_lg(:, iend) = gl + model%tw_lk(iend) = k + END IF + END DO + END SUBROUTINE assemble_twist + + SUBROUTINE tw_build_K7(model, cm, ck, cv, bases, ErrStat, ErrMsg) + !! The effective tangent of the nodal-twist step in 7-DOF-per-node order ([r, m, phi] per + !! node, KL = KU = 13) from the cable's ws_Keffb (already in the rigid-end basis, Dirichlet + !! applied) and the twist data of the last tangent assembly: cm M + ck K + cv Kv for the + !! angles' lumped inertia, stiffness and damping and their coupling to q (the q rows and + !! columns of a rigid end in its basis, those of fixed DOFs and of held angles zeroed). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: cm, ck, cv, bases(3, 3, 2) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i6, j6, i7, j7, e, a, gi, p, iend, node, b + REAL(wp) :: colv(12), rowv(12), d, kl3(3) + ErrStat = CD_HCDYN_OK + ErrMsg = '' + model%tw_K7 = CD_ZERO + DO j6 = 1, model%ndof + j7 = j6 + (j6 - 1)/6 + DO i6 = MAX(1, j6 - KU_D), MIN(model%ndof, j6 + KL_D) + i7 = i6 + (i6 - 1)/6 + model%tw_K7(2*KB7 + 1 + i7 - j7, j7) = model%ws_Keffb(KL_D + KU_D + 1 + i6 - j6, j6) + END DO + END DO + DO e = 1, model%ne + ! q rows of the angle columns, (ck GJ/l0 + cv Bt/l0) g, and angle rows of the q columns, + ! ck (GJ/l0 g + Bt/l0 H q_dot) + cv Bt/l0 g; both + at phi_{e+1} and - at phi_e + colv = (ck*model%tw_ek(e) + cv*model%tw_ed(e))*model%tw_eg(:, e) + rowv = ck*(model%tw_ek(e)*model%tw_eg(:, e) + model%tw_ed(e)*model%tw_ehv(:, e)) + & + cv*model%tw_ed(e)*model%tw_eg(:, e) + IF (e == 1) CALL rigid_local(1, colv(4:6), rowv(4:6)) + IF (e == model%ne) CALL rigid_local(2, colv(10:12), rowv(10:12)) + d = ck*model%tw_ek(e) + cv*model%tw_ed(e) + DO a = 1, 12 + gi = elem_gdof(e, a) + IF (.NOT. model%solve_mask(gi)) CYCLE + DO p = e, e + 1 + IF (.NOT. model%tw_free(p)) CYCLE + CALL add7(gi + (gi - 1)/6, 7*p, MERGE(colv(a), -colv(a), p == e + 1)) + CALL add7(7*p, gi + (gi - 1)/6, MERGE(rowv(a), -rowv(a), p == e + 1)) + END DO + END DO + DO p = e, e + 1 + IF (.NOT. model%tw_free(p)) CYCLE + DO i6 = e, e + 1 + IF (.NOT. model%tw_free(i6)) CYCLE + CALL add7(7*p, 7*i6, MERGE(d, -d, p == i6)) + END DO + END DO + END DO + DO iend = 1, 2 + IF (.NOT. model%tw_lk(iend) > CD_ZERO) CYCLE + node = MERGE(1, model%nn, iend == 1) + IF (.NOT. model%tw_free(node)) CYCLE + kl3 = -ck*model%tw_lk(iend)*model%tw_lg(:, iend) + colv(1:3) = kl3 + rowv(1:3) = kl3 + CALL rigid_local(iend, colv(1:3), rowv(1:3)) + b = 6*node - 3 + DO a = 1, 3 + gi = b + a + IF (.NOT. model%solve_mask(gi)) CYCLE + CALL add7(gi + (gi - 1)/6, 7*node, colv(a)) + CALL add7(7*node, gi + (gi - 1)/6, rowv(a)) + END DO + CALL add7(7*node, 7*node, ck*model%tw_lk(iend)) + END DO + DO p = 1, model%nn + IF (model%tw_free(p)) THEN + CALL add7(7*p, 7*p, cm*model%tw_mass(p)) + ELSE + model%tw_K7(2*KB7 + 1, 7*p) = CD_ONE + END IF + END DO + ! column by column (a reshaped copy would be a heap temporary) + DO p = 1, SIZE(model%tw_K7, 2) + IF (.NOT. CD_All_Finite(model%tw_K7(:, p))) THEN + ErrStat = CD_HCDYN_NOCONVERGE + ErrMsg = 'twist: non-finite effective tangent' + RETURN + END IF + END DO + CONTAINS + SUBROUTINE add7(r7, c7, val) + INTEGER, INTENT(IN) :: r7, c7 + REAL(wp), INTENT(IN) :: val + model%tw_K7(2*KB7 + 1 + r7 - c7, c7) = model%tw_K7(2*KB7 + 1 + r7 - c7, c7) + val + END SUBROUTINE add7 + SUBROUTINE rigid_local(iend_l, cv3, rv3) + !! The tangent-DOF entries of a rigid end in its basis (as transform_rigid_band). + INTEGER, INTENT(IN) :: iend_l + REAL(wp), INTENT(INOUT) :: cv3(3), rv3(3) + IF (model%endconn_mode(iend_l) /= CD_ENDCONN_RIGID) RETURN + cv3 = MATMUL(TRANSPOSE(bases(:, :, iend_l)), cv3) + rv3 = MATMUL(rv3, bases(:, :, iend_l)) + END SUBROUTINE rigid_local + END SUBROUTINE tw_build_K7 + + SUBROUTINE tw_solve(model, ErrStat, ErrMsg) + !! Solve the factored tw_K7 for the direction [ws_dq, tw_dp] (right-hand sides on entry, + !! the solution on return). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i + DO i = 1, model%ndof + model%tw_x7(i + (i - 1)/6) = model%ws_dq(i) + END DO + DO i = 1, model%nn + model%tw_x7(7*i) = model%tw_dp(i) + END DO + CALL CD_Solve_Factored_Banded(model%tw_K7, KB7, KB7, model%tw_ipiv, model%tw_x7, ErrStat, ErrMsg, & + factor_validated=.TRUE.) + IF (ErrStat /= CD_LINALG_OK) RETURN + DO i = 1, model%ndof + model%ws_dq(i) = model%tw_x7(i + (i - 1)/6) + END DO + DO i = 1, model%nn + model%tw_dp(i) = model%tw_x7(7*i) + END DO + END SUBROUTINE tw_solve + + SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) + !! Install the nodal twist of the committed configuration under the uniform torque mt (the + !! condensed torque of the static state): directors carried along the line from the End-1 + !! frame (each element's own transport, so every interior reference twist is the element + !! holonomy), angles accumulated from the element twists mt l0/GJ - rho_e and the end + !! compliances, rates zero. A rigid end 2 holds phi = Phi: the last element's reference + !! twist takes the multiple of 2 pi the accumulated angle needs, as an elastic end 2's psi + !! does; a remainder above STATE_TOL (a static state off equilibrium) fails closed. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: mt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), PARAMETER :: STATE_TOL = 1.0e-6_wp + INTEGER :: nn, ne, i, e, es + REAL(wp) :: v(3), t(3), he, ge(12), qe(12), rho, beta, g(12), h(12, 12), diff, kk, ends(3, 4), phi_end, psi + REAL(wp) :: tol + CHARACTER(200) :: em + CHARACTER(1024) :: em2 + ErrStat = CD_HCDYN_OK + ErrMsg = '' + nn = model%nn + ne = model%ne + IF (ALLOCATED(model%tw_phi)) THEN + IF (SIZE(model%tw_phi) /= nn) CALL tw_release(model) + END IF + IF (.NOT. ALLOCATED(model%tw_phi)) THEN + ALLOCATE (model%tw_phi(nn), model%tw_w(nn), model%tw_al(nn), model%tw_mass(nn), model%tw_u(3, nn), & + model%tw_tn(3, nn), model%tw_beta(ne), model%tw_mt(ne), model%tw_free(nn)) + ALLOCATE (model%tw_pn(nn), model%tw_wn(nn), model%tw_an(nn), model%tw_pk(nn), model%tw_wk(nn), & + model%tw_ak(nn), model%tw_ptrial(nn), model%tw_dp(nn), model%tw_G(nn), model%tw_Gt(nn), & + model%tw_Rk(nn), model%tw_Rt(nn), model%tw_R(nn), model%tw_fcR(nn), model%tw_pe(nn), & + model%tw_we(nn)) + ALLOCATE (model%tw_eg(12, ne), model%tw_ehv(12, ne), model%tw_ek(ne), model%tw_ed(ne), model%tw_me(ne)) + ALLOCATE (model%tw_K7(3*KB7 + 1, 7*nn), model%tw_x7(7*nn), model%tw_ipiv(7*nn)) + ALLOCATE (model%tw_su(3, nn), model%tw_stn(3, nn), model%tw_sbeta(ne)) + ALLOCATE (model%ws_recovery_tw(tw_pack_size(model))) + END IF + model%tw_pn = CD_ZERO; model%tw_wn = CD_ZERO; model%tw_an = CD_ZERO; model%tw_pk = CD_ZERO + model%tw_wk = CD_ZERO; model%tw_ak = CD_ZERO; model%tw_ptrial = CD_ZERO; model%tw_dp = CD_ZERO + model%tw_G = CD_ZERO; model%tw_Gt = CD_ZERO; model%tw_Rk = CD_ZERO; model%tw_Rt = CD_ZERO + model%tw_R = CD_ZERO; model%tw_fcR = CD_ZERO; model%tw_eg = CD_ZERO; model%tw_ehv = CD_ZERO + model%tw_ek = CD_ZERO; model%tw_ed = CD_ZERO; model%tw_me = CD_ZERO + CALL tw_set_derived(model, model%torsion) + DO i = 1, nn + model%tw_tn(:, i) = model%q(6*i - 2:6*i)/NORM2(model%q(6*i - 2:6*i)) + END DO + ends = model%torsion%ends + phi_end = model%torsion%phi + model%tw_u(:, 1) = unit_perp(CD_HermiteTwist_Carry(ends(:, 1), model%tw_tn(:, 1), ends(:, 2)), model%tw_tn(:, 1)) + DO e = 1, ne + qe = model%q(6*e - 5:6*e + 6) + CALL CD_HermiteTorsion_Element(qe, model%l0(e), he, ge, es, em, quadrature_order=model%torsion%quadrature_order) + IF (es /= CD_HTORS_OK) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = 'twist: '//TRIM(em) + RETURN + END IF + t = model%tw_tn(:, e + 1) + v = CD_HermiteTwist_Carry(model%tw_tn(:, e), t, model%tw_u(:, e)) + model%tw_u(:, e + 1) = unit_perp(COS(he)*v + SIN(he)*tw_cross(t, v), t) + END DO + IF (model%tw_rigid(2)) model%tw_u(:, nn) = unit_perp(CD_HermiteTwist_Carry(ends(:, 3), model%tw_tn(:, nn), & + ends(:, 4)), model%tw_tn(:, nn)) + DO e = 1, ne + model%tw_beta(e) = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(model%tw_tn(:, e), model%tw_tn(:, e + 1), & + model%tw_u(:, e)), model%tw_u(:, e + 1), & + model%tw_tn(:, e + 1)) + END DO + ! a rigid end's element takes its end-frame constant in tw_beta: its formula at the + ! committed state is tw_beta itself, so take the director angle of the gauge directly + model%tw_psi = CD_ZERO + model%tw_som = CD_ZERO + model%tw_om = CD_ZERO + model%tw_oal = CD_ZERO + IF (.NOT. model%tw_rigid(1)) model%tw_psi(1) = CD_HermiteTwist_Angle(model%tw_u(:, 1), & + CD_HermiteTwist_Carry(ends(:, 1), & + model%tw_tn(:, 1), & + ends(:, 2)), & + model%tw_tn(:, 1)) + ! angles from the uniform torque + tol = STATE_TOL*MAX(CD_ONE, ABS(phi_end)) + model%tw_phi = CD_ZERO + IF (.NOT. model%tw_rigid(1)) model%tw_phi(1) = mt*model%torsion%end_compliance(1) + model%tw_psi(1) + model%tors_use_step = .FALSE. + DO e = 1, ne + CALL twist_reference(model, e, model%q, ends, .FALSE., rho, beta, g, h, es, em2) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HCDYN_BADINPUT + ErrMsg = TRIM(em2) + RETURN + END IF + model%tw_phi(e + 1) = model%tw_phi(e) + mt*model%l0(e)/model%torsion%gj(e) - rho + IF (e == ne .AND. model%tw_rigid(2)) THEN + diff = model%tw_phi(nn) - phi_end + kk = ANINT(diff/(2.0_wp*CD_HTORS_PI)) + IF (ABS(diff - 2.0_wp*CD_HTORS_PI*kk) > tol) THEN + ErrStat = CD_HCDYN_BADINPUT + WRITE (ErrMsg, '(A,ES10.3,A)') 'twist: the static torsion state misses the End-2 twist by ', & + ABS(diff - 2.0_wp*CD_HTORS_PI*kk), ' rad (solve the statics with torsion first)' + RETURN + END IF + model%tw_beta(ne) = model%tw_beta(ne) + diff + model%tw_phi(nn) = phi_end + END IF + END DO + IF (.NOT. model%tw_rigid(2)) THEN + ! the End-2 spring: its psi at the committed state is the director angle itself, on the + ! branch that puts the static end twist mt/k_2 on it + psi = CD_HermiteTwist_Angle(model%tw_u(:, nn), CD_HermiteTwist_Carry(ends(:, 3), model%tw_tn(:, nn), & + ends(:, 4)), model%tw_tn(:, nn)) + diff = mt*model%torsion%end_compliance(2) - (psi + phi_end - model%tw_phi(nn)) + kk = ANINT(diff/(2.0_wp*CD_HTORS_PI)) + IF (ABS(diff - 2.0_wp*CD_HTORS_PI*kk) > tol) THEN + ErrStat = CD_HCDYN_BADINPUT + WRITE (ErrMsg, '(A,ES10.3,A)') 'twist: the static torsion state misses the End-2 spring twist by ', & + ABS(diff - 2.0_wp*CD_HTORS_PI*kk), ' rad (solve the statics with torsion first)' + RETURN + END IF + model%tw_psi(2) = psi + diff + END IF + model%tw_w = CD_ZERO + model%tw_al = CD_ZERO + model%tw_mt = mt + model%tw_active = .TRUE. + CONTAINS + PURE FUNCTION unit_perp(x, ax) RESULT(y) + REAL(wp), INTENT(IN) :: x(3), ax(3) + REAL(wp) :: y(3) + y = x - DOT_PRODUCT(x, ax)*ax + y = y/NORM2(y) + END FUNCTION unit_perp + END SUBROUTINE tw_init + + SUBROUTINE tw_set_derived(model, tors) + !! The rigid ends, held angles and lumped polar inertia (half of each adjacent element's + !! Irn l0) the torsion description tors gives. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + TYPE(CD_HermiteTorsionType), INTENT(IN) :: tors + INTEGER :: e + model%tw_rigid = .NOT. (tors%end_compliance > CD_ZERO) + model%tw_free = .TRUE. + IF (model%tw_rigid(1)) model%tw_free(1) = .FALSE. + IF (model%tw_rigid(2)) model%tw_free(model%nn) = .FALSE. + model%tw_mass = CD_ZERO + DO e = 1, model%ne + model%tw_mass(e) = model%tw_mass(e) + 0.5_wp*tors%irn(e)*model%l0(e) + model%tw_mass(e + 1) = model%tw_mass(e + 1) + 0.5_wp*tors%irn(e)*model%l0(e) + END DO + END SUBROUTINE tw_set_derived + + SUBROUTINE tw_settle_committed(model) + !! After an evaluation of the committed state (solve_consistent_acceleration): the angles' + !! accelerations staged in tw_ak, the element torques, and the condensed view Theta_eff = + !! Phi - summed twist with its mean torque (Phi - Theta_eff)/C. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + model%tw_al = model%tw_ak + model%tw_mt = model%tw_me + model%torsion%theta = model%torsion%phi - model%tw_tsum + model%torsion%torque = model%tw_tsum/CD_HermiteTorsion_Compliance(model%torsion, model%l0) + END SUBROUTINE tw_settle_committed + + SUBROUTINE tw_release(model) + !! Deallocate the nodal-twist state and scratch. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + model%tw_active = .FALSE. + IF (ALLOCATED(model%tw_phi)) DEALLOCATE (model%tw_phi, model%tw_w, model%tw_al, model%tw_mass, model%tw_u, & + model%tw_tn, model%tw_beta, model%tw_mt, model%tw_free) + IF (ALLOCATED(model%tw_pn)) DEALLOCATE (model%tw_pn, model%tw_wn, model%tw_an, model%tw_pk, model%tw_wk, & + model%tw_ak, model%tw_ptrial, model%tw_dp, model%tw_G, model%tw_Gt, & + model%tw_Rk, model%tw_Rt, model%tw_R, model%tw_fcR, model%tw_pe, & + model%tw_we) + IF (ALLOCATED(model%tw_eg)) DEALLOCATE (model%tw_eg, model%tw_ehv, model%tw_ek, model%tw_ed, model%tw_me) + IF (ALLOCATED(model%tw_K7)) DEALLOCATE (model%tw_K7, model%tw_x7, model%tw_ipiv) + IF (ALLOCATED(model%tw_su)) DEALLOCATE (model%tw_su, model%tw_stn, model%tw_sbeta) + IF (ALLOCATED(model%ws_recovery_tw)) DEALLOCATE (model%ws_recovery_tw) + IF (ALLOCATED(model%snap_tw)) DEALLOCATE (model%snap_tw) + IF (ALLOCATED(model%snap_tw_fcR)) DEALLOCATE (model%snap_tw_fcR) + END SUBROUTINE tw_release + + SUBROUTINE tw_advance_reference(model, q_new, ends_new, ErrStat, ErrMsg) + !! The twist reference at q_new with the frames ends_new, into the commit scratch: the + !! reference twists and end-frame references (the step's own formulas, so the committed + !! state reproduces the converged iterate bit for bit), the unit tangents and the directors + !! carried over by the smallest rotation (a rigid end's: its end frame's normal carried). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: q_new(:), ends_new(3, 4) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: e, i, iend + REAL(wp) :: rho, beta, g(12), h(12, 12), psi, gl(3), hl(3, 3), u(3), t(3) + ErrStat = CD_HCDYN_OK + ErrMsg = '' + DO e = 1, model%ne + CALL twist_reference(model, e, q_new, ends_new, .FALSE., rho, beta, g, h, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + model%tw_sbeta(e) = beta + END DO + model%tw_spsi = model%tw_psi + DO iend = 1, 2 + IF (model%tw_rigid(iend)) CYCLE + CALL twist_link(model, iend, q_new, ends_new, .FALSE., psi, gl, hl, ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) RETURN + model%tw_spsi(iend) = psi + END DO + DO i = 1, model%nn + t = q_new(6*i - 2:6*i)/NORM2(q_new(6*i - 2:6*i)) + model%tw_stn(:, i) = t + IF (i == 1 .AND. model%tw_rigid(1)) THEN + u = CD_HermiteTwist_Carry(ends_new(:, 1), t, ends_new(:, 2)) + ELSE IF (i == model%nn .AND. model%tw_rigid(2)) THEN + u = CD_HermiteTwist_Carry(ends_new(:, 3), t, ends_new(:, 4)) + ELSE + u = CD_HermiteTwist_Carry(model%tw_tn(:, i), t, model%tw_u(:, i)) + END IF + u = u - DOT_PRODUCT(u, t)*t + model%tw_su(:, i) = u/NORM2(u) + END DO + END SUBROUTINE tw_advance_reference + + SUBROUTINE tw_frame_rates(model, dt) + !! tw_som: the angular velocity of each end frame from the committed frames to the step's, + !! log(R_{n+1} R_n^T)/dt with R = [d n d x n] (spatial, as end_w of twist_reference). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + REAL(wp), INTENT(IN) :: dt + REAL(wp) :: r0(3, 3), r1(3, 3) + INTEGER :: k + model%tw_som = CD_ZERO + IF (.NOT. dt > CD_ZERO) RETURN + DO k = 1, 2 + IF (ALL(model%tors_step_ends(:, 2*k - 1:2*k) == model%torsion%ends(:, 2*k - 1:2*k))) CYCLE + r0(:, 1:2) = model%torsion%ends(:, 2*k - 1:2*k) + r0(:, 3) = tw_cross(r0(:, 1), r0(:, 2)) + r1(:, 1:2) = model%tors_step_ends(:, 2*k - 1:2*k) + r1(:, 3) = tw_cross(r1(:, 1), r1(:, 2)) + model%tw_som(:, k) = CD_Log_SO3(MATMUL(r1, TRANSPOSE(r0)))/dt + END DO + END SUBROUTINE tw_frame_rates + + SUBROUTINE tw_commit_reference(model) + !! Make the reference state of tw_advance_reference the committed one. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + model%tw_beta = model%tw_sbeta + model%tw_psi = model%tw_spsi + model%tw_tn = model%tw_stn + model%tw_u = model%tw_su + END SUBROUTINE tw_commit_reference + SUBROUTINE add_endconn_band(R, Kb, q_cfg, node, k_rot, d0, want_residual, want_tangent, & ErrStat, ErrMsg) !! Scatter one rotational end connection into the dynamic residual and band tangent. @@ -9511,6 +10973,14 @@ SUBROUTINE solve_consistent_acceleration(model, ErrStat, ErrMsg, pres_dofs, pres IF (es /= CD_HCDYN_OK) THEN ErrStat = es; ErrMsg = 'solve_consistent_acceleration: '//TRIM(em2); RETURN END IF + ! Nodal twist: the angles' accelerations from their lumped inertia (a held angle keeps its + ! own), installed with the cable's at the end. + IF (model%tw_active) THEN + DO i = 1, model%nn + model%tw_ak(i) = model%tw_al(i) + IF (model%tw_free(i)) model%tw_ak(i) = -model%tw_R(i)/model%tw_mass(i) + END DO + END IF ! Total mass = structural + added (the added-mass matrix at the current configuration). model%ws_Msumb = model%Mgb IF (model%has_am) THEN @@ -9542,6 +11012,7 @@ SUBROUTINE solve_consistent_acceleration(model, ErrStat, ErrMsg, pres_dofs, pres END DO IF (nf == 0) THEN model%a = model%ws_an + IF (model%tw_active) CALL tw_settle_committed(model) RETURN END IF ! In-band Dirichlet on a mass copy + full-size banded solve. The free RHS is @@ -9565,6 +11036,7 @@ SUBROUTINE solve_consistent_acceleration(model, ErrStat, ErrMsg, pres_dofs, pres CALL transform_rigid_vector_to_global(model, rigid_basis, model%ws_dq) model%a = model%ws_dq + model%ws_an IF (has_pres) model%a(pres_dofs) = pres_a + IF (model%tw_active) CALL tw_settle_committed(model) END SUBROUTINE solve_consistent_acceleration SUBROUTINE scatter12_band(abg, Ke, e) diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index 35de7d21..75743309 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -56,6 +56,12 @@ MODULE CableDyn_HermiteTorsion PUBLIC :: CD_HermiteTorsion_Work_Init PUBLIC :: CD_HermiteTorsion_Work_End PUBLIC :: CD_HermiteTorsion_Work_Add_Hessian + PUBLIC :: CD_HermiteTwist_Reference + PUBLIC :: CD_HermiteTwist_Carry + PUBLIC :: CD_HermiteTwist_Angle + PUBLIC :: CD_HermiteTwist_Omega + PUBLIC :: CD_HermiteTwist_Omega_Gradient + PUBLIC :: CD_HermiteTorsion_Stretch_Derivatives INTEGER, PARAMETER, PUBLIC :: CD_HTORS_OK = 0 INTEGER, PARAMETER, PUBLIC :: CD_HTORS_BADINPUT = 1 @@ -109,6 +115,11 @@ MODULE CableDyn_HermiteTorsion !! 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(:) + !! Nodal-twist dynamics (CableDyn_HermiteCableDynamic): the polar rotary inertia Irn + !! [kg m^2/m] of every element and, optionally, its internal torsional damping Bt [N m^2 s] + !! (torque Bt d tau/dt). With irn unallocated the dynamics keeps the condensed, quasi-static + !! torsion; the statics never read them. + REAL(wp), ALLOCATABLE :: irn(:), bt(:) 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). @@ -200,6 +211,40 @@ PURE SUBROUTINE CD_HermiteTorsion_Validate(tors, l0, ErrStat, ErrMsg) RETURN END IF END IF + IF (ALLOCATED(tors%irn)) THEN + IF (SIZE(tors%irn) /= SIZE(l0)) THEN + ErrMsg = 'torsion: the polar rotary inertia must have one entry per element' + RETURN + END IF + IF (.NOT. CD_All_Finite(tors%irn)) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'torsion: non-finite polar rotary inertia' + RETURN + END IF + IF (ANY(.NOT. (tors%irn > CD_ZERO))) THEN + ErrMsg = 'torsion: the polar rotary inertia must be positive on every element' + RETURN + END IF + END IF + IF (ALLOCATED(tors%bt)) THEN + IF (.NOT. ALLOCATED(tors%irn)) THEN + ErrMsg = 'torsion: torsional damping needs the polar rotary inertia (nodal twist)' + RETURN + END IF + IF (SIZE(tors%bt) /= SIZE(l0)) THEN + ErrMsg = 'torsion: the torsional damping must have one entry per element' + RETURN + END IF + IF (.NOT. CD_All_Finite(tors%bt)) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'torsion: non-finite torsional damping' + RETURN + END IF + IF (ANY(tors%bt < CD_ZERO)) THEN + ErrMsg = 'torsion: the torsional damping must be non-negative' + RETURN + END IF + END IF IF (ANY(tors%end_compliance < CD_ZERO)) THEN ErrMsg = 'torsion: end compliances must be non-negative' RETURN @@ -1253,6 +1298,232 @@ PURE SUBROUTINE CD_HermiteTorsion_Accept(theta_prev, theta_raw, theta_new, ErrSt ErrMsg = '' END SUBROUTINE CD_HermiteTorsion_Accept + ! ------------------------------------------------------------------------------------------ + ! nodal twist: reference twist of the time-parallel-transported directors + ! ------------------------------------------------------------------------------------------ + + PURE SUBROUTINE CD_HermiteTwist_Reference(qe, L, tri, tslot, tsign, value, grad, ErrStat, ErrMsg, hess, & + holonomy, fixed_grad, quadrature_order) + !! The reference twist of the nodal-twist model on one element [r1, m1, r2, m2] of reference + !! length L: value = sum_k tsign_k Omega(x_k, y_k, z_k) - h_e (h_e, the element holonomy, only + !! when holonomy, the default), with its gradient and optionally its Hessian over the 12 DOFs. + !! Each triangle k takes its vertices from tri(:, j, k) where tslot(j, k) = 0 (a vector fixed + !! over the step: a committed node tangent or an end director), the unit node-1 tangent + !! b = m1/|m1| where tslot(j, k) = 1 and the unit node-2 tangent c = m2/|m2| where it is 2. + !! A caller adds the step constant (the committed reference twist). fixed_grad(:, j, k) is the + !! gradient in the raw fixed vertex tri(:, j, k) (zero for a node-tangent vertex). + !! + !! An interior element with committed unit tangents a, d and committed reference twist beta^n + !! has the reference twist beta^n - Omega(a, b, c) - Omega(a, c, d) - h_e: its directors are the + !! committed ones carried by the smallest rotation from a to b and from d to c, and the + !! transport around the quadrilateral a, b, c, d turns a vector by its solid angle. A routine + !! of a single node passes no node-2 vertex and holonomy = .FALSE.; then only qe(4:6) is read. + !! Every triangle edge must satisfy 1 + x . y >= CD_HTORS_FOLD_MIN (else CD_HTORS_FOLD). + REAL(wp), INTENT(IN) :: qe(12), L, tri(:, :, :), tsign(:) + INTEGER, INTENT(IN) :: tslot(:, :) + REAL(wp), INTENT(OUT) :: value, grad(12) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(OUT), OPTIONAL :: hess(12, 12), fixed_grad(:, :, :) + LOGICAL, INTENT(IN), OPTIONAL :: holonomy + INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + INTEGER :: order, k, j, i, ntri, si, sj + LOGICAL :: want_hess, with_h, need(2), finite + REAL(wp) :: node_t(3, 2), proj(3, 3, 2), x(3, 3), om, g9(9), h9(9, 9), gt(3, 2), htt(3, 3, 2, 2) + REAL(wp) :: he, ge(12), hk(12, 12), dmy, blk(3, 3), blk2(3, 3) + CHARACTER(200) :: em + + value = CD_ZERO + grad = CD_ZERO + IF (PRESENT(hess)) hess = CD_ZERO + IF (PRESENT(fixed_grad)) fixed_grad = CD_ZERO + want_hess = PRESENT(hess) + with_h = .TRUE. + IF (PRESENT(holonomy)) with_h = holonomy + order = NG_DEFAULT + IF (PRESENT(quadrature_order)) order = quadrature_order + ntri = SIZE(tsign) + ErrStat = CD_HTORS_BADINPUT + IF (SIZE(tri, 1) /= 3 .OR. SIZE(tri, 2) /= 3 .OR. SIZE(tri, 3) /= ntri .OR. SIZE(tslot, 1) /= 3 .OR. & + SIZE(tslot, 2) /= ntri) THEN + ErrMsg = 'CD_HermiteTwist_Reference: tri(3, 3, n), tslot(3, n) and tsign(n) must agree' + RETURN + END IF + IF (PRESENT(fixed_grad)) THEN + IF (SIZE(fixed_grad, 1) /= 3 .OR. SIZE(fixed_grad, 2) /= 3 .OR. SIZE(fixed_grad, 3) /= ntri) THEN + ErrMsg = 'CD_HermiteTwist_Reference: fixed_grad must be shaped as tri' + RETURN + END IF + END IF + IF (ANY(tslot < 0) .OR. ANY(tslot > 2)) THEN + ErrMsg = 'CD_HermiteTwist_Reference: a vertex slot must be 0, 1 or 2' + RETURN + END IF + IF (order < 1 .OR. order > NG_MAX) THEN + ErrMsg = 'CD_HermiteTwist_Reference: quadrature order must lie in [1,6]' + RETURN + END IF + need(1) = ANY(tslot == 1) .OR. with_h + need(2) = ANY(tslot == 2) .OR. with_h + ! (column by column: a reshaped copy of the assumed-shape tri would be a heap temporary) + finite = CD_All_Finite(qe) .AND. CD_Is_Finite(L) .AND. CD_All_Finite(tsign) + DO k = 1, ntri + DO j = 1, 3 + finite = finite .AND. CD_All_Finite(tri(:, j, k)) + END DO + END DO + IF (.NOT. finite) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'CD_HermiteTwist_Reference: non-finite input' + RETURN + END IF + IF (with_h .AND. L <= GEOM_TOL) THEN + ErrMsg = 'CD_HermiteTwist_Reference: element length must be positive' + RETURN + END IF + node_t = CD_ZERO + proj = CD_ZERO + DO j = 1, 2 + IF (.NOT. need(j)) CYCLE + IF (NORM2(qe(6*j - 2:6*j)) <= GEOM_TOL) THEN + ErrMsg = 'CD_HermiteTwist_Reference: zero tangent handle at a node' + RETURN + END IF + node_t(:, j) = qe(6*j - 2:6*j)/NORM2(qe(6*j - 2:6*j)) + CALL normalisation_jacobian(qe(6*j - 2:6*j), proj(:, :, j)) + END DO + DO k = 1, ntri + DO j = 1, 3 + IF (tslot(j, k) == 0) THEN + IF (ABS(NORM2(tri(:, j, k)) - CD_ONE) > FRAME_TOL) THEN + ErrMsg = 'CD_HermiteTwist_Reference: a fixed triangle vertex must be a unit vector' + RETURN + END IF + END IF + END DO + END DO + + gt = CD_ZERO + htt = CD_ZERO + DO k = 1, ntri + DO j = 1, 3 + IF (tslot(j, k) == 0) THEN + x(:, j) = tri(:, j, k) + ELSE + x(:, j) = node_t(:, tslot(j, k)) + END IF + END DO + DO j = 1, 3 + IF (CD_ONE + DOT_PRODUCT(x(:, j), x(:, MOD(j, 3) + 1)) < CD_HTORS_FOLD_MIN) THEN + ErrStat = CD_HTORS_FOLD + ErrMsg = 'CD_HermiteTwist_Reference: a director turned by more than 120 degrees in one step or element' + RETURN + END IF + END DO + CALL solid_angle(x(:, 1), x(:, 2), x(:, 3), want_hess, om, g9, h9) + value = value + tsign(k)*om + DO j = 1, 3 + si = tslot(j, k) + IF (si == 0) THEN + IF (PRESENT(fixed_grad)) fixed_grad(:, j, k) = tsign(k)*g9(3*j - 2:3*j) + CYCLE + END IF + gt(:, si) = gt(:, si) + tsign(k)*g9(3*j - 2:3*j) + IF (.NOT. want_hess) CYCLE + DO i = 1, 3 + sj = tslot(i, k) + IF (sj == 0) CYCLE + htt(:, :, si, sj) = htt(:, :, si, sj) + tsign(k)*h9(3*j - 2:3*j, 3*i - 2:3*i) + END DO + END DO + END DO + ! chain to the tangent handles m1 (DOFs 4:6) and m2 (DOFs 10:12) + DO j = 1, 2 + IF (.NOT. need(j)) CYCLE + grad(6*j - 2:6*j) = MATMUL(proj(:, :, j), gt(:, j)) + IF (.NOT. want_hess) CYCLE + ! (staged in 3 x 3 locals: a result into a run-time section, or a nested product, would + ! take a heap temporary) + blk2 = htt(:, :, j, j) + blk = normalised_hessian(qe(6*j - 2:6*j), gt(:, j), blk2) + hess(6*j - 2:6*j, 6*j - 2:6*j) = blk + END DO + IF (want_hess .AND. need(1) .AND. need(2)) THEN + blk2 = MATMUL(htt(:, :, 1, 2), proj(:, :, 2)) + blk = MATMUL(proj(:, :, 1), blk2) + hess(4:6, 10:12) = blk + hess(10:12, 4:6) = TRANSPOSE(blk) + END IF + IF (with_h) THEN + CALL element_holonomy(qe, L, order, want_hess, he, ge, hk, dmy, ErrStat, em) + IF (ErrStat /= CD_HTORS_OK) THEN + ErrMsg = 'CD_HermiteTwist_Reference: '//em + value = CD_ZERO + grad = CD_ZERO + IF (PRESENT(hess)) hess = CD_ZERO + IF (PRESENT(fixed_grad)) fixed_grad = CD_ZERO + RETURN + END IF + value = value - he + grad = grad - ge + IF (want_hess) hess = hess - hk + END IF + IF (.NOT. (CD_Is_Finite(value) .AND. CD_All_Finite(grad))) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'CD_HermiteTwist_Reference: non-finite twist or derivative' + value = CD_ZERO + grad = CD_ZERO + RETURN + END IF + IF (want_hess) THEN + finite = .TRUE. + DO j = 1, 12 + finite = finite .AND. CD_All_Finite(hess(:, j)) + END DO + IF (.NOT. finite) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'CD_HermiteTwist_Reference: non-finite twist Hessian' + value = CD_ZERO + grad = CD_ZERO + hess = CD_ZERO + RETURN + END IF + END IF + ErrStat = CD_HTORS_OK + ErrMsg = '' + END SUBROUTINE CD_HermiteTwist_Reference + + PURE FUNCTION CD_HermiteTwist_Carry(from, to, v) RESULT(r) + !! The smallest rotation taking the unit vector from to the unit vector to, applied to v (the + !! parallel transport of the nodal-twist directors; requires 1 + from . to > 0). + REAL(wp), INTENT(IN) :: from(3), to(3), v(3) + REAL(wp) :: r(3) + r = smallest_rotation(from, to, v) + END FUNCTION CD_HermiteTwist_Carry + + PURE REAL(wp) FUNCTION CD_HermiteTwist_Angle(x, y, axis) RESULT(ang) + !! The angle in (-pi, pi] about axis, right-hand rule, from x to y (both perpendicular to it). + REAL(wp), INTENT(IN) :: x(3), y(3), axis(3) + ang = ATAN2(DOT_PRODUCT(axis, cross(x, y)), DOT_PRODUCT(x, y)) + END FUNCTION CD_HermiteTwist_Angle + + PURE REAL(wp) FUNCTION CD_HermiteTwist_Omega(x, y, z) RESULT(om) + !! The signed solid angle of the geodesic triangle x, y, z of CD_HermiteTwist_Reference, on + !! the same arithmetic: the value a triangle of fixed vertices takes inside that routine. + REAL(wp), INTENT(IN) :: x(3), y(3), z(3) + REAL(wp) :: g(9), h(9, 9) + CALL solid_angle(x, y, z, .FALSE., om, g, h) + END FUNCTION CD_HermiteTwist_Omega + + PURE SUBROUTINE CD_HermiteTwist_Omega_Gradient(x, y, z, om, g) + !! CD_HermiteTwist_Omega with its gradient g = [dOmega/dx, dOmega/dy, dOmega/dz] in the raw + !! vertex vectors. + REAL(wp), INTENT(IN) :: x(3), y(3), z(3) + REAL(wp), INTENT(OUT) :: om, g(9) + REAL(wp) :: h(9, 9) + CALL solid_angle(x, y, z, .FALSE., om, g, h) + END SUBROUTINE CD_HermiteTwist_Omega_Gradient + ! ------------------------------------------------------------------------------------------ ! element holonomy ! ------------------------------------------------------------------------------------------ @@ -1307,6 +1578,17 @@ PURE REAL(wp) FUNCTION CD_HermiteTorsion_Element_Stretch(qe, L, quadrature_order CALL element_stretch(qe, L, order, .FALSE., ls, g, h) END FUNCTION CD_HermiteTorsion_Element_Stretch + PURE SUBROUTINE CD_HermiteTorsion_Stretch_Derivatives(qe, L, ls, grad, hess, quadrature_order) + !! CD_HermiteTorsion_Element_Stretch with its gradient and Hessian over the 12 DOFs. + REAL(wp), INTENT(IN) :: qe(12), L + REAL(wp), INTENT(OUT) :: ls, grad(12), hess(12, 12) + INTEGER, INTENT(IN), OPTIONAL :: quadrature_order + INTEGER :: order + order = NG_DEFAULT + IF (PRESENT(quadrature_order)) order = quadrature_order + CALL element_stretch(qe, L, order, .TRUE., ls, grad, hess) + END SUBROUTINE CD_HermiteTorsion_Stretch_Derivatives + 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 diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 93b1e901..55be3705 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -43,7 +43,9 @@ MODULE CableDyn_OpenFAST_HermiteFMF CD_HermiteCable_Dyn_End, CD_HCDYN_OK, & CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Set_Torsion_Drive, & CD_HermiteCable_Dyn_Set_Torsion_Frames, & - CD_HermiteCable_Dyn_Set_SegmentLength + CD_HermiteCable_Dyn_Set_SegmentLength, & + CD_HermiteCable_Dyn_Twist_Mirror_Size, CD_HermiteCable_Dyn_Twist_Pack, & + CD_HermiteCable_Dyn_Twist_Unpack, CD_HermiteCable_Dyn_Twist_Check USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HermiteTorsion_Line, & CD_HermiteTorsion_Unwrap, CD_HTORS_OK, CD_HTORS_MAX_STEP USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Shapes @@ -862,6 +864,15 @@ SUBROUTINE CD_HFMF_PreflightCoupledKinematics(self, u_pos, u_vel, u_acc, ErrStat END DO ALLOCATE (qc(SIZE(self%line%q)), g(SIZE(self%line%q))) CALL coupled_candidate_q(self, u_pos, tangent_q, qc) + 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) + IF (ks /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_SOLVEFAIL + ErrMsg = 'CD_HFMF_PreflightCoupledKinematics: '//TRIM(km) + END IF + RETURN + END IF 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) @@ -1667,12 +1678,13 @@ INTEGER FUNCTION CD_HFMF_BoundaryMirrorSize(self) RESULT(n) END FUNCTION CD_HFMF_BoundaryMirrorSize INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) - !! Mirror slots of the condensed torsion, last: the accepted (unwrapped) Theta, Phi and the - !! four end-frame vectors (14 values); zero without torsion. + !! Mirror slots of the torsion, last: the accepted (unwrapped) Theta, Phi and the four + !! end-frame vectors (14 values), then the nodal twist's state + !! (CD_HermiteCable_Dyn_Twist_Mirror_Size); zero without torsion. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN - IF (self%line%torsion%active) n = 14 + IF (self%line%torsion%active) n = 14 + CD_HermiteCable_Dyn_Twist_Mirror_Size(self%line) END FUNCTION CD_HFMF_TorsionMirrorSize INTEGER FUNCTION CD_HFMF_ForceMirrorSize(self) RESULT(n) @@ -1774,6 +1786,9 @@ SUBROUTINE CD_HFMF_PackMirror(self, buf, ErrStat, ErrMsg) buf(k + 1) = self%line%torsion%theta buf(k + 2) = self%line%torsion%phi buf(k + 3:k + 14) = RESHAPE(self%line%torsion%ends, [12]) + IF (self%line%tw_active) & + CALL CD_HermiteCable_Dyn_Twist_Pack(self%line, buf(k + 15:k + 14 + CD_HermiteCable_Dyn_Twist_Mirror_Size( & + self%line))) END IF END SUBROUTINE CD_HFMF_PackMirror @@ -1790,7 +1805,8 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) REAL(wp), INTENT(IN) :: t INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, nf, nh, k, kb + INTEGER :: i, nf, nh, k, kb, es + CHARACTER(1024) :: em ErrStat = CD_HFMF_OK; ErrMsg = '' IF (.NOT. self%initialized) THEN ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_UnpackMirror: module not initialised'; RETURN @@ -1808,9 +1824,18 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_UnpackMirror: mirror must be finite'; RETURN END IF IF (self%line%torsion%active) THEN - ! the torsion block (last 14 values) is checked before anything is written: each end's - ! director and reference normal must be orthonormal, as Set_Torsion_Drive requires - k = SIZE(buf) - 14 + ! the torsion block (the last CD_HFMF_TorsionMirrorSize values) is checked before anything + ! is written: each end's director and reference normal must be orthonormal, as + ! Set_Torsion_Drive requires, and the nodal twist's directors unit vectors + k = SIZE(buf) - CD_HFMF_TorsionMirrorSize(self) + IF (self%line%tw_active) THEN + CALL CD_HermiteCable_Dyn_Twist_Unpack(self%line, buf(k + 15:SIZE(buf)), es, em, check_only=.TRUE.) + IF (es /= CD_HCDYN_OK) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_UnpackMirror: '//TRIM(em) + RETURN + END IF + END IF DO i = 0, 1 ASSOCIATE (dv => buf(k + 3 + 6*i:k + 5 + 6*i), nv => buf(k + 6 + 6*i:k + 8 + 6*i)) IF (ABS(NORM2(dv) - CD_ONE) > 1.0e-8_wp .OR. ABS(NORM2(nv) - CD_ONE) > 1.0e-8_wp .OR. & @@ -1910,6 +1935,8 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%torsion%torque = (self%line%torsion%phi - self%line%torsion%theta)/ & CD_HermiteTorsion_Compliance(self%line%torsion, self%line%l0) self%line%tors_drive_set = .FALSE. + ! the nodal twist, checked above (its force-cache part rides with the cable's) + IF (self%line%tw_active) CALL CD_HermiteCable_Dyn_Twist_Unpack(self%line, buf(k + 15:SIZE(buf)), es, em) ! (a parent-attached torsion frame turns with the parent orientation, which the boundary ! block restored as committed, so a later step without u_orientation holds it) END IF diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 index 285d0f2c..72b8c94c 100644 --- a/tests/test_coupled_torsion.f90 +++ b/tests/test_coupled_torsion.f90 @@ -7,9 +7,12 @@ PROGRAM test_coupled_torsion !! straight 100 m neutral line of test_torsion_deck (GJ 5e4 N m^2, both ends clamped and !! restrained in torsion, no pretwist), its End A on the platform fairlead (0, 0, -50) and !! End B on a fixed anchor. Rolling the platform by phi about the line axis (+x) twists the - !! line by -phi: Twist1 = -phi and Torq = GJ (-phi) / L, with no torsional inertia. - !! 1. feedthrough: a non-stepping update with a rolled orientation gives that twist and - !! torque, and the fairlead moment is the restoring torque about the line axis; + !! line by -phi: Twist1 = -phi and, with a negligible polar inertia (Irn 1e-9: the quasi-static + !! limit of the nodal twist), Torq = GJ (-phi) / L. + !! 1. feedthrough: a non-stepping update with a rolled orientation twists the end element + !! alone against the frozen interior (as the coupled end's translation stretches it): + !! Twist1 = -phi, Torq = GJ (-phi) / l_e at the fairlead and 0 at the anchor until the next + !! step, and the fairlead moment is that restoring torque about the line axis; !! 2. march: the platform rolls at 60 deg/s; every step gives Twist1 = -phi(t) and the !! quasi-static torque (the coupled twin of the standalone vessel-roll gate), and the !! single-cable entry driven with the same calls gives the same values bit for bit; @@ -41,9 +44,11 @@ PROGRAM test_coupled_torsion INTEGER :: n_fail = 0 CHARACTER(160) :: neutral_type - ! neutral 0.2 m section: mass = rhoW pi d^2 / 4; EA 1e7, EI 1e6, GAs 1e8, GJ 5e4 + ! neutral 0.2 m section: mass = rhoW pi d^2 / 4; EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-9 (the + ! quasi-static torsion these gates check: the nodal twist's limit of a negligible polar inertia, + ! whose inertia test_nodal_twist_dynamic gates) WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & - ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0' + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-9 0.0 0.0 0.0 0.0' CALL check_feedthrough() CALL check_march() @@ -210,11 +215,12 @@ SUBROUTINE check_feedthrough() CALL require(es == CD_AGG_OK, '1: a rolled orientation is accepted: '//TRIM(em)) CALL CD_AGG_CalcOutput(agg, es, em) CALL channels(agg, ta, tb, tw) - m_ref = GJ*(-phi)/L + ! the end element (of 40) takes the roll + m_ref = GJ*(-phi)/(L/40.0_wp) WRITE (*, '(A,3ES15.7,A,ES15.7)') '1 feedthrough: Torq A/B, Twist ', ta, tb, tw, '; ref torque ', m_ref CALL require(ABS(tw + 20.0_wp) <= 1.0e-6_wp, '1: Twist1 = -roll') - CALL require(ABS(ta - m_ref) <= 1.0e-6_wp*ABS(m_ref) .AND. ABS(tb - m_ref) <= 1.0e-6_wp*ABS(m_ref), & - '1: Torq = GJ (-roll) / L at both ends') + CALL require(ABS(ta - m_ref) <= 1.0e-6_wp*ABS(m_ref) .AND. ABS(tb) <= 1.0e-9_wp*ABS(m_ref), & + '1: Torq = GJ (-roll) / l_e at the fairlead, 0 at the anchor (the frozen interior)') CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) WRITE (*, '(A,3ES15.7)') '1 feedthrough: fairlead moment ', moment(:, 1) CALL require(ABS(ABS(moment(1, 1)) - ABS(m_ref)) <= 1.0e-6_wp*ABS(m_ref), & diff --git a/tests/test_hermite_twist_kernel.f90 b/tests/test_hermite_twist_kernel.f90 new file mode 100644 index 00000000..17ddfb5a --- /dev/null +++ b/tests/test_hermite_twist_kernel.f90 @@ -0,0 +1,284 @@ +! File: tests/test_hermite_twist_kernel.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_twist_kernel + !! Gates for the reference twist of the nodal-twist model (CD_HermiteTwist_Reference): + !! I the solid-angle forms equal the direct composition of the smallest rotations for an + !! interior element, an element at a rigid End A, at a rigid End B, a one-element line + !! rigid at both ends, and the end links of an elastic end, + !! T with the holonomy, the reference twist is the angle from the director carried along + !! the element (fine smallest-rotation transport of its tangent) to the next director, + !! F gradient and Hessian against central differences, and the fixed-vertex gradient + !! against rotations of the fixed vertices, + !! G the fold guard and the input checks fail closed. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTwist_Reference, CD_HermiteTwist_Carry, CD_HermiteTwist_Angle, & + CD_HTORS_OK, CD_HTORS_FOLD, CD_HTORS_BADINPUT + IMPLICIT NONE + + INTEGER :: nfail + REAL(wp) :: qe(12), el, a(3), d(3), b(3), c(3), u1n(3), u2n(3), dA(3), nA(3), dB(3), nB(3) + + nfail = 0 + CALL setup() + CALL check_identities() + CALL check_transport() + CALL check_derivatives() + CALL check_guards() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: nodal-twist reference twist matches the direct transports and its derivatives' + +CONTAINS + + SUBROUTINE require(ok, label) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. ok) THEN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//label + END IF + END SUBROUTINE require + + FUNCTION unit(v) RESULT(w) + REAL(wp), INTENT(IN) :: v(3) + REAL(wp) :: w(3) + w = v/NORM2(v) + END FUNCTION unit + + FUNCTION perp(v, t) RESULT(w) + !! unit part of v perpendicular to the unit t + REAL(wp), INTENT(IN) :: v(3), t(3) + REAL(wp) :: w(3) + w = unit(v - DOT_PRODUCT(v, t)*t) + END FUNCTION perp + + FUNCTION cross(x, y) RESULT(z) + REAL(wp), INTENT(IN) :: x(3), y(3) + REAL(wp) :: z(3) + z = [x(2)*y(3) - x(3)*y(2), x(3)*y(1) - x(1)*y(3), x(1)*y(2) - x(2)*y(1)] + END FUNCTION cross + + FUNCTION rotate(v, w) RESULT(r) + !! exp(w) v (Rodrigues) + REAL(wp), INTENT(IN) :: v(3), w(3) + REAL(wp) :: r(3), th, k(3) + th = NORM2(w) + IF (th <= 0.0_wp) THEN + r = v + RETURN + END IF + k = w/th + r = v*COS(th) + cross(k, v)*SIN(th) + k*DOT_PRODUCT(k, v)*(1.0_wp - COS(th)) + END FUNCTION rotate + + SUBROUTINE setup() + !! A curved, stretched element and committed tangents a step away from its node tangents. + el = 2.3_wp + qe(1:3) = [0.1_wp, -0.2_wp, 0.05_wp] + qe(4:6) = [0.95_wp, 0.25_wp, -0.12_wp] + qe(7:9) = qe(1:3) + [2.1_wp, 0.9_wp, 0.4_wp] + qe(10:12) = [0.72_wp, 0.55_wp, 0.38_wp] + b = unit(qe(4:6)) + c = unit(qe(10:12)) + a = rotate(b, [0.03_wp, -0.07_wp, 0.05_wp]) + d = rotate(c, [-0.06_wp, 0.02_wp, 0.04_wp]) + u1n = perp([0.2_wp, 1.0_wp, -0.3_wp], a) + u2n = perp([-0.4_wp, 0.3_wp, 1.0_wp], d) + dA = rotate(b, [0.15_wp, 0.1_wp, -0.08_wp]) + nA = perp([0.0_wp, 0.3_wp, 1.0_wp], dA) + dB = rotate(c, [-0.12_wp, 0.09_wp, 0.11_wp]) + nB = perp([1.0_wp, -0.2_wp, 0.1_wp], dB) + END SUBROUTINE setup + + REAL(wp) FUNCTION ref(tri, tslot, tsign, hol) RESULT(v) + REAL(wp), INTENT(IN) :: tri(:, :, :), tsign(:) + INTEGER, INTENT(IN) :: tslot(:, :) + LOGICAL, INTENT(IN) :: hol + REAL(wp) :: g(12) + INTEGER :: es + CHARACTER(200) :: em + CALL CD_HermiteTwist_Reference(qe, el, tri, tslot, tsign, v, g, es, em, holonomy=hol) + CALL require(es == CD_HTORS_OK, 'reference evaluation: '//TRIM(em)) + END FUNCTION ref + + SUBROUTINE check_identities() + REAL(wp) :: tri(3, 3, 2), direct, formula, cst, z(3) + INTEGER :: slot(3, 2) + CHARACTER(120) :: msg + + ! interior: beta = beta^n - Omega(a, b, c) - Omega(a, c, d) + direct = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(b, c, CD_HermiteTwist_Carry(a, b, u1n)), & + CD_HermiteTwist_Carry(d, c, u2n), c) + cst = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(a, d, u1n), u2n, d) + z = 0.0_wp + tri(:, :, 1) = RESHAPE([a, z, z], [3, 3]) + tri(:, :, 2) = RESHAPE([a, z, d], [3, 3]) + slot(:, 1) = [0, 1, 2] + slot(:, 2) = [0, 2, 0] + formula = cst + ref(tri, slot, [-1.0_wp, -1.0_wp], .FALSE.) + WRITE (msg, '(A,2ES12.4)') 'I interior element: direct vs formula ', direct, formula + CALL require(ABS(direct - formula) < 1.0e-13_wp, msg) + CALL require(ABS(direct - cst) > 1.0e-3_wp, 'I interior element: the step moves the reference twist') + + ! rigid End A: u_1 = G(dA -> b) nA; beta = angle(G(dA -> d) nA -> u2n) - Omega(dA, b, c) - Omega(dA, c, d) + direct = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(b, c, CD_HermiteTwist_Carry(dA, b, nA)), & + CD_HermiteTwist_Carry(d, c, u2n), c) + cst = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(dA, d, nA), u2n, d) + tri(:, :, 1) = RESHAPE([dA, z, z], [3, 3]) + tri(:, :, 2) = RESHAPE([dA, z, d], [3, 3]) + formula = cst + ref(tri, slot, [-1.0_wp, -1.0_wp], .FALSE.) + WRITE (msg, '(A,2ES12.4)') 'I rigid End A element: direct vs formula ', direct, formula + CALL require(ABS(direct - formula) < 1.0e-13_wp, msg) + + ! rigid End B: u_2 = G(dB -> c) nB; beta = angle(u1n -> G(dB -> a) nB) + Omega(dB, c, a) - Omega(a, b, c) + direct = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(b, c, CD_HermiteTwist_Carry(a, b, u1n)), & + CD_HermiteTwist_Carry(dB, c, nB), c) + cst = CD_HermiteTwist_Angle(u1n, CD_HermiteTwist_Carry(dB, a, nB), a) + tri(:, :, 1) = RESHAPE([dB, z, a], [3, 3]) + tri(:, :, 2) = RESHAPE([a, z, z], [3, 3]) + slot(:, 1) = [0, 2, 0] + slot(:, 2) = [0, 1, 2] + formula = cst + ref(tri, slot, [1.0_wp, -1.0_wp], .FALSE.) + WRITE (msg, '(A,2ES12.4)') 'I rigid End B element: direct vs formula ', direct, formula + CALL require(ABS(direct - formula) < 1.0e-13_wp, msg) + + ! one element rigid at both ends: beta = angle(nA -> G(dB -> dA) nB) + Omega(dB, c, dA) - Omega(dA, b, c) + direct = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(b, c, CD_HermiteTwist_Carry(dA, b, nA)), & + CD_HermiteTwist_Carry(dB, c, nB), c) + cst = CD_HermiteTwist_Angle(nA, CD_HermiteTwist_Carry(dB, dA, nB), dA) + tri(:, :, 1) = RESHAPE([dB, z, dA], [3, 3]) + tri(:, :, 2) = RESHAPE([dA, z, z], [3, 3]) + slot(:, 1) = [0, 2, 0] + slot(:, 2) = [0, 1, 2] + formula = cst + ref(tri, slot, [1.0_wp, -1.0_wp], .FALSE.) + WRITE (msg, '(A,2ES12.4)') 'I rigid at both ends: direct vs formula ', direct, formula + CALL require(ABS(direct - formula) < 1.0e-13_wp, msg) + + ! elastic End A link: psi = angle(u_1 -> G(dA -> b) nA) = angle(u1n -> G(dA -> a) nA) + Omega(dA, b, a) + direct = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(a, b, u1n), CD_HermiteTwist_Carry(dA, b, nA), b) + cst = CD_HermiteTwist_Angle(u1n, CD_HermiteTwist_Carry(dA, a, nA), a) + tri(:, :, 1) = RESHAPE([dA, z, a], [3, 3]) + slot(:, 1) = [0, 1, 0] + formula = cst + ref(tri(:, :, 1:1), slot(:, 1:1), [1.0_wp], .FALSE.) + WRITE (msg, '(A,2ES12.4)') 'I elastic end link: direct vs formula ', direct, formula + CALL require(ABS(direct - formula) < 1.0e-13_wp, msg) + END SUBROUTINE check_identities + + SUBROUTINE check_transport() + !! With the holonomy, value + beta^n is the angle from u_1 carried along the element's own + !! tangent field to u_2 (both time-transported), here with u_1 = u1n, u_2 = u2n and a = b, + !! d = c (no step). + INTEGER, PARAMETER :: NSUB = 20000 + REAL(wp) :: tri(3, 3, 2), z(3), v(3), tp(3), tc(3), x, hh(4), direct, formula, cst, ua(3), ub(3) + INTEGER :: slot(3, 2), k, es + REAL(wp) :: g(12), val + CHARACTER(200) :: em + CHARACTER(120) :: msg + z = 0.0_wp + ua = perp(u1n, b) + ub = perp(u2n, c) + v = ua + tp = b + DO k = 1, NSUB + x = REAL(k, wp)/REAL(NSUB, wp) + hh = [-6.0_wp*x + 6.0_wp*x*x, el*(1.0_wp - 4.0_wp*x + 3.0_wp*x*x), 6.0_wp*x - 6.0_wp*x*x, & + el*(-2.0_wp*x + 3.0_wp*x*x)] + tc = unit(hh(1)*qe(1:3) + hh(2)*qe(4:6) + hh(3)*qe(7:9) + hh(4)*qe(10:12)) + IF (k == NSUB) tc = c + v = CD_HermiteTwist_Carry(tp, tc, v) + tp = tc + END DO + direct = CD_HermiteTwist_Angle(v, ub, c) + cst = CD_HermiteTwist_Angle(CD_HermiteTwist_Carry(b, c, ua), ub, c) + tri(:, :, 1) = RESHAPE([b, z, z], [3, 3]) + tri(:, :, 2) = RESHAPE([b, z, c], [3, 3]) + slot(:, 1) = [0, 1, 2] + slot(:, 2) = [0, 2, 0] + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [-1.0_wp, -1.0_wp], val, g, es, em, quadrature_order=6) + CALL require(es == CD_HTORS_OK, 'T transport evaluation: '//TRIM(em)) + formula = cst + val + WRITE (msg, '(A,2ES14.6)') 'T element transport: fine transport vs beta - h_e ', direct, formula + CALL require(ABS(direct - formula) < 1.0e-6_wp, msg) + CALL require(ABS(direct - cst) > 1.0e-3_wp, 'T the element holonomy is not negligible on this element') + END SUBROUTINE check_transport + + SUBROUTINE check_derivatives() + REAL(wp) :: tri(3, 3, 2), z(3), g(12), h(12, 12), gp(12), gm(12), fg(3, 3, 2), vp, vm, v0, eps + REAL(wp) :: err_g, err_h, err_f, scale_g, scale_h, q0(12), w(3), x0(3), num + INTEGER :: slot(3, 2), i, es, k, j + CHARACTER(200) :: em + CHARACTER(120) :: msg + z = 0.0_wp + tri(:, :, 1) = RESHAPE([a, z, z], [3, 3]) + tri(:, :, 2) = RESHAPE([a, z, d], [3, 3]) + slot(:, 1) = [0, 1, 2] + slot(:, 2) = [0, 2, 0] + q0 = qe + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [-1.0_wp, -1.0_wp], v0, g, es, em, hess=h, fixed_grad=fg) + CALL require(es == CD_HTORS_OK, 'F evaluation: '//TRIM(em)) + eps = 1.0e-6_wp + err_g = 0.0_wp + err_h = 0.0_wp + scale_g = MAXVAL(ABS(g)) + scale_h = MAXVAL(ABS(h)) + DO i = 1, 12 + qe = q0 + qe(i) = q0(i) + eps + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [-1.0_wp, -1.0_wp], vp, gp, es, em) + qe(i) = q0(i) - eps + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [-1.0_wp, -1.0_wp], vm, gm, es, em) + err_g = MAX(err_g, ABS((vp - vm)/(2.0_wp*eps) - g(i))) + err_h = MAX(err_h, MAXVAL(ABS((gp - gm)/(2.0_wp*eps) - h(:, i)))) + END DO + qe = q0 + WRITE (msg, '(A,2ES10.2)') 'F gradient and Hessian relative errors ', err_g/scale_g, err_h/scale_h + CALL require(err_g/scale_g < 1.0e-7_wp .AND. err_h/scale_h < 1.0e-6_wp, msg) + CALL require(MAXVAL(ABS(h - TRANSPOSE(h))) < 1.0e-10_wp*scale_h, 'F the Hessian is symmetric') + ! fixed vertices: rotate each by a small angle about a few axes + err_f = 0.0_wp + DO k = 1, 2 + DO j = 1, 3 + IF (slot(j, k) /= 0) CYCLE + x0 = tri(:, j, k) + DO i = 1, 3 + w = 0.0_wp + w(i) = 1.0_wp + tri(:, j, k) = rotate(x0, eps*w) + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [-1.0_wp, -1.0_wp], vp, gp, es, em) + tri(:, j, k) = rotate(x0, -eps*w) + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [-1.0_wp, -1.0_wp], vm, gm, es, em) + tri(:, j, k) = x0 + num = (vp - vm)/(2.0_wp*eps) + err_f = MAX(err_f, ABS(num - DOT_PRODUCT(fg(:, j, k), cross(w, x0)))) + END DO + END DO + END DO + WRITE (msg, '(A,ES10.2)') 'F fixed-vertex gradient error ', err_f + CALL require(err_f < 1.0e-8_wp, msg) + END SUBROUTINE check_derivatives + + SUBROUTINE check_guards() + REAL(wp) :: tri(3, 3, 1), z(3), g(12), v + INTEGER :: slot(3, 1), es + CHARACTER(200) :: em + z = 0.0_wp + ! a committed tangent opposite to the node tangent: folded + tri(:, :, 1) = RESHAPE([-b, z, z], [3, 3]) + slot(:, 1) = [0, 1, 2] + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [1.0_wp], v, g, es, em) + CALL require(es == CD_HTORS_FOLD, 'G a reversed tangent fails with the fold status') + ! a non-unit fixed vertex + tri(:, :, 1) = RESHAPE([2.0_wp*a, z, z], [3, 3]) + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [1.0_wp], v, g, es, em) + CALL require(es == CD_HTORS_BADINPUT, 'G a non-unit fixed vertex is refused') + ! a bad slot + tri(:, :, 1) = RESHAPE([a, z, z], [3, 3]) + slot(:, 1) = [0, 3, 2] + CALL CD_HermiteTwist_Reference(qe, el, tri, slot, [1.0_wp], v, g, es, em) + CALL require(es == CD_HTORS_BADINPUT, 'G a vertex slot outside 0..2 is refused') + END SUBROUTINE check_guards + +END PROGRAM test_hermite_twist_kernel diff --git a/tests/test_nodal_twist_dynamic.f90 b/tests/test_nodal_twist_dynamic.f90 new file mode 100644 index 00000000..f4caa2fd --- /dev/null +++ b/tests/test_nodal_twist_dynamic.f90 @@ -0,0 +1,631 @@ +! File: tests/test_nodal_twist_dynamic.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_nodal_twist_dynamic + !! Gates of the nodal twist (a twist angle at every node, with the polar rotary inertia Irn) + !! on the cubic-Hermite cable, a 10 m line restrained in torsion at both ends: + !! Q quasi-static limit: with a negligible Irn the nodal twist reproduces the condensed + !! torsion on a bowed line that sways, rolls through more than a turn at its coupled end + !! and takes an imposed twist: the centreline, the mean and nodal torques, the coupled + !! end force and moment agree, for clamped ends, bending-pinned ends (the end tangent + !! moves off the end director) and elastic torsional ends; + !! W torsional waves: a straight line, clamped and rigid in torsion at both ends, driven in + !! roll at one end below its first torsional mode, carries at the other end the torque of + !! the continuum, GJ A k / sin(kL) with k = Omega sqrt(Irn/GJ); at kL = pi/2 the driven end's + !! reaction moment is zero, GJ A k cot(kL), its held section's polar inertia included, + !! for a roll of the parent and for an imposed twist; + !! D torsional damping: the first torsional mode rings down at zeta_1 = omega_1 Bt/(2 GJ); + !! a parent rolling its end frame at a steady rate Omega (negligible Irn) loads the held + !! end with (GJ theta + Bt Omega)/L, the damping of the frame's own turn included; + !! E energy: free vibration of a bowed, twisted line with a real Irn (rho_inf = 1): kinetic + !! (with the polar part) + elastic (with the twist) stays within the band of the line + !! without torsion; a parent rolling the clamped line's end frame at a steady rate puts + !! the continuum's polar kinetic energy into it, the held end section's spin included; + !! R restart: a rolling, torsionally damped run restored from a snapshot, and one rebuilt + !! from the checkpoint mirror, continue bit-identically. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & + CD_HTORS_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Energy, & + CD_HermiteCable_Dyn_End, CD_HermiteCable_Dyn_Set_EndConnection, & + CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Torsion_State, & + CD_HermiteCable_Dyn_Node_Torque, CD_HCDYN_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_Init, CD_HFMF_Set_EndConnection, & + CD_HFMF_Set_Torsion, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, & + CD_HFMF_Snapshot, CD_HFMF_Restore, CD_HFMF_MirrorSize, & + CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, CD_HFMF_End, CD_HFMF_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: LL = 10.0_wp, EA = 1.0e5_wp, EI = 100.0_wp, GJ = 80.0_wp, RHOA = 1.0_wp + INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDOF = 6*NN + INTEGER :: nfail = 0 + + CALL check_quasi_static('clamped', .FALSE., 0.0_wp) + CALL check_quasi_static('bending-pinned', .TRUE., 0.0_wp) + CALL check_quasi_static('elastic', .FALSE., 0.05_wp) + CALL check_waves() + CALL check_driven_end('parent roll') + CALL check_driven_end('imposed twist') + CALL check_damping() + CALL check_frame_damping() + CALL check_energy() + CALL check_frame_energy() + CALL check_restart() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: nodal twist 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 + + 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 + + SUBROUTINE line_seed(bow_y, bow_z, q) + !! Straight line along +x (node 1 at the origin), optionally bowed by y = bow_y sin^2(pi s/L), + !! z = bow_z sin^2(2 pi s/L) (end tangents stay along +x, as the clamps require). + REAL(wp), INTENT(IN) :: bow_y, bow_z + REAL(wp), INTENT(OUT) :: q(NDOF) + INTEGER :: k + REAL(wp) :: s + q = 0.0_wp + DO k = 1, NN + s = LL*REAL(k - 1, wp)/REAL(NE, wp) + q(6*k - 5) = s + q(6*k - 4) = bow_y*SIN(PI*s/LL)**2 + q(6*k - 3) = bow_z*SIN(2.0_wp*PI*s/LL)**2 + q(6*k - 2) = 1.0_wp + q(6*k - 1) = bow_y*(PI/LL)*SIN(2.0_wp*PI*s/LL) + q(6*k) = bow_z*(2.0_wp*PI/LL)*SIN(4.0_wp*PI*s/LL) + END DO + END SUBROUTINE line_seed + + SUBROUTINE torsion_of(q, phi, tors, irn, compliance, bt) + !! Torsion of the line: both ends along +x with reference normal +z, GJ on every element, + !! imposed twist phi, Theta of the seed q (branch nearest 0); irn > 0 adds the polar inertia + !! (nodal twist), compliance the torsional end compliances, bt the torsional damping. + REAL(wp), INTENT(IN) :: q(NDOF), phi, irn, compliance + TYPE(CD_HermiteTorsionType), INTENT(OUT) :: tors + REAL(wp), INTENT(IN), OPTIONAL :: bt + REAL(wp) :: g(NDOF), raw, l0(NE) + INTEGER :: es + CHARACTER(200) :: em + l0 = LL/REAL(NE, wp) + tors%active = .TRUE. + tors%phi = phi + tors%ends = RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp], [3, 4]) + tors%end_compliance = compliance + ALLOCATE (tors%gj(NE)) + tors%gj = GJ + IF (irn > 0.0_wp) THEN + ALLOCATE (tors%irn(NE)) + tors%irn = irn + END IF + IF (PRESENT(bt)) THEN + ALLOCATE (tors%bt(NE)) + tors%bt = bt + END IF + CALL CD_HermiteTorsion_Line(q, l0, tors%ends, raw, g, es, em) + CALL require(es == CD_HTORS_OK, 'seed twist evaluates: '//TRIM(em)) + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + END SUBROUTINE torsion_of + + SUBROUTINE build_cable(cab, q, phi, dt, tol, rho_inf, pinned, irn, compliance, bt) + !! HFMF cable on seed q: node NN coupled (driven), node 1 held; Rigid bending connections + !! along +x at both ends (none with pinned), the coupled one in parent axes (identity + !! attitude); torsion with the coupled end's frame attached to the parent (damping bt). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + REAL(wp), INTENT(IN) :: q(NDOF), phi, dt, tol, rho_inf, irn, compliance + LOGICAL, INTENT(IN) :: pinned + REAL(wp), INTENT(IN), OPTIONAL :: bt + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: l0(NE), eye(3, 3), frame(3, 2) + INTEGER :: es + CHARACTER(300) :: em + l0 = LL/REAL(NE, wp) + eye = roll_x(0.0_wp) + CALL CD_HFMF_Init(cab, l0, [(EA, es=1, NE)], [(EI, es=1, NE)], [(RHOA, es=1, NE)], [(0.0_wp, es=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, rho_inf, dt, NN, es, em, & + max_iter=60, tol=tol) + CALL require(es == CD_HFMF_OK, 'cable init: '//TRIM(em)) + IF (.NOT. pinned) THEN + CALL CD_HFMF_Set_EndConnection(cab, [0.0_wp, 0.0_wp], RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], & + [3, 2]), es, em, & + coupled_d0_parent=[1.0_wp, 0.0_wp, 0.0_wp], parent_orientation=eye, & + connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + CALL require(es == CD_HFMF_OK, 'cable end connections: '//TRIM(em)) + END IF + CALL torsion_of(q, phi, tors, irn, compliance, bt) + frame(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] + frame(:, 2) = [0.0_wp, 0.0_wp, 1.0_wp] + CALL CD_HFMF_Set_Torsion(cab, tors, es, em, coupled_frame_parent=frame, parent_orientation=eye) + CALL require(es == CD_HFMF_OK, 'cable torsion: '//TRIM(em)) + END SUBROUTINE build_cable + + SUBROUTINE drive(k, x, v, a, dcm, w, al, phi) + !! Coupled-end drive: a lateral sway with a roll of the parent about the line axis (3 rad/s, + !! more than a turn by step 250) and an imposed twist following it. + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: x(3), v(3), a(3), dcm(3, 3), w(3), al(3), phi + REAL(wp), PARAMETER :: DT = 0.01_wp, AMP = 0.05_wp, OM = 2.0_wp, ROLL_RATE = 3.0_wp + REAL(wp) :: t + t = DT*REAL(k, wp) + x = [LL, AMP*SIN(OM*t), 0.0_wp] + v = [0.0_wp, AMP*OM*COS(OM*t), 0.0_wp] + a = [0.0_wp, -AMP*OM*OM*SIN(OM*t), 0.0_wp] + dcm = roll_x(ROLL_RATE*t) + w = [ROLL_RATE, 0.0_wp, 0.0_wp] + al = 0.0_wp + phi = 1.0_wp - ROLL_RATE*t + 0.5_wp*SIN(OM*t) + END SUBROUTINE drive + + SUBROUTINE march(cab, k0, k1, ok) + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + INTEGER, INTENT(IN) :: k0, k1 + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: x(3), v(3), a(3), dcm(3, 3), w(3), al(3), phi + INTEGER :: k, es + CHARACTER(300) :: em + ok = .TRUE. + DO k = k0 + 1, k1 + CALL drive(k, x, v, a, dcm, w, al, phi) + CALL CD_HFMF_UpdateStates(cab, x, v, a, es, em, u_orientation=dcm, u_angular_velocity=w, & + u_angular_acceleration=al, u_twist=phi) + IF (es /= CD_HFMF_OK) THEN + WRITE (*, '(A,I0,A)') ' march step ', k, ': '//TRIM(em) + ok = .FALSE. + RETURN + END IF + END DO + END SUBROUTINE march + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_quasi_static(label, pinned, compliance) + !! Q: the nodal twist with Irn = 1e-9 kg m against the condensed torsion on the same run. + CHARACTER(*), INTENT(IN) :: label + LOGICAL, INTENT(IN) :: pinned + REAL(wp), INTENT(IN) :: compliance + INTEGER, PARAMETER :: NSTEP = 300 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cc, cn + REAL(wp) :: q(NDOF), x(3), v(3), a(3), dcm(3, 3), w(3), al(3), phi, fc(3), mc(3), fn(3), mn(3) + REAL(wp) :: err_q, err_t, err_n, err_f, err_m, mref, thc, mtc, thn, mtn, ntq(NN) + INTEGER :: k, es, esc, esn + CHARACTER(300) :: em + ALLOCATE (cc, cn) + CALL line_seed(0.3_wp, 0.1_wp, q) + CALL build_cable(cc, q, 1.0_wp, 0.01_wp, 1.0e-10_wp, 0.8_wp, pinned, 0.0_wp, compliance) + CALL build_cable(cn, q, 1.0_wp, 0.01_wp, 1.0e-10_wp, 0.8_wp, pinned, 1.0e-9_wp, compliance) + CALL require(cn%line%tw_active .AND. .NOT. cc%line%tw_active, 'Q '//label//': the nodal twist is active') + err_q = 0.0_wp + err_t = 0.0_wp + err_n = 0.0_wp + err_f = 0.0_wp + err_m = 0.0_wp + mref = GJ/LL + DO k = 1, NSTEP + CALL drive(k, x, v, a, dcm, w, al, phi) + CALL CD_HFMF_UpdateStates(cc, x, v, a, esc, em, u_orientation=dcm, u_angular_velocity=w, & + u_angular_acceleration=al, u_twist=phi) + CALL require(esc == CD_HFMF_OK, 'Q '//label//': condensed step: '//TRIM(em)) + CALL CD_HFMF_UpdateStates(cn, x, v, a, esn, em, u_orientation=dcm, u_angular_velocity=w, & + u_angular_acceleration=al, u_twist=phi) + CALL require(esn == CD_HFMF_OK, 'Q '//label//': nodal step: '//TRIM(em)) + IF (esc /= CD_HFMF_OK .OR. esn /= CD_HFMF_OK) EXIT + err_q = nan_max_abs([err_q, nan_max_abs(cn%line%q - cc%line%q)]) + CALL CD_HermiteCable_Dyn_Torsion_State(cc%line, thc, mtc, es, em) + CALL CD_HermiteCable_Dyn_Torsion_State(cn%line, thn, mtn, es, em) + err_t = nan_max_abs([err_t, ABS(mtn - mtc)/mref]) + CALL CD_HermiteCable_Dyn_Node_Torque(cn%line, ntq, es, em) + err_n = nan_max_abs([err_n, nan_max_abs(ntq - mtc)/mref]) + CALL CD_HFMF_CalcOutput(cc, fc, es, em, y_moment=mc) + CALL CD_HFMF_CalcOutput(cn, fn, es, em, y_moment=mn) + err_f = nan_max_abs([err_f, NORM2(fn - fc)/MAX(1.0_wp, NORM2(fc))]) + err_m = nan_max_abs([err_m, NORM2(mn - mc)/MAX(mref, NORM2(mc))]) + END DO + WRITE (*, '(A,A,A,5ES10.2)') 'Q quasi-static limit (', label, '): q, torque, node torque, end force, '// & + 'end moment ', err_q, err_t, err_n, err_f, err_m + CALL require(err_q <= 1.0e-7_wp, 'Q '//label//': the centreline follows the condensed torsion') + CALL require(err_t <= 1.0e-6_wp, 'Q '//label//': the mean torque is the condensed torque') + CALL require(err_n <= 1.0e-6_wp, 'Q '//label//': every node carries the condensed torque') + CALL require(err_f <= 1.0e-6_wp, 'Q '//label//': the coupled end force agrees') + CALL require(err_m <= 1.0e-6_wp, 'Q '//label//': the coupled end moment agrees') + CALL CD_HFMF_End(cc) + CALL CD_HFMF_End(cn) + END SUBROUTINE check_quasi_static + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_waves() + !! W: a roll A sin(Omega t) of the coupled end (amplitude ramped in over the first eight + !! periods) below the first torsional mode of the clamped line, Irn = 0.5 kg m; after the + !! ramp the held end's torque swings with the continuum's amplitude GJ A k / sin(kL). + REAL(wp), PARAMETER :: IRN = 0.5_wp, AMPR = 0.2_wp + INTEGER, PARAMETER :: NPER_RAMP = 8, NPER = 14, NPP = 200 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab + REAL(wp) :: q(NDOF), c, om1, om, dt, t, env, ang, x(3), kw, ntq(NN), tmax, tmin, expect, ramp_t + INTEGER :: k, es, nstep + CHARACTER(300) :: em + ALLOCATE (cab) + c = SQRT(GJ/IRN) + om1 = PI*c/LL + om = 0.5_wp*om1 + dt = 2.0_wp*PI/om/REAL(NPP, wp) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL build_cable(cab, q, 0.0_wp, dt, 1.0e-10_wp, 0.9_wp, .FALSE., IRN, 0.0_wp) + x = q(NDOF - 5:NDOF - 3) + nstep = NPER*NPP + ramp_t = REAL(NPER_RAMP, wp)*2.0_wp*PI/om + tmax = -HUGE(1.0_wp) + tmin = HUGE(1.0_wp) + DO k = 1, nstep + t = dt*REAL(k, wp) + env = MIN(t/ramp_t, 1.0_wp) + env = env**3*(10.0_wp - 15.0_wp*env + 6.0_wp*env**2) + ang = AMPR*env*SIN(om*t) + CALL CD_HFMF_UpdateStates(cab, x, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(ang)) + CALL require(es == CD_HFMF_OK, 'W: step: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + IF (t > ramp_t + 2.0_wp*PI/om) THEN + CALL CD_HermiteCable_Dyn_Node_Torque(cab%line, ntq, es, em) + tmax = MAX(tmax, ntq(1)) + tmin = MIN(tmin, ntq(1)) + END IF + END DO + kw = om/c + expect = GJ*AMPR*kw/SIN(kw*LL) + WRITE (*, '(A,F8.4,A,2ES14.6,A,ES14.6)') 'W torsional wave (Omega/omega_1 = ', om/om1, & + '): held-end torque swing ', 0.5_wp*(tmax - tmin), 0.5_wp*(tmax + tmin), ' expected amplitude ', expect + CALL require(ABS(0.5_wp*(tmax - tmin) - expect) <= 1.0e-2_wp*expect, & + 'W: the held end carries the continuum torque GJ A k / sin(kL)') + CALL require(ABS(0.5_wp*(tmax + tmin)) <= 1.0e-2_wp*expect, 'W: the torque swings about zero') + CALL CD_HFMF_End(cab) + END SUBROUTINE check_waves + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_driven_end(label) + !! W: the drive of check_waves at Omega = omega_1/2 (kL = pi/2), by the parent's roll or by + !! the imposed twist: the continuum's torque at the driven end, GJ A k cos(kL)/sin(kL), is + !! zero, so the axial reaction moment there swings only by the discretisation; without the + !! held end section's inertia (Irn l0/2) it would swing by Irn l0/2 Omega^2 A, 4 % of + !! GJ A k here. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), PARAMETER :: IRN = 0.5_wp, AMPR = 0.2_wp + INTEGER, PARAMETER :: NPER_RAMP = 8, NPER = 14, NPP = 200 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab + REAL(wp) :: q(NDOF), c, om, dt, t, env, ang, x(3), f(3), m(3), mmax, mmin, scale, ramp_t + INTEGER :: k, es + CHARACTER(300) :: em + ALLOCATE (cab) + c = SQRT(GJ/IRN) + om = 0.5_wp*PI*c/LL + dt = 2.0_wp*PI/om/REAL(NPP, wp) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL build_cable(cab, q, 0.0_wp, dt, 1.0e-10_wp, 0.9_wp, .FALSE., IRN, 0.0_wp) + x = q(NDOF - 5:NDOF - 3) + ramp_t = REAL(NPER_RAMP, wp)*2.0_wp*PI/om + mmax = -HUGE(1.0_wp) + mmin = HUGE(1.0_wp) + DO k = 1, NPER*NPP + t = dt*REAL(k, wp) + env = MIN(t/ramp_t, 1.0_wp) + env = env**3*(10.0_wp - 15.0_wp*env + 6.0_wp*env**2) + ang = AMPR*env*SIN(om*t) + IF (label == 'parent roll') THEN + CALL CD_HFMF_UpdateStates(cab, x, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(ang)) + ELSE + CALL CD_HFMF_UpdateStates(cab, x, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(0.0_wp), u_twist=ang) + END IF + CALL require(es == CD_HFMF_OK, 'W '//label//': step: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + IF (t > ramp_t + 2.0_wp*PI/om) THEN + CALL CD_HFMF_CalcOutput(cab, f, es, em, y_moment=m) + mmax = MAX(mmax, m(1)) + mmin = MIN(mmin, m(1)) + END IF + END DO + scale = GJ*AMPR*(om/c) + WRITE (*, '(A,A,A,ES12.4,A,ES12.4)') 'W driven end at kL = pi/2 (', label, '): axial reaction swing ', & + 0.5_wp*(mmax - mmin), ' of GJ A k ', scale + CALL require(0.5_wp*(mmax - mmin) <= 1.0e-2_wp*scale, & + 'W '//label//': the driven end reacts with the continuum torque, its section inertia included') + CALL CD_HFMF_End(cab) + END SUBROUTINE check_driven_end + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_damping() + !! D: torsional damping Bt (torque Bt dtau/dt) is stiffness-proportional, so the first + !! torsional mode of the clamped line has zeta_1 = omega_1 Bt/(2 GJ). The coupled end rolls + !! by 0.2 rad in a quarter period of that mode and holds; the held end's torque then rings + !! down about GJ 0.2/L with the logarithmic decrement 2 pi zeta_1/sqrt(1 - zeta_1^2) of the + !! first mode (the higher modes, damped in proportion to their frequency, die first). + REAL(wp), PARAMETER :: IRN = 0.5_wp, ZETA = 0.05_wp, ROLL = 0.2_wp + INTEGER, PARAMETER :: NPP = 400, NPER = 12 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), c, om1, dt, t, ang, x(3), ntq(NN), bt, mst, prev, prev2, delta, expect, tq + REAL(wp) :: peaks(64), l0(NE), eye(3, 3), frame(3, 2) + INTEGER :: k, es, npk + CHARACTER(300) :: em + ALLOCATE (cab) + c = SQRT(GJ/IRN) + om1 = PI*c/LL + bt = 2.0_wp*GJ*ZETA/om1 + dt = 2.0_wp*PI/om1/REAL(NPP, wp) + l0 = LL/REAL(NE, wp) + eye = roll_x(0.0_wp) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL CD_HFMF_Init(cab, l0, [(EA, es=1, NE)], [(EI, es=1, NE)], [(RHOA, es=1, NE)], [(0.0_wp, es=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, 1.0_wp, dt, NN, es, em, & + max_iter=60, tol=1.0e-10_wp) + CALL CD_HFMF_Set_EndConnection(cab, [0.0_wp, 0.0_wp], RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], & + [3, 2]), es, em, & + coupled_d0_parent=[1.0_wp, 0.0_wp, 0.0_wp], parent_orientation=eye, & + connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + CALL torsion_of(q, 0.0_wp, tors, IRN, 0.0_wp) + ALLOCATE (tors%bt(NE)) + tors%bt = bt + frame(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] + frame(:, 2) = [0.0_wp, 0.0_wp, 1.0_wp] + CALL CD_HFMF_Set_Torsion(cab, tors, es, em, coupled_frame_parent=frame, parent_orientation=eye) + CALL require(es == CD_HFMF_OK, 'D: damped torsion: '//TRIM(em)) + x = q(NDOF - 5:NDOF - 3) + mst = GJ*ROLL/LL + npk = 0 + prev = 0.0_wp + prev2 = 0.0_wp + DO k = 1, NPER*NPP + t = dt*REAL(k, wp) + ang = ROLL*MIN(1.0_wp, t/(0.25_wp*2.0_wp*PI/om1)) + CALL CD_HFMF_UpdateStates(cab, x, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(ang)) + CALL require(es == CD_HFMF_OK, 'D: step: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + CALL CD_HermiteCable_Dyn_Node_Torque(cab%line, ntq, es, em) + tq = ntq(1) - mst + ! local maxima of the deviation after the first two periods + IF (k > 2 .AND. t > 2.0_wp*2.0_wp*PI/om1 .AND. prev > prev2 .AND. prev >= tq .AND. prev > 0.0_wp) THEN + IF (npk < SIZE(peaks)) THEN + npk = npk + 1 + peaks(npk) = prev + END IF + END IF + prev2 = prev + prev = tq + END DO + CALL require(npk >= 4, 'D: the torque rings down through several periods') + IF (npk < 4) RETURN + delta = LOG(peaks(1)/peaks(4))/3.0_wp + expect = 2.0_wp*PI*ZETA/SQRT(1.0_wp - ZETA**2) + WRITE (*, '(A,F8.5,A,F8.5,A,ES10.3)') 'D torsional damping: logarithmic decrement ', delta, ' expected ', & + expect, '; mean torque - GJ roll/L ', ntq(1) - mst + CALL require(ABS(delta - expect) <= 0.1_wp*expect, 'D: the first torsional mode decays at zeta = omega Bt/(2 GJ)') + CALL CD_HFMF_End(cab) + END SUBROUTINE check_damping + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_frame_damping() + !! D: the straight clamped line with Irn = 1e-9 kg m and Bt = 40 N m2 s; the parent rolls the + !! coupled end's frame (the imposed twist stays 0) at a rate eased in to OMR over 1 s, then + !! steady. Every element carries the torque, so the held end reads (GJ theta + Bt theta_dot)/L + !! with theta the parent's roll: the damping of the twist the frame's turn puts into the end + !! element (a sixth of the torque here) included. + REAL(wp), PARAMETER :: BT = 40.0_wp, OMR = 0.5_wp, TR = 1.0_wp, DT = 0.01_wp + INTEGER, PARAMETER :: NSTEP = 300 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab + REAL(wp) :: q(NDOF), x(3), t, ang, rate, ntq(NN), expect, err, mref + INTEGER :: k, es + CHARACTER(300) :: em + ALLOCATE (cab) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL build_cable(cab, q, 0.0_wp, DT, 1.0e-11_wp, 0.8_wp, .FALSE., 1.0e-9_wp, 0.0_wp, bt=BT) + x = q(NDOF - 5:NDOF - 3) + err = 0.0_wp + mref = (GJ*OMR*REAL(NSTEP, wp)*DT + BT*OMR)/LL + DO k = 1, NSTEP + t = DT*REAL(k, wp) + IF (t < TR) THEN + ang = OMR*(t**3/TR**2 - 0.5_wp*t**4/TR**3) + rate = OMR*(3.0_wp*t**2/TR**2 - 2.0_wp*t**3/TR**3) + ELSE + ang = OMR*(t - 0.5_wp*TR) + rate = OMR + END IF + CALL CD_HFMF_UpdateStates(cab, x, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(ang)) + CALL require(es == CD_HFMF_OK, 'D frame: step: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + IF (t > TR + 0.5_wp) THEN + CALL CD_HermiteCable_Dyn_Node_Torque(cab%line, ntq, es, em) + expect = (GJ*ang + BT*rate)/LL + err = MAX(err, MAXVAL(ABS(ABS(ntq) - expect))/mref) + END IF + END DO + WRITE (*, '(A,ES10.3,A,ES12.5,A,ES12.5)') 'D frame-driven damping: node torques against (GJ theta + Bt Omega)/L ', & + err, '; held end ', ntq(1), ', elastic part ', GJ*ang/LL + CALL require(err <= 1.0e-4_wp, 'D: a turning end frame loads the line with its torsional damping') + CALL CD_HFMF_End(cab) + END SUBROUTINE check_frame_damping + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE energy_run(phi, irn, band, e_vib) + !! Free vibration of the bowed line clamped at both ends (no gravity, no fluid), rho_inf = 1, + !! ten periods of the first bending mode; band = (max - min) of kinetic + elastic over the + !! run, relative to the vibration energy above the straight twisted state. + REAL(wp), INTENT(IN) :: phi, irn + REAL(wp), INTENT(OUT) :: band, e_vib + TYPE(CD_HermiteCableDynType) :: m + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), l0(NE), ke, se, e0, emax, emin, t1, dt, e_straight + INTEGER :: k, es, nstep + CHARACTER(300) :: em + l0 = LL/REAL(NE, wp) + CALL line_seed(0.05_wp, 0.03_wp, q) + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(RHOA, k=1, NE)], [(0.0_wp, k=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, 1.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'E: init: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Set_EndConnection(m, [0.0_wp, 0.0_wp], & + RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + es, em, connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + CALL require(es == CD_HCDYN_OK, 'E: end connections: '//TRIM(em)) + e_straight = 0.0_wp + IF (phi > 0.0_wp) THEN + CALL torsion_of(q, phi, tors, irn, 0.0_wp) + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + CALL require(es == CD_HCDYN_OK, 'E: torsion: '//TRIM(em)) + e_straight = 0.5_wp*(LL/GJ)*(GJ*phi/LL)**2 + END IF + t1 = 2.0_wp*PI/(22.373_wp*SQRT(EI/(RHOA*LL**4))) + dt = t1/400.0_wp + nstep = 4000 + CALL CD_HermiteCable_Dyn_Energy(m, ke, se, es, em) + e0 = ke + se + e_vib = e0 - e_straight + emax = e0 + emin = e0 + DO k = 1, nstep + CALL CD_HermiteCable_Dyn_Step(m, dt, 40, 1.0e-10_wp, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'E: step: '//TRIM(em)) + EXIT + END IF + CALL CD_HermiteCable_Dyn_Energy(m, ke, se, es, em) + emax = nan_max_abs([emax, ke + se]) + emin = MIN(emin, ke + se) + END DO + band = (emax - emin)/e_vib + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE energy_run + + SUBROUTINE check_energy() + REAL(wp) :: band0, band1, ev0, ev1 + CALL energy_run(0.0_wp, 0.0_wp, band0, ev0) + CALL energy_run(4.0_wp, 0.02_wp, band1, ev1) + WRITE (*, '(A,ES10.3,A,ES10.3,A)') 'E energy band over 10 periods (rho_inf = 1): nodal twist ', band1, & + ', untwisted ', band0, ' of the vibration energy' + CALL require(band1 <= 5.0e-3_wp, 'E: kinetic + elastic energy with the nodal twist conserved within 0.5 %') + END SUBROUTINE check_energy + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_frame_energy() + !! E: the straight clamped line with Irn = 0.5 kg m and Bt = 10 N m2 s (zeta_1 = 0.25); the + !! parent rolls the coupled end's frame (the imposed twist stays 0) at a rate eased in to OMR + !! over 5 s, then steady. The sections spin as the continuum's, OMR s/L, so the kinetic + !! energy is 1/2 sum I_j (OMR s_j/L)^2 over the lumped polar inertias, the held end's + !! (I l0/2, its section spinning at OMR with a held angle) 7 % of it here. + REAL(wp), PARAMETER :: IRN = 0.5_wp, BT = 10.0_wp, OMR = 0.5_wp, TR = 5.0_wp, DT = 0.01_wp + INTEGER, PARAMETER :: NSTEP = 1000 + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab + REAL(wp) :: q(NDOF), x(3), t, ang, ke, se, expect, err, l0, mj + INTEGER :: k, j, es + CHARACTER(300) :: em + ALLOCATE (cab) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL build_cable(cab, q, 0.0_wp, DT, 1.0e-11_wp, 0.8_wp, .FALSE., IRN, 0.0_wp, bt=BT) + x = q(NDOF - 5:NDOF - 3) + l0 = LL/REAL(NE, wp) + expect = 0.0_wp + DO j = 1, NN + mj = MERGE(0.5_wp, 1.0_wp, j == 1 .OR. j == NN)*IRN*l0 + expect = expect + 0.5_wp*mj*(OMR*REAL(j - 1, wp)/REAL(NE, wp))**2 + END DO + err = 0.0_wp + DO k = 1, NSTEP + t = DT*REAL(k, wp) + IF (t < TR) THEN + ang = OMR*(t**3/TR**2 - 0.5_wp*t**4/TR**3) + ELSE + ang = OMR*(t - 0.5_wp*TR) + END IF + CALL CD_HFMF_UpdateStates(cab, x, [0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], es, em, & + u_orientation=roll_x(ang)) + CALL require(es == CD_HFMF_OK, 'E frame: step: '//TRIM(em)) + IF (es /= CD_HFMF_OK) EXIT + IF (t > 0.8_wp*REAL(NSTEP, wp)*DT) THEN + CALL CD_HermiteCable_Dyn_Energy(cab%line, ke, se, es, em) + CALL require(es == CD_HCDYN_OK, 'E frame: energy: '//TRIM(em)) + err = MAX(err, ABS(ke - expect)/expect) + END IF + END DO + WRITE (*, '(A,ES10.3,A,ES12.5)') 'E frame-driven spin: kinetic energy against the continuum''s ', err, & + ' of ', expect + CALL require(err <= 1.0e-2_wp, 'E: a held end section spinning with its frame carries its kinetic energy') + CALL CD_HFMF_End(cab) + END SUBROUTINE check_frame_energy + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_restart() + !! R: 150 steps, snapshot, 100 more; restore and redo the 100: identical. A fresh module + !! rebuilt from the mirror at step 150 continues identically too. + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab, cab2 + REAL(wp) :: q(NDOF), qref(NDOF), pref(NN), qb(NDOF), pb(NN) + REAL(wp), ALLOCATABLE :: mirror(:) + INTEGER :: es + LOGICAL :: ok + CHARACTER(300) :: em + ALLOCATE (cab, cab2) + CALL line_seed(0.3_wp, 0.1_wp, q) + CALL build_cable(cab, q, 1.0_wp, 0.01_wp, 1.0e-10_wp, 0.8_wp, .FALSE., 0.05_wp, 0.0_wp, bt=0.5_wp) + CALL march(cab, 0, 150, ok) + CALL require(ok, 'R: first leg') + CALL CD_HFMF_Snapshot(cab, es, em) + CALL require(es == CD_HFMF_OK, 'R: snapshot: '//TRIM(em)) + ALLOCATE (mirror(CD_HFMF_MirrorSize(cab))) + CALL CD_HFMF_PackMirror(cab, mirror, es, em) + CALL require(es == CD_HFMF_OK, 'R: mirror pack: '//TRIM(em)) + CALL march(cab, 150, 250, ok) + CALL require(ok, 'R: second leg') + qref = cab%line%q + pref = cab%line%tw_phi + CALL CD_HFMF_Restore(cab, es, em) + CALL require(es == CD_HFMF_OK, 'R: restore: '//TRIM(em)) + CALL march(cab, 150, 250, ok) + qb = cab%line%q + pb = cab%line%tw_phi + CALL require(ok .AND. ALL(bits(qb) == bits(qref)) .AND. ALL(bits(pb) == bits(pref)), & + 'R: the restored run continues bit-identically') + CALL line_seed(0.3_wp, 0.1_wp, q) + CALL build_cable(cab2, q, 1.0_wp, 0.01_wp, 1.0e-10_wp, 0.8_wp, .FALSE., 0.05_wp, 0.0_wp, bt=0.5_wp) + CALL CD_HFMF_UnpackMirror(cab2, mirror, 1.5_wp, es, em) + CALL require(es == CD_HFMF_OK, 'R: mirror reload: '//TRIM(em)) + CALL march(cab2, 150, 250, ok) + CALL require(ok .AND. ALL(bits(cab2%line%q) == bits(qref)) .AND. ALL(bits(cab2%line%tw_phi) == bits(pref)), & + 'R: the run rebuilt from the mirror continues bit-identically') + WRITE (*, '(A,F10.4,A)') 'R restart: end twist angle ', pref(NN), ' rad, snapshot and mirror runs identical' + CALL CD_HFMF_End(cab) + CALL CD_HFMF_End(cab2) + END SUBROUTINE check_restart + + ELEMENTAL INTEGER(8) FUNCTION bits(x) + REAL(wp), INTENT(IN) :: x + bits = TRANSFER(x, 0_8) + END FUNCTION bits + +END PROGRAM test_nodal_twist_dynamic diff --git a/tests/test_step_allocations.f90 b/tests/test_step_allocations.f90 index 13e16441..e5bc065c 100644 --- a/tests/test_step_allocations.f90 +++ b/tests/test_step_allocations.f90 @@ -21,10 +21,12 @@ PROGRAM test_step_allocations !! coupled end swaying while the parent rolls about the line axis and the imposed twist !! changes, so every step evaluates the twist kernel, its Hessian and the bordered solve. The !! committed-state outputs (CD_HFMF_SetCoupledKinematics, CD_HFMF_CalcOutput with the connection - !! moment, both end forces, the energy and the torque query) are gated as well. + !! moment, both end forces, the energy and the torque query) are gated as well. With "nodal" + !! the same cable carries the nodal twist (polar inertia and torsional damping), with its + !! 7-DOF-per-node band and the node-torque and element-twist queries. !! !! Usage: test_step_allocations [ranges] - !! test_step_allocations torsion + !! test_step_allocations torsion | nodal USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_LONG_LONG USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -33,7 +35,8 @@ PROGRAM test_step_allocations CD_HFMF_Set_Torsion, CD_HFMF_UpdateStates, CD_HFMF_CalcOutput, CD_HFMF_End, & CD_HFMF_SetCoupledKinematics USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HermiteCable_Dyn_Energy, & - CD_HermiteCable_Dyn_Torsion_State + CD_HermiteCable_Dyn_Torsion_State, CD_HermiteCable_Dyn_Node_Torque, & + CD_HermiteCable_Dyn_Element_Twist USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & CD_AGG_NFluidNodes, CD_AGG_NumChannels, CD_AGG_GetMovingPointMesh, & CD_AGG_Snapshot, CD_AGG_SetFluidFields, CD_AGG_Step_Moving, & @@ -64,8 +67,8 @@ END SUBROUTINE cd_test_allocation_counting IF (COMMAND_ARGUMENT_COUNT() == 1) THEN CALL GET_COMMAND_ARGUMENT(1, arg) - IF (TRIM(arg) /= 'torsion') ERROR STOP 'a single argument must be "torsion"' - CALL torsion_gate() + IF (TRIM(arg) /= 'torsion' .AND. TRIM(arg) /= 'nodal') ERROR STOP 'a single argument must be "torsion" or "nodal"' + CALL torsion_gate(TRIM(arg) == 'nodal') STOP END IF IF (COMMAND_ARGUMENT_COUNT() /= 3 .AND. COMMAND_ARGUMENT_COUNT() /= 4) THEN @@ -169,14 +172,16 @@ SUBROUTINE march(first_step, count, counted) END DO END SUBROUTINE march - SUBROUTINE torsion_gate() - !! Zero heap allocation in CD_HFMF_UpdateStates of a cable with condensed torsion. + SUBROUTINE torsion_gate(nodal) + !! Zero heap allocation in CD_HFMF_UpdateStates of a cable with condensed torsion, or with the + !! nodal twist. + LOGICAL, INTENT(IN) :: nodal INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDOF = 6*NN, N_WARM = 40, N_COUNT = 200 REAL(wp), PARAMETER :: LL = 10.0_wp, DTT = 0.01_wp TYPE(CD_HFMF_ModuleType) :: cab TYPE(CD_HermiteTorsionType) :: tors REAL(wp) :: q(NDOF), l0(NE), eye(3, 3), frame(3, 2), t, x(3), v(3), a(3), dcm(3, 3), f(3), m(3), psi - REAL(wp) :: fe(3), ke, se, th, mt + REAL(wp) :: fe(3), ke, se, th, mt, ntq(NN), etw(NE) INTEGER :: k INTEGER(C_LONG_LONG) :: c0, n_alloc, n_out, n_energy n_out = 0 @@ -206,6 +211,11 @@ SUBROUTINE torsion_gate() 0.0_wp, 0.0_wp, 1.0_wp], [3, 4]) ALLOCATE (tors%gj(NE)) tors%gj = 80.0_wp + IF (nodal) THEN + ALLOCATE (tors%irn(NE), tors%bt(NE)) + tors%irn = 0.05_wp + tors%bt = 0.5_wp + END IF tors%has_theta = .TRUE. frame(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] frame(:, 2) = [0.0_wp, 0.0_wp, 1.0_wp] @@ -241,6 +251,8 @@ SUBROUTINE torsion_gate() IF (es == 0) CALL CD_HermiteCable_Dyn_End_Force(cab%line, 1, fe, es, em) IF (es == 0) CALL CD_HermiteCable_Dyn_End_Force(cab%line, NN, fe, es, em) IF (es == 0) CALL CD_HermiteCable_Dyn_Torsion_State(cab%line, th, mt, es, em) + IF (es == 0 .AND. nodal) CALL CD_HermiteCable_Dyn_Node_Torque(cab%line, ntq, es, em) + IF (es == 0 .AND. nodal) CALL CD_HermiteCable_Dyn_Element_Twist(cab%line, etw, es, em) CALL cd_test_allocation_counting(0_C_INT) CALL check('torsion cable output') n_out = n_out + (cd_test_allocation_count() - c0) @@ -254,6 +266,7 @@ SUBROUTINE torsion_gate() CALL check('torsion cable energy') IF (k > N_WARM) n_energy = MAX(n_energy, cd_test_allocation_count() - c0) END DO + IF (nodal .AND. .NOT. cab%line%tw_active) ERROR STOP 'the nodal gate runs without the nodal twist' CALL CD_HFMF_End(cab) PRINT '(A,I0,A,I0,A,I0,A)', 'torsion cable: ', N_COUNT, ' counted steps, ', n_alloc, & ' heap allocations in the steps, ', n_out, ' in the outputs' diff --git a/tests/test_torsion_coupling.f90 b/tests/test_torsion_coupling.f90 index e47055bf..75e8fdcd 100644 --- a/tests/test_torsion_coupling.f90 +++ b/tests/test_torsion_coupling.f90 @@ -22,6 +22,9 @@ PROGRAM test_torsion_coupling !! 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). + !! 9. The march with the torsional damping of GJ|K|Bt: a damping ratio (Bt < 0) gives the + !! run of the Bt it resolves to, -Bt l0 sqrt(GJ Irn), bit for bit; a fourth part of the + !! GJ column fails closed. 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 @@ -40,6 +43,7 @@ PROGRAM test_torsion_coupling CALL check_pretwist() CALL check_zero_and_refusal() CALL check_dynamic() + CALL check_damping_grammar() CALL check_recovery() CALL check_compression() CALL check_aggregate() @@ -297,6 +301,65 @@ SUBROUTINE check_aggregate() CALL CD_AGG_End(agg, es, em) END SUBROUTINE check_aggregate + SUBROUTINE check_damping_grammar() + !! The march of check_dynamic (its motion file) with Bt as a damping ratio (1e6, visible with + !! the negligible Irn of the case) and as the value + !! it resolves to on the 40 elements of 99/40 m (Irn 1e-9 kg m): the same outputs, byte for + !! byte; GJ|K|Bt|x is refused by name. + REAL(wp) :: bt + CHARACTER(64) :: gjtxt + LOGICAL :: conv + INTEGER :: es + CHARACTER(512) :: em + bt = 1.0e6_wp*(L0/40.0_wp)*SQRT(GJ*1.0e-9_wp) + CALL write_case('tcpl_zeta.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, dynamic=.TRUE., & + gj_text='5.0e4|4.0e5|-1.0e6') + CALL CD_Run_Deck_Driver('tcpl_zeta.dat', 'tcpl_zeta', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'the march with a torsional damping ratio runs: '//TRIM(em)) + WRITE (gjtxt, '(A,ES24.16)') '5.0e4|4.0e5|', bt + gjtxt = remove_blanks(gjtxt) + CALL write_case('tcpl_bt.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, dynamic=.TRUE., & + gj_text=TRIM(gjtxt)) + CALL CD_Run_Deck_Driver('tcpl_bt.dat', 'tcpl_bt', conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, 'the march with the resolved torsional damping runs: '//TRIM(em)) + CALL require(same_file('tcpl_zeta.out', 'tcpl_bt.out'), & + 'a torsional damping ratio is the Bt it resolves to, -Bt l0 sqrt(GJ Irn), bit for bit') + CALL require(.NOT. same_file('tcpl_bt.out', 'tcpl_dyn.out'), 'the torsional damping changes the march') + CALL write_case('tcpl_bad4.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 0', KTT, & + gj_text='5.0e4|0|1.0|2.0') + CALL CD_Run_Deck_Driver('tcpl_bad4.dat', 'tcpl_bad4', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'takes GJ, GJ|K or GJ|K|Bt') > 0, & + 'a fourth part of the GJ column fails closed: '//TRIM(em)) + END SUBROUTINE check_damping_grammar + + LOGICAL FUNCTION same_file(a, b) RESULT(same) + !! Byte-identical text files. + CHARACTER(*), INTENT(IN) :: a, b + INTEGER :: ua, ub, ia, ib + CHARACTER(4096) :: la, lb + same = .FALSE. + OPEN (NEWUNIT=ua, FILE=a, STATUS='OLD', ACTION='READ', IOSTAT=ia) + IF (ia /= 0) RETURN + OPEN (NEWUNIT=ub, FILE=b, STATUS='OLD', ACTION='READ', IOSTAT=ib) + IF (ib /= 0) THEN + CLOSE (ua) + RETURN + END IF + DO + READ (ua, '(A)', IOSTAT=ia) la + READ (ub, '(A)', IOSTAT=ib) lb + IF (ia /= 0 .OR. ib /= 0) EXIT + IF (la /= lb) THEN + CLOSE (ua) + CLOSE (ub) + RETURN + END IF + END DO + same = ia /= 0 .AND. ib /= 0 + CLOSE (ua) + CLOSE (ub) + END FUNCTION same_file + 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). @@ -333,15 +396,15 @@ SUBROUTINE straight_case(root, conn_a, conn_b, k, v, torsion, length, option) CLOSE (u) END SUBROUTINE straight_case - SUBROUTINE write_case(path, conn_a, conn_b, k, torsion, dynamic, length, option) + SUBROUTINE write_case(path, conn_a, conn_b, k, torsion, dynamic, length, option, gj_text) !! 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. + !! elements, TMax 0; the GJ column carries GJ|K (k < 0 writes the plain GJ), or gj_text as given; + !! 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 + CHARACTER(*), INTENT(IN), OPTIONAL :: option, gj_text INTEGER :: u CHARACTER(64) :: gjcol, lcol LOGICAL :: tors, dyn @@ -355,6 +418,7 @@ SUBROUTINE write_case(path, conn_a, conn_b, k, torsion, dynamic, length, option) WRITE (gjcol, '(ES12.5,A,ES12.5)') GJ, '|', k END IF gjcol = remove_blanks(gjcol) + IF (PRESENT(gj_text)) gjcol = gj_text lcol = '99.0' IF (PRESENT(length)) WRITE (lcol, '(F10.4)') length OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') @@ -362,8 +426,9 @@ SUBROUTINE write_case(path, conn_a, conn_b, k, torsion, dynamic, length, option) 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) (-) (-) (-) (-)' + ! Irn 1e-9: the march's quasi-static end state (the nodal twist without polar inertia) 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' + ' 1.0 1.0e-9 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) (-)' diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index 428fa7ac..36734b9c 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -45,9 +45,12 @@ PROGRAM test_torsion_deck CHARACTER(16) :: arg CHARACTER(8) :: no_rows(0) - ! neutral 0.2 m section: mass = rhoW pi d^2 / 4; EA 1e7, EI 1e6, GAs 1e8, GJ 5e4 + ! neutral 0.2 m section: mass = rhoW pi d^2 / 4; EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 (the + ! massless-line torsion these gates check, down to the coarse-step pendulum's trapezoidal closed + ! form: the nodal twist's limit of a negligible polar inertia, whose inertia + ! test_nodal_twist_dynamic gates) WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & - ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0' + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' ! optional argument: run only gate 1..9 (diagnostics) only = 0 @@ -911,7 +914,7 @@ SUBROUTINE check_errors() CALL expect_error('an imposed twist above 1000 turns is named', 'tdeck_e16.dat', 'tdeck_e16', & 'line 1: the imposed twist Pretwist(B) - Pretwist(A) = 4.00000E+05 deg exceeds 1000 turns') ! a twist far beyond the buckling onset: the failed stage is named once, with its line - t10(1) = 'cab 0.2 32.2013246 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0' + t10(1) = 'cab 0.2 32.2013246 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-9 0.0 0.0 0.0 0.0' CALL straight_deck('tdeck_e15.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Rigid 0 0 1 36000', OUTS, t10) CALL expect_error('a failed torsion stage is named without a doubled prefix', 'tdeck_e15.dat', 'tdeck_e15', & 'CableDyn_DeckDriver: line 1: finite-EI torsion static solve failed') From 27b77381c5c3edb17d43f51d247661f67feaf289 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 17:03:03 +0900 Subject: [PATCH 21/51] feat(capi): host rotations, torsion through the C API (#70) The C API moved line ends by translation only, so it refused every deck with a line restrained in torsion and held a Rigid end connection on its deck direction. A host that turns the bodies its Coupled points are fixed to now passes their rotations (C ABI 1 minor extension 3, additive): - `CableDyn_InitDeckRotating`: `CableDyn_InitDeckAt` (or `InitDeck` with `n_q0 = 0`) whose handle takes the host's rotations and passes them, as orientation and angular velocity and acceleration, with every `UpdateStates` and `Step` on the aggregate route, as the coupled OpenFAST shell does. It accepts torsion decks; the rotations start at identity (the deck's axes at the static start). - `CableDyn_UpdateRotations(dcm, omega, alpha, n_block)`: per coupled block, the global-to-body DCM (row-major, the OpenFAST mesh orientation) and the angular velocity and acceleration in global axes, kept until the next call. All or nothing: a handle without rotations, a wrong block count, a null pointer, a non-finite value or a DCM that is not proper orthogonal to 1e-8 is refused with the rotations unchanged. `SaveState` / `RestoreState` carry them with the model. - `CableDyn_GetCoupledMoments`: the moment each block applies to the host about the coupled point (a finite-EI line's torsional and bending reaction; zero for EI = 0 lines and the point route), on any initialised handle. Python: `CableDyn.init_deck_rotating`, `update_rotations`, `coupled_moments` (`HOST_ROTATION_ABI_MINOR = 3`). Docs: the C API reference (new guide step and reference section), the Python API, and the pages that said the C API refuses torsion; the guard message names the new call. Gates: `c_api_host_rotation` (C, through the shared library) on the straight neutral torsion line of `test_coupled_torsion`: `InitDeck` refuses it naming `CableDyn_InitDeckRotating`; a 20 deg feedthrough roll twists the end element alone (Twist1 = -20 deg, the coupled moment GJ phi / l_e about the line axis, resisting the roll); a 60 deg/s roll gives Twist1 = -phi (2e-15 deg) and the quasi-static torque GJ phi / L at both ends and as the coupled moment (3e-6 N m); a restore after other rotations steps bit-identically; the rejections leave the handle stepping bit-identically to one that never saw them; the point route takes rotations and returns zero moments. `python/tests/test_host_rotation.py` mirrors them. Full suite passes; examples unchanged (no code path of a deck run changed). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 + CMakeLists.txt | 11 + doc/api_python.rst | 55 +++- doc/capabilities.rst | 8 +- doc/capi.rst | 132 +++++++++- doc/driver_format.md | 7 +- doc/openfast.rst | 7 +- doc/troubleshooting.rst | 8 +- python/cabledyn/_lib.py | 30 ++- python/cabledyn/deck_file.py | 3 +- python/cabledyn/model.py | 137 ++++++++-- python/tests/test_host_coupling.py | 2 +- python/tests/test_host_rotation.py | 129 +++++++++ python/tests/test_objects.py | 2 +- release/check_release_metadata.py | 2 +- src/CableDyn_CAPI.f90 | 285 ++++++++++++++++++-- src/CableDyn_CAPI.h | 42 ++- src/CableDyn_DeckDriver.f90 | 3 +- src/cabledyn.def | 3 + src/cabledyn.exp | 3 + src/cabledyn.map | 3 + tests/test_c_api_host_coupling.c | 4 +- tests/test_c_api_host_rotation.c | 404 +++++++++++++++++++++++++++++ 23 files changed, 1218 insertions(+), 71 deletions(-) create mode 100644 python/tests/test_host_rotation.py create mode 100644 tests/test_c_api_host_rotation.c diff --git a/CHANGELOG.md b/CHANGELOG.md index 57797afa..ed89f606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,15 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- 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 + torsion and a `Rigid` end connection turn with the host, as on the coupled OpenFAST route; a + torsion deck, refused by `CableDyn_InitDeck`/`InitDeckAt`, runs there. + `CableDyn_GetCoupledMoments` returns the moments the lines apply to the host. On a straight + line rolled at 60 deg/s the coupled torque is the quasi-static `GJ phi / L` to 3e-6 N m, and + `SaveState`/`RestoreState` carry the rotations. Python: `CableDyn.init_deck_rotating`, + `update_rotations`, `coupled_moments`. - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index ad31d2c0..86650b99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1240,6 +1240,17 @@ add_test(NAME c_api_host_coupling ${CMAKE_CURRENT_SOURCE_DIR}/examples/clump_weight_free_point.dat) set_tests_properties(c_api_host_coupling PROPERTIES LABELS "c;unit;capi;shared;dynamic") +add_executable(test_c_api_host_rotation tests/test_c_api_host_rotation.c) +target_include_directories(test_c_api_host_rotation PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") +target_link_libraries(test_c_api_host_rotation PRIVATE cabledyn_shared) +if(NOT WIN32) + target_link_libraries(test_c_api_host_rotation PRIVATE m) +endif() +add_test(NAME c_api_host_rotation + COMMAND test_c_api_host_rotation ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/foam_esflowc_box_points.dat + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(c_api_host_rotation PROPERTIES LABELS "c;unit;capi;shared;dynamic;torsion") + find_package(Threads QUIET) if(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) add_executable(test_c_api_concurrency tests/test_c_api_concurrency.c) diff --git a/doc/api_python.rst b/doc/api_python.rst index 671d10b6..cfae771e 100644 --- a/doc/api_python.rst +++ b/doc/api_python.rst @@ -540,6 +540,57 @@ library is located. Array ordering, frames, and units at the coupling boundary f multiple of 3; or if ``q0`` is not finite. :raises RuntimeError: if the loaded library predates ABI 1 minor extension 2. + .. py:method:: init_deck_rotating(deck, q0=None) + + Initialise from a deck for a host that turns the bodies its coupled points are fixed to + (``CableDyn_InitDeckRotating``): :meth:`init_deck_at`, or :meth:`init_deck` with + ``q0=None``, whose model takes each coupled block's rotation from + :meth:`update_rotations` and passes it with every :meth:`update_states` and :meth:`step`. + A line restrained in torsion (``END CONNECTIONS`` ``TorsStiffness``) and a ``Rigid`` bending + end connection then turn with the host at their host-driven end, as on the coupled + OpenFAST route; the other initialisations refuse a deck with a line restrained in torsion. + The rotations start at identity (the deck's axes at the static start) and rest. + + :param deck: Path of the ``.dat`` deck, as for :meth:`init_deck`. + :type deck: str | os.PathLike + :param q0: The host positions of :meth:`init_deck_at`, or ``None`` for the deck positions. + :type q0: array_like | None + :raises CableDynError: as :meth:`init_deck_at`. + :raises ValueError: as :meth:`init_deck_at`. + :raises RuntimeError: if the loaded library predates ABI 1 minor extension 3. + + .. py:method:: update_rotations(dcm, omega, alpha) + + Set the host's rotation of every coupled block for the following :meth:`update_states` + and :meth:`step` calls (``CableDyn_UpdateRotations``); it is kept until the next call and + saved and restored with :meth:`save_state` and :meth:`restore_state`. Only a finite-EI + line's host-driven end uses its block. + + :param dcm: ``(n_block, 3, 3)``: block ``k``'s global-to-body direction cosine matrix, its + rows the body axes in global axes (the OpenFAST mesh orientation); identity is the body + at its static-start attitude. + :type dcm: array_like + :param omega: ``(n_block, 3)``: the body's angular velocity in global axes (rad/s). + :type omega: array_like + :param alpha: ``(n_block, 3)``: the body's angular acceleration in global axes (rad/s²). + :type alpha: array_like + :raises ValueError: if an array has the wrong shape. + :raises CableDynError: on a model not initialised by :meth:`init_deck_rotating`, or a + matrix that is not proper orthogonal to 1e-8 or a non-finite value (the rotations are + then unchanged). + :raises RuntimeError: if the loaded library predates ABI 1 minor extension 3. + + .. py:method:: coupled_moments() + + Return the moments the lines apply to the host at the coupled points + (``CableDyn_GetCoupledMoments``), at the state :meth:`calc_output` reports: block ``k`` + (entries ``3k .. 3k+2``, N m, global axes) is a finite-EI line's torsional and bending + reaction about the coupled point at its host-driven end, zero for the other blocks and for + ``EI = 0`` lines. + + :rtype: numpy.ndarray + :raises RuntimeError: if the loaded library predates ABI 1 minor extension 3. + .. py:method:: save_state() restore_state() @@ -776,7 +827,9 @@ imports without the shared library. .. py:function:: abi_minor() - Return the extension level of ABI 1 of the loaded library: 2 when it also has the + Return the extension level of ABI 1 of the loaded library: 3 when it also has the + host-rotation calls behind :meth:`CableDyn.init_deck_rotating`, + :meth:`CableDyn.update_rotations` and :meth:`CableDyn.coupled_moments`, 2 when it has the host-coupling calls behind :meth:`CableDyn.init_deck_at`, :meth:`CableDyn.save_state` and :meth:`CableDyn.coupled_layout`, 1 when it has the object queries behind :attr:`CableDyn.lines` and :meth:`CableDyn.channel`, 0 for an older library. diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 0568936b..06cb61a7 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -91,9 +91,11 @@ Line and constitutive capability 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 - :doc:`openfast`); ``Torq``/``Twist`` channels and standalone range graphs. Stopped by - name: the standalone mixed ``EI = 0`` + finite-EI aggregate and the C API (which move the - line ends by translation only), OpenFAST linearisation of a line restrained in torsion, + :doc:`openfast`) and through the C API with the host's rotations + (``CableDyn_InitDeckRotating``, :doc:`capi`); ``Torq``/``Twist`` channels and standalone + range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI aggregate and + ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by translation only), + OpenFAST linearisation of a line restrained in torsion, rod ends, bodies other than Rigid6, lines with ``ATTACHMENTS``, modal analysis, and ``False alpha_force_blend``. Not modelled: seabed friction against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) diff --git a/doc/capi.rst b/doc/capi.rst index 77ea8dc7..872978d8 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -29,13 +29,14 @@ A model lives behind an opaque handle. The lifecycle is: .. code-block:: text CableDyn_Create - -> CableDyn_InitDeck | CableDyn_InitDeckAt (initialize; may repeat) - | CableDyn_InitLine | CableDyn_InitLines + -> CableDyn_InitDeck | CableDyn_InitDeckAt | CableDyn_InitDeckRotating + | CableDyn_InitLine | CableDyn_InitLines (initialize; may repeat) -> CableDyn_GetCoupledMotion (read the initial state) -> loop: [CableDyn_SaveState | CableDyn_RestoreState] (host outer correctors) [CableDyn_UpdatePointFluidFields] + [CableDyn_UpdateRotations] (a host that turns) CableDyn_Step(dt, motion at t+dt) - CableDyn_CalcOutput (loads at t+dt) + CableDyn_CalcOutput [, CableDyn_GetCoupledMoments] (loads at t+dt) -> CableDyn_Close A host solver that drives the ``Coupled`` points of a deck, a CFD code in particular, should @@ -83,6 +84,11 @@ MoorDyn's C API. - host coupling (ABI 1.2): initialization with the statics at the host's positions, a one-slot state save and restore for outer correctors, and the owner of each block of the coupled vector (`Host coupling calls`_) + * - ``CableDyn_InitDeckRotating``, ``CableDyn_UpdateRotations``, + ``CableDyn_GetCoupledMoments`` + - host rotations (ABI 1.3): a host that turns the bodies its coupled points are fixed to, + for lines restrained in torsion and Rigid end connections, and the moments the lines + apply (`Host rotation calls`_) Building and linking -------------------- @@ -237,9 +243,9 @@ ABI and versioning - 1 - the C ABI revision the header describes * - ``CABLEDYN_CAPI_ABI_MINOR`` / ``CableDyn_GetAbiMinor()`` - - 2 + - 3 - additive extensions of ABI 1: 1 adds the `Object queries`_, 2 the - `Host coupling calls`_ + `Host coupling calls`_, 3 the `Host rotation calls`_ * - ``CableDyn_GetVersion(&major, &minor, &patch, &abi)`` - runtime - the same four numbers, reported by the loaded library @@ -270,8 +276,9 @@ The Python package does this check at import and rejects a library that speaks a A minor extension only adds functions: every ABI 1 prototype and its semantics are unchanged, so a caller built against an older header keeps working. A caller that uses the additions checks -``CableDyn_GetAbiMinor() >= 1`` before calling the object queries, and -``CableDyn_GetAbiMinor() >= 2`` before calling the host-coupling functions. +``CableDyn_GetAbiMinor() >= 1`` before calling the object queries, +``CableDyn_GetAbiMinor() >= 2`` before calling the host-coupling functions, and +``CableDyn_GetAbiMinor() >= 3`` before calling the host-rotation functions. Calling conventions ------------------- @@ -650,6 +657,33 @@ SI units in the global right-handed frame with z up and still water at :math:`z (:doc:`conventions`), as in MoorDyn. A host in another frame or unit system converts the motion it passes and the loads it receives. +Step 8: a host that turns: torsion and rigid end connections +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The coupled vector carries translations only, which is all an ``EI = 0`` line or a pinned +finite-EI end takes. A finite-EI line restrained in torsion (``END CONNECTIONS`` +``TorsStiffness``) twists with the body's roll about the line, and a ``Rigid`` bending end +connection holds the line's end tangent on a direction fixed to the body: both need the body's +rotation. ``CableDyn_InitDeck`` and ``CableDyn_InitDeckAt`` move the ends by translation only and +refuse a deck with a line restrained in torsion; a ``Rigid`` end connection there keeps its deck +direction. + +*CableDyn.* Initialise with ``CableDyn_InitDeckRotating`` (``CableDyn_InitDeckAt`` that takes +rotations; ``n_q0 = 0`` for the deck positions) and, before every ``CableDyn_UpdateStates`` and +``CableDyn_Step``, pass the body's rotation at the same instant with +``CableDyn_UpdateRotations``: for each block of the coupled vector, the global-to-body +direction cosine matrix (row-major: its rows are the body axes in global axes, the OpenFAST +mesh orientation) and the body's angular velocity and acceleration in global axes. The body's +axes are the deck's at the static start, so the rotation starts at identity; a host whose body +starts rotated passes its rotation relative to that start. ``CableDyn_GetCoupledMoments`` then +returns the moment each line applies to the body about its fairlead, in global axes, beside the +force of ``CableDyn_CalcOutput``; add :math:`\sum_k m_k` to the moment of Step 5. *MoorDyn* has +no line torsion; its coupled bodies and rods take 6 values per object. + +The rotations are inputs, like the motion: an end frame turned by more than a quarter turn +about its line since the last committed step is refused, and ``CableDyn_SaveState``/``CableDyn_RestoreState`` carry the +last rotations with the model. + Call sequence ~~~~~~~~~~~~~ @@ -684,9 +718,12 @@ the deck's ``POINTS`` order of the ``Coupled`` points) the host computes from th } ++j; } + /* a host that turns (CableDyn_InitDeckRotating): the body's rotation at t first */ + /* CableDyn_UpdateRotations(h, dcm, omega, alpha, n / 3, &err); */ CableDyn_Step(h, dt, q, v, a, n, &converged, &stalled, &n_iter, &err); CableDyn_CalcOutput(h, f, n, &err); /* F = sum of f over the host blocks; M = sum of (x - r) x f over the same blocks */ + /* (+ the moments of CableDyn_GetCoupledMoments over the same blocks, Step 8) */ /* End of the run. */ CableDyn_Close(&h, &err); @@ -1953,6 +1990,87 @@ line-bound points of every type in ``POINTS`` order; on the aggregate route they 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``. +Host rotation calls +~~~~~~~~~~~~~~~~~~~ + +ABI 1 minor extension 3: check ``CableDyn_GetAbiMinor() >= 3`` before calling these. +`Step 8: a host that turns: torsion and rigid end connections`_ shows how they fit together. + +.. code-block:: c + + void CableDyn_InitDeckRotating(void *handle, const char *deck_path, + int deck_path_len, const double *q0, int n_q0, + int *err_stat); + void CableDyn_UpdateRotations(void *handle, const double *dcm, + const double *omega, const double *alpha, + int n_block, int *err_stat); + void CableDyn_GetCoupledMoments(void *handle, double *coupled_moments, + int n_coupled_dof, int *err_stat); + +**CableDyn_InitDeckRotating.** ``CableDyn_InitDeckAt`` for a host that turns its coupled points: +the arguments, routes, rejections, serialisation and transactions are those of +``CableDyn_InitDeckAt``, and ``n_q0 = 0`` (``q0`` may be ``NULL``) solves the statics at the deck +positions, as ``CableDyn_InitDeck``. The handle takes each coupled block's rotation from +``CableDyn_UpdateRotations`` and passes it with every ``CableDyn_UpdateStates`` and +``CableDyn_Step``, so a line restrained in torsion and a ``Rigid`` bending end connection turn +with the host at their host-driven end, as on the coupled OpenFAST route. It accepts a deck +with a line restrained in torsion, which the other ``Init*`` calls refuse. The rotations start +at identity and rest. Another ``Init*`` call makes the handle one that takes no rotations. + +**CableDyn_UpdateRotations.** The rotation of each 3-DOF block of the coupled vector for the +following ``CableDyn_UpdateStates`` and ``CableDyn_Step`` calls; it is kept until the next call. + +.. list-table:: + :header-rows: 1 + :widths: 18 8 12 12 12 38 + + * - Argument + - Dir + - C type + - Length + - NULL + - Meaning + * - ``dcm`` + - in + - ``const double *`` + - ``9 * n_block`` + - only if ``n_block == 0`` + - ``dcm[9k + 3i + j]`` is :math:`R_{ij}` of block ``k``'s global-to-body direction cosine + matrix, row-major: row ``i`` is body axis ``i`` in global axes (the OpenFAST mesh + orientation). Identity is the body at its static-start attitude. + * - ``omega``, ``alpha`` + - in + - ``const double *`` + - ``3 * n_block`` each + - only if ``n_block == 0`` + - the body's angular velocity [rad/s] and acceleration [rad/s²] in global axes + * - ``n_block`` + - in + - ``int`` + - -- + - -- + - must equal ``CableDyn_NCoupledDOF / 3`` + +Only a finite-EI line's host-driven end uses its block; the other blocks (``EI = 0`` lines, +the point route, bodies and rods) are checked and not used. The call is all or nothing: a +handle not initialised by ``CableDyn_InitDeckRotating``, a wrong ``n_block``, a ``NULL`` +pointer, a non-finite entry, and a matrix that is not proper orthogonal to :math:`10^{-8}` +(:math:`\max |R R^T - I|` and :math:`|\det R - 1|`) return ``CD_C_BAD_INPUT`` and leave the +rotations unchanged. The rotations are checked against the lines at the next update or step: +an end frame turned by more than a quarter turn about its line since the last committed state is +refused there. +``CableDyn_SaveState`` saves the rotations with the model and ``CableDyn_RestoreState`` restores +them. + +**CableDyn_GetCoupledMoments.** The moment [N m] each block of the coupled vector applies to the +host, about the coupled point in global axes, at the state ``CableDyn_CalcOutput`` reports +(after an update without a step, against the frozen interior as there). It is a finite-EI +line's torsional and bending reaction at its host-driven end, and zero for the other blocks and +on the point route. ``coupled_moments`` holds ``n_coupled_dof`` values (``NULL`` only if +``n_coupled_dof == 0``), which must equal ``CableDyn_NCoupledDOF``; it is set to zero before the +evaluation and stays zero if the call fails. It is available on any initialised handle, so a +host without rotations can read the moment of a ``Rigid`` end connection at its deck direction. + Examples -------- diff --git a/doc/driver_format.md b/doc/driver_format.md index 905f9d4e..4b26a61a 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -865,9 +865,10 @@ Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B torsion on an `EI = 0` line, on a rod end or on a `Point3` body, a line with `ATTACHMENTS`, modal analysis (`nModes`), a dynamic or coupled run with `False alpha_force_blend`, any restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines -without a body or through the C API, which move the line ends by translation only (`a line -restrained in torsion needs a host that turns its fairlead frame ...`; with a body such a deck -runs on the multibody route, which supports torsion), OpenFAST linearisation of a line +without a body or through the C API's `CableDyn_InitDeck`/`InitDeckAt`, which move the line +ends by translation only (`a line restrained in torsion needs a host that turns its fairlead +frame ...`; with a body such a deck runs on the multibody route, which supports torsion, and a C +API host passes its rotations after `CableDyn_InitDeckRotating`), OpenFAST linearisation of a line restrained in torsion, and a `Torq`/`Twist` channel on a line that is not restrained at both ends. Seabed friction does not resist twist (the laid part of a line twists freely), and there is no torque–tension coupling. diff --git a/doc/openfast.rst b/doc/openfast.rst index abfe73cc..767dd668 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -345,9 +345,10 @@ substeps; an output probe moves the frame without a step, is limited to 90° fro committed twist, and stops by name beyond it (a restart first restores the checkpoint's twist, so it is not limited this way). Formal linearisation of a line restrained in torsion fails during initialisation: the torque's -rotational stiffness has no column in the translation-only quasi-static reduction. The C API -and the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body move the line -ends by translation only and refuse torsion columns. +rotational stiffness has no column in the translation-only quasi-static reduction. The C API's +``CableDyn_InitDeck``/``InitDeckAt`` and the standalone deck that mixes ``EI = 0`` and finite-EI +lines without a body move the line ends by translation only and refuse torsion columns; a C API +host that initialises with ``CableDyn_InitDeckRotating`` passes its rotations (:doc:`capi`). Lifecycle features ------------------ diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 5125a222..c9179535 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -399,9 +399,11 @@ Torsion buoyancy section. * - ``a line restrained in torsion needs a host that turns its fairlead frame`` - the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body, and the C - API, move the line ends by translation only. Run the line in a coupled OpenFAST or - FAST.Farm run, add a body (such a deck runs on the multibody route, which supports - torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. + API's ``CableDyn_InitDeck``/``InitDeckAt``, move the line ends by translation only. Run the + line in a coupled OpenFAST or FAST.Farm run, initialise a C API handle with + ``CableDyn_InitDeckRotating`` and pass the host's rotations, add a body (such a deck runs + on the multibody route, which supports torsion), or set ``TorsStiffness Free`` in every + ``END CONNECTIONS`` row. * - ``formal OpenFAST linearization of a line restrained in torsion is not supported`` - linearise the model with ``TorsStiffness Free``; the twist and the torque carry no linearisation state. diff --git a/python/cabledyn/_lib.py b/python/cabledyn/_lib.py index 5495a4b8..44c49741 100644 --- a/python/cabledyn/_lib.py +++ b/python/cabledyn/_lib.py @@ -180,8 +180,7 @@ def _bind_object_queries() -> bool: # restore of outer correctors, and the coupled layout query. A library built # before the extension lacks these symbols and reports ``abi_minor() < 2``. -#: Minor extension level of ABI 1 this binding uses for the host-coupling calls -#: (the newest extension the binding knows). +#: Minor extension level of ABI 1 this binding uses for the host-coupling calls. HOST_COUPLING_ABI_MINOR = 2 @@ -210,6 +209,33 @@ def _bind_host_coupling() -> bool: _has_host_coupling = _bind_host_coupling() +# --- ABI 1, minor extension 3: host rotations -------------------------------- +# Initialization for a host that turns its coupled points, their rotations, and +# the coupled moments. A library built before the extension lacks these symbols +# and reports ``abi_minor() < 3``. + +#: Minor extension level of ABI 1 this binding uses for the host-rotation calls +#: (the newest extension the binding knows). +HOST_ROTATION_ABI_MINOR = 3 + + +def _bind_host_rotation() -> bool: + try: + init_rot = _lib.CableDyn_InitDeckRotating + except AttributeError: + return False + init_rot.argtypes = [c_void_p, c_char_p, c_int, _DBL, c_int, POINTER(c_int)] + init_rot.restype = None + _lib.CableDyn_UpdateRotations.argtypes = [c_void_p, _DBL, _DBL, _DBL, c_int, POINTER(c_int)] + _lib.CableDyn_UpdateRotations.restype = None + _lib.CableDyn_GetCoupledMoments.argtypes = [c_void_p, _DBL, c_int, POINTER(c_int)] + _lib.CableDyn_GetCoupledMoments.restype = None + return True + + +_has_host_rotation = _bind_host_rotation() + + def abi_minor() -> int: """The loaded library's ABI 1 extension level (0 before the object queries).""" if not _has_object_queries: diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index c72dd9db..19745538 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4282,7 +4282,8 @@ def _check_torsion_lines( if has_torsion_column and aggregate_route and not self.caller_driven: raise DeckFormatError( f"{self._label}: a line restrained in torsion needs a host that turns its fairlead " - "frame: coupled OpenFAST and FAST.Farm runs do, while the C API and a standalone " + "frame: coupled OpenFAST and FAST.Farm runs do, and a C API host initialised with " + "CableDyn_InitDeckRotating, while CableDyn_InitDeck/InitDeckAt and a standalone " "deck that mixes EI = 0 and finite-EI lines without a BODY move the line ends by " "translation only (with a BODY such a deck runs on the multibody route, which " "supports torsion); set TorsStiffness Free in every END CONNECTIONS row" diff --git a/python/cabledyn/model.py b/python/cabledyn/model.py index bc55aea1..7b2a776d 100644 --- a/python/cabledyn/model.py +++ b/python/cabledyn/model.py @@ -90,6 +90,26 @@ def _dbl_ptr(arr: FloatArray) -> Any: return arr.ctypes.data_as(POINTER(c_double)) +def _host_positions(q0: ArrayInput) -> FloatArray: + """``q0`` of :meth:`CableDyn.init_deck_at`: flat ``(3 n,)`` or column-per-point ``(3, n)``.""" + q = _as_real_array(q0, "q0") + if q.ndim == 2 and q.shape == (3, 3): + # three points: column-per-point and row-per-point look alike + raise ValueError( + "q0 of shape (3, 3) is ambiguous (column-per-point or row-per-point); " + "pass it flat, x1 y1 z1 x2 y2 z2 ..." + ) + if q.ndim == 2 and q.shape[0] == 3: + q = np.ascontiguousarray(q.reshape(-1, order="F")) + if q.ndim != 1 or q.size % 3 != 0: + raise ValueError( + f"q0 must be flat (3 * n,) or column-per-point (3, n); got shape {np.shape(q0)}" + ) + if not np.all(np.isfinite(q)): + raise ValueError("q0 must be finite (no NaN or Inf)") + return q + + def _encode_path(deck: str | os.PathLike[str]) -> bytes: """Encode a deck path for the Fortran runtime's narrow-character ``OPEN``.""" text = os.fspath(deck) @@ -239,21 +259,7 @@ def init_deck_at(self, deck: str | os.PathLike[str], q0: ArrayInput) -> None: _encode_path(deck) # rejects a NUL before any file-system call resolved = Path(deck).expanduser().resolve() path = _encode_path(resolved) - q = _as_real_array(q0, "q0") - if q.ndim == 2 and q.shape == (3, 3): - # three points: column-per-point and row-per-point look alike - raise ValueError( - "q0 of shape (3, 3) is ambiguous (column-per-point or row-per-point); " - "pass it flat, x1 y1 z1 x2 y2 z2 ..." - ) - if q.ndim == 2 and q.shape[0] == 3: - q = np.ascontiguousarray(q.reshape(-1, order="F")) - if q.ndim != 1 or q.size % 3 != 0: - raise ValueError( - f"q0 must be flat (3 * n,) or column-per-point (3, n); got shape {np.shape(q0)}" - ) - if not np.all(np.isfinite(q)): - raise ValueError("q0 must be finite (no NaN or Inf)") + q = _host_positions(q0) with self._lock: self._require_host_coupling() status = c_int() @@ -263,6 +269,39 @@ def init_deck_at(self, deck: str | os.PathLike[str], q0: ArrayInput) -> None: self._check("CableDyn_InitDeckAt", status.value) self._initialized_from(resolved) + def init_deck_rotating( + self, deck: str | os.PathLike[str], q0: ArrayInput | None = None + ) -> None: + """Initialize from a deck for a host that turns the bodies its coupled points are on. + + :meth:`init_deck_at` (or :meth:`init_deck` with ``q0=None``) whose model + takes each coupled block's rotation from :meth:`update_rotations` and + passes it with every :meth:`update_states` and :meth:`step`, so a line + restrained in torsion (``END CONNECTIONS`` ``TorsStiffness``) and a + ``Rigid`` bending end connection turn with the host at their host-driven + end; the other initializations refuse a deck with a line restrained in + torsion. The rotations start at identity (the deck's axes at the static + start) and rest. :meth:`coupled_moments` returns the moments the lines + apply to the host. + """ + _encode_path(deck) # rejects a NUL before any file-system call + resolved = Path(deck).expanduser().resolve() + path = _encode_path(resolved) + q = np.zeros(0) if q0 is None else _host_positions(q0) + with self._lock: + self._require_host_rotation() + status = c_int() + _lib.CableDyn_InitDeckRotating( + self._handle, + path, + len(path), + _dbl_ptr(q) if q.size else None, + int(q.size), + byref(status), + ) + self._check("CableDyn_InitDeckRotating", status.value) + self._initialized_from(resolved) + def _initialized_from(self, deck: Path) -> None: """Book-keeping after a successful deck initialization (the caller holds the lock).""" self._generation += 1 @@ -271,6 +310,15 @@ def _initialized_from(self, deck: Path) -> None: self._saved_time = None self._deck = deck + @staticmethod + def _require_host_rotation() -> None: + if _lib_module.abi_minor() < _lib_module.HOST_ROTATION_ABI_MINOR: + # not a C status: the loaded library lacks the entry points + raise RuntimeError( + "the loaded CableDyn library predates the host-rotation calls " + "(ABI 1 minor extension 3); rebuild it from this checkout" + ) + @staticmethod def _require_host_coupling() -> None: if _lib_module.abi_minor() < _lib_module.HOST_COUPLING_ABI_MINOR: @@ -540,6 +588,65 @@ def restore_state(self) -> None: if self._saved_time is not None: self._time = self._saved_time + # -- host rotations ------------------------------------------------------- + + def update_rotations(self, dcm: ArrayInput, omega: ArrayInput, alpha: ArrayInput) -> None: + """Set the host's rotation of every coupled block for the next updates and steps. + + ``dcm`` is ``(n_block, 3, 3)``: ``dcm[k]`` is block ``k``'s global-to-body + direction cosine matrix (its rows are the body axes in global axes, the + OpenFAST mesh orientation; identity is the body at its static-start + attitude). ``omega`` and ``alpha`` are ``(n_block, 3)``: the body's + angular velocity [rad/s] and acceleration [rad/s^2] in global axes. Only a + finite-EI line's host-driven end uses its block. The rotations are kept + until the next call and saved with :meth:`save_state`. Requires + :meth:`init_deck_rotating`; a rejected input (a matrix that is not proper + orthogonal to 1e-8, a non-finite value) leaves the rotations unchanged. + """ + with self._lock: + self._require_host_rotation() + nb = self.n_coupled_dof // 3 + r = _as_real_array(dcm, "dcm") + w = _as_real_array(omega, "omega") + al = _as_real_array(alpha, "alpha") + if r.shape != (nb, 3, 3): + raise ValueError(f"dcm must be shaped ({nb}, 3, 3); got {r.shape}") + for name, x in (("omega", w), ("alpha", al)): + if x.shape != (nb, 3): + raise ValueError(f"{name} must be shaped ({nb}, 3); got {x.shape}") + r = np.ascontiguousarray(r.reshape(-1)) + w = np.ascontiguousarray(w.reshape(-1)) + al = np.ascontiguousarray(al.reshape(-1)) + status = c_int() + _lib.CableDyn_UpdateRotations( + self._handle, + _dbl_ptr(r) if nb else None, + _dbl_ptr(w) if nb else None, + _dbl_ptr(al) if nb else None, + nb, + byref(status), + ) + self._check("CableDyn_UpdateRotations", status.value) + + def coupled_moments(self) -> FloatArray: + """The moments the lines apply to the host at the coupled points, ``(n_dof,)`` N m. + + Block ``k`` (entries ``3k .. 3k+2``, global axes) is a finite-EI line's + torsional and bending reaction about the coupled point at its host-driven + end, at the state :meth:`calc_output` reports; zero for the other blocks + and for ``EI = 0`` lines. + """ + with self._lock: + self._require_host_rotation() + n = self.n_coupled_dof + moments = np.zeros(n) + status = c_int() + _lib.CableDyn_GetCoupledMoments( + self._handle, _dbl_ptr(moments) if n else None, n, byref(status) + ) + self._check("CableDyn_GetCoupledMoments", status.value) + return moments + def coupled_layout(self) -> tuple[tuple[int, PointKind], ...]: """The owner of each 3-DOF block of the coupled vector, as ``(point_id, kind)``. diff --git a/python/tests/test_host_coupling.py b/python/tests/test_host_coupling.py index 1c104f57..78012600 100644 --- a/python/tests/test_host_coupling.py +++ b/python/tests/test_host_coupling.py @@ -49,7 +49,7 @@ def _motion(model: CableDyn, q0: np.ndarray, amp: float, t: float): def test_abi_minor_reports_the_host_coupling_extension(): assert _lib.HOST_COUPLING_ABI_MINOR == 2 - assert _lib.abi_minor() == cabledyn.abi_minor() == _lib.HOST_COUPLING_ABI_MINOR + assert _lib.abi_minor() == cabledyn.abi_minor() >= _lib.HOST_COUPLING_ABI_MINOR def test_point_route_layout(): diff --git a/python/tests/test_host_rotation.py b/python/tests/test_host_rotation.py new file mode 100644 index 00000000..6e2aaffe --- /dev/null +++ b/python/tests/test_host_rotation.py @@ -0,0 +1,129 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Host rotations (C ABI 1 minor extension 3): a host that turns its coupled points. + +The deck is the straight neutral torsion line of test_coupled_torsion: GJ 5e4 N m^2, +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. +""" + +from __future__ import annotations + +import math +from pathlib import Path + +import numpy as np +import pytest + +try: + import cabledyn._lib # 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) + +import cabledyn +from cabledyn import _lib +from cabledyn.errors import CableDynError +from cabledyn.model import CableDyn + +GJ = 5.0e4 +LENGTH = 100.0 +DT = 0.05 +BOX = Path(__file__).resolve().parents[2] / "tests" / "data" / "foam_esflowc_box_points.dat" + + +def _deck(tmp_path: Path, tors: str = "Rigid") -> Path: + mass = 1025.0 * 0.25 * math.pi * 0.04 + outputs = "Torq1N1\nTorq1N41\nTwist1\n" if tors != "Free" else "FairTen1\n" + text = ( + "host rotation gate\n--- LINE TYPES ---\n" + "Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat\n" + "(-) (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" + "--- 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" + "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist\n" + "(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)\n" + f"1 A Rigid 1 0 0 {tors} 0 0 1 0\n1 B Rigid 1 0 0 {tors} 0 0 1 0\n" + "--- 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.write_text(text, encoding="utf-8") + return path + + +def _roll(phi: float) -> np.ndarray: + """OpenFAST mesh orientation (global to local) of a roll phi about +x, (1, 3, 3).""" + c, s = math.cos(phi), math.sin(phi) + return np.array([[[1.0, 0.0, 0.0], [0.0, c, s], [0.0, -s, c]]]) + + +def test_abi_minor_reports_the_host_rotation_extension(): + assert _lib.HOST_ROTATION_ABI_MINOR == 3 + assert _lib.abi_minor() == cabledyn.abi_minor() == _lib.HOST_ROTATION_ABI_MINOR + + +def test_torsion_deck_needs_the_rotating_initialization(tmp_path): + deck = _deck(tmp_path) + with CableDyn() as model: + with pytest.raises(CableDynError, match="CableDyn_InitDeckRotating"): + model.init_deck(deck) + model.init_deck_rotating(deck) + assert model.n_coupled_dof == 3 + assert np.all(np.abs(model.coupled_moments()) <= 1.0e-6) + + +def test_rolling_host_gets_the_quasi_static_torque(tmp_path): + rate = math.radians(60.0) + with CableDyn() as model: + model.init_deck_rotating(_deck(tmp_path)) + q, v, a = model.get_coupled_motion() + for k in range(1, 11): + phi = rate * DT * k + model.update_rotations(_roll(phi), [[rate, 0.0, 0.0]], np.zeros((1, 3))) + model.step(DT, q, v, a) + m = model.coupled_moments() + assert m[0] == pytest.approx(-GJ * phi / LENGTH, abs=1.0e-6 * GJ) + assert abs(m[1]) <= 1.0e-6 * GJ and abs(m[2]) <= 1.0e-6 * GJ + assert model.channel("Twist1") == pytest.approx(-math.degrees(phi), abs=1.0e-6) + + +def test_save_restore_carries_the_rotations(tmp_path): + rate = math.radians(60.0) + with CableDyn() as model: + model.init_deck_rotating(_deck(tmp_path)) + q, v, a = model.get_coupled_motion() + model.update_rotations(_roll(rate * DT), [[rate, 0.0, 0.0]], np.zeros((1, 3))) + model.save_state() + model.step(DT, q, v, a) + first = model.coupled_moments() + model.update_rotations(_roll(0.5), [[0.0, 0.0, 0.0]], np.zeros((1, 3))) + model.restore_state() + model.step(DT, q, v, a) + assert np.array_equal(model.coupled_moments(), first) + + +def test_rotation_input_is_checked(tmp_path): + with CableDyn() as model: + model.init_deck_rotating(_deck(tmp_path)) + with pytest.raises(ValueError, match="dcm must be shaped"): + model.update_rotations(np.eye(3), np.zeros((1, 3)), np.zeros((1, 3))) + with pytest.raises(CableDynError, match="proper orthogonal"): + model.update_rotations(1.01 * _roll(0.1), np.zeros((1, 3)), np.zeros((1, 3))) + with CableDyn() as model: + model.init_deck(_deck(tmp_path, "Free")) + with pytest.raises(CableDynError, match="CableDyn_InitDeckRotating"): + model.update_rotations(_roll(0.1), np.zeros((1, 3)), np.zeros((1, 3))) + + +def test_point_route_takes_rotations_and_returns_no_moment(): + with CableDyn() as model: + model.init_deck_rotating(BOX) + nb = model.n_coupled_dof // 3 + 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)) diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index e360af3d..e4f99a45 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -450,7 +450,7 @@ def test_unbound_handle_and_raw_lines(monkeypatch, tmp_path): def test_abi_minor_is_reported(): assert _lib.OBJECT_QUERY_ABI_MINOR == 1 - assert _lib.abi_minor() == cabledyn.abi_minor() == _lib.HOST_COUPLING_ABI_MINOR == 2 + assert _lib.abi_minor() == cabledyn.abi_minor() == _lib.HOST_ROTATION_ABI_MINOR == 3 assert objects_module.OBJ_ROD == 4 diff --git a/release/check_release_metadata.py b/release/check_release_metadata.py index d1dfcefc..21c3bbbd 100644 --- a/release/check_release_metadata.py +++ b/release/check_release_metadata.py @@ -140,7 +140,7 @@ def main() -> int: "C header ABI minor level": f"CABLEDYN_CAPI_ABI_MINOR {abi_minor}" in read( "src/CableDyn_CAPI.h" ), - "Python ABI minor level": f"HOST_COUPLING_ABI_MINOR = {abi_minor}" in read( + "Python ABI minor level": f"HOST_ROTATION_ABI_MINOR = {abi_minor}" in read( "python/cabledyn/_lib.py" ), "C header ABI version": f"CABLEDYN_CAPI_ABI_VERSION {abi_version}" in read( diff --git a/src/CableDyn_CAPI.f90 b/src/CableDyn_CAPI.f90 index f44140e5..1cf5a9e8 100644 --- a/src/CableDyn_CAPI.f90 +++ b/src/CableDyn_CAPI.f90 @@ -31,7 +31,7 @@ MODULE CableDyn_CAPI CD_FAST_NCoupledDOF, CD_FAST_NPoints, CD_FAST_NLines, CD_FAST_OK, CD_FAST_BADINPUT, & CD_FAST_NOT_INITIALIZED, CD_FAST_ALLOCFAIL, CD_FAST_UpdatePointFluidFields USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType - USE CableDyn_Precision, ONLY: wp, CD_ZERO + USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE USE CableDyn_System, ONLY: CD_SystemType, CD_System_Line_NDOF, CD_Get_System_PointBlocks, CD_SYSTEM_OK, & CD_POINT_COUPLED IMPLICIT NONE @@ -67,6 +67,9 @@ MODULE CableDyn_CAPI PUBLIC :: CableDyn_SaveState PUBLIC :: CableDyn_RestoreState PUBLIC :: CableDyn_GetCoupledLayout + PUBLIC :: CableDyn_InitDeckRotating + PUBLIC :: CableDyn_UpdateRotations + PUBLIC :: CableDyn_GetCoupledMoments INTEGER(C_INT), PARAMETER :: CD_C_OK = 0_C_INT INTEGER(C_INT), PARAMETER :: CD_C_BAD_HANDLE = 1_C_INT @@ -80,8 +83,10 @@ MODULE CableDyn_CAPI INTEGER(C_INT), PARAMETER :: CD_C_ABI_VERSION = 1_C_INT CHARACTER(*), PARAMETER :: CD_C_VERSION_STRING = 'CableDyn 0.3.0 C-ABI 1' !> Minor extension level of ABI 1: 1 adds the in-process object queries, 2 the host-coupling - !> calls (initialization at host positions, state save/restore, the coupled layout query). - INTEGER(C_INT), PARAMETER :: CD_C_ABI_MINOR = 2_C_INT + !> calls (initialization at host positions, state save/restore, the coupled layout query), 3 + !> the host rotations (initialization for a host that turns its coupled points, their + !> rotations, the coupled moments). + INTEGER(C_INT), PARAMETER :: CD_C_ABI_MINOR = 3_C_INT !> Object kinds of CableDyn_NObjects / CableDyn_GetObjectInfo. INTEGER(C_INT), PARAMETER :: CD_C_OBJ_LINE = 1_C_INT, CD_C_OBJ_POINT = 2_C_INT, CD_C_OBJ_BODY = 3_C_INT, & CD_C_OBJ_ROD = 4_C_INT @@ -156,6 +161,13 @@ END FUNCTION cabledyn_blas_threads_once TYPE(CD_AGG_ModuleType) :: agg REAL(wp) :: agg_dt = CD_ZERO, agg_t = CD_ZERO REAL(wp), ALLOCATABLE :: agg_pos(:, :), agg_vel(:, :), agg_acc(:, :), agg_load(:, :) + ! A handle initialised by CableDyn_InitDeckRotating (host_rot): the host's rotation of each + ! coupled block, set by CableDyn_UpdateRotations and passed with every update and step on the + ! aggregate route (agg_dcm: OpenFAST's global-to-body DCM; agg_om, agg_al: the angular + ! velocity and acceleration in global axes; identity and rest at the static start). + ! agg_moment: the coupled moments' workspace of CableDyn_GetCoupledMoments. + LOGICAL :: host_rot = .FALSE. + REAL(wp), ALLOCATABLE :: agg_dcm(:, :, :), agg_om(:, :), agg_al(:, :), agg_moment(:, :) ! Point-route line inventory for the object queries: the deck-line-id -> system-line map ! (pt_obj, 0 = no such line; pt_is_cable all .FALSE.) the shared channel evaluator resolves ! through, and an empty cable store to pass it. Raw-line handles number their lines 1..n. @@ -171,6 +183,7 @@ END FUNCTION cabledyn_blas_threads_once TYPE(CD_FAST_ModuleType) :: saved_fast TYPE(CD_AGG_ModuleType), ALLOCATABLE :: saved_agg REAL(wp) :: saved_agg_t = CD_ZERO + REAL(wp), ALLOCATABLE :: saved_dcm(:, :, :), saved_om(:, :), saved_al(:, :) CHARACTER(CD_C_MSG_LEN) :: last_error = '' END TYPE CD_C_Handle @@ -257,49 +270,86 @@ SUBROUTINE CableDyn_InitDeckAt(handle, deck_path_ptr, deck_path_len, q0_ptr, n_q TYPE(C_PTR), VALUE :: handle, deck_path_ptr, q0_ptr INTEGER(C_INT), VALUE :: deck_path_len, n_q0 INTEGER(C_INT), INTENT(OUT) :: err_stat + + CALL init_deck_at(handle, deck_path_ptr, deck_path_len, q0_ptr, n_q0, 'CableDyn_InitDeckAt', .FALSE., err_stat) + END SUBROUTINE CableDyn_InitDeckAt + + SUBROUTINE CableDyn_InitDeckRotating(handle, deck_path_ptr, deck_path_len, q0_ptr, n_q0, err_stat) & + BIND(C, NAME='CableDyn_InitDeckRotating') + !! CableDyn_InitDeckAt for a host that turns its coupled points: the handle takes each + !! coupled block's rotation from CableDyn_UpdateRotations and passes it with every update and + !! step, so a line restrained in torsion (END CONNECTIONS TorsStiffness) and a Rigid bending + !! END CONNECTION turn with the host at their coupled end, as on the coupled OpenFAST route. + !! The rotations start at identity (the deck's axes at the static start) and rest. n_q0 = 0 + !! solves the statics at the deck positions, as CableDyn_InitDeck. Serialised process-wide + !! and transactional like CableDyn_InitDeck. + TYPE(C_PTR), VALUE :: handle, deck_path_ptr, q0_ptr + INTEGER(C_INT), VALUE :: deck_path_len, n_q0 + INTEGER(C_INT), INTENT(OUT) :: err_stat + + CALL init_deck_at(handle, deck_path_ptr, deck_path_len, q0_ptr, n_q0, 'CableDyn_InitDeckRotating', .TRUE., & + err_stat) + END SUBROUTINE CableDyn_InitDeckRotating + + SUBROUTINE init_deck_at(handle, deck_path_ptr, deck_path_len, q0_ptr, n_q0, caller, rotating, err_stat) + !! CableDyn_InitDeckAt / CableDyn_InitDeckRotating body: the host positions q0 (n_q0 = 0: + !! none, the deck positions) and, with rotating, a handle that takes the host's rotations. + TYPE(C_PTR), VALUE :: handle, deck_path_ptr, q0_ptr + INTEGER(C_INT), VALUE :: deck_path_len, n_q0 + CHARACTER(*), INTENT(IN) :: caller + LOGICAL, INTENT(IN) :: rotating + INTEGER(C_INT), INTENT(OUT) :: err_stat TYPE(CD_C_Handle), POINTER :: h REAL(C_DOUBLE), POINTER :: q0_c(:) REAL(wp), ALLOCATABLE :: positions(:, :) INTEGER :: stat - IF (.NOT. blas_runtime_ready(handle, 'CableDyn_InitDeckAt', err_stat)) RETURN + IF (.NOT. blas_runtime_ready(handle, caller, err_stat)) RETURN err_stat = validate_handle(handle, h) IF (err_stat /= CD_C_OK) RETURN IF (n_q0 < 0_C_INT .OR. MOD(n_q0, 3_C_INT) /= 0_C_INT) THEN - CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeckAt: n_q0 must be a non-negative multiple of 3', & - err_stat) + CALL set_status(h, CD_C_BAD_INPUT, caller//': n_q0 must be a non-negative multiple of 3', err_stat) RETURN END IF IF (n_q0 > 0_C_INT .AND. .NOT. C_ASSOCIATED(q0_ptr)) THEN - CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeckAt: q0 pointer is null', err_stat) + CALL set_status(h, CD_C_BAD_INPUT, caller//': q0 pointer is null', err_stat) + RETURN + END IF + IF (rotating .AND. n_q0 == 0_C_INT) THEN + ! no host positions: the statics at the deck positions, as CableDyn_InitDeck + CALL cabledyn_input_lock() + CALL init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, err_stat, rotating=rotating) + CALL cabledyn_input_unlock() RETURN END IF ALLOCATE (positions(3, INT(n_q0)/3), STAT=stat) IF (stat /= 0) THEN - CALL set_status(h, CD_C_ALLOC_FAIL, 'CableDyn_InitDeckAt: q0 allocation failed', err_stat) + CALL set_status(h, CD_C_ALLOC_FAIL, caller//': q0 allocation failed', err_stat) RETURN END IF IF (n_q0 > 0_C_INT) THEN CALL C_F_POINTER(q0_ptr, q0_c, [INT(n_q0)]) IF (.NOT. ALL(IEEE_IS_FINITE(q0_c))) THEN - CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_InitDeckAt: q0 must be finite', err_stat) + CALL set_status(h, CD_C_BAD_INPUT, caller//': q0 must be finite', err_stat) RETURN END IF positions = RESHAPE(REAL(q0_c, wp), SHAPE(positions)) END IF CALL cabledyn_input_lock() - CALL init_deck_serialised(handle, deck_path_ptr, deck_path_len, 'CableDyn_InitDeckAt', err_stat, positions) + CALL init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, err_stat, positions, rotating) CALL cabledyn_input_unlock() - END SUBROUTINE CableDyn_InitDeckAt + END SUBROUTINE init_deck_at - SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, err_stat, positions) - !! CableDyn_InitDeck / CableDyn_InitDeckAt body; the caller holds the process-wide input - !! lock. positions (3, n): the host positions of CableDyn_InitDeckAt. + SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, err_stat, positions, rotating) + !! CableDyn_InitDeck / CableDyn_InitDeckAt / CableDyn_InitDeckRotating body; the caller holds + !! the process-wide input lock. positions (3, n): the host positions of CableDyn_InitDeckAt; + !! rotating: the handle takes the host's rotations (CableDyn_InitDeckRotating). TYPE(C_PTR), VALUE :: handle, deck_path_ptr INTEGER(C_INT), VALUE :: deck_path_len CHARACTER(*), INTENT(IN) :: caller INTEGER(C_INT), INTENT(OUT) :: err_stat REAL(wp), INTENT(IN), OPTIONAL :: positions(:, :) + LOGICAL, INTENT(IN), OPTIONAL :: rotating TYPE(CD_C_Handle), POINTER :: h TYPE(CD_FAST_ModuleType) :: new_fast @@ -308,9 +358,11 @@ SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, er INTEGER :: i, es, end_es, stat, n_objects, n_finite INTEGER, ALLOCATABLE :: line_ids(:) REAL(wp) :: dtm, gravity, rho_water - LOGICAL :: has_dtm + LOGICAL :: has_dtm, rot CHARACTER(CD_C_MSG_LEN) :: em, end_em + rot = .FALSE. + IF (PRESENT(rotating)) rot = rotating err_stat = validate_handle(handle, h) IF (err_stat /= CD_C_OK) RETURN IF (deck_path_len < 1_C_INT .OR. .NOT. C_ASSOCIATED(deck_path_ptr)) THEN @@ -340,7 +392,7 @@ SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, er CALL CD_Deck_Query_dtM(TRIM(deck_path), dtm, has_dtm, es, em, standalone_scan=.TRUE., n_bodies_rods=n_objects, & n_finite_ei=n_finite) IF (es == CD_DECKDRV_OK .AND. (n_objects > 0 .OR. n_finite > 0)) THEN - CALL init_deck_aggregate(h, TRIM(deck_path), has_dtm, dtm, caller, err_stat, positions) + CALL init_deck_aggregate(h, TRIM(deck_path), has_dtm, dtm, caller, rot, err_stat, positions) RETURN END IF ! An absent positions argument stays absent through the optional coupled_positions. @@ -366,6 +418,9 @@ SUBROUTINE init_deck_serialised(handle, deck_path_ptr, deck_path_len, caller, er CALL drop_aggregate(h) CALL drop_saved_state(h) CALL set_point_line_map(h, line_ids) + ! the point route's EI = 0 lines take no rotation (CableDyn_UpdateRotations checks and + ! ignores it) + h%host_rot = rot CALL store_status(h, CD_C_OK, '') err_stat = CD_C_OK END SUBROUTINE init_deck_serialised @@ -424,23 +479,27 @@ PURE LOGICAL FUNCTION same_position(x, y) RESULT(same) same = ALL(ABS(x - y) <= 1.0e-9_wp*MAX(1.0_wp, ABS(y))) END FUNCTION same_position - SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, caller, err_stat, positions) + SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, caller, rotating, err_stat, positions) !! Build a BODIES/RODS deck on the coupled aggregate (transactional: the handle keeps its !! previous model on failure). Coupled/Vessel rods and bodies are 6-DOF host nodes, which the !! translational C ABI cannot drive; the standalone deck rules already reject them without a !! motionFile, and the aggregate rejects a motionFile. positions (3, n_moving): the host - !! positions of CableDyn_InitDeckAt, in the aggregate's coupled order. + !! positions of CableDyn_InitDeckAt, in the aggregate's coupled order. rotating: the host + !! passes the coupled points' rotations (CableDyn_InitDeckRotating), which a line restrained + !! in torsion needs; without it such a deck is refused. TYPE(CD_C_Handle), POINTER, INTENT(INOUT) :: h CHARACTER(*), INTENT(IN) :: deck_path LOGICAL, INTENT(IN) :: has_dtm REAL(wp), INTENT(IN) :: dtm CHARACTER(*), INTENT(IN) :: caller + LOGICAL, INTENT(IN) :: rotating INTEGER(C_INT), INTENT(OUT) :: err_stat REAL(wp), INTENT(IN), OPTIONAL :: positions(:, :) ! On the heap: InitDeck runs on the host's thread, whose stack size the host chooses. TYPE(CD_AGG_ModuleType), ALLOCATABLE :: new_agg INTEGER :: es, nm, stat, k REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :) + REAL(wp), ALLOCATABLE :: dcm(:, :, :), om(:, :), al(:, :), moment(:, :) CHARACTER(CD_C_MSG_LEN) :: em IF (.NOT. (has_dtm .AND. dtm > CD_ZERO)) THEN @@ -454,7 +513,8 @@ SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, caller, err_stat, pos RETURN END IF ! An absent positions argument stays absent through the optional coupled_positions. - CALL CD_AGG_Init_From_Deck(new_agg, deck_path, dtm, es, em, coupled_positions=positions) + CALL CD_AGG_Init_From_Deck(new_agg, deck_path, dtm, es, em, coupled_positions=positions, & + host_orientation=rotating) IF (es /= CD_AGG_OK) THEN CALL map_agg_status(es, err_stat) CALL store_status(h, err_stat, caller//': '//TRIM(em)) @@ -464,7 +524,8 @@ SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, caller, err_stat, pos nm = CD_AGG_NMovingPoints(new_agg, es, em) ! Allocate the new route's workspace before releasing the old route, so an ! allocation failure leaves the handle's previous model in place. - ALLOCATE (pos(3, nm), vel(3, nm), acc(3, nm), load(3, nm), STAT=stat) + ALLOCATE (pos(3, nm), vel(3, nm), acc(3, nm), load(3, nm), dcm(3, 3, nm), om(3, nm), al(3, nm), & + moment(3, nm), STAT=stat) IF (stat /= 0) THEN CALL CD_AGG_End(new_agg, es, em) CALL set_status(h, CD_C_ALLOC_FAIL, caller//': aggregate workspace allocation failed', err_stat) @@ -503,6 +564,20 @@ SUBROUTINE init_deck_aggregate(h, deck_path, has_dtm, dtm, caller, err_stat, pos CALL MOVE_ALLOC(vel, h%agg_vel) CALL MOVE_ALLOC(acc, h%agg_acc) CALL MOVE_ALLOC(load, h%agg_load) + dcm = CD_ZERO + DO k = 1, nm + dcm(1, 1, k) = CD_ONE + dcm(2, 2, k) = CD_ONE + dcm(3, 3, k) = CD_ONE + END DO + om = CD_ZERO + al = CD_ZERO + moment = CD_ZERO + CALL MOVE_ALLOC(dcm, h%agg_dcm) + CALL MOVE_ALLOC(om, h%agg_om) + CALL MOVE_ALLOC(al, h%agg_al) + CALL MOVE_ALLOC(moment, h%agg_moment) + h%host_rot = rotating CALL move_aggregate(new_agg, h%agg) CALL clear_point_line_map(h) h%use_agg = .TRUE. @@ -554,6 +629,7 @@ SUBROUTINE drop_saved_state(h) END IF CALL CD_FAST_End(h%saved_fast, es, em) h%saved_agg_t = CD_ZERO + IF (ALLOCATED(h%saved_dcm)) DEALLOCATE (h%saved_dcm, h%saved_om, h%saved_al) h%has_saved = .FALSE. END SUBROUTINE drop_saved_state @@ -567,6 +643,8 @@ SUBROUTINE drop_aggregate(h) h%agg_dt = CD_ZERO h%agg_t = CD_ZERO IF (ALLOCATED(h%agg_pos)) DEALLOCATE (h%agg_pos, h%agg_vel, h%agg_acc, h%agg_load) + IF (ALLOCATED(h%agg_dcm)) DEALLOCATE (h%agg_dcm, h%agg_om, h%agg_al, h%agg_moment) + h%host_rot = .FALSE. END SUBROUTINE drop_aggregate SUBROUTINE map_agg_status(agg_stat, err_stat) @@ -933,7 +1011,12 @@ SUBROUTINE CableDyn_UpdateStates(handle, q_ptr, v_ptr, a_ptr, n_coupled_dof, err h%agg_vel = RESHAPE(REAL(v_c, wp), SHAPE(h%agg_vel)) h%agg_acc = RESHAPE(REAL(a_c, wp), SHAPE(h%agg_acc)) END IF - CALL CD_AGG_UpdateStates_Moving(h%agg, h%agg_pos, h%agg_vel, h%agg_acc, es, em) + IF (h%host_rot) THEN + CALL CD_AGG_UpdateStates_Moving(h%agg, h%agg_pos, h%agg_vel, h%agg_acc, es, em, orientation=h%agg_dcm, & + angular_velocity=h%agg_om, angular_acceleration=h%agg_al) + ELSE + CALL CD_AGG_UpdateStates_Moving(h%agg, h%agg_pos, h%agg_vel, h%agg_acc, es, em) + END IF CALL map_agg_status(es, err_stat) CALL store_status(h, err_stat, em) RETURN @@ -1043,8 +1126,14 @@ SUBROUTINE CableDyn_Step(handle, dt, q_ptr, v_ptr, a_ptr, n_coupled_dof, converg h%agg_vel = RESHAPE(REAL(v_c, wp), SHAPE(h%agg_vel)) h%agg_acc = RESHAPE(REAL(a_c, wp), SHAPE(h%agg_acc)) END IF - CALL CD_AGG_Step_Moving(h%agg, REAL(dt, wp), h%agg_pos, h%agg_vel, h%agg_acc, conv_f, stall_f, nit, es, em, & - t_committed=h%agg_t + REAL(dt, wp)) + IF (h%host_rot) THEN + CALL CD_AGG_Step_Moving(h%agg, REAL(dt, wp), h%agg_pos, h%agg_vel, h%agg_acc, conv_f, stall_f, nit, es, & + em, t_committed=h%agg_t + REAL(dt, wp), orientation=h%agg_dcm, & + angular_velocity=h%agg_om, angular_acceleration=h%agg_al) + ELSE + CALL CD_AGG_Step_Moving(h%agg, REAL(dt, wp), h%agg_pos, h%agg_vel, h%agg_acc, conv_f, stall_f, nit, es, & + em, t_committed=h%agg_t + REAL(dt, wp)) + END IF IF (es == CD_AGG_OK) h%agg_t = h%agg_t + REAL(dt, wp) converged = LOGICAL(conv_f, C_BOOL) stalled = LOGICAL(stall_f, C_BOOL) @@ -1769,8 +1858,9 @@ SUBROUTINE CableDyn_SaveState(handle, err_stat) BIND(C, NAME='CableDyn_SaveState !! Save the whole model into the handle's single save slot, replacing any earlier save: !! every line, point, body and rod state with its solver history (viscoelastic, Syrope and !! friction states, the last converged step), the point fluid fields, and on the aggregate - !! route the committed time. The slot holds a deep copy of the model object, independent of - !! the step's own rollback buffers, so any number of steps may follow before the restore. + !! route the committed time and the host's rotations (CableDyn_UpdateRotations). The slot + !! holds a deep copy of the model object, independent of the step's own rollback buffers, + !! so any number of steps may follow before the restore. !! A successful Init* call discards the slot; a failed InitDeck/InitDeckAt keeps it with the !! model, and a failed InitLine/InitLines discards it unless the handle's live model is an !! aggregate (drop_point_save_on_failure). Only the allocation of the aggregate slot itself @@ -1795,6 +1885,12 @@ SUBROUTINE CableDyn_SaveState(handle, err_stat) BIND(C, NAME='CableDyn_SaveState END IF CALL copy_aggregate(h%agg, h%saved_agg) h%saved_agg_t = h%agg_t + ! the host's rotations are the inputs of the saved instant (CableDyn_UpdateRotations) + IF (h%host_rot) THEN + h%saved_dcm = h%agg_dcm + h%saved_om = h%agg_om + h%saved_al = h%agg_al + END IF ELSE CALL copy_point_system(h%fast, h%saved_fast) END IF @@ -1820,6 +1916,11 @@ SUBROUTINE CableDyn_RestoreState(handle, err_stat) BIND(C, NAME='CableDyn_Restor IF (h%use_agg) THEN CALL copy_aggregate(h%saved_agg, h%agg) h%agg_t = h%saved_agg_t + IF (h%host_rot) THEN + h%agg_dcm = h%saved_dcm + h%agg_om = h%saved_om + h%agg_al = h%saved_al + END IF ELSE CALL copy_point_system(h%saved_fast, h%fast) END IF @@ -1861,6 +1962,140 @@ SUBROUTINE CableDyn_GetCoupledLayout(handle, point_id_ptr, point_type_ptr, n_blo CALL store_status(h, CD_C_OK, '') END SUBROUTINE CableDyn_GetCoupledLayout + ! --------------------------------------------------------------------------------------- + ! Host rotations (C ABI 1, minor extension 3): CableDyn_InitDeckRotating (above, with + ! InitDeckAt), the rotation of each coupled block, and the coupled moments. + ! --------------------------------------------------------------------------------------- + + SUBROUTINE CableDyn_UpdateRotations(handle, dcm_ptr, omega_ptr, alpha_ptr, n_block, err_stat) & + BIND(C, NAME='CableDyn_UpdateRotations') + !! The host's rotation of each 3-DOF block k of the coupled vector, for the following + !! CableDyn_UpdateStates and CableDyn_Step calls (kept until the next call): dcm[9k + 3i + j] + !! = R_ij of the global-to-body DCM (row-major; rows are the body axes in global axes, the + !! OpenFAST mesh orientation), omega[3k + i] and alpha[3k + i] the body's angular velocity + !! and acceleration in global axes. The body is the host part the coupled point is fixed to, + !! with its axes on the deck's axes at the static start (identity). A finite-EI line's + !! host-driven end turns with it; the other blocks take no rotation (their entries are + !! checked and not used). n_block must equal CableDyn_NCoupledDOF / 3. Only a handle + !! initialised by CableDyn_InitDeckRotating takes rotations. The call is all or nothing: a + !! rejected input (a DCM that is not finite and proper orthogonal to 1e-8, non-finite rates) + !! leaves the rotations unchanged. + TYPE(C_PTR), VALUE :: handle, dcm_ptr, omega_ptr, alpha_ptr + INTEGER(C_INT), VALUE :: n_block + INTEGER(C_INT), INTENT(OUT) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + REAL(C_DOUBLE), POINTER :: dcm_c(:), om_c(:), al_c(:) + REAL(wp) :: r(3, 3), gram(3, 3), det + INTEGER :: n, k, i, j + + IF (.NOT. query_ready(handle, h, 'CableDyn_UpdateRotations', err_stat)) RETURN + IF (.NOT. h%host_rot) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: the handle takes no rotations (initialise it '// & + 'with CableDyn_InitDeckRotating)', err_stat) + RETURN + END IF + IF (n_block < 0_C_INT .OR. n_block > HUGE(n_block)/9_C_INT) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: n_block does not match '// & + 'CableDyn_NCoupledDOF / 3', err_stat) + RETURN + END IF + IF (.NOT. valid_coupled_dof_count(h, 3_C_INT*n_block, err_stat)) THEN + IF (err_stat == CD_C_BAD_INPUT) CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: n_block '// & + 'does not match CableDyn_NCoupledDOF / 3', err_stat) + RETURN + END IF + n = INT(n_block) + IF (n == 0) THEN + CALL store_status(h, CD_C_OK, '') + err_stat = CD_C_OK + RETURN + END IF + IF (.NOT. (C_ASSOCIATED(dcm_ptr) .AND. C_ASSOCIATED(omega_ptr) .AND. C_ASSOCIATED(alpha_ptr))) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: input pointer is null', err_stat) + RETURN + END IF + CALL C_F_POINTER(dcm_ptr, dcm_c, [9*n]) + CALL C_F_POINTER(omega_ptr, om_c, [3*n]) + CALL C_F_POINTER(alpha_ptr, al_c, [3*n]) + IF (.NOT. (ALL(IEEE_IS_FINITE(dcm_c)) .AND. ALL(IEEE_IS_FINITE(om_c)) .AND. ALL(IEEE_IS_FINITE(al_c)))) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: rotations must be finite', err_stat) + RETURN + END IF + ! every block is checked before any is stored (the aggregate's own test of its orientations) + DO k = 1, n + DO i = 1, 3 + DO j = 1, 3 + r(i, j) = REAL(dcm_c(9*(k - 1) + 3*(i - 1) + j), wp) + END DO + END DO + gram = MATMUL(r, TRANSPOSE(r)) + DO i = 1, 3 + gram(i, i) = gram(i, i) - CD_ONE + END DO + det = r(1, 1)*(r(2, 2)*r(3, 3) - r(2, 3)*r(3, 2)) - r(1, 2)*(r(2, 1)*r(3, 3) - r(2, 3)*r(3, 1)) + & + r(1, 3)*(r(2, 1)*r(3, 2) - r(2, 2)*r(3, 1)) + IF (MAXVAL(ABS(gram)) > 1.0e-8_wp .OR. ABS(det - CD_ONE) > 1.0e-8_wp) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: the DCM of block '//TRIM(int_text(k - 1))// & + ' is not proper orthogonal', err_stat) + RETURN + END IF + END DO + IF (h%use_agg) THEN + DO k = 1, n + DO i = 1, 3 + DO j = 1, 3 + h%agg_dcm(i, j, k) = REAL(dcm_c(9*(k - 1) + 3*(i - 1) + j), wp) + END DO + END DO + h%agg_om(:, k) = REAL(om_c(3*k - 2:3*k), wp) + h%agg_al(:, k) = REAL(al_c(3*k - 2:3*k), wp) + END DO + END IF + CALL store_status(h, CD_C_OK, '') + err_stat = CD_C_OK + END SUBROUTINE CableDyn_UpdateRotations + + SUBROUTINE CableDyn_GetCoupledMoments(handle, moments_ptr, n_coupled_dof, err_stat) & + BIND(C, NAME='CableDyn_GetCoupledMoments') + !! The moment each 3-DOF block of the coupled vector applies to the host, about the coupled + !! point in global axes, at the state CableDyn_CalcOutput reports: a finite-EI line's + !! torsional and bending reaction at its host-driven end (a line restrained in torsion, a + !! Rigid or spring bending END CONNECTION), zero for the other blocks and on the point + !! route. n_coupled_dof must equal CableDyn_NCoupledDOF. + TYPE(C_PTR), VALUE :: handle, moments_ptr + INTEGER(C_INT), VALUE :: n_coupled_dof + INTEGER(C_INT), INTENT(OUT) :: err_stat + TYPE(CD_C_Handle), POINTER :: h + REAL(C_DOUBLE), POINTER :: moments_c(:) + INTEGER :: es + CHARACTER(CD_C_MSG_LEN) :: em + + IF (.NOT. query_ready(handle, h, 'CableDyn_GetCoupledMoments', err_stat)) RETURN + IF (.NOT. valid_coupled_dof_count(h, n_coupled_dof, err_stat)) RETURN + IF (n_coupled_dof == 0_C_INT) THEN + CALL store_status(h, CD_C_OK, '') + err_stat = CD_C_OK + RETURN + END IF + IF (.NOT. C_ASSOCIATED(moments_ptr)) THEN + CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_GetCoupledMoments: moments pointer is null', err_stat) + RETURN + END IF + CALL C_F_POINTER(moments_ptr, moments_c, [INT(n_coupled_dof)]) + moments_c = 0.0_C_DOUBLE + IF (.NOT. h%use_agg) THEN + CALL store_status(h, CD_C_OK, '') + err_stat = CD_C_OK + RETURN + END IF + CALL CD_AGG_CalcOutput(h%agg, es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_GetMovingPointMesh(h%agg, h%agg_pos, h%agg_vel, h%agg_acc, h%agg_load, es, em, & + moment=h%agg_moment) + IF (es == CD_AGG_OK) moments_c = REAL(RESHAPE(h%agg_moment, [INT(n_coupled_dof)]), C_DOUBLE) + CALL map_agg_status(es, err_stat) + CALL store_status(h, err_stat, em) + END SUBROUTINE CableDyn_GetCoupledMoments + SUBROUTINE coupled_layout(h, ids, types, err_stat) !! Deck point id and point type (the CD_POINT_* codes) of each coupled block. Point route: !! the line-bound points of every type in deck POINT order. Aggregate route: the moving diff --git a/src/CableDyn_CAPI.h b/src/CableDyn_CAPI.h index d9067dd5..484be890 100644 --- a/src/CableDyn_CAPI.h +++ b/src/CableDyn_CAPI.h @@ -127,8 +127,9 @@ int CableDyn_NLines(void *handle, int *err_stat); * aggregate (it needs dtM); other decks keep the point route. Check * CableDyn_GetAbiMinor() >= 1 before using these on a library of unknown * vintage. CABLEDYN_CAPI_ABI_MINOR is the extension level this header - * declares (2: the host-coupling calls below are present too). */ -#define CABLEDYN_CAPI_ABI_MINOR 2 + * declares (3: the host-coupling and host-rotation calls below are present + * too). */ +#define CABLEDYN_CAPI_ABI_MINOR 3 #define CD_C_OBJ_LINE 1 #define CD_C_OBJ_POINT 2 @@ -218,6 +219,43 @@ void CableDyn_RestoreState(void *handle, int *err_stat); void CableDyn_GetCoupledLayout(void *handle, int *point_id, int *point_type, int n_block, int *err_stat); +/* ---- ABI 1, minor extension 3: host rotations ------------------------------ + * + * For a host that turns the bodies its Coupled points are fixed to: a line + * restrained in torsion (END CONNECTIONS TorsStiffness) and a Rigid bending END + * CONNECTION turn with the host at their coupled end, as on the coupled + * OpenFAST route. Check CableDyn_GetAbiMinor() >= 3 before using these on a + * library of unknown vintage. */ + +/* CableDyn_InitDeckAt for a host that passes rotations: the handle takes each + * coupled block's rotation from CableDyn_UpdateRotations and passes it with + * every CableDyn_UpdateStates and CableDyn_Step. The rotations start at + * identity (the deck's axes at the static start) and rest. n_q0 = 0 (q0 may be + * NULL) solves the statics at the deck positions, as CableDyn_InitDeck. A deck + * with a line restrained in torsion needs this initialization. */ +void CableDyn_InitDeckRotating(void *handle, const char *deck_path, + int deck_path_len, const double *q0, int n_q0, + int *err_stat); +/* The rotation of each 3-DOF block k of the coupled vector for the following + * UpdateStates and Step calls (kept until the next call; SaveState/RestoreState + * carry it): dcm[9k + 3i + j] = R_ij of the global-to-body DCM (row-major; the + * rows are the body axes in global axes), omega[3k + i] and alpha[3k + i] the + * body's angular velocity and acceleration in global axes. Only a finite-EI + * line's host-driven end uses its block; the other blocks are checked and not + * used. n_block = CableDyn_NCoupledDOF / 3. All or nothing: a DCM that is not + * finite and proper orthogonal (to 1e-8) or a non-finite rate leaves the + * rotations unchanged. */ +void CableDyn_UpdateRotations(void *handle, const double *dcm, + const double *omega, const double *alpha, + int n_block, int *err_stat); +/* The moment each block of the coupled vector applies to the host, about the + * coupled point in global axes, at the state CableDyn_CalcOutput reports: a + * finite-EI line's torsional and bending reaction at its host-driven end, zero + * for the other blocks and on the point route. Available on any initialized + * handle. */ +void CableDyn_GetCoupledMoments(void *handle, double *coupled_moments, + int n_coupled_dof, int *err_stat); + #ifdef __cplusplus } #endif diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 035060bf..6c7fdd97 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -283,7 +283,8 @@ MODULE CableDyn_DeckDriver CHARACTER(*), PARAMETER :: INSPECTION_NOTE = ' Output contains only committed states and is for inspection only.' ! a line restrained in torsion on an entry whose caller does not turn the fairlead frame CHARACTER(*), PARAMETER :: TORSION_NEEDS_ORIENTATION = 'a line restrained in torsion needs a host that '// & - 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, while the C API '// & + 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, and a C API host '// & + 'initialised with CableDyn_InitDeckRotating, while CableDyn_InitDeck/InitDeckAt '// & 'and a standalone deck that mixes EI = 0 and finite-EI lines without a BODY move '// & 'the line ends by translation only (with a BODY such a deck runs on the multibody '// & 'route, which supports torsion); set TorsStiffness Free in every END CONNECTIONS row' diff --git a/src/cabledyn.def b/src/cabledyn.def index 9d2679d4..107e180e 100644 --- a/src/cabledyn.def +++ b/src/cabledyn.def @@ -9,6 +9,7 @@ EXPORTS CableDyn_GetAbiMinor CableDyn_GetBodyState CableDyn_GetCoupledLayout + CableDyn_GetCoupledMoments CableDyn_GetCoupledMotion CableDyn_GetLastError CableDyn_GetLineValues @@ -19,6 +20,7 @@ EXPORTS CableDyn_GetVersionString CableDyn_InitDeck CableDyn_InitDeckAt + CableDyn_InitDeckRotating CableDyn_InitLine CableDyn_InitLines CableDyn_IsInitialized @@ -30,4 +32,5 @@ EXPORTS CableDyn_SaveState CableDyn_Step CableDyn_UpdatePointFluidFields + CableDyn_UpdateRotations CableDyn_UpdateStates diff --git a/src/cabledyn.exp b/src/cabledyn.exp index 945fcb2f..7c6ff0d0 100644 --- a/src/cabledyn.exp +++ b/src/cabledyn.exp @@ -8,6 +8,7 @@ _CableDyn_EvalChannel _CableDyn_GetAbiMinor _CableDyn_GetBodyState _CableDyn_GetCoupledLayout +_CableDyn_GetCoupledMoments _CableDyn_GetCoupledMotion _CableDyn_GetLastError _CableDyn_GetLineValues @@ -18,6 +19,7 @@ _CableDyn_GetVersion _CableDyn_GetVersionString _CableDyn_InitDeck _CableDyn_InitDeckAt +_CableDyn_InitDeckRotating _CableDyn_InitLine _CableDyn_InitLines _CableDyn_IsInitialized @@ -29,4 +31,5 @@ _CableDyn_RestoreState _CableDyn_SaveState _CableDyn_Step _CableDyn_UpdatePointFluidFields +_CableDyn_UpdateRotations _CableDyn_UpdateStates diff --git a/src/cabledyn.map b/src/cabledyn.map index 125f69b0..53952d5c 100644 --- a/src/cabledyn.map +++ b/src/cabledyn.map @@ -11,6 +11,7 @@ CableDyn_GetAbiMinor; CableDyn_GetBodyState; CableDyn_GetCoupledLayout; + CableDyn_GetCoupledMoments; CableDyn_GetCoupledMotion; CableDyn_GetLastError; CableDyn_GetLineValues; @@ -21,6 +22,7 @@ CableDyn_GetVersionString; CableDyn_InitDeck; CableDyn_InitDeckAt; + CableDyn_InitDeckRotating; CableDyn_InitLine; CableDyn_InitLines; CableDyn_IsInitialized; @@ -32,6 +34,7 @@ CableDyn_SaveState; CableDyn_Step; CableDyn_UpdatePointFluidFields; + CableDyn_UpdateRotations; CableDyn_UpdateStates; local: *; diff --git a/tests/test_c_api_host_coupling.c b/tests/test_c_api_host_coupling.c index d85fbec6..c3b65c30 100644 --- a/tests/test_c_api_host_coupling.c +++ b/tests/test_c_api_host_coupling.c @@ -206,8 +206,8 @@ static int edit_deck(const char *in_path, const char *out_path, const char *old_ static int check_version(void) { - CHECK(CABLEDYN_CAPI_ABI_MINOR == 2 && CableDyn_GetAbiMinor() == CABLEDYN_CAPI_ABI_MINOR, - "ABI minor level 2"); + CHECK(CABLEDYN_CAPI_ABI_MINOR >= 2 && CableDyn_GetAbiMinor() == CABLEDYN_CAPI_ABI_MINOR, + "ABI minor level 2 or later"); return 0; } diff --git a/tests/test_c_api_host_rotation.c b/tests/test_c_api_host_rotation.c new file mode 100644 index 00000000..963e5fb6 --- /dev/null +++ b/tests/test_c_api_host_rotation.c @@ -0,0 +1,404 @@ +/* File: tests/test_c_api_host_rotation.c + * SPDX-License-Identifier: Apache-2.0 + * Host-rotation gate of C ABI 1 minor extension 3, through the public header + * and the shared library. + * + * Usage: test_c_api_host_rotation + * + * The test writes the straight neutral torsion line of test_coupled_torsion + * (GJ 5e4 N m^2, 100 m along +x from the Coupled fairlead (0, 0, -50) to a + * Fixed anchor, 40 elements, both ends clamped and restrained in torsion, a + * negligible polar inertia: the quasi-static torsion) and checks: + * - CableDyn_InitDeck refuses the deck and names CableDyn_InitDeckRotating, + * which accepts it (statics at the deck positions, rotations at rest); + * - feedthrough: CableDyn_UpdateRotations with a 20 deg roll about the line + * axis, then CableDyn_UpdateStates, twists the end element alone (Twist1 = + * -20 deg); CableDyn_GetCoupledMoments returns its torque GJ phi / l_e about + * the line axis, resisting the roll, and no bending moment; + * - march: a roll at 60 deg/s gives Twist1 = -phi(t) and the quasi-static + * torque GJ phi / L at both ends and as the coupled moment, at every step; + * - SaveState/RestoreState carry the rotations: a restore after other + * rotations were set steps bit-identically to the step from the save; + * - the rejections are all or nothing: a wrong block count, a null pointer, a + * DCM that is not proper orthogonal and a non-finite rate leave the handle + * stepping bit-identically to one that never saw them; + * - a handle initialised without rotations refuses CableDyn_UpdateRotations; + * the EI = 0 point route (box_points.dat) takes rotations and ignores them, + * and its coupled moments are zero. + * The decks this test writes are removed on every exit path. + */ +#include "CableDyn_CAPI.h" + +#include +#include +#include +#include + +#define CHECK(condition, message) \ + do { \ + if (!(condition)) { \ + fprintf(stderr, "FAIL: %s\n", (message)); \ + return 1; \ + } \ + } while (0) + +/* CHECK for functions that release resources at their label done. */ +#define REQUIRE(condition, message) \ + do { \ + if (!(condition)) { \ + fprintf(stderr, "FAIL: %s\n", (message)); \ + goto done; \ + } \ + } while (0) + +#define PI 3.14159265358979323846 +#define DEG (PI / 180.0) +#define GJ 5.0e4 +#define LEN 100.0 +#define NSEG 40 +#define DT 0.05 + +static const char *g_box; + +#define TORSION_DECK "capi_rot_torsion.dat" +#define FREE_DECK "capi_rot_free.dat" +static const char *const g_written[] = {TORSION_DECK, FREE_DECK}; + +static void remove_written_decks(void) +{ + for (size_t i = 0; i < sizeof g_written / sizeof g_written[0]; ++i) remove(g_written[i]); +} + +static void report(void *h, const char *where, int err) +{ + char msg[1025]; + CableDyn_GetLastError(h, msg, (int)sizeof msg); + fprintf(stderr, "FAIL: %s (status %d): %s\n", where, err, msg); +} + +static int last_error_has(void *h, const char *text) +{ + char msg[4097]; + CableDyn_GetLastError(h, msg, (int)sizeof msg); + return strstr(msg, text) != NULL; +} + +/* The straight neutral torsion line; tors = "Rigid" (restrained) or "Free". */ +static int write_deck(const char *path, const char *tors) +{ + FILE *f = fopen(path, "w"); + if (!f) return 1; + fputs("host rotation gate\n--- LINE TYPES ---\n", f); + fputs("Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat\n", f); + fputs("(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)\n", f); + fprintf(f, "cab 0.2 %.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", 1025.0 * 0.25 * PI * 0.04); + fputs("--- POINTS ---\nID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n", f); + fputs("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); + fputs("--- LINES ---\nID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 -\n", f); + fputs("--- SECTIONS ---\nLineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 cab 100.0 40\n", f); + fputs("--- END CONNECTIONS ---\nLineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist\n", f); + fputs("(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)\n", f); + fprintf(f, "1 A Rigid 1 0 0 %s 0 0 1 0\n1 B Rigid 1 0 0 %s 0 0 1 0\n", tors, tors); + fputs("--- OPTIONS ---\n9.80665 g\n1025.0 rhoW\n0.05 dtM\n0.0 TMax\n", f); + fputs(strcmp(tors, "Free") == 0 ? "--- OUTPUTS ---\nFairTen1\n--- END ---\n" + : "--- OUTPUTS ---\nTorq1N1\nTorq1N41\nTwist1\n--- END ---\n", + f); + return fclose(f) != 0; +} + +/* OpenFAST mesh orientation (global to local) of a roll phi about +x, row-major. */ +static void roll_dcm(double phi, double *r) +{ + const double c = cos(phi), s = sin(phi); + const double m[9] = {1.0, 0.0, 0.0, 0.0, c, s, 0.0, -s, c}; + memcpy(r, m, sizeof m); +} + +static int channel(void *h, const char *token, double *value) +{ + int err = -1; + CableDyn_EvalChannel(h, token, (int)strlen(token), value, &err); + if (err != CD_C_OK) { + report(h, token, err); + return 1; + } + return 0; +} + +static int rotate(void *h, double phi, double rate) +{ + double r[9]; + const double om[3] = {rate, 0.0, 0.0}, al[3] = {0.0, 0.0, 0.0}; + int err = -1; + roll_dcm(phi, r); + CableDyn_UpdateRotations(h, r, om, al, 1, &err); + if (err != CD_C_OK) { + report(h, "UpdateRotations", err); + return 1; + } + return 0; +} + +static int step_at_deck(void *h) +{ + const double q[3] = {0.0, 0.0, -50.0}, z[3] = {0.0, 0.0, 0.0}; + bool converged = false, stalled = false; + int n_iter = 0, err = -1; + CableDyn_Step(h, DT, q, z, z, 3, &converged, &stalled, &n_iter, &err); + if (err != CD_C_OK || !converged) { + report(h, "Step", err); + return 1; + } + return 0; +} + +static int moments(void *h, double *m) +{ + int err = -1; + CableDyn_GetCoupledMoments(h, m, 3, &err); + if (err != CD_C_OK) { + report(h, "GetCoupledMoments", err); + return 1; + } + return 0; +} + +static int init_rotating(void **h, const char *deck) +{ + int err = -1; + CableDyn_Create(h, &err); + CHECK(err == CD_C_OK, "create"); + CableDyn_InitDeckRotating(*h, deck, (int)strlen(deck), NULL, 0, &err); + if (err != CD_C_OK) { + report(*h, "InitDeckRotating", err); + return 1; + } + return 0; +} + +static void close_handle(void **h) +{ + int err; + if (*h) CableDyn_Close(h, &err); + *h = NULL; +} + +static int check_init(void) +{ + void *h = NULL; + int err = -1, failed = 1; + CHECK(CableDyn_GetAbiMinor() >= 3, "the library declares ABI minor 3"); + CableDyn_Create(&h, &err); + REQUIRE(err == CD_C_OK, "create"); + CableDyn_InitDeck(h, TORSION_DECK, (int)strlen(TORSION_DECK), &err); + if (err != CD_C_BAD_INPUT || !last_error_has(h, "CableDyn_InitDeckRotating")) { + report(h, "InitDeck refuses a line restrained in torsion, naming CableDyn_InitDeckRotating", err); + goto done; + } + close_handle(&h); + if (init_rotating(&h, TORSION_DECK)) goto done; + REQUIRE(CableDyn_NCoupledDOF(h, &err) == 3 && err == CD_C_OK, "one coupled point"); + { + double ta, tw, m[3]; + if (channel(h, "Torq1N1", &ta) || channel(h, "Twist1", &tw) || moments(h, m)) goto done; + REQUIRE(fabs(ta) <= 1.0e-6 && fabs(tw) <= 1.0e-9, "no pretwist, no torque at rest"); + REQUIRE(fabs(m[0]) <= 1.0e-6, "no coupled torque at rest"); + } + /* a handle without rotations refuses them */ + close_handle(&h); + CableDyn_Create(&h, &err); + REQUIRE(err == CD_C_OK, "create"); + CableDyn_InitDeck(h, FREE_DECK, (int)strlen(FREE_DECK), &err); + if (err != CD_C_OK) { + report(h, "InitDeck (torsion free)", err); + goto done; + } + { + double r[9]; + const double z[3] = {0.0, 0.0, 0.0}; + roll_dcm(0.1, r); + CableDyn_UpdateRotations(h, r, z, z, 1, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(h, "CableDyn_InitDeckRotating"), + "a handle initialised by CableDyn_InitDeck refuses rotations"); + } + puts("init: InitDeck refuses the torsion deck, InitDeckRotating takes it at rest"); + failed = 0; +done: + close_handle(&h); + return failed; +} + +static int check_feedthrough(void) +{ + void *h = NULL; + int err = -1, failed = 1; + const double phi = 20.0 * DEG, le = LEN / NSEG, m_ref = GJ * phi / le; + const double q[3] = {0.0, 0.0, -50.0}, z[3] = {0.0, 0.0, 0.0}; + double ta, tb, tw, m[3]; + if (init_rotating(&h, TORSION_DECK)) goto done; + if (rotate(h, phi, 0.0)) goto done; + CableDyn_UpdateStates(h, q, z, z, 3, &err); + if (err != CD_C_OK) { + report(h, "UpdateStates", err); + goto done; + } + if (channel(h, "Torq1N1", &ta) || channel(h, "Torq1N41", &tb) || channel(h, "Twist1", &tw) || moments(h, m)) + goto done; + printf("feedthrough: Twist1 %.9f deg, Torq1N1 %.6e (ref %.6e), coupled moment %.6e %.3e %.3e\n", tw, ta, + -m_ref, m[0], m[1], m[2]); + REQUIRE(fabs(tw + 20.0) <= 1.0e-6, "feedthrough: Twist1 = -roll"); + REQUIRE(fabs(ta + m_ref) <= 1.0e-6 * m_ref && fabs(tb) <= 1.0e-9 * m_ref, + "feedthrough: the end element alone takes the twist"); + REQUIRE(fabs(fabs(m[0]) - m_ref) <= 1.0e-6 * m_ref, "feedthrough: the coupled moment is the torque"); + REQUIRE(m[0] * phi < 0.0, "feedthrough: the moment on the host resists its roll"); + REQUIRE(fmax(fabs(m[1]), fabs(m[2])) <= 1.0e-6 * m_ref, "feedthrough: a straight line has no bending moment"); + failed = 0; +done: + close_handle(&h); + return failed; +} + +static int check_march(void) +{ + void *h = NULL; + int failed = 1; + const double rate = 60.0 * DEG; + double werr = 0.0, terr = 0.0, merr = 0.0; + if (init_rotating(&h, TORSION_DECK)) goto done; + for (int k = 1; k <= 10; ++k) { + const double phi = rate * DT * k; + double ta, tb, tw, m[3]; + if (rotate(h, phi, rate) || step_at_deck(h)) goto done; + if (channel(h, "Torq1N1", &ta) || channel(h, "Torq1N41", &tb) || channel(h, "Twist1", &tw) || moments(h, m)) + goto done; + werr = fmax(werr, fabs(tw + phi / DEG)); + terr = fmax(terr, fmax(fabs(ta + GJ * phi / LEN), fabs(tb - ta))); + merr = fmax(merr, fmax(fabs(m[0] + GJ * phi / LEN), fmax(fabs(m[1]), fabs(m[2])))); + } + printf("march: Twist1 error %.3e deg, torque error %.3e N m, coupled moment error %.3e N m\n", werr, terr, merr); + REQUIRE(werr <= 1.0e-6, "march: Twist1 = -roll(t) at every step"); + REQUIRE(terr <= 1.0e-6 * GJ, "march: Torq = GJ Twist / L at both ends at every step"); + REQUIRE(merr <= 1.0e-6 * GJ, "march: the coupled moment is the restoring torque at every step"); + failed = 0; +done: + close_handle(&h); + return failed; +} + +static int check_save_restore(void) +{ + void *h = NULL; + int err = -1, failed = 1; + const double rate = 60.0 * DEG; + double m1[3], m2[3], tw1, tw2; + if (init_rotating(&h, TORSION_DECK)) goto done; + for (int k = 1; k <= 4; ++k) + if (rotate(h, rate * DT * k, rate) || step_at_deck(h)) goto done; + if (rotate(h, rate * DT * 5, rate)) goto done; + CableDyn_SaveState(h, &err); + REQUIRE(err == CD_C_OK, "SaveState"); + if (step_at_deck(h) || moments(h, m1) || channel(h, "Twist1", &tw1)) goto done; + /* other rotations set and stepped before the restore */ + if (rotate(h, rate * DT * 9, 3.0 * rate) || step_at_deck(h)) goto done; + CableDyn_RestoreState(h, &err); + REQUIRE(err == CD_C_OK, "RestoreState"); + if (step_at_deck(h) || moments(h, m2) || channel(h, "Twist1", &tw2)) goto done; + printf("save/restore: coupled torque %.9e and %.9e\n", m1[0], m2[0]); + REQUIRE(memcmp(m1, m2, sizeof m1) == 0 && tw1 == tw2, + "a restore brings back the saved rotations and steps bit-identically"); + failed = 0; +done: + close_handle(&h); + return failed; +} + +static int check_rejections(void) +{ + void *a = NULL, *b = NULL; + int err = -1, failed = 1; + const double rate = 60.0 * DEG; + double r[9], ma[3], mb[3]; + const double z[3] = {0.0, 0.0, 0.0}; + if (init_rotating(&a, TORSION_DECK) || init_rotating(&b, TORSION_DECK)) goto done; + for (int k = 1; k <= 3; ++k) { + const double phi = rate * DT * k; + if (rotate(a, phi, rate) || rotate(b, phi, rate)) goto done; + /* rejected updates on a only */ + roll_dcm(phi + 0.5, r); + CableDyn_UpdateRotations(a, r, z, z, 2, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(a, "n_block"), "a wrong block count is refused"); + CableDyn_UpdateRotations(a, r, NULL, z, 1, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(a, "null"), "a null pointer is refused"); + for (int i = 0; i < 9; ++i) r[i] *= 1.01; + CableDyn_UpdateRotations(a, r, z, z, 1, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(a, "proper orthogonal"), + "a DCM that is not proper orthogonal is refused"); + roll_dcm(phi + 0.5, r); + { + const double nan_rate[3] = {NAN, 0.0, 0.0}; + CableDyn_UpdateRotations(a, r, nan_rate, z, 1, &err); + REQUIRE(err == CD_C_BAD_INPUT && last_error_has(a, "finite"), "a non-finite rate is refused"); + } + if (step_at_deck(a) || step_at_deck(b)) goto done; + } + if (moments(a, ma) || moments(b, mb)) goto done; + REQUIRE(memcmp(ma, mb, sizeof ma) == 0, "rejected rotations leave the handle unchanged"); + puts("rejections: block count, null pointer, DCM, rate refused; the handle steps unchanged"); + failed = 0; +done: + close_handle(&a); + close_handle(&b); + return failed; +} + +static int check_point_route(void) +{ + void *h = NULL; + int err = -1, failed = 1, n, nb; + double *dcm = NULL, *om = NULL, *m = NULL; + if (init_rotating(&h, g_box)) goto done; + n = CableDyn_NCoupledDOF(h, &err); + REQUIRE(err == CD_C_OK && n > 0 && n % 3 == 0, "the box has coupled blocks"); + nb = n / 3; + dcm = calloc((size_t)(9 * nb), sizeof *dcm); + om = calloc((size_t)(3 * nb), sizeof *om); + m = malloc((size_t)n * sizeof *m); + REQUIRE(dcm && om && m, "allocation"); + for (int k = 0; k < nb; ++k) roll_dcm(0.3, dcm + 9 * k); + CableDyn_UpdateRotations(h, dcm, om, om, nb, &err); + REQUIRE(err == CD_C_OK, "the point route takes rotations"); + for (int i = 0; i < n; ++i) m[i] = 1.0; + CableDyn_GetCoupledMoments(h, m, n, &err); + REQUIRE(err == CD_C_OK, "GetCoupledMoments on the point route"); + for (int i = 0; i < n; ++i) REQUIRE(m[i] == 0.0, "EI = 0 lines apply no moment"); + puts("point route: rotations taken and unused, moments zero"); + failed = 0; +done: + free(dcm); + free(om); + free(m); + close_handle(&h); + return failed; +} + +int main(int argc, char **argv) +{ + int failed; + if (argc != 2) { + fputs("usage: test_c_api_host_rotation \n", stderr); + return 2; + } + g_box = argv[1]; + remove_written_decks(); + if (write_deck(TORSION_DECK, "Rigid") || write_deck(FREE_DECK, "Free")) { + fputs("FAIL: writing the decks\n", stderr); + remove_written_decks(); + return 1; + } + failed = check_init() || check_feedthrough() || check_march() || check_save_restore() || check_rejections() || + check_point_route(); + remove_written_decks(); + if (failed) return 1; + puts("PASS: CableDyn C API host rotations"); + return 0; +} From 6195432e47d934988b5de3c488428ea6060ab669 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 18:58:21 +0900 Subject: [PATCH 22/51] feat(torsion): ATTACHMENTS on a line restrained in torsion (#71) A finite-EI line restrained in torsion refused discrete ATTACHMENTS ("torsion is not combined with ATTACHMENTS in this build"), which ruled out the usual lazy-wave power cable with buoyancy modules. The static start of an attachment line solves the smeared equilibrium, then carries it to the lumped loads by a homotopy (the attachment polish); the torsion stage ran on the smeared state before the polish, whose untwisted solves would have unwound it. - A line with ATTACHMENTS takes its torsion stage after the polish, on the discrete equilibrium: `torsion_stage` runs on the final mesh with the modules' net weights `-(m - rho V) g` (and, in a deck current, their drag) as nodal loads (`hermite_static_torsion` passes `f_nodal` to the static solve). The drag depends on the node's depth and tangent, so the stage repeats with the drag of the last twisted state until the nodes move by less than 1e-9 m, as the polish does. - Every drag pass starts from the polished, untwisted state, so a writhe a buckling descent left cannot put the next pass on another branch. - The twisted discrete start gets the mesh safety diagnosis (`attachment_mesh_checks`, the kink limit away from the attachment nodes and, under `tensile_safety True`, no compression with the torque-tension coupling force added), which the smeared-state diagnosis cannot give it; the verdict of a polish fallback shares the same checks. The untwisted state's lateral hand-off note is not written for a torsion line (the torsion stage tests the twisted start's stability). - The torsion notes moved to `torsion_note`, written once for the accepted stage. - The deck rule and its Python mirror are removed; docs (driver format, capabilities, troubleshooting) say the modules add no polar inertia to the twist. Gates, new `torsion_attachments`: - neutral modules (m = rho V, no drag) on the straight taut twisted line of `test_torsion_deck`: torque and twist equal the bare line's, GJ Phi / L and 720 deg; - `tests/data/lazy_wave_torsion_attachments.dat` (25 modules, one turn of pretwist, Irn 1 kg m: the nodal twist): a still 10 s run keeps the fairlead tension, both end torques and the twist of the static start to the output precision (spread 0 of 8 digits), in still water and in a cross-flow current of (0.2, 0.3) m/s. With the torsion stage on the smeared state (before the polish) the start is untwisted by the polish and the run rings by 3.4e-3 (End A) and 6.7e-3 (End B) of the torque. - a coupled line (GJ|K, Phi = -45 deg) whose coupling force compresses it, with one neutral module, is refused under `tensile_safety True` as the bare line is (the smeared-state diagnosis alone let it start with -2142 N). `torsion_deck` and the Python parity test now accept the deck they refused. Full suite passes; examples unchanged. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 6 + CMakeLists.txt | 7 + doc/capabilities.rst | 5 +- doc/driver_format.md | 7 +- doc/theory.rst | 3 +- doc/troubleshooting.rst | 5 +- python/cabledyn/deck_file.py | 6 - python/tests/test_deck_native_parity.py | 2 +- src/CableDyn_DeckDriver.f90 | 256 ++++++++++++++--- tests/data/lazy_wave_torsion_attachments.dat | 51 ++++ tests/test_torsion_attachments.f90 | 278 +++++++++++++++++++ tests/test_torsion_deck.f90 | 12 +- 12 files changed, 575 insertions(+), 63 deletions(-) create mode 100644 tests/data/lazy_wave_torsion_attachments.dat create mode 100644 tests/test_torsion_attachments.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index ed89f606..1fd9b19e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,12 @@ All notable changes to CableDyn are recorded in this file. The format follows line rolled at 60 deg/s the coupled torque is the quasi-static `GJ phi / L` to 3e-6 N m, and `SaveState`/`RestoreState` carry the rotations. Python: `CableDyn.init_deck_rotating`, `update_rotations`, `coupled_moments`. +- `ATTACHMENTS` on a finite-EI line restrained in torsion: the torsion stage of the static start + runs on the discrete equilibrium, after the attachment polish, with the modules' net weights + and current drag (to a fixed point) as nodal loads. A lazy wave with 25 buoyancy modules and + one turn of pretwist, in still water and in a cross-flow current, keeps its torque, twist and + fairlead tension over a still 10 s run to the output precision (a torsion stage before the + polish would ring by 3e-3 of the torque); neutral modules reproduce the bare line's GJ Phi / L. - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 86650b99..80bb7490 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2095,6 +2095,13 @@ target_link_libraries(test_torsion_deck PRIVATE cabledyn_core) add_test(NAME torsion_deck COMMAND test_torsion_deck) set_tests_properties(torsion_deck PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_torsion_attachments tests/test_torsion_attachments.f90) +target_link_libraries(test_torsion_attachments PRIVATE cabledyn_core) +add_test(NAME torsion_attachments + COMMAND test_torsion_attachments ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_torsion_attachments.dat + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(torsion_attachments PROPERTIES LABELS "fortran;driver;integration;static;dynamic") + add_executable(test_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) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 06cb61a7..37dd07fb 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -96,7 +96,7 @@ Line and constitutive capability range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI aggregate and ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by translation only), OpenFAST linearisation of a line restrained in torsion, - rod ends, bodies other than Rigid6, lines with ``ATTACHMENTS``, modal analysis, and + rod ends, bodies other than Rigid6, modal analysis, and ``False alpha_force_blend``. Not modelled: seabed friction against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws @@ -106,7 +106,8 @@ Line and constitutive capability production route * - Discrete attachments (``ATTACHMENTS``: buoyancy modules, clumps) - Supported - - lumped at nodes of a finite-EI cable, standalone and coupled; rejected on the two-moving-end + - 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 * - Bend stiffeners (``STIFFENERS``) - Supported with limits diff --git a/doc/driver_format.md b/doc/driver_format.md index 4b26a61a..93552c5b 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -862,7 +862,7 @@ Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B `GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point or a Rigid6 `Body` point; in a coupled OpenFAST or FAST.Farm run the End A frame turns with the platform (see the manual's OpenFAST page, Line torsion). Each of the following stops with a named error: -torsion on an `EI = 0` line, on a rod end or on a `Point3` body, a line with `ATTACHMENTS`, +torsion on an `EI = 0` line, on a rod end or on a `Point3` body, modal analysis (`nModes`), a dynamic or coupled run with `False alpha_force_blend`, any restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines without a body or through the C API's `CableDyn_InitDeck`/`InitDeckAt`, which move the line @@ -945,7 +945,10 @@ Behaviour: - The static equilibrium is solved first with each attachment's net weight spread over the two elements at its node, then carried to the discrete loads by continuation. The current drag depends on the node's depth and line direction, so the final solve is repeated until the - node positions change by less than 1e-9 m. + node positions change by less than 1e-9 m. On a line restrained in torsion the torsion stage + (the imposed twist) follows on the discrete equilibrium, with the attachments' net weights + and drag as nodal loads (the drag again to a fixed point), so a run starts in the twisted + equilibrium. An attachment adds no polar inertia to the line's twist. - A row fails if the line is not finite-EI, the arc lies beyond the line, every one of `Mass`, `Volume`, `CdA` and `CdAx` is zero, a value is negative or non-finite, or a series has a non-positive diff --git a/doc/theory.rst b/doc/theory.rst index 76bab7a5..faecf21e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -442,7 +442,8 @@ post-buckled states of the validation (see :doc:`validation`) that rate is 0.05 same term enters the dynamic effective tangent, scaled by :math:`1 - \alpha_f` of the force blend, and is frozen together with a reused factorisation. -**Statics and stability.** The imposed twist is the last static load stage, ramped from the +**Statics and stability.** The imposed twist is the last static load stage (on a line with +``ATTACHMENTS``, after the attachment polish, on the discrete equilibrium), ramped from the geometric twist of the untwisted equilibrium in steps of at most :math:`\pi/4`. Each converged stage is tested for stability by the inertia of :math:`\mathbf{K}` on the free DOFs, :math:`\operatorname{neg}(\mathbf{K}) = \operatorname{neg}(\mathbf{B}) - diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index c9179535..b9bb2e23 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -393,10 +393,9 @@ Torsion with Fixed End B`` - torsion is solved on cubic-Hermite lines whose End B is an anchor. * - ``a torsional END CONNECTION on a rod end is not supported`` / ``on a body needs a Rigid6 - body`` / ``torsion is not combined with ATTACHMENTS in this build`` + body`` - outside the torsion scope (:doc:`capabilities`). Move End A to a ``Fixed``, - ``Coupled``/``Vessel`` point or a Rigid6 body, or represent the modules as a smeared - buoyancy section. + ``Coupled``/``Vessel`` point or a Rigid6 body. * - ``a line restrained in torsion needs a host that turns its fairlead frame`` - the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body, and the C API's ``CableDyn_InitDeck``/``InitDeckAt``, move the line ends by translation only. Run the diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 19745538..7ec699f9 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4225,7 +4225,6 @@ def _check_torsion_lines( and FAST.Farm routes turn the fairlead frame with the platform and accept it. """ # _check_attachments has already accepted every LineID as an integer - attachment_lines = {str(_native_int(row.tokens[0])) for row in self._rows("ATTACHMENTS")} torsion_lines: set[str] = set() has_torsion_column = False for line_id, ends in torsion_ends.items(): @@ -4259,11 +4258,6 @@ 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 line_id in attachment_lines: - raise DeckFormatError( - f"{self._label}: line {line_id}: torsion is not combined with ATTACHMENTS " - "in this build" - ) if _rod_point(point_types[end_a]) is not None: raise DeckFormatError( f"{self._label}: line {line_id}: a torsional END CONNECTION on a rod end is " diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 21d15d46..be2879ca 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -1057,7 +1057,7 @@ def test_torsion_scope_rules_follow_the_native_checks(): f"1 50.0 10.0 0.0 0.0 0.0\n{_BAR} OPTIONS {_BAR}", ), ) - _rejects(attachments, "torsion is not combined with ATTACHMENTS") + DeckFile.from_text(attachments) # a torsional line with ATTACHMENTS is accepted # restrained at both ends, End B must be Fixed _rejects( _torsion_two_moving("1 A Pinned 1 0 0 Rigid 0 0 1 0\n"), diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 6c7fdd97..6ca7bfce 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -1824,6 +1824,10 @@ 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 residual tolerance the accepted torsion stage met (torsion_note) + REAL(wp) :: tors_tol_used + CHARACTER(*), PARAMETER :: TWISTED_WHAT = 'finite-EI static solve with discrete ATTACHMENTS: the twisted '// & + 'discrete equilibrium ' ! 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(:) @@ -2968,7 +2972,9 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 'found, so a cross-flow or a lateral disturbance can move the line away from it' CALL report_note(note_text) END IF - IF (tors_line) THEN + ! A line with ATTACHMENTS takes its torsion stage on the discrete equilibrium, after the + ! attachment polish (torsion_after_attachments). + IF (tors_line .AND. .NOT. has_att) THEN CALL torsion_stage(es, em) IF (es /= CD_DECKDRV_OK) THEN ErrStat = es @@ -2976,6 +2982,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ErrMsg = 'CableDyn_DeckDriver: line '//TRIM(int_to_str(ln%id))//': '//TRIM(em) RETURN END IF + CALL torsion_note() END IF IF (contact_enabled) CALL anchor_overshoot_note() ! Safety is independent of the opt-in adaptive accuracy policy. Diagnose the @@ -3116,9 +3123,24 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, 'load steps) and passed the acceptance checks of the smeared state') END IF ! On the final mesh, with the bare weights the polished state carries; the bending-length - ! rule of the note uses the smeared section weights w. - CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, fixed_dofs, & - .TRUE.) + ! rule of the note uses the smeared section weights w. A line restrained in torsion starts + ! from the twisted state, whose stability the torsion stage tests (with the same static + ! constraints: its static solve runs in 3D), so the note of the untwisted state is not + ! written for it. + IF (.NOT. tors_line) & + CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & + fixed_dofs, .TRUE.) + IF (tors_line) THEN + CALL torsion_after_attachments(es, em) + IF (es == CD_DECKDRV_OK) CALL twisted_attachment_checks(es, em) + IF (es /= CD_DECKDRV_OK) THEN + ErrStat = es + IF (INDEX(em, 'CableDyn_DeckDriver: ') == 1) em = em(LEN('CableDyn_DeckDriver: ') + 1:) + ErrMsg = 'CableDyn_DeckDriver: line '//TRIM(int_to_str(ln%id))//': '//TRIM(em) + RETURN + END IF + CALL torsion_note() + END IF w = w_bare WRITE (note_text, '(A,I0,A,I0,A,ES10.3,A)') 'line ', ln%id, ': ', SIZE(att_node), & ' attachment(s) lumped at the nearest nodes (largest arc offset ', att_offset, ' m)' @@ -3306,42 +3328,57 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF CONTAINS - SUBROUTINE torsion_stage(est, emt) + SUBROUTINE torsion_stage(est, emt, f_nodal) !! The condensed-torsion load stage of a line restrained in torsion at both ends: from the !! converged untwisted state on the final mesh (l0_am), CD_HermiteCable_Static_Solve ramps !! the imposed twist Phi = Pretwist(End B) - Pretwist(End A) with the same loads, contact, !! end connections and current as the untwisted solve, tests every stage for stability and !! descends from an unstable one. End frames are taken in the solve frame: internal end 1 !! is deck End B (global axes), end 2 deck End A (its parent's axes, turned with it). + !! f_nodal: the stage of a line with ATTACHMENTS, after the attachment polish (the final + !! mesh then is l0, with the bare weights w_bare and the deck mesh l0_deck_att), with the + !! attachments' lumped loads. INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt + REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) REAL(wp) :: nvec(3), dvec(3), tol_t INTEGER :: k, attempt - CHARACTER(320) :: tnote + LOGICAL :: nodal_loads TYPE(CD_HermiteTorsionType) :: tors0 + ! the deck mesh, the final mesh and its per-element arrays of this stage + REAL(wp), ALLOCATABLE :: ld(:), lf(:), w_fin(:) est = CD_DECKDRV_OK emt = '' + IF (PRESENT(f_nodal)) THEN + ld = l0_deck_att + lf = l0 + w_fin = w_bare + ELSE + ld = l0 + lf = l0_am + w_fin = w_am + END IF tors = CD_HermiteTorsionType() tors%active = .TRUE. 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) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%gj, ld, lf) ! 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) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%couple, ld, lf) END IF ! the polar rotary inertia Irn per element: the dynamics then carries a twist angle at ! every node (CD_HermiteCable_Dyn_Set_Torsion) tors%irn = i_rn_in - IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%irn, l0, l0_am) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%irn, ld, lf) ! torsional damping (GJ|K|Bt): a negative value is -zeta of an element's critical torsional ! damping l0 sqrt(GJ Irn), on the final mesh IF (ANY(ABS(bt_in) > CD_ZERO)) THEN tors%bt = bt_in - IF (SIZE(l0_am) /= SIZE(l0)) CALL remap_elem_by_reference_arc(tors%bt, l0, l0_am) + IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%bt, ld, lf) DO k = 1, SIZE(tors%bt) - IF (tors%bt(k) < CD_ZERO) tors%bt(k) = -tors%bt(k)*l0_am(k)*SQRT(tors%gj(k)*tors%irn(k)) + IF (tors%bt(k) < CD_ZERO) tors%bt(k) = -tors%bt(k)*lf(k)*SQRT(tors%gj(k)*tors%irn(k)) END DO END IF DO k = 1, 2 @@ -3367,8 +3404,10 @@ SUBROUTINE torsion_stage(est, emt) tors%phi = ln%tors_pretwist(2) - ln%tors_pretwist(1) ! Rotating a buckled shape about a common clamp axis is an exact symmetry only without ! weight or current, with both ends clamped on one axis. - tors%zero_mode_allowed = .NOT. ANY(ABS(w_am) > CD_ZERO) .AND. .NOT. opts%has_current .AND. & - ALL(endconn_mode == CD_ENDCONN_RIGID) .AND. & + nodal_loads = .FALSE. + IF (PRESENT(f_nodal)) nodal_loads = ANY(ABS(f_nodal) > CD_ZERO) + tors%zero_mode_allowed = .NOT. ANY(ABS(w_fin) > CD_ZERO) .AND. .NOT. opts%has_current .AND. & + .NOT. nodal_loads .AND. ALL(endconn_mode == CD_ENDCONN_RIGID) .AND. & DOT_PRODUCT(tors%ends(:, 1), tors%ends(:, 3)) > CD_ONE - 1.0e-12_wp ! As for the untwisted solve: a residual stall at the tight standalone tolerance is ! repeated at the coupled static tolerance (a round-off floor of a stiff, light line). @@ -3378,7 +3417,20 @@ SUBROUTINE torsion_stage(est, emt) tors = tors0 tol_t = static_tol_target IF (attempt == 2) tol_t = COUPLED_STATIC_TOL - IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + IF (PRESENT(f_nodal)) THEN + ! after the attachment polish every array is on the final mesh l0 + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL hermite_static_torsion(l0, l0, ea, ei, w_bare, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & + q_static, curv, fixed_dofs, contact_enabled, contact_z, frame_cs, & + endconn_k, endconn_d0_local, endconn_mode, opts, tol_t, tors, est, emt, & + bathymetry=bathymetry, cur_obj=cur_obj, f_nodal=f_nodal) + ELSE + CALL hermite_static_torsion(l0, l0, ea, ei, w_bare, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & + q_static, curv, fixed_dofs, contact_enabled, contact_z, frame_cs, & + endconn_k, endconn_d0_local, endconn_mode, opts, tol_t, tors, est, emt, & + cur_obj=cur_obj, f_nodal=f_nodal) + END IF + ELSE IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN CALL hermite_static_torsion(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, curv, fixed_am, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, & endconn_mode, opts, tol_t, tors, est, emt, bathymetry=bathymetry, & @@ -3391,18 +3443,99 @@ SUBROUTINE torsion_stage(est, emt) IF (est == CD_DECKDRV_OK .OR. est == CD_DECKDRV_BADINPUT) EXIT IF (static_tol_target >= COUPLED_STATIC_TOL) EXIT END DO - IF (est == CD_DECKDRV_OK .AND. tol_t > static_tol_target) THEN + tors_tol_used = tol_t + IF (est /= CD_DECKDRV_OK) RETURN + IF (ALLOCATED(tors%couple)) tors_axial_offset = tors%couple*tors%torque + END SUBROUTINE torsion_stage + + SUBROUTINE torsion_note() + !! The notes of the accepted torsion stage: a residual floor above the tolerance, and the + !! imposed twist and torque. + CHARACTER(320) :: tnote + IF (tors_tol_used > static_tol_target) THEN WRITE (tnote, '(A,I0,A,ES9.2,A,ES9.2)') 'line ', ln%id, ': torsion static residual floor above the '// & - 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tol_t + 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tors_tol_used 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))' CALL report_note(tnote) - END SUBROUTINE torsion_stage + END SUBROUTINE torsion_note + + SUBROUTINE torsion_after_attachments(est, emt) + !! The torsion stage of a line with ATTACHMENTS, on its discrete equilibrium (after the + !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes and, + !! in a deck current, their drag at the twisted state as nodal loads. The drag depends on + !! the node's depth and line tangent, so the stage is repeated, each time a fresh torsion + !! solve from the last state, with the drag of the last solution until the solution stops + !! moving (fixed point, as in attachment_static_polish). + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + INTEGER, PARAMETER :: MAX_FIXED_POINT = 60 + REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m + REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), q_prev(:), q_polished(:) + LOGICAL :: has_drag + INTEGER :: k, fp + est = CD_DECKDRV_OK + emt = '' + ! every pass starts from the polished, untwisted discrete state (a pass from the last twisted + ! state would first relax it, and a writhe a buckling descent left could put Theta_0 a turn + ! away, on another branch) + q_polished = q_static + ALLOCATE (f_att(SIZE(q_static)), f_drag(SIZE(q_static))) + f_att = CD_ZERO + DO k = 1, SIZE(att_node) + f_att(6*(att_node(k) - 1) + 3) = f_att(6*(att_node(k) - 1) + 3) - & + (ln%att(2, k) - opts%rhoW*ln%att(3, k))*opts%g + END DO + has_drag = opts%has_current .AND. ANY(ln%att(4, :) > CD_ZERO .OR. ln%att(6, :) > CD_ZERO) + DO fp = 1, MAX_FIXED_POINT + f_drag = CD_ZERO + IF (has_drag) THEN + CALL attachment_static_drag(q_static, att_node, ln%att, opts, frame_cs, f_drag, est, emt) + IF (est /= CD_DECKDRV_OK) THEN + emt = 'finite-EI static attachment drag failed: '//TRIM(emt) + RETURN + END IF + END IF + q_prev = q_static + q_static = q_polished + CALL torsion_stage(est, emt, f_att + f_drag) + IF (est /= CD_DECKDRV_OK) RETURN + IF (.NOT. has_drag) RETURN + IF (MAXVAL(ABS(q_static - q_prev)) <= FIXED_POINT_TOL) RETURN + END DO + est = CD_DECKDRV_SOLVEFAIL + emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment current drag did not '// & + 'settle to a fixed point' + END SUBROUTINE torsion_after_attachments + + SUBROUTINE twisted_attachment_checks(est, emt) + !! The mesh safety diagnosis of the twisted discrete start of a line with ATTACHMENTS (the + !! smeared-state diagnosis above saw the untwisted state): the kink limit away from the + !! attachment nodes and, under tensile_safety True, no axial compression, the + !! torque-tension coupling force (K/GJ) M_t added (attachment_mesh_checks). + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + LOGICAL :: accepted_t + CHARACTER(1024) :: msg_t + est = CD_DECKDRV_OK + emt = '' + IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN + CALL attachment_mesh_checks(l0, q_static, ea, ei, att_node, contact_z, & + opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, TWISTED_WHAT, accepted_t, msg_t, & + bathymetry=bathymetry, frame_cs=frame_cs, axial_offset=tors_axial_offset) + ELSE + CALL attachment_mesh_checks(l0, q_static, ea, ei, att_node, contact_z, & + opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, TWISTED_WHAT, accepted_t, msg_t, & + axial_offset=tors_axial_offset) + END IF + IF (.NOT. accepted_t) THEN + est = CD_DECKDRV_SOLVEFAIL + emt = TRIM(msg_t) + END IF + END SUBROUTINE twisted_attachment_checks SUBROUTINE bow_route(done, why) !! A line too long for its span whose anchor walk failed or reached an equilibrium the @@ -6458,12 +6591,13 @@ END SUBROUTINE hermite_static_stable SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q, curv, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0, endconn_mode, opts, & - tol, tors, ErrStat, ErrMsg, bathymetry, cur_obj) + tol, tors, ErrStat, ErrMsg, bathymetry, cur_obj, f_nodal) !! Torsion stage of a deck cable on its final mesh l0: CD_HermiteCable_Static_Solve from the !! converged untwisted state q (one EI and buoyancy stage, a polish) with the torsion !! description tors, under the same contact, dry-buoyancy, end-connection and current terms - !! as hermite_static_stable. On success q and curv hold the twisted equilibrium and tors its - !! accepted Theta, torque and stability report. + !! as hermite_static_stable, and the nodal loads f_nodal (the discrete ATTACHMENTS). On + !! success q and curv hold the twisted equilibrium and tors its accepted Theta, torque and + !! stability report. REAL(wp), INTENT(IN) :: l0_deck(:), l0(:), ea(:), ei(:), w(:), diam_deck(:), dry_deck(:) REAL(wp), INTENT(INOUT) :: q(:), curv(:) INTEGER, INTENT(IN) :: fixed_dofs(:) @@ -6476,6 +6610,7 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry TYPE(CD_HermiteStaticCurrentType), INTENT(IN), OPTIONAL :: cur_obj + REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) REAL(wp), ALLOCATABLE :: diam(:), dry(:), knnode(:), q_out(:) REAL(wp) :: res INTEGER :: i, ne, it, es @@ -6505,7 +6640,8 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q bending_quadrature_order=opts%bending_quadrature_order, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & - water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors) + water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors, & + f_nodal=f_nodal) ELSE CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w, q, fixed_dofs, contact_z, CD_ZERO, 1, 200, & tol, 0.7_wp, q_out, curv, res, it, es, em, n_buoy_steps=1, & @@ -6513,7 +6649,8 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q bending_quadrature_order=opts%bending_quadrature_order, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & - water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors) + water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors, & + f_nodal=f_nodal) END IF IF (es == CD_HCSTAT_BADINPUT) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI torsion static solve rejected the input: '//TRIM(em)); RETURN @@ -6553,12 +6690,52 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, CHARACTER(*), PARAMETER :: WHAT = 'finite-EI static solve with discrete ATTACHMENTS: the discrete '// & 'equilibrium reached after a failed Newton solve (pseudo-transient '// & 'continuation, line search or smaller load steps) ' + LOGICAL :: physical, mesh_ok + CHARACTER(1024) :: em + accepted = .FALSE. + message = '' + IF (PRESENT(bathymetry) .AND. PRESENT(frame_cs)) THEN + CALL attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, WHAT, mesh_ok, message, & + bathymetry=bathymetry, frame_cs=frame_cs) + ELSE + CALL attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, WHAT, mesh_ok, message) + END IF + IF (.NOT. mesh_ok) RETURN + CALL audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, em, ignore_kink=.TRUE.) + IF (.NOT. physical) THEN + message = WHAT//'is rejected: '//TRIM(em); RETURN + END IF + IF (.NOT. stable) THEN + message = WHAT//'is an unstable equilibrium (tangent stiffness not positive definite)'; RETURN + END IF + accepted = .TRUE. + END SUBROUTINE CD_Attachment_Discrete_Verdict + + SUBROUTINE attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, what, accepted, message, & + bathymetry, frame_cs, axial_offset) + !! The mesh safety checks of a discrete attachment equilibrium on its mesh l0 with state q: + !! 1. the kink limit (h*kappa <= CD_HC_KINK_LIMIT), except on the elements beside an + !! attachment node att_node, where the lumped load turns the line by a slope jump that the + !! C1 Hermite elements carry as curvature (h*kappa of about twice the jump) at any mesh + !! size; + !! 2. with tensile_error (tensile_safety True), no axial compression in the mesh safety + !! diagnosis (the strict, smoothed compression mode), axial_offset (the torque-tension + !! coupling force (K/GJ) M_t of a twisted line, per element) added to the resultant. + !! accepted is false when a check fails, and message (what, then the check) names it. + REAL(wp), INTENT(IN) :: l0(:), q(:), ea(:), ei(:), contact_z + INTEGER, INTENT(IN) :: att_node(:) + LOGICAL, INTENT(IN) :: tensile_error + CHARACTER(*), INTENT(IN) :: what + LOGICAL, INTENT(OUT) :: accepted + CHARACTER(*), INTENT(OUT) :: message + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), INTENT(IN), OPTIONAL :: frame_cs(2) + REAL(wp), INTENT(IN), OPTIONAL :: axial_offset(:) TYPE(CD_HermiteResolutionType) :: diag REAL(wp), ALLOCATABLE :: hk(:) LOGICAL, ALLOCATABLE :: beside(:) REAL(wp) :: hk_peak INTEGER :: ne, e, k, es, e_peak - LOGICAL :: physical CHARACTER(1024) :: em accepted = .FALSE. message = '' @@ -6567,13 +6744,15 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, IF (PRESENT(bathymetry) .AND. PRESENT(frame_cs)) THEN CALL CD_HermiteCable_Resolution_Metrics(l0, q, contact_z, CD_ZERO, CD_HC_KINK_LIMIT, diag, es, em, & bathymetry=bathymetry, contact_frame_cs=frame_cs, EA=ea, EI=ei, & - compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk) + compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk, & + axial_offset=axial_offset) ELSE CALL CD_HermiteCable_Resolution_Metrics(l0, q, contact_z, CD_ZERO, CD_HC_KINK_LIMIT, diag, es, em, & - EA=ea, EI=ei, compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk) + EA=ea, EI=ei, compression_mode=CD_HC_COMPRESSION_STRICT, elem_h_kappa=hk, & + axial_offset=axial_offset) END IF IF (es /= CD_HCSTAT_OK) THEN - message = WHAT//'could not be diagnosed: '//TRIM(em); RETURN + message = what//'could not be diagnosed: '//TRIM(em); RETURN END IF beside = .FALSE. DO k = 1, SIZE(att_node) @@ -6593,24 +6772,17 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, IF (hk_peak > CD_HC_KINK_LIMIT) THEN WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A)') 'is unresolved/kinked: max(h*kappa)=', hk_peak, & ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', e_peak, ' (away from the attachment nodes)' - message = WHAT//TRIM(em); RETURN + message = what//TRIM(em); RETURN END IF IF (tensile_error .AND. diag%axial_compression) THEN WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A,F8.5,A,ES12.5)') & 'carries axial compression under tensile_safety True: element-mean axial force=', & diag%axial_strain_min_resultant, ' N below tolerance=', diag%axial_tolerance, ' N at element ', & diag%axial_strain_min_elem, ', xi=', diag%axial_strain_min_xi, ', strain=', diag%axial_strain_min - message = WHAT//TRIM(em); RETURN - END IF - CALL audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, em, ignore_kink=.TRUE.) - IF (.NOT. physical) THEN - message = WHAT//'is rejected: '//TRIM(em); RETURN - END IF - IF (.NOT. stable) THEN - message = WHAT//'is an unstable equilibrium (tangent stiffness not positive definite)'; RETURN + message = what//TRIM(em); RETURN END IF accepted = .TRUE. - END SUBROUTINE CD_Attachment_Discrete_Verdict + END SUBROUTINE attachment_mesh_checks SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, message, compression_note, & ignore_kink) @@ -17280,8 +17452,8 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio SUBROUTINE check_torsion_line(ln, es_t, em_t) !! A line with a torsional END CONNECTIONS restraint: a finite-EI (cubic-Hermite) line. With !! both ends restrained (torsion active) End B must be Fixed, every section's LINE TYPES row - !! must give an explicit GJ, End A may not be a rod end, a body End A must be a Rigid6 body, - !! and ATTACHMENTS are not combined with it. + !! must give an explicit GJ, End A may not be a rod end, and a body End A must be a Rigid6 + !! body. TYPE(DeckLine), INTENT(IN) :: ln INTEGER, INTENT(OUT) :: es_t CHARACTER(*), INTENT(OUT) :: em_t @@ -17326,10 +17498,6 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) RETURN END IF END DO - IF (ALLOCATED(ln%att)) THEN - CALL fail(es_t, em_t, 'line '//TRIM(lid)//': torsion is not combined with ATTACHMENTS in this build') - RETURN - END IF jp = find_point(points, ln%nodeA) IF (jp < 1) RETURN IF (is_rod_point_type(points(jp)%ptype)) THEN diff --git a/tests/data/lazy_wave_torsion_attachments.dat b/tests/data/lazy_wave_torsion_attachments.dat new file mode 100644 index 00000000..55662a0d --- /dev/null +++ b/tests/data/lazy_wave_torsion_attachments.dat @@ -0,0 +1,51 @@ +--------------------- CableDyn Input File ------------------------------------ +Lazy-wave power cable with discrete buoyancy modules, restrained in torsion +-- The cable of lazy_wave_touchdown_planar_coarse_att.dat (25 discrete buoyancy modules at a 4 m pitch +-- from 80 m to 176 m), clamped at both ends and restrained in torsion (Rigid) with one turn of +-- pretwist at End B, and the polar inertia Irn = 1 kg m of its LINE TYPES row, so its dynamics carry +-- a twist angle at every node. The torsion stage runs on the discrete equilibrium, after the +-- attachment polish, with the modules' net weights (and, in a deck current, their drag) as nodal +-- loads. A still run from it keeps its torque, twist and fairlead tension. +--------------------- LINE TYPES --------------------------------------------- +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-) +bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------- +ID Type X Y Z +(-) (-) (m) (m) (m) +7 Coupled 30.0 0.0 -20.0 +8 Fixed 500.0 0.0 -200.0 +--------------------- LINES -------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +4 7 8 - +--------------------- SECTIONS ----------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +4 bare 80.0 20 +4 bare 100.0 25 +4 bare 420.0 42 +--------------------- ATTACHMENTS ------------------------------------------- +LineID ArcLength Mass Volume CdA Ca CdAx +(-) (m) (kg) (m^3) (m^2) (-) (m^2) +4 80.0:4.0:176.0 91.32 0.18378 1.392 1.0 0.0 +--------------------- END CONNECTIONS ---------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +4 A Rigid 0.1058 0 -0.9944 Rigid 0 1 0 0 +4 B Rigid 1 0 0 Rigid 0 1 0 360 +--------------------- OPTIONS ------------------------------------------------ +9.80665 g +1025.0 rhoW +3.0e6 kBot +3.0e5 cBot +0.35 frictionMu +200.0 WtrDpth +0.025 dtM +10.0 TMax +--------------------- OUTPUTS ------------------------------------------------ +FairTen4 +Torq4N1 +Torq4N88 +Twist4 +--------------------- END ---------------------------------------------------- diff --git a/tests/test_torsion_attachments.f90 b/tests/test_torsion_attachments.f90 new file mode 100644 index 00000000..d050c461 --- /dev/null +++ b/tests/test_torsion_attachments.f90 @@ -0,0 +1,278 @@ +! File: tests/test_torsion_attachments.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Deck-level gates of a line restrained in torsion with discrete ATTACHMENTS (the torsion stage +!> on the discrete equilibrium, after the attachment polish): +!> 1. neutral attachments (mass = rhoW volume, no drag) on the straight neutral line of +!> test_torsion_deck held taut, two turns of pretwist: the torque and the twist are those of the +!> bare line, GJ Phi / L and 720 deg; +!> 2. the lazy wave of tests/data/lazy_wave_torsion_attachments.dat (25 buoyancy modules, one turn +!> of pretwist, Irn 1 kg m: the nodal twist), in still water and in a cross-flow current +!> (the attachment drag of the twisted state, to a fixed point): a still 10 s run keeps the +!> fairlead tension, the torque at both ends and the twist of its static start. A torsion +!> stage on the smeared state, before the polish, leaves the discrete start untwisted and the +!> run rings by 3e-3 of the torque; +!> 3. the mesh safety diagnosis of the twisted discrete start: a line of test_torsion_coupling +!> (GJ|K, stretched by 1e-4, Phi = -45 deg, tensile_safety True) whose coupling force +!> compresses it is refused with one neutral module as without it (the diagnosis of the +!> untwisted smeared state alone would let it start). +!> +!> Usage: test_torsion_attachments +PROGRAM test_torsion_attachments + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + INTEGER :: n_fail = 0 + CHARACTER(512) :: lazy_wave + + IF (COMMAND_ARGUMENT_COUNT() /= 1) THEN + WRITE (*, '(A)') 'usage: test_torsion_attachments ' + ERROR STOP 2 + END IF + CALL GET_COMMAND_ARGUMENT(1, lazy_wave) + CALL check_neutral() + CALL check_still_lazy_wave('still water', '') + CALL check_still_lazy_wave('cross-flow current', 'uniform 0.2 0.3 0.0 current') + CALL check_tensile_safety() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' torsion attachment check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: torsion with ATTACHMENTS (neutral modules, still lazy wave in water and current)' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE run_deck(path, root, ok) + CHARACTER(*), INTENT(IN) :: path, root + LOGICAL, INTENT(OUT) :: ok + LOGICAL :: conv + INTEGER :: es + CHARACTER(2048) :: em + CALL CD_Run_Deck_Driver(path, root, conv, es, em) + ok = es == CD_DECKDRV_OK .AND. conv + IF (.NOT. ok) WRITE (*, '(A)') ' '//TRIM(path)//': '//TRIM(em) + END SUBROUTINE run_deck + + SUBROUTINE read_rows(path, ncol, vals, nrow, ok) + !! Every data row of a driver .out file (up to SIZE(vals, 2) rows), ncol columns each. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: ncol + REAL(wp), INTENT(OUT) :: vals(:, :) + INTEGER, INTENT(OUT) :: nrow + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios + CHARACTER(2048) :: buf + ok = .FALSE. + nrow = 0 + vals = 0.0_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO WHILE (nrow < SIZE(vals, 2)) + READ (u, *, IOSTAT=ios) vals(1:ncol, nrow + 1) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + ok = nrow > 0 .AND. ALL(IEEE_IS_FINITE(vals(1:ncol, 1:nrow))) + END SUBROUTINE read_rows + + SUBROUTINE write_straight(path, attachments) + !! The straight neutral line of test_torsion_deck (100 m along +x at z = -50 from a Coupled End A + !! to a Fixed End B, clamped, rigid in torsion, two turns of pretwist at End B; statics only), held + !! taut at 0.5 % strain (a weightless line at zero strain has no unique static shape), with or + !! without three neutral attachments. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: attachments + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'torsion with neutral attachments' + 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 5.0e4 1.0 1.0e-12 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.5 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 100.0 40' + IF (attachments) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 25.0:25.0:75.0 102.5 0.1 0.0 1.0' + END IF + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + 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 720' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N41' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_straight + + SUBROUTINE check_neutral() + REAL(wp) :: bare(4, 1), att(4, 1), m_ref + INTEGER :: nb, na + LOGICAL :: ok + CALL write_straight('tatt_bare.dat', .FALSE.) + CALL write_straight('tatt_neutral.dat', .TRUE.) + CALL run_deck('tatt_bare.dat', 'tatt_bare', ok) + CALL require(ok, '1: the bare twisted line solves') + IF (.NOT. ok) RETURN + CALL run_deck('tatt_neutral.dat', 'tatt_neutral', ok) + CALL require(ok, '1: the twisted line with neutral ATTACHMENTS solves') + IF (.NOT. ok) RETURN + CALL read_rows('tatt_bare.out', 4, bare, nb, ok) + CALL require(ok, '1: bare output') + CALL read_rows('tatt_neutral.out', 4, att, na, ok) + CALL require(ok, '1: neutral-attachment output') + IF (.NOT. ok) RETURN + m_ref = GJ*(4.0_wp*PI)/L + WRITE (*, '(A,3ES16.8,A,3ES16.8,A,ES16.8)') '1 neutral modules: Torq A, B, Twist ', att(2:4, 1), & + '; bare ', bare(2:4, 1), '; GJ Phi / L ', m_ref + CALL require(MAXVAL(ABS(att(2:3, 1) - m_ref)) <= 1.0e-6_wp*m_ref .AND. ABS(att(4, 1) - 720.0_wp) <= 1.0e-6_wp, & + '1: neutral modules leave the torque GJ Phi / L and the twist 720 deg') + CALL require(MAXVAL(ABS(att(2:4, 1) - bare(2:4, 1))) <= 1.0e-9_wp*m_ref, & + '1: neutral modules reproduce the bare line') + END SUBROUTINE check_neutral + + SUBROUTINE check_still_lazy_wave(label, option) + !! The lazy wave deck, optionally with one more OPTIONS row, run still for 10 s. + CHARACTER(*), INTENT(IN) :: label, option + INTEGER, PARAMETER :: MAXROW = 1000 + REAL(wp), ALLOCATABLE :: vals(:, :) + REAL(wp) :: spread(4) + INTEGER :: nrow, j + LOGICAL :: ok + CHARACTER(64) :: path, root + root = 'tatt_lw_'//MERGE('still ', 'current', LEN_TRIM(option) == 0) + path = TRIM(root)//'.dat' + CALL copy_with_option(TRIM(lazy_wave), TRIM(path), option, ok) + CALL require(ok, '2 '//label//': the deck is written') + IF (.NOT. ok) RETURN + CALL run_deck(TRIM(path), TRIM(root), ok) + CALL require(ok, '2 '//label//': the lazy wave with modules and torsion solves and runs') + IF (.NOT. ok) RETURN + ALLOCATE (vals(5, MAXROW)) + CALL read_rows(TRIM(root)//'.out', 5, vals, nrow, ok) + CALL require(ok .AND. nrow == 401, '2 '//label//': 401 output rows') + IF (.NOT. ok) RETURN + DO j = 1, 4 + spread(j) = (MAXVAL(vals(j + 1, 1:nrow)) - MINVAL(vals(j + 1, 1:nrow)))/ABS(vals(j + 1, 1)) + END DO + WRITE (*, '(A,A,A,4ES14.6,A,4ES10.2)') '2 ', label, ': FairTen, Torq A, Torq B, Twist ', vals(2:5, 1), & + '; relative spread over 10 s ', spread + CALL require(ABS(vals(5, 1)) > 300.0_wp, '2 '//label//': the static start is twisted (one turn of pretwist)') + CALL require(MAXVAL(spread) <= 1.0e-6_wp, '2 '//label//': a still run keeps the twisted discrete static start') + END SUBROUTINE check_still_lazy_wave + + SUBROUTINE check_tensile_safety() + !! The coupled line of test_torsion_coupling's compression gate with one neutral module. + INTEGER :: u + LOGICAL :: conv + INTEGER :: es + CHARACTER(2048) :: em + OPEN (NEWUNIT=u, FILE='tatt_comp.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'torsion with attachments under tensile_safety' + 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 5.0e4|4.0e5 1.0 1.0e-9 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 99.9900 40' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 50.0 102.5 0.1 0.0 1.0' + 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 -45' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') 'True tensile_safety' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('tatt_comp.dat', 'tatt_comp', conv, es, em) + WRITE (*, '(A)') '3 tensile_safety with a neutral module: '//TRIM(em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'twisted discrete equilibrium carries axial compression') > 0, & + '3: the coupling-compressed twisted start with ATTACHMENTS is refused under tensile_safety True') + END SUBROUTINE check_tensile_safety + + SUBROUTINE copy_with_option(src, dst, option, ok) + !! Copy deck src to dst, inserting the row option after the TMax row (none if blank). + CHARACTER(*), INTENT(IN) :: src, dst, option + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ui, uo, ios + CHARACTER(512) :: buf + ok = .FALSE. + OPEN (NEWUNIT=ui, FILE=src, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + OPEN (NEWUNIT=uo, FILE=dst, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + IF (ios /= 0) THEN + CLOSE (ui) + RETURN + END IF + DO + READ (ui, '(A)', IOSTAT=ios) buf + IF (ios /= 0) EXIT + WRITE (uo, '(A)') TRIM(buf) + IF (LEN_TRIM(option) > 0 .AND. INDEX(buf, 'TMax') > 0) WRITE (uo, '(A)') option + END DO + CLOSE (ui) + CLOSE (uo) + ok = .TRUE. + END SUBROUTINE copy_with_option + +END PROGRAM test_torsion_attachments diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index 36734b9c..e82e29d8 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -1005,8 +1005,8 @@ SUBROUTINE write_lines(path, rows) END SUBROUTINE write_lines SUBROUTINE check_scope_refusals() - !! 6 (continued). Torsion outside its scope stops by name: End A on a rod end, End A on a - !! Point3 body, and a torsional line carrying ATTACHMENTS. + !! 6 (continued). Torsion outside its scope stops by name: End A on a rod end and End A on a + !! Point3 body; a torsional line carrying ATTACHMENTS solves (test_torsion_attachments). CHARACTER(120) :: tail(9), ty(4) ty(1) = '--- LINE TYPES ---' ty(2) = 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' @@ -1055,8 +1055,12 @@ SUBROUTINE check_scope_refusals() '--- END CONNECTIONS ---', 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist', & '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)', '1 A Rigid 1 0 0 Rigid 0 0 1 0', & '1 B Rigid 1 0 0 Rigid 0 0 1 0', tail(5:9)]) - CALL expect_error('a torsional line with ATTACHMENTS is named', 'tdeck_s3.dat', 'tdeck_s3', & - 'not combined with ATTACHMENTS') + BLOCK + LOGICAL :: ok + CHARACTER(512) :: em + CALL run_deck('tdeck_s3.dat', 'tdeck_s3', ok, em) + CALL require(ok, 'a torsional line with ATTACHMENTS solves (got: '//TRIM(em)//')') + END BLOCK END SUBROUTINE check_scope_refusals END PROGRAM test_torsion_deck From 0f53412969f82e1964ae5f7cf5440f3d06f9713f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 30 Oct 2026 23:29:32 +0900 Subject: [PATCH 23/51] feat: MoorDyn parity - CoupledPinned bodies, CONTROL on Syrope and viscoelastic segments, MoorDyn-C Currents 2 and 5 (#72) Three MoorDyn features CableDyn refused or lacked, for 0.4.0, in one PR. Each is kept as its own commits (bodies, line control, currents), followed by a gate where they meet. ## 1. CoupledPinned bodies in OpenFAST Every deck refused MoorDyn-F's `CoupledPinned`/`VesselPinned` bodies. They now run on the coupled route (`CompMooring = 5`) as MoorDyn-F's coupled pinned body. - The body reference point is a node of the coupling mesh that takes the platform position only; the body turns about it with its own three rotations (`M_rr alpha = M - m [c]x a_p - w x (I_p w)`), and the node returns the body's net load less its inertia, with no moment. The 24-real body mirror carries the state (restarts and correction rewinds are bit-identical); `PtfmInit` moves and turns the body before the static solve, which balances the moment about the node. - 14-, 15- and 18-column BODIES rows; aliases `CpldPin`/`VesselPinned`/`VesPin`. Standalone, in the C API, without inertias and under the linearisation probe the body is refused by name, and the Python deck validator mirrors the rules. - MoorDyn-F's `inertialF` is accepted as `1` (CableDyn always returns the inertia of coupled bodies and rods); `0` and `2` are refused by name; `inertialF_rampT` is parsed and ignored. - Start accelerations in OpenFAST (a result change, under Fixed): the module restores its state mirror after the output call at `t = 0`, which marked the accelerations of Free Rigid6 bodies and Free, Pinned and CoupledPinned rods as committed before they were solved, so their first step started from zero acceleration. The aggregate now solves them when it initialises and at a committed step-start transfer before the first step. An object in its static equilibrium changes at round-off (1e-12 m, 1e-6 deg over 10 s); one released out of balance (`bodyIC deck`) changes by the first step's velocity error, 0.02 m/s and 0.05 deg for a hanging Pinned rod, up to 0.6 m/s far from balance. The standalone driver is unchanged. Gates, new `openfast_pinned_body`: a dry compound pendulum keeps the elliptic-integral period to 1.6e-4 at `dt = T/100` and the analytic pin reaction to 4e-16 of m g; under a constant node acceleration it swings about `-atan(a/g)` with the effective-gravity period; a body with a CoupledPinned rod's mass and inertia follows the rod to 2e-12; a symmetric mooring does not turn the body; snapshot/probe/restart are bit-identical; `PtfmInit` with the static start balances the moment to 3e-13; the shell's order (mirror Get/Set before the first step) against the direct order for pinned and free bodies and rods: identical now, up to 87 apart within 1 s before. Against the MoorDyn-F driver (`inertialF 1`) a pendulum with its line at the node agrees to 0.09 deg over a 120 deg swing (0.15 deg with the node surging). ## 2. CONTROL on Syrope and viscoelastic segments Active line control (`CONTROL`, OpenFAST `CableDeltaL`/`CableDeltaLdot`) of a Syrope or a viscoelastic segment (`Es|Ed`, `Es|alphaMBL|vbeta`) stopped at initialisation. MoorDyn-F and MoorDyn-C keep each segment's slow-branch stretch as its state and read it at the new length; CableDyn now does the same (the committed slow strain is read at the present length; the running maximum of a Syrope segment is kept). An uncontrolled element reads its state as before, so no other deck changes. - Syrope state solve (a result change, under Fixed): a line held at its running maximum under `False alpha_force_blend` stopped with "Syrope backward-Euler state solve did not converge" (the Newton difference quotient straddled the kink next to the top sample of the working curve), and a light rope (BA_s|BA_d = 1e4|1e3) failed where its residual changes sign between two adjacent reals. The solve now finishes by bisection there and returns the end with the smaller residual when the bracket cannot be split. Over 440,000 fuzzed states every solve that converged before is bit-identical; the 26 that failed now converge. Gates, new `syrope_control` and `viscoelastic_control`, on a taut 100 m line with the fairlead segment paid out 0.5 m, hauled in to -1 m and paid back: the tension follows the rest curve of its load history to 2.5e-4 of T0 along the ramps and 6e-7 at rest (Syrope; working curve, OWC with the ratchet, then the working curve of the new maximum) and the static law `Es (D/L - 1)` to 1.7e-4 and 4e-9 (viscoelastic); after a 5 cm pay-out or 4 cm haul-in step the tension is MoorDyn's at the carried stretch to 6e-16 (carrying the strain instead is off by 0.4 to 4.6 % and fails); restarts in the ramp continue bit for bit; a Syrope segment paid out inside sub-steps matches plain steps of dt/4 to 9.5e-14 of the fairlead load. `syrope` gains the 26 fuzzed states and the stalled solve (they fail on the previous kernel). ## 3. MoorDyn-C Currents 2 and 5 The standalone routes read MoorDyn-C's time-varying depth profile (`Currents 2`, `current_profile_dynamic.txt`) and its grid in x, y, z and time (`Currents 5`, `current_profile_4d.txt`) as MoorDyn-C v2.7.1 does: resampled at the smallest time interval, repeating past the last sample, trilinear in space and held beyond the grid, no fluid acceleration. `deck_current_velocity` now takes the position and time, so every current consumer (EI = 0 lines, finite-EI cables, points, rods, bodies at their reference point, attachments) samples the field where and when it evaluates the fluid; the static start takes it at `t = 0`, the finite-EI solver through its turned and translated solve frame. The coupled and mixed aggregate routes refuse the files by name (the host supplies the water kinematics), and the point-system shells of the C API and OpenFAST, which have no clock, refuse a table that varies in time and apply a constant one. - EI = 0 static current (a result change, under Fixed): the static start of an `EI = 0` line decided from the current sampled on the straight chord whether to carry it, so a current zero along the chord but not where the line sags (a depth profile, a grid) was left out; the start was solved in still water and the march drifted (192 N in 4 s on a 70 m rope with its ends at z = -20 m in 0.8 m/s below z = -32 m). The decision now looks at the field, and the static tangent takes the current's gradient along the line (without it that start did not converge). A later `current` row also discards the levels of an earlier profile row. Gates, new `mdc_currents` and `mdc_currents_runs`: the current at 739 points and times is identical to MoorDyn-C v2.7.1's and within 4.4e-16 m/s of an independent Python evaluation; a constant Currents 2 table equals Currents 1 and a grid uniform in x and y equals Currents 2; on a 70 m rope across the flow the tension change of a time-varying and of a sheared current is within 0.8 % and 0.9 % of MoorDyn-C's; the static start in a sheared grid is an equilibrium of the march on the EI = 0, finite-EI and point-connected routes (1.4e-7 of the change the current makes); the off-chord decks hold their start to 0 N (EI = 0) and 1e-4 N (finite-EI) over 4 s, within 0.14 % of each other; `step_allocations_current_grid`: 20,000 grid velocity and gradient evaluations make no heap allocation. ## 4. Where the features meet New gate `parity_integration`: - A CoupledPinned body in a Currents 2 or 5 deck is refused on the coupled aggregate (with and without the host fluid field) for its current files, "the MoorDyn-C WaveKin 3/7 and Currents 1/2/5 files are not supported on the aggregate route (coupled runs take water kinematics from the host; ...)"; the deck without them initialises; the standalone driver refuses it for the body ("CoupledPinned/VesselPinned BODY requires a coupled host"). - CONTROL in the host's cross-flow (fields at every node, its steady current for the static start): a still 10 s run at a zero command keeps the start (node drift 1.4e-14 m viscoelastic, 6.0e-12 m Syrope); after a 0.3 m pay-out (viscoelastic) or a 0.2 m haul-in (Syrope) and a 40 s hold the line rests at the static start of the deck with that segment changed, to 1.1e-12 m and 3.8e-12 of the tension (viscoelastic) and 5.0e-7 m and 7.1e-7 (Syrope), with cross-flow deflections of 0.39 m and 0.08 m. - ATTACHMENTS on a line restrained in torsion (#71) in a Currents 5 grid: the lazy wave with 25 modules and one turn of pretwist, turned by 30 deg and moved off the origin, in a grid sheared in x, y and z. The attachment drag fixed point after the polish samples the grid at the modules' global positions, and a still 10 s run keeps the start to 8.6e-8 of the fairlead tension and 0 in torque and twist (the grid moves the start by 4.5e-3 and 2.0e-2). Sampling at x = y = 0 or at the unturned solve-frame position instead leaves spreads of 1.6e-4 to 1.5e-3. A grid in depth only gives the start of the same Currents 1 profile to the output precision. ## Checks Full ctest 328/328; pytest (`python/tests`, `tests`) 2124 passed, 114 skipped; ruff check and format clean; pre-commit clean; docs build with `-W` clean. Every example deck (53 of 53) is byte-identical to dev's. The result changes are the three named above: Free bodies and rods start from their solved accelerations in OpenFAST, the `EI = 0` static start carries an off-chord current, and the Syrope state solve converges where it stopped. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 65 + CMakeLists.txt | 69 + VALIDATION.md | 1 + doc/api_python.rst | 3 +- doc/capabilities.rst | 22 +- doc/capi.rst | 10 +- doc/coupling.rst | 3 +- doc/driver_format.md | 112 +- doc/file_formats.rst | 8 +- doc/migrating.rst | 6 +- doc/openfast.rst | 23 +- doc/options.rst | 22 +- doc/python.rst | 3 +- doc/theory.rst | 88 +- python/cabledyn/builder.py | 5 +- python/cabledyn/deck_file.py | 141 +- python/cabledyn/study.py | 10 +- python/tests/test_deck_file.py | 79 +- python/tests/test_deck_native_parity.py | 20 +- python/tests/test_native_model.py | 44 +- src/CableDyn_DeckDriver.f90 | 1289 +++++++++++-- src/CableDyn_HermiteCableStatic.f90 | 35 +- src/CableDyn_Hydro.f90 | 299 +++ src/CableDyn_Model.f90 | 117 +- src/CableDyn_OpenFAST_Aggregate.f90 | 142 +- src/CableDyn_Static.f90 | 52 +- src/CableDyn_Syrope.f90 | 42 + src/openfast/CableDyn_OF.f90 | 7 +- .../data/currents_mdc/c1/current_profile.txt | 14 + tests/data/currents_mdc/c1/currents.dat | 26 + tests/data/currents_mdc/c1/points.txt | 45 + tests/data/currents_mdc/c1/ref_moordyn_c.csv | 46 + tests/data/currents_mdc/c1/ref_python.csv | 46 + .../c2/current_profile_dynamic.txt | 11 + tests/data/currents_mdc/c2/currents.dat | 26 + tests/data/currents_mdc/c2/points.txt | 170 ++ tests/data/currents_mdc/c2/ref_moordyn_c.csv | 171 ++ tests/data/currents_mdc/c2/ref_python.csv | 171 ++ .../c2const/current_profile_dynamic.txt | 9 + tests/data/currents_mdc/c2const/currents.dat | 26 + tests/data/currents_mdc/c2const/points.txt | 45 + .../currents_mdc/c2const/ref_moordyn_c.csv | 46 + .../data/currents_mdc/c2const/ref_python.csv | 46 + .../c2stof/current_profile_dynamic.txt | 9 + tests/data/currents_mdc/c2stof/currents.dat | 26 + tests/data/currents_mdc/c2stof/points.txt | 64 + .../currents_mdc/c2stof/ref_moordyn_c.csv | 65 + tests/data/currents_mdc/c2stof/ref_python.csv | 65 + .../currents_mdc/c5/current_profile_4d.txt | 134 ++ tests/data/currents_mdc/c5/currents.dat | 26 + tests/data/currents_mdc/c5/points.txt | 120 ++ tests/data/currents_mdc/c5/ref_moordyn_c.csv | 121 ++ tests/data/currents_mdc/c5/ref_python.csv | 121 ++ .../c5uniform/current_profile_4d.txt | 105 ++ .../data/currents_mdc/c5uniform/currents.dat | 26 + tests/data/currents_mdc/c5uniform/points.txt | 340 ++++ .../currents_mdc/c5uniform/ref_moordyn_c.csv | 341 ++++ .../currents_mdc/c5uniform/ref_python.csv | 341 ++++ tests/data/currents_mdc/offchord/c1.dat | 25 + tests/data/currents_mdc/offchord/c2.dat | 25 + .../currents_mdc/offchord/current_profile.txt | 7 + .../offchord/current_profile_dynamic.txt | 8 + .../tension_c0/ref_moordyn_c_tension.csv | 222 +++ .../data/currents_mdc/tension_c0/tension.dat | 25 + .../tension_c2/current_profile_dynamic.txt | 10 + .../tension_c2/ref_moordyn_c_tension.csv | 222 +++ .../data/currents_mdc/tension_c2/tension.dat | 25 + .../tension_c5/current_profile_4d.txt | 78 + .../tension_c5/ref_moordyn_c_tension.csv | 222 +++ .../data/currents_mdc/tension_c5/tension.dat | 25 + tests/test_c_api.f90 | 118 +- tests/test_mdc_currents.f90 | 273 +++ tests/test_mdc_currents_runs.py | 260 +++ tests/test_openfast_pinned_body.f90 | 1668 +++++++++++++++++ tests/test_parity_integration.f90 | 603 ++++++ tests/test_step_allocations.f90 | 61 +- tests/test_syrope.f90 | 119 +- tests/test_syrope_control.f90 | 930 +++++++++ tests/test_viscoelastic.f90 | 16 +- tests/test_viscoelastic_control.f90 | 469 +++++ tests/test_wavekin_modes.f90 | 4 +- validation/scripts/currents_mdc_reference.py | 231 +++ validation/scripts/currents_mdc_tension.cpp | 81 + 83 files changed, 10906 insertions(+), 340 deletions(-) create mode 100644 tests/data/currents_mdc/c1/current_profile.txt create mode 100644 tests/data/currents_mdc/c1/currents.dat create mode 100644 tests/data/currents_mdc/c1/points.txt create mode 100644 tests/data/currents_mdc/c1/ref_moordyn_c.csv create mode 100644 tests/data/currents_mdc/c1/ref_python.csv create mode 100644 tests/data/currents_mdc/c2/current_profile_dynamic.txt create mode 100644 tests/data/currents_mdc/c2/currents.dat create mode 100644 tests/data/currents_mdc/c2/points.txt create mode 100644 tests/data/currents_mdc/c2/ref_moordyn_c.csv create mode 100644 tests/data/currents_mdc/c2/ref_python.csv create mode 100644 tests/data/currents_mdc/c2const/current_profile_dynamic.txt create mode 100644 tests/data/currents_mdc/c2const/currents.dat create mode 100644 tests/data/currents_mdc/c2const/points.txt create mode 100644 tests/data/currents_mdc/c2const/ref_moordyn_c.csv create mode 100644 tests/data/currents_mdc/c2const/ref_python.csv create mode 100644 tests/data/currents_mdc/c2stof/current_profile_dynamic.txt create mode 100644 tests/data/currents_mdc/c2stof/currents.dat create mode 100644 tests/data/currents_mdc/c2stof/points.txt create mode 100644 tests/data/currents_mdc/c2stof/ref_moordyn_c.csv create mode 100644 tests/data/currents_mdc/c2stof/ref_python.csv create mode 100644 tests/data/currents_mdc/c5/current_profile_4d.txt create mode 100644 tests/data/currents_mdc/c5/currents.dat create mode 100644 tests/data/currents_mdc/c5/points.txt create mode 100644 tests/data/currents_mdc/c5/ref_moordyn_c.csv create mode 100644 tests/data/currents_mdc/c5/ref_python.csv create mode 100644 tests/data/currents_mdc/c5uniform/current_profile_4d.txt create mode 100644 tests/data/currents_mdc/c5uniform/currents.dat create mode 100644 tests/data/currents_mdc/c5uniform/points.txt create mode 100644 tests/data/currents_mdc/c5uniform/ref_moordyn_c.csv create mode 100644 tests/data/currents_mdc/c5uniform/ref_python.csv create mode 100644 tests/data/currents_mdc/offchord/c1.dat create mode 100644 tests/data/currents_mdc/offchord/c2.dat create mode 100644 tests/data/currents_mdc/offchord/current_profile.txt create mode 100644 tests/data/currents_mdc/offchord/current_profile_dynamic.txt create mode 100644 tests/data/currents_mdc/tension_c0/ref_moordyn_c_tension.csv create mode 100644 tests/data/currents_mdc/tension_c0/tension.dat create mode 100644 tests/data/currents_mdc/tension_c2/current_profile_dynamic.txt create mode 100644 tests/data/currents_mdc/tension_c2/ref_moordyn_c_tension.csv create mode 100644 tests/data/currents_mdc/tension_c2/tension.dat create mode 100644 tests/data/currents_mdc/tension_c5/current_profile_4d.txt create mode 100644 tests/data/currents_mdc/tension_c5/ref_moordyn_c_tension.csv create mode 100644 tests/data/currents_mdc/tension_c5/tension.dat create mode 100644 tests/test_mdc_currents.f90 create mode 100644 tests/test_mdc_currents_runs.py create mode 100644 tests/test_openfast_pinned_body.f90 create mode 100644 tests/test_parity_integration.f90 create mode 100644 tests/test_syrope_control.f90 create mode 100644 tests/test_viscoelastic_control.f90 create mode 100644 validation/scripts/currents_mdc_reference.py create mode 100644 validation/scripts/currents_mdc_tension.cpp diff --git a/CHANGELOG.md b/CHANGELOG.md index 1fd9b19e..e1061aa3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,33 @@ All notable changes to CableDyn are recorded in this file. The format follows one turn of pretwist, in still water and in a cross-flow current, keeps its torque, twist and fairlead tension over a still 10 s run to the output precision (a torsion stage before the polish would ring by 3e-3 of the torque); neutral modules reproduce the bare line's GJ Phi / L. +- `CoupledPinned`/`VesselPinned` bodies in OpenFAST, as MoorDyn-F's coupled pinned body: the + body reference point is a node of the coupling mesh that takes the platform position only, the + body turns about it with its own three rotations, and the node returns the body's net load + less its inertia, with no moment. `PtfmInit` moves and turns the body, `bodyIC static` balances + it about its node, and the checkpoint state and correction rewind carry it. A dry compound + pendulum keeps the elliptic-integral period to 1.6e-4 at `dt = T/100`, a body with a + `CoupledPinned` rod's mass and inertia follows the rod to 2e-12, and against MoorDyn-F + (`inertialF 1`) a pendulum swinging through 120 deg agrees to 0.09 deg (0.15 deg when its node + surges). Outside a coupled host, without inertias, and in linearisation the body fails closed + by name. +- Active line control (`CONTROL`, OpenFAST `CableDeltaL`/`CableDeltaLdot`) of a Syrope + polyester segment, which stopped at initialisation before. As in MoorDyn-F and MoorDyn-C the + segment's slow stretch carries over the length change (its slow strain is read at the new + length) and the running maximum is kept. On a taut 100 m line whose fairlead segment is paid + out by 0.5 m, hauled in to -1 m and paid back, the tension follows the rest curve of its load + history (working curve, OWC, then the working curve of the new maximum) to 2.5e-4 along the + ramps and 6e-7 at rest; after a length step it is MoorDyn's at the carried stretch to 1e-15 + (carrying the strain instead would be off by 0.4 to 2.4 %); a restart in the ramp continues + bit for bit; a polyester-chain line with a Syrope fairlead segment and a + chain-polyester-chain line run. +- Active line control of a viscoelastic segment (`Es|Ed` and `Es|alphaMBL|vbeta`), which + stopped at initialisation before. As in MoorDyn-F and MoorDyn-C the slow-branch stretch + `dl_1` is left as it is and read at the new length. On the same taut line and cycle the + tension follows the static law `Es` times the strain to 1.7e-4 along the ramps (4.6e-4 + load-dependent) and 4e-9 at rest; after a length step it is MoorDyn's at the carried stretch + to 4e-16 (carrying the strain instead would be off by 0.4 to 4.6 %); a restart in the ramp + continues bit for bit. - 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 @@ -115,6 +142,16 @@ All notable changes to CableDyn are recorded in this file. The format follows - Output channels `StfMomN`, the share of the section moment a bend stiffener carries, and `FairDefl`/`AnchDefl`, the deflection of the end force from the direction a held END CONNECTIONS row declares (with the end tension, a stiffener's load case). +- MoorDyn-C time-varying and gridded currents on the standalone routes: `Currents 2` (the depth + profile in time `current_profile_dynamic.txt`) and `Currents 5` (the grid in x, y, z and time + `current_profile_4d.txt`), read and interpolated as MoorDyn-C v2.7.1 does (resampled at the + smallest time interval, repeating past the last sample, held beyond the grid, no fluid + acceleration) at every node's position and time, the static start included. At 739 points and + times the current is identical to MoorDyn-C v2.7.1's; a constant table equals `Currents 1` and a + grid uniform in x and y equals `Currents 2`; on a 70 m rope the tension change of a time-varying + and of a sheared current matches MoorDyn-C's within 0.9 %, and the static start in a sheared grid + holds the tensions to 1.4e-7 of the change the current makes. The C API, without a clock, + refuses a table that varies in time. ### Changed @@ -165,6 +202,34 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- 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 + were solved. They are now solved when the module initialises (and, before the first step, at a + committed step-start transfer and in new host fluid fields, so a SeaState current or wave starts + them in that field), and the line ends on a CoupledPinned object move with them. + An object in its static equilibrium changes at round-off (1e-12 m and 1e-6 deg over 10 s); one + started out of balance (`bodyIC deck`) changes by the first step's velocity error, 0.02 m/s and + 0.05 deg for a hanging Pinned rod and up to 0.6 m/s for bodies and rods released far out of + balance. The committed host kinematics at the first step are those of the initial state, so a + host acceleration at `t = 0` enters neither version. +- MoorDyn-F's `inertialF` option was an unknown keyword; `inertialF 1` (CableDyn's behaviour) + is now accepted, and `0` and `2` are rejected by name. +- A Syrope line held at its running maximum (the fairlead pulled out and held) under + `False alpha_force_blend` stopped with "Syrope backward-Euler state solve did not converge": + next to the top sample of the working curve the Newton step's difference quotient straddled + the kink and crept along one side of the bracket. The solve now finishes by bisection there, + and where a light rope's steep residual (BA_s|BA_d = 1e4|1e3) changes sign between two + adjacent reals it returns that root to machine precision. Over 440,000 fuzzed states every + solve that converged before is bit-identical, and the 26 that failed now converge. +- The static start of an `EI = 0` line now carries a deck current that is zero along the + straight chord between its ends but not where the line sags (a depth profile or a current + grid): it was solved in still water and the march drifted toward the current's equilibrium. + On a 70 m rope with its ends at z = -20 m in 0.8 m/s below z = -32 m the start now holds to + machine precision (it drifted 192 N in 4 s) and agrees with the finite-EI route within 0.14 %. + The static tangent takes the current's gradient along the line, so the Newton iteration also + converges in a current sheared across the line. A later `current` row now discards the levels + of an earlier profile row. - 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 80bb7490..7960bd80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1133,6 +1133,19 @@ add_test(NAME openfast_pinned_rod COMMAND test_openfast_pinned_rod WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openfast_pinned_rod) set_tests_properties(openfast_pinned_rod PROPERTIES LABELS "fortran;dynamic;openfast;validation") +# CoupledPinned bodies on the coupled aggregate: the compound-pendulum period and pin reaction of +# a held node, a constant node acceleration against closed forms, a CoupledPinned rod of the same +# inertia as a second route, a symmetric mooring that does not turn the body, the output probe, +# snapshot/restore and restart, PtfmInit with the static start, sub-cycling, the OpenFAST shell's +# state-mirror restore before the first step, the refusals, and the start of Free bodies and rods +# in a host fluid field. +add_executable(test_openfast_pinned_body tests/test_openfast_pinned_body.f90) +target_link_libraries(test_openfast_pinned_body PRIVATE cabledyn_core) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/openfast_pinned_body) +add_test(NAME openfast_pinned_body COMMAND test_openfast_pinned_body + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/openfast_pinned_body) +set_tests_properties(openfast_pinned_body PROPERTIES LABELS "fortran;dynamic;openfast;validation") + # Maintained IEA-15 MW mixed deck: the finite-EI power cable has a genuine multi-node # grounded run and marches through the OpenFAST aggregate at 40 Hz with host current. add_executable(test_openfast_touchdown tests/test_openfast_touchdown.f90) @@ -1418,6 +1431,9 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN # And with the nodal twist (polar inertia, torsional damping, the 7-DOF-per-node band). add_test(NAME step_allocations_nodal_twist COMMAND test_step_allocations nodal) set_tests_properties(step_allocations_nodal_twist PROPERTIES LABELS "fortran;dynamic;memory") + # And the MoorDyn-C current grid (Currents 2 and 5) every standalone step samples at the nodes. + add_test(NAME step_allocations_current_grid COMMAND test_step_allocations current_grid) + set_tests_properties(step_allocations_current_grid PROPERTIES LABELS "fortran;dynamic;memory") endif() add_executable(test_snap_load tests/test_snap_load.f90) @@ -1703,6 +1719,17 @@ if(Python3_Interpreter_FOUND) LABELS "python;integration;dynamic;viv;validation" TIMEOUT ${_viv_lockin_timeout} ENVIRONMENT "${_cabledyn_python_test_environment}") + # MoorDyn-C Currents 2 and 5 runs: tensions against MoorDyn-C v2.7.1, two sources of one + # field, and the static start in a sheared grid on the EI = 0 and finite-EI routes + add_test(NAME mdc_currents_runs + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_mdc_currents_runs.py + --exe $ + --data ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/currents_mdc + --output ${CMAKE_BINARY_DIR}/mdc_currents_runs) + set_tests_properties(mdc_currents_runs PROPERTIES + LABELS "python;integration;dynamic;validation" + TIMEOUT ${_viv_lockin_timeout} + ENVIRONMENT "${_cabledyn_python_test_environment}") else() message(STATUS "viv_lockin: skipped (numpy not importable in ${Python3_EXECUTABLE})") endif() @@ -2085,6 +2112,19 @@ target_link_libraries(test_wavekin_modes PRIVATE cabledyn_core) add_test(NAME wavekin_modes COMMAND test_wavekin_modes WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(wavekin_modes PROPERTIES LABELS "fortran;driver;validation;dynamic") +# MoorDyn-C Currents 2 and 5 vs MoorDyn-C v2.7.1 and an independent evaluation on shared inputs +# (the reference rows come from validation/scripts/currents_mdc_reference.py) +file(GLOB_RECURSE CD_CURRENTS_MDC_FILES RELATIVE ${CMAKE_SOURCE_DIR}/tests/data/currents_mdc + ${CMAKE_SOURCE_DIR}/tests/data/currents_mdc/*) +foreach(f IN LISTS CD_CURRENTS_MDC_FILES) + configure_file(tests/data/currents_mdc/${f} ${CMAKE_BINARY_DIR}/currents_mdc/${f} COPYONLY) +endforeach() +add_executable(test_mdc_currents tests/test_mdc_currents.f90) +target_link_libraries(test_mdc_currents PRIVATE cabledyn_core) +add_test(NAME mdc_currents COMMAND test_mdc_currents WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/mdc_currents_work) +set_tests_properties(mdc_currents PROPERTIES LABELS "fortran;driver;validation;dynamic") +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/mdc_currents_work) + add_executable(test_clamped_cable_ends tests/test_clamped_cable_ends.f90) target_link_libraries(test_clamped_cable_ends PRIVATE cabledyn_core) add_test(NAME clamped_cable_ends COMMAND test_clamped_cable_ends) @@ -2102,6 +2142,18 @@ add_test(NAME torsion_attachments WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(torsion_attachments PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +# Where the MoorDyn-parity features meet: a CoupledPinned body in a Currents 2/5 deck (refused on +# the coupled aggregate for the current files, standalone for the body), CONTROL on viscoelastic +# and Syrope segments in the host's cross-flow against the static start of the changed deck, and +# ATTACHMENTS on a turned torsion line in a sheared Currents 5 grid (a still run keeps the start) +add_executable(test_parity_integration tests/test_parity_integration.f90) +target_link_libraries(test_parity_integration PRIVATE cabledyn_core) +file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/parity_integration) +add_test(NAME parity_integration + COMMAND test_parity_integration ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_torsion_attachments.dat + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/parity_integration) +set_tests_properties(parity_integration PROPERTIES LABELS "fortran;driver;integration;dynamic;openfast") + 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) @@ -2112,6 +2164,20 @@ 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") +# Active line control of Syrope segments on the coupled route (the slow stretch carried over a +# length change, as MoorDyn-F/C carry it): quasi-static cycle, length step, restart, composites +add_executable(test_syrope_control tests/test_syrope_control.f90) +target_link_libraries(test_syrope_control PRIVATE cabledyn_core) +add_test(NAME syrope_control COMMAND test_syrope_control) +set_tests_properties(syrope_control PROPERTIES LABELS "fortran;integration;dynamic;openfast") + +# Active line control of viscoelastic (ElasticMod 2/3) segments on the coupled route (the dl_1 +# stretch carried over a length change, as MoorDyn-F/C carry it): quasi-static cycle, step, restart +add_executable(test_viscoelastic_control tests/test_viscoelastic_control.f90) +target_link_libraries(test_viscoelastic_control PRIVATE cabledyn_core) +add_test(NAME viscoelastic_control COMMAND test_viscoelastic_control) +set_tests_properties(viscoelastic_control PROPERTIES LABELS "fortran;integration;dynamic;openfast") + 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) @@ -2781,6 +2847,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") -Wno-maybe-uninitialized) target_compile_options(test_torsion_deck PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_hermite_cable_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) + target_compile_options(test_syrope_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) + target_compile_options(test_viscoelastic_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) endif() if(CABLEDYN_ENABLE_COVERAGE) @@ -2860,6 +2928,7 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_fmf test_openfast_aggregate test_openfast_pinned_rod + test_openfast_pinned_body test_of_mooring_counters test_ei0_mesh_scaling_counters test_c_api diff --git a/VALIDATION.md b/VALIDATION.md index c1eb64a6..ffa88d62 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -812,6 +812,7 @@ stop with a named error. | Coupled `Rigid6` bodies + `Point3` buoys | Pass verified | 6-DOF `Rigid6` motion with hydrostatic (`C33`/`C44`/`C55`) restoring, checkpoint state (bit-identical `openfast -restart` of a 13.9 MN-swinging tethered body), and SeaState drag / Froude–Krylov / added mass. `Point3` buoys take buoyancy and drag/added-mass/FK; a submerged volume-only buoy takes FK. Tests: `case_coupled_rigid6`/`_mirror`/`_fluid`, `case_coupled_point3_buoy`/`_fluid` | | Coupled rigid rods | Pass verified | host-driven `RodA/B` endpoints, correction rewind, bit-identical 24-scalar-per-rod checkpoint state, and two Gauss fluid nodes per rod with SeaState drag/Froude–Krylov/added mass; `case_coupled_rod`, `_mirror`, and `_fluid` pass, and the OpenFAST module compiles with rod decks enabled | | Coupled pinned rods (`Pinned`, `CoupledPinned`/`VesselPinned`) | Pass verified | `openfast_pinned_rod` on the aggregate: a dry rod (10 m, 500 kg) released at 30° swings with the elliptic-integral compound-pendulum period to 1.6e-4 at `dt = T/100`, End A on the pin to 0 m; a held `CoupledPinned` node reproduces the `Pinned` rod to round-off (1e-12), returns zero moment, and its force equals the analytic pin reaction to 2.0e-13 of `mg`; a pin accelerating at 2 m/s² gives the mean angle `atan(a/g)` to 1e-6 rad and the period of `sqrt(g² + a²)` to 1.6e-4; a harmonic pin motion follows the linear base-excitation solution to 1.5e-3 / 3.7e-4 of the amplitude at `T0/100` / `T0/200` (ratio 4.03); a 0.1 s step sub-cycled 7 times reproduces a run at the sub-step size to 1e-14 rad and 4e-10 N for a drifting pin; a 1 m `Pinned` rod that carries no line (dry and hanging, or buoyant and upright under water) at a 0.6 s step (`omega0 dt` 2.29 / 3.42, beyond the explicit limit 2) sub-cycles it 6 / 9 times from its own swing stiffness `|W d_g - B d_b|`, equals the run at the sub-step size bit for bit, stays within its release angle and keeps the elliptic-integral period to 6.0e-3 / 5.9e-3 (taken whole, the step turns the rod over); a `CoupledPinned` pin crossing the free surface within one step at constant velocity (a 1 kg/m rod lifted from submerged to dry in 0.1 s, `omega dt` 2.13 wet; a 33 kg/m rod lowered from dry to submerged in 0.6 s, 2.29 dry) takes at least 6 sub-steps from its step-start wetting (more from the waterplane near the surface) and ends within 5e-5 / 3e-4 rad of a run at a sixtieth of the step, where the end-of-step wetting alone gives one sub-step and an angle error of 0.20 / 0.69 rad; on a stiff seabed (`kBot` 1e7 N/m³) a `Pinned` rod whose far end rests on the bed (0.1 s step) and a `Free` rod lying on it (0.05 s step) sub-cycle their contact mode (34–36 and 26 sub-steps), stay at rest on the bed over 5 s (angle change 3.8e-3 / 4e-15 rad, the undamped static settlement) and end within 1.9e-6 / 8e-8 of a run at a tenth of the step, where the sub-steps of the lines and swing alone (1 and 4) throw them off the bed (4.2 rad, 0.8 m); an output probe returns `-m (I_c/I_p) a_p` within 1e-10 of `mg` (not `-m a_p`), and its pin force moves by 2e-11 N when the held end acceleration of the attached tethers changes their end load by 8 N; snapshot/restore, probe restore and restart overlay are bit-identical, the restored state's loads before the next step included; a step without the staged rods (the step-start pin carried by the rod) is bit-identical to the staged one; a `Free` or `Coupled` rod with an end without a line is refused by name; with `PtfmInit` the static start leaves 1.4e-8 N·m about the pin. OpenFAST (IEA-15 UMaine, JONSWAP Hs 6 m, 60 s, `dtM = DT = 0.025 s`) with line 1 hung from a 4 m `CoupledPinned` rod at its fairlead: `openfast -restart` at 30 s reproduces every later OpenFAST output row bit for bit (`NumCrctn` 0 and 1), `NumCrctn = 1` equals `NumCrctn = 0` bit for bit, and surge/heave/pitch statistics stay within 0.2 % / 0.4 % / 1.7 % (mean) of the deck with line 1 on a `Coupled` point | +| Coupled pinned bodies (`CoupledPinned`/`VesselPinned`) | Pass verified | `openfast_pinned_body` on the aggregate: a dry compound pendulum (1000 kg, CG 2 m below the node, released at 30°) swings with the elliptic-integral period to 1.6e-4 at `dt = T/100`, its reference point stays on the held node, and the node force equals the analytic pin reaction plus the line force at the node to 4e-16 of m g; under a 2 m/s² node acceleration it swings about -atan(a/g) (-0.201184 rad) with the effective-gravity period to 1.6e-4; a body with the mass, CG and inertia of a `CoupledPinned` rod and the rod's End B line follows the rod under a harmonic surge (axis 1.5e-13, angular velocity 1.3e-12 of 0.21 rad/s, node force 2.2e-12); on four symmetric lines a heaving body does not turn (omega = 0) and its node force is the line sum plus weight, buoyancy and (m + ρ V Ca) a to 5e-16; an output probe returns -m (I_cg/I_p) a_p besides the line's change; snapshot/restore, a restored probe and a restart overlay are bit-identical; `PtfmInit` with the static start balances the moment about the node to 3e-13; a sub-cycled coarse step equals a run at the sub-step size to 1e-11. Against MoorDyn-F's driver (`inertialF 1`, `TmaxIC 0`), CableDyn run in the OpenFAST shell's order (a state-mirror restore after the output call at t = 0), with the line at the node: 0.09° over a 120° swing (node force 1.5e-3) with the node held, 0.15° over 158° with the node surging 0.5 m (the body part of the node force 1.4e-2; the line force of the jerked slack line differs by up to 0.4 of its peak). With the line pulling at a 4 m arm the swings differ by up to 4.7° of 57° early on; both codes are converged in time step and the difference comes from the lines (CableDyn's initial angular acceleration is 6 % larger: its consistent line mass gives the body an end-node inertia of m l/3 of the end element, less with the interior following, against MoorDyn's lumped m l/2) | | Coupled finite-EI touchdown/contact | Pass verified | flat `WtrDpth` and equivalent constant structured bathymetry initialise and step with matching loads; friction and checkpoint restore are tested. The IEA-15 mixed example (its power cable on 248 elements, each at most half the bending length) has 149 grounded nodes and completes a 20 s aggregate trajectory at `dtM=0.025 s` with 2 m surge, 1 m heave, and 0.5 m/s host current, without fallback or stall recovery, at most 12 Newton iterations. A full-turbine run of the same model (one hour after a 200 s transient; TurbSim normal turbulence, 10.6 m/s, 17 % TI; JONSWAP Hs 8 m, Tp 12 s, aligned with the wind and the cable; AeroDyn with the rotor held at 7.55 rpm, no controller, rigid blades and tower; SeaState grid covering the lines) completes without recoveries or non-finite values. The cable's hang-off tension is 11.5 ± 1.1 kN (static 11.9 kN, maximum 17.9 kN). The 149 nodes grounded at the static state stay grounded, joined by one more once the platform has drifted (the touchdown moves 2.5 m toward the platform). The peak curvature is 0.156 1/m at the sag bend, 72 m from the hang-off, and 0.109 1/m at the touchdown. On the former 87-element mesh (10 m elements along the laid section) the peak was 0.160 1/m and the touchdown curvature 0.075 1/m, under-resolved by about 30 %. These curvatures were recorded before the `Curv` channels took the curvature recovered from nodal equilibrium: they are the geometric curvature of the centreline (the larger one-sided trace at a node), which `OutputRecovery element` reproduces. The chain-only twin of the run matches stock MoorDyn over 1200 s to 0.3 % in platform motion and fairlead tension statistics. The anchor tension of the laid cable stays at its static 1.23 kN (maximum 1.24 kN): the seabed friction of the 370 m laid section holds the tension changes at the touchdown. On the former mesh it read 1.39 kN (median) with wave-frequency stick-slip peaks up to 4.1 kN lasting under 1 s, which the resolved mesh does not show, and before the anchor-end correction of this release it locked at about 2.75 kN for the whole run. The run takes 27.1 min of wall time (18.8 min on the former mesh) | | `WaterKin` from file | Pass verified | See [WaterKin and SeaState modes](#waterkin-and-seastate-modes) | | Syrope polyester (`SYROPE:` syntax; [Falkenberg et al., 2017](https://cabledyn.readthedocs.io/en/latest/references.html#ref-falkenberg2017)) | Pass verified | MoorDyn-F/C `BA_s|BA_d` rate and force equations; analytic position/velocity tangents with finite-difference checks; projected, bracketed backward-Euler slow-state update with a strong-unloading boundary test; OWC running maximum; `SYROPE IC` `Tmax0/Tmean0` history with range/order checks; both states carried through every lifecycle stage and the coupled checkpoint. `BA_s` is kept separate from line axial damping (`BA`) and tested against double counting. The line takes the seabed, Morison loads, current, waves, host fluid and VIV of any `EI = 0` line: a taut 88.5 m polyester line in water whose fairlead sways 2 m matches MoorDyn-C v2.7.2 within 10.6 N over a 44.8 kN tension range (1.03 MN mean; t = 0 within 0.5 N), and its range grows 4.8 % without drag and added mass (`syrope_hydro`). Composite lines (a 400 m Syrope polyester section between chains, `syrope_composite`): every polyester element starts on its OWC to 2e-11 across its 1.005–1.012 MN tension range, a still run keeps the fairlead tension to the printed digits (one secant per section moved it by 1.4e-5 within 2 s), the chains keep their `BA` damping, a `SYROPE IC` history puts the section on the `Tmax0` working curve, a line split into two Syrope sections reaches the single section's tensions to 1e-8, and a tension above the OWC table stops with a named error. Finite-EI combinations stop with a named error | diff --git a/doc/api_python.rst b/doc/api_python.rst index cfae771e..20262612 100644 --- a/doc/api_python.rst +++ b/doc/api_python.rst @@ -336,7 +336,8 @@ Deck editing and case generation family of edited decks for a batch study. It and :meth:`DeckModel.save` (with ``rebase=True``) rewrite relative ancillary paths for the new folder and copy the fixed-name MoorDyn-C kinematics files (``wave_elevation.txt`` for ``3 WaveKin``, ``wave_frequencies.txt`` for -``7 WaveKin``, ``current_profile.txt`` for ``1 Currents``), which the solver reads from the deck's +``7 WaveKin``, ``current_profile.txt``, ``current_profile_dynamic.txt`` and ``current_profile_4d.txt`` +for ``1``, ``2`` and ``5 Currents``), which the solver reads from the deck's own folder, next to the new decks (:doc:`python`). .. autoclass:: cabledyn.DeckFile diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 37dd07fb..77f203d5 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -74,13 +74,16 @@ Line and constitutive capability * - Viscoelastic rope (MoorDyn ``ElasticMod`` 2/3) - Supported - per-element series-Kelvin state (standard linear solid only when ``BA_D = 0``), - including load-dependent dynamic stiffness; ``EI = 0`` lines + including load-dependent dynamic stiffness; ``EI = 0`` lines, with active line control + in coupled OpenFAST runs (the slow-branch stretch carried over the length change, as in + MoorDyn) * - Syrope polyester - Supported with limits - dynamic line with OWC and two history states, single-section and taut or between linear-elastic ``EI = 0`` sections (chain–polyester–chain), with the seabed, Morison loads, - current, waves, host fluid fields and VIV of any ``EI = 0`` line; finite-EI combinations - fail closed by name + current, waves, host fluid fields and VIV of any ``EI = 0`` line, and active line control + of a Syrope segment in coupled OpenFAST runs (its slow stretch carried over the length + change, as in MoorDyn); finite-EI combinations fail closed by name * - Torsion of finite-EI lines - Supported with limits - isotropic torsion of a finite-EI line restrained in torsion at both ends @@ -158,6 +161,11 @@ Loads and environment * - Uniform/profile current - Supported - standalone deck source; coupled runs use explicitly selected host/file sources + * - MoorDyn-C currents in time and space (``Currents 2``, ``Currents 5``) + - Standalone only + - ``current_profile_dynamic.txt`` and ``current_profile_4d.txt``, interpolated as MoorDyn-C + v2.7.1 does at every node's position and time, the static start included; see + :ref:`moordyn-c-wavekin` * - Airy and JONSWAP waves - Supported - standalone deck source or OpenFAST SeaState, never an accidental double source @@ -196,8 +204,9 @@ alternative discretisation of the line. Supported translations include fixed/cou attachments, free or connecting masses and clumps, ``Point3`` buoys, ``Rigid6`` bodies, and coupled rigid rods. In OpenFAST, ``Coupled``/``Vessel`` bodies and rods are platform-borne 6-DOF nodes that return a force and a moment, ``CoupledPinned``/``VesselPinned`` rods turn about a platform-borne -node that takes the platform position only and returns a force with zero moment, and ``Pinned`` -rods turn about a fixed End A; ``CoupledPinned`` bodies are not supported. The C API and Python +node that takes the platform position only and returns a force with zero moment, as do +``CoupledPinned``/``VesselPinned`` bodies about a node at their reference point, and ``Pinned`` +rods turn about a fixed End A. The C API and Python run free, fixed and pinned rods and free bodies in still water. The coupled body/rod routes carry checkpoint state and SeaState drag, Froude–Krylov, and added mass. ``Rigid6`` also carries the documented hydrostatic restoring terms. Consult :doc:`driver_format` @@ -209,7 +218,8 @@ OpenFAST coverage The ``CompMooring = 5`` shell covers normal coupled time-domain stepping with its own ``dtM``, nonzero ``PtfmInit``, correction iterations, SeaState fields, checkpoint/restart, scoped quasi-static ``dYdu`` linearisation, line failures, active-tension control of ``EI = 0`` lines -and finite-EI cables, and FAST.Farm shared moorings. Restart and linearisation do not arise under +(linear-elastic, viscoelastic or Syrope segments) and finite-EI cables, and FAST.Farm shared +moorings. Restart and linearisation do not arise under FAST.Farm, which does not call those module operations, and active-tension control is rejected there. See :doc:`openfast` for setup and :doc:`coupling_boundary` for the interface contract. diff --git a/doc/capi.rst b/doc/capi.rst index 872978d8..75e5faae 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -930,7 +930,7 @@ The deck is validated under the standalone-deck rules: - Where it is supported * - ``Coupled``/``Vessel`` bodies or rods (6-DOF host nodes) - the OpenFAST module; the standalone driver with a ``motionFile`` - * - ``CoupledPinned``/``VesselPinned`` rods (a pin the host moves) + * - ``CoupledPinned``/``VesselPinned`` rods or bodies (a pin the host moves) - the OpenFAST module * - a ``motionFile`` option - the standalone driver (prescribe motion through ``CableDyn_Step`` instead) @@ -943,6 +943,9 @@ The deck is validated under the standalone-deck rules: * - a ``waves`` option (regular or JONSWAP deck waves) - the standalone driver; supply time-varying fluid kinematics through ``CableDyn_UpdatePointFluidFields`` + * - a MoorDyn-C ``Currents 2``/``5`` table that varies in time + - the standalone driver; supply time-varying fluid kinematics through + ``CableDyn_UpdatePointFluidFields`` * - FAST.Farm ``Turbine`` points - the OpenFAST module in FAST.Farm * - ``frictionMu`` in a deck that has ``Free`` or ``Connect`` points @@ -952,8 +955,9 @@ The deck is validated under the standalone-deck rules: .. important:: The C ABI has no simulation clock and no per-node fluid input. A deck's current is applied - as a steady field. A deck with a ``waves`` option is rejected with ``CD_C_BAD_INPUT``, - because its waves could not be evaluated. Time-varying fluid kinematics reach the ``Free`` + as a steady field. A deck with a ``waves`` option, or a MoorDyn-C ``Currents 2``/``5`` table + that varies in time, is rejected with ``CD_C_BAD_INPUT``, because it could not be evaluated + in time; such a table constant in time is applied as the steady field. Time-varying fluid kinematics reach the ``Free`` and ``Connect`` points through ``CableDyn_UpdatePointFluidFields``. Parse and validation failures, including a file that cannot be opened, return diff --git a/doc/coupling.rst b/doc/coupling.rst index f1184768..5ce5b2f1 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -30,7 +30,8 @@ integration surface: coupled time-domain analysis at a 0.1 s CableDyn step by de checkpoint-restart, quasi-static linearisation (``dYdu``), FAST.Farm farm-level shared moorings (``Mod_SharedMooring = 5``), coupled ``Rigid6`` 6-DOF rigid bodies (buoyancy, ``C33``/``C44``/``C55`` hydrostatic restoring, restart state, and SeaState drag / Froude-Krylov / -added-mass), coupled ``Point3`` buoys (buoyancy and SeaState drag / Froude-Krylov / added-mass), and +added-mass), including MoorDyn-F's coupled pinned bodies (``CoupledPinned``, force only), coupled +``Point3`` buoys (buoyancy and SeaState drag / Froude-Krylov / added-mass), and coupled rigid rods with host-driven endpoints, correction rewind, checkpoint state, and two-point Gauss SeaState sampling, including MoorDyn-F's coupled pinned rods (``CoupledPinned``, force only) and rods pinned to a fixed point. diff --git a/doc/driver_format.md b/doc/driver_format.md index 93552c5b..a9890723 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -302,7 +302,8 @@ and `BA = BA_s|BA_d`: initialisation, or a composite line whose other sections are linear-elastic `EI = 0` sections (a chain–polyester–chain mooring), with every Syrope element in tension at initialisation. It runs on a dynamic deck (`dtM`/`TMax`) and takes the seabed, `bathymetryFile`, Morison loads, current, - waves, host fluid fields and VIV of any `EI = 0` line. + waves, host fluid fields and VIV of any `EI = 0` line, and active line control of a Syrope + segment on the OpenFAST route ([CONTROL](#control-optional-openfast-line-control)). - The static start solves each Syrope element on the rest curve of its load history (the OWC, or the `Tmax0` working curve under `SYROPE IC`). A single-section line takes one secant EA from the curve at its mean strain; on a composite line, where the tension varies along a sagging Syrope @@ -339,7 +340,7 @@ points only): the deck is partitioned through the same atomic aggregate used by `Coupled`/`Vessel` endpoints are held at their deck positions. The run writes the common `.out` and the all-line `.static.out` tables, plus the range graph of every line with the `r` flag. Mixed decks reject, by name, `motionFile`, deck wave/current OPTIONS, WaterKin `WaveKinMod 1`, -MoorDyn-C `WaveKin 3`/`7` and `Currents 1`, and per-line `p`/`t` flags. +MoorDyn-C `WaveKin 3`/`7` and `Currents 1`/`2`/`5`, and per-line `p`/`t` flags. (multibody-march)= **Multibody march** (bodies, rods, `Connect`/`Free` points, EI = 0 lines and finite-EI cables in @@ -438,6 +439,17 @@ row. On this route: and added-mass inertia (MoorDyn-F's coupled body). They may share a deck with `Free` bodies: when the free bodies sub-cycle the coupling step, the host-driven bodies follow the host motion interpolated from the step start; +- `CoupledPinned`/`VesselPinned` bodies are pinned to the platform as `CoupledPinned` rods are: + a mesh node at the body reference point (moved and turned by `PtfmInit` with the body) that + takes the platform position only. The body turns about it with its own three rotations, the + node orientation and angular rates are ignored, and the node returns the body's net load less + its inertia, with no moment (MoorDyn-F's coupled pinned body); the angular acceleration in that + inertia is solved for the node's current acceleration. With `bodyIC static` the body starts + balanced about its node. `PtfmInit` turns the body with the platform, as it turns the body's + attachment points (M^T R0 for the deck orientation R0 and the platform's global-to-local DCM + M); MoorDyn-F's driver instead starts a coupled pinned body at its deck orientation, so with + `bodyIC deck` and a rotation in `PtfmInit` the two start from different poses. Outside a + coupled host such a body is rejected by name ("requires a coupled host"); - cables may be suspended or use the same flat/structured seabed contact, normal damping, and stick-slip friction as the standalone Hermite route. @@ -450,22 +462,23 @@ columns, or 18 with the trailing inertias, or the 14 columns of a MoorDyn v2 row | Column | Meaning | |--------|---------| | `ID` | unique body id ≥ 1 (referenced by `Body` points) | -| `Type` | `Point3` (3-DOF translational buoy or clump), `Rigid6` (6-DOF rigid body), or `Coupled`/`Vessel` (a `Rigid6` body whose pose follows the host: the OpenFAST platform, or `motionFile` rows for its `Body` points in the standalone driver) | +| `Type` | `Point3` (3-DOF translational buoy or clump), `Rigid6` (6-DOF rigid body), `Coupled`/`Vessel` (a `Rigid6` body whose pose follows the host: the OpenFAST platform, or `motionFile` rows for its `Body` points in the standalone driver), or `CoupledPinned`/`VesselPinned` (MoorDyn aliases `CpldPin`, `VesPin`: a `Rigid6` body whose reference point follows the OpenFAST platform position while it turns about that point; OpenFAST only) | | `X,Y,Z` | reference position [m] | | `Roll,Pitch,Yaw` | reference orientation [deg] (`Rigid6`; ignored for `Point3`) | -| `Mass` | body mass [kg]; > 0 | +| `Mass` | body mass [kg]; > 0 (≥ 0 for `Coupled`/`Vessel` and `CoupledPinned`/`VesselPinned`) | | `Vol` | displaced volume [m³] (buoyancy ρ_w·g·Vol); ≥ 0 | | `C33` | heave hydrostatic restoring ρ_w·g·A_wp [N/m] | | `C44/55` | roll/pitch restoring [N·m/rad] (`Rigid6`) | | `CdA`, `Ca` | drag area and added-mass coefficient (dynamic); ≥ 0 | -| `Ixx,Iyy,Izz` | trailing diagonal rotational inertias [kg·m²]; required and > 0 for `Rigid6` (≥ 0, like `Mass`, for `Coupled`/`Vessel`) | +| `Ixx,Iyy,Izz` | trailing diagonal rotational inertias [kg·m²]; required and > 0 for `Rigid6` and `CoupledPinned`/`VesselPinned` (≥ 0, like `Mass`, for `Coupled`/`Vessel`) | Every body value must be finite. Both body types require a dynamic deck (`dtM`/`TMax`) in the standalone driver. The MoorDyn v2 row `ID Attachment X0 Y0 Z0 r0 p0 y0 Mass CG* I* Volume CdA* Ca*` defines a -`Rigid6` body with a centre of gravity: `Attachment` is `Free`, or `Coupled`/`Vessel` for a -host-driven body (`CoupledPinned` fails closed); `CG` is `z` or `x|y|z` in +`Rigid6` body with a centre of gravity: `Attachment` is `Free`, `Coupled`/`Vessel` for a +host-driven body, or `CoupledPinned`/`VesselPinned` for a body pinned to a host node; `CG` is `z` +or `x|y|z` in the body frame from the reference point (it is also the centre of buoyancy, as in MoorDyn); `I` is one value or `Ixx|Iyy|Izz` about the CG; `CdA` is one value, `CdA|CdA_rot`, or 3 or 6 entries, and `Ca` one value or 3 entries. The body model is isotropic, so direction-dependent @@ -938,13 +951,14 @@ Behaviour: - Loads: the net weight `(Mass − rhoW Volume) g` downward; with the dry mass, the added mass `Ca rhoW Volume` (a constant nodal mass); the fluid-inertia force `rhoW Volume (1 + Ca) du/dt` and the drag against the current and wave velocity at the node. - A deck `current` (uniform or profile) loads the attachments in the static initial condition + A deck current (a `current` row, uniform or profile, or a MoorDyn-C `Currents` field at + `t = 0`, sampled at the attachment node) loads the attachments in the static initial condition with the same drag law at rest, so a run in a current starts in equilibrium. An attachment above the free surface carries its weight only. Attachments have no seabed contact of their own; the node's contact acts on the line. - The static equilibrium is solved first with each attachment's net weight spread over the two elements at its node, then carried to the discrete loads by continuation. The current drag - depends on the node's depth and line direction, so the final solve is repeated until the + depends on the node's position and line direction, so the final solve is repeated until the node positions change by less than 1e-9 m. On a line restrained in torsion the torsion stage (the imposed twist) follows on the discrete equilibrium, with the attachments' net weights and drag as nodal loads (the drag again to a fixed point), so a run starts in the twisted @@ -1081,8 +1095,10 @@ the `NodeB` written in the deck. A line written in the stock MoorDyn order, with end at `NodeB`, is therefore controlled where MoorDyn-F controls it, at its last segment N at `AttachB`; so is a line with both or no host-driven ends. A line written fairlead first, with its only host-driven end at `NodeA`, is controlled at that end. The length is held over the advance. -Axial damping on that segment acts on the strain rate, as in MoorDyn-F, so a segment paid out at -constant strain carries no damping tension. +On a linear-elastic segment the axial damping acts on the strain rate, as in MoorDyn-F +(`BA (lstrd − lstr ld/l)/l`), so a segment paid out at constant strain carries no damping +tension; the viscoelastic and Syrope laws take the plain chord rate `lstrd`, as MoorDyn-F and +MoorDyn-C do (see the bullets below). A command outside MoorDyn-F's bounds stops the run with a message that names the channel, the line, the command and the bound, as MoorDyn-F stops there. With `UnstrLen` the line's unstretched @@ -1099,6 +1115,19 @@ bounds that would make it zero or negative (possible when it is shorter than hal advance (with the force blend, the default, the step-start force; under `False alpha_force_blend`, lengths blended with the configuration), so a length ramp is followed without lag at any `rhoInf`. +- A Syrope polyester segment (a Syrope line, or a composite line whose fairlead-side section is + Syrope) carries its slow stretch over the length change, as MoorDyn-F and MoorDyn-C carry it: + they keep the stretch `dl_1` of the segment as its state and read its slow strain as `dl_1` + over the new length. The running maximum tension is kept, and the slow-strain rate takes the + chord rate without the paid-out term, as MoorDyn's Syrope rate does. A slow pay-out therefore + unloads the segment along the working curve of its load history, and a haul-in beyond the + running maximum follows the OWC and raises it. +- A viscoelastic segment (`Es|Ed` or `Es|alphaMBL|vbeta`) keeps its slow-branch stretch `dl_1` + as it is over the length change and reads it at the new length, as MoorDyn-F and MoorDyn-C do: + the tension `EA_1 dl_1/L0 + BA ld_1/L0`, the rate `ld_1` with `dl` = stretched length − `L0`, + and the load-dependent `EA_D` all take the new `L0`, and the rate takes the chord rate without + the paid-out term. A slow pay-out or haul-in therefore follows the static law `Es` times the + strain; a fast change first meets the dynamic stiffness and relaxes to it. - On a finite-EI cable, which runs from a `Fixed` anchor to a host-driven fairlead, the segment is the fairlead segment of the deck mesh (the length of the `SECTIONS` row at the fairlead over its `NumSegs`). Where the static initialisation refined the mesh, it is the cable elements that @@ -1194,33 +1223,70 @@ in, so keys such as `staticRelTol` or `staticMaxIter` are rejected like any othe set the dynamic Newton controls with `dynamic_solver`. The stock MoorDyn keywords `dtIC`, `TmaxIC`, `CdScaleIC`, `threshIC`, `TScheme`, `WriteLog`, and `dtOut` are accepted and ignored, because CableDyn uses a Newton static initial condition, an implicit integrator, and -caller-controlled output cadence. +caller-controlled output cadence. MoorDyn-F's `inertialF` is accepted as `1` only (CableDyn +always returns the inertia of coupled bodies and rods; `0` and `2` are rejected by name), and +`inertialF_rampT` is accepted and ignored. (moordyn-c-wavekin)= ### MoorDyn-C `WaveKin` and `Currents` modes A MoorDyn-C deck selects its water kinematics with the numeric `WaveKin` and `Currents` options -and fixed-name files in the deck folder. CableDyn reduces each file to wave components or a depth -profile and evaluates them exactly at every node, with Wheeler stretching; MoorDyn-C tabulates -them on `water_grid.txt` and interpolates, so that file is not read. Standalone decks only. +and fixed-name files in the deck folder. CableDyn reduces each wave file to wave components and +evaluates them exactly at every node, with Wheeler stretching; MoorDyn-C tabulates them on +`water_grid.txt` and interpolates, so that file is not read. The current files are evaluated at +every node's position and time as MoorDyn-C interpolates them. Standalone decks only. | Option | File | Meaning | |---|---|---| | `WaveKin 3` | `wave_elevation.txt` | `time elevation` rows from `t = 0` (no header rows), resampled linearly at `dtWave` to `floor(t_last/dtWave) + 1` samples (the last dropped when the count is odd) and reduced to its Fourier components; components above `WvHiCOff` (default 0.5 Hz, MoorDyn-C's fixed cut) are dropped and the mean is a mean-level offset, as MoorDyn-C does. Waves travel along +x | | `WaveKin 7` | `wave_frequencies.txt` | `omega Re Im [beta]` rows [rad/s, m, m, rad], the first at `omega = 0`: each row is the component `\|c\| sin(omega t - k d + arg c)`, `d = x cos(beta) + y sin(beta)`; the `omega = 0` row is a mean-level offset. All rows must share one `beta` | | `Currents 1` | `current_profile.txt` | `z ux uy uz` rows after its header rows, strictly increasing `z`; linear in `z` and held beyond the end rows | +| `Currents 2` | `current_profile_dynamic.txt` | a depth profile in time: lines 1-4 and 6 are free text, line 5 lists the depths `z1 ... zn` (strictly increasing, read in single precision as MoorDyn-C does), and each later row is `t ux1 ... uxn [uy1 ... uyn [uz1 ... uzn]]` (missing components zero), at least two rows with strictly increasing `t` | +| `Currents 5` | `current_profile_4d.txt` | a grid in x, y, z and time: line 1 is `nx ny nz nt`, lines 2-5 the x, y, z and t coordinates (each strictly increasing, at least two times), then one `x y z t ux uy uz` row per grid point, in any order, matched to the grid by value; a text line 6 is a header | + +`Currents 2` and `5` follow MoorDyn-C v2.7.1 (`constructDynamicCurrentGrid`, +`construct4DCurrentGrid` and `CurrentGrid::getCurrentKin`): + +- the table is resampled in time at its smallest time interval `dt`, from `t = 0` to + `floor(t_last/dt) dt` (a last time that is not a multiple of `dt` is not reached), linearly + between rows and held at the first and last rows; +- between samples the current is linear in time; past the last sample the grid repeats with + period `nt dt` (`nt` samples), holding its `t = 0` value over the last interval of each period, + as MoorDyn-C's index wrap does. A run longer than the last sample prints a note; +- in x, y and z the current is linear between grid coordinates and held beyond the end ones; the + node elevation is not stretched; +- the current has no fluid acceleration (MoorDyn-C sets it to zero), so its time variation adds + no Froude-Krylov or added-mass load; +- the static start takes the current at `t = 0`, as MoorDyn-C's default stationary initial + condition does (its legacy dynamic relaxation, `ICgenDynamic 1`, samples the current over the + relaxation time instead); +- a grid holds at most 2e6 resampled points in space and time (every static solve holds a copy, + 48 MB at the limit); +- the C API and the OpenFAST point-system shells have no simulation clock: they apply a current + constant in time as a steady field, as `Currents 1`, and refuse one that varies in time; +- `current_profile_4d.txt` is read as MoorDyn-C documents it, which MoorDyn-C v2.7.1 does not + quite do: it reads its rows from line 7, so a row on line 6 leaves that grid point at zero, and + it matches a row to the grid by the text of its coordinates, so a row writing `-0` for `0` or + `1.0` for `1` lands on the first grid point. CableDyn reads line 6 as a row unless it is text + and matches by value, and it rejects a missing, repeated or off-grid point. A file with a text + line 6 and its coordinates written as on lines 2-5 reads the same in both codes. + +With `WaveKin 3`, MoorDyn-C (its default `UnifyCurrentGrid 1`) adds a current to the wave grid, +where it is sampled on `water_grid.txt`; CableDyn adds the current at the nodes, as MoorDyn-C's +`UnifyCurrentGrid 0`. Rejected by name: `WaveKin 1` (kinematics set node by node through the MoorDyn-C API; a deck has no source for them), `WaveKin 2` (the FFT grid: `wave_frequencies.txt` resampled to an even spectrum; `WaveKin 7` evaluates the same file's components exactly), `WaveKin 4`-`6` and -`Currents 3`-`4` (no kinematics source in MoorDyn-C v2.7.1), `Currents 2` (the -time-varying profile `current_profile_dynamic.txt`), `Currents 5` (the 4-D current grid), and a -`wave_frequencies.txt` whose rows have different directions. A deck that also declares a `waves` -option, a WaterKin file, or a second current source is rejected as double counting. On shared -inputs the `wavekin_modes` test holds `WaveKin 7` and `Currents 1` identical to MoorDyn-C v2.7.1 -(`5e-12` relative) and `WaveKin 3` within `3e-7` m in elevation and `1e-4` in velocity and -acceleration at MoorDyn-C's grid points, the remainder being MoorDyn-C's grid interpolation and -its approximate wave number. +`Currents 3`-`4` (no kinematics source in MoorDyn-C v2.7.1), and a `wave_frequencies.txt` whose +rows have different directions. A deck that also declares a `waves` option, a WaterKin file, or a +second current source is rejected as double counting. On shared inputs the `wavekin_modes` test +holds `WaveKin 7` and `Currents 1` identical to MoorDyn-C v2.7.1 (`5e-12` relative) and `WaveKin 3` +within `3e-7` m in elevation and `1e-4` in velocity and acceleration at MoorDyn-C's grid points, +the remainder being MoorDyn-C's grid interpolation and its approximate wave number. The +`mdc_currents` test holds `Currents 2` and `5` identical to MoorDyn-C v2.7.1 at 739 points and +times (including past the last sample), and `mdc_currents_runs` matches the tension change of a +time-varying and of a sheared current to MoorDyn-C's within 0.9 % on a 70 m rope. (waterkin-file-modes)= ### MoorDyn-F `WaterKin` file modes diff --git a/doc/file_formats.rst b/doc/file_formats.rst index ce828700..430b1c13 100644 --- a/doc/file_formats.rst +++ b/doc/file_formats.rst @@ -42,15 +42,15 @@ page. - the ``OWC`` row of the Syrope settings file - the directory of the settings file * - MoorDyn-C kinematics files ``wave_elevation.txt``, ``wave_frequencies.txt``, - ``current_profile.txt`` - - OPTIONS ``3 WaveKin``, ``7 WaveKin`` and ``1 Currents`` (grammar in - :ref:`moordyn-c-wavekin`); the file names are fixed + ``current_profile.txt``, ``current_profile_dynamic.txt``, ``current_profile_4d.txt`` + - OPTIONS ``3 WaveKin``, ``7 WaveKin``, ``1 Currents``, ``2 Currents`` and ``5 Currents`` + (grammar in :ref:`moordyn-c-wavekin`); the file names are fixed - the deck directory The parser reads no other input files. Line-type properties, nonlinear ``EA`` data other than the Syrope OWC table, wave spectra, and control-channel values all come from the deck itself or from the coupling host. Because the MoorDyn-C file names are -fixed, a deck that uses ``WaveKin 3``/``7`` or ``Currents 1`` must sit in the same +fixed, a deck that uses ``WaveKin 3``/``7`` or ``Currents 1``/``2``/``5`` must sit in the same folder as its kinematics file; a copied or generated deck needs a copy of that file beside it. diff --git a/doc/migrating.rst b/doc/migrating.rst index 39010cfa..2772a9c6 100644 --- a/doc/migrating.rst +++ b/doc/migrating.rst @@ -115,9 +115,9 @@ Keyword map ``Body`` points and at rod ends (``RA``/``RB`` in ``LINES``, or ``RodA``/``RodB`` points) (:doc:`tutorial_bodies`); ``ROD TYPES`` ``Cd Ca CdEnd CaEnd`` as in MoorDyn, with optional axial side ``CdAx CaAx`` columns. - ``CoupledPinned``/``VesselPinned`` rods run in OpenFAST as in MoorDyn-F (End A follows - the platform position, the rod turns about it, a force is returned without moment); - ``CoupledPinned`` bodies are rejected + ``CoupledPinned``/``VesselPinned`` rods and bodies run in OpenFAST as in MoorDyn-F (End A + or the body reference point follows the platform position, the object turns about it, a + force is returned without moment) * - ``dtM``, ``TMax`` (standalone), ``WtrDpth``, ``rhoW``/``WtrDnsty``, ``g`` - same * - ``kBot``, ``cBot``, seabed friction coefficient diff --git a/doc/openfast.rst b/doc/openfast.rst index 767dd668..cad5ffc3 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -385,7 +385,9 @@ without an auxiliary process: * **Active tensioning** maps ServoDyn ``CableDeltaL``/``CableDeltaLdot`` control onto the fairlead-side segment of ``EI = 0`` lines and finite-EI cables, the segment at the line's end on a host-driven point, or at the ``NodeB`` written in the deck when both or neither ends are - (:doc:`driver_format`, CONTROL). On a finite-EI cable the command scales every cable element + (:doc:`driver_format`, CONTROL). A viscoelastic or Syrope polyester segment carries its + slow stretch over the length change, as MoorDyn-F and MoorDyn-C do. + On a finite-EI cable the command scales every cable element of that segment, and needs the force-blended generalised-α (the default). On both kinds a command outside MoorDyn-F's bounds, from minus half to plus one ``UnstrLen``/N of the line (the controlled segment's initial length on a line of one section), stops the run with a @@ -394,8 +396,9 @@ without an auxiliary process: CONTROL. * **Rigid6 bodies, Point3 bodies, and rigid rods** are translated at the deck boundary; their supported loads and restrictions in coupled runs are listed in :doc:`capabilities`. Free - Rigid6 bodies, free rods and pinned rods start at their static equilibrium with the platform - at ``PtfmInit`` (``bodyIC static``, the default), as in standalone runs; one that carries no + Rigid6 bodies, free and pinned rods and pinned bodies start at their static equilibrium with + the platform at ``PtfmInit`` (``bodyIC static``, the default), as in standalone runs; one that + carries no line is not part of that solve and starts at rest in its deck pose. ``Coupled``/``Vessel`` rods are platform-borne: each is a node of the coupling mesh at its End A that follows the platform position and orientation and returns a force and a moment (MoorDyn-F's coupled rod, @@ -410,7 +413,19 @@ without an auxiliary process: the platform before the static solve balances it about its pin. ``Pinned`` rods turn about a fixed End A. ``Coupled``/``Vessel`` bodies are platform-borne the same way as ``Coupled`` rods, with the node at the body reference point, and may share a deck with ``Free`` bodies. - ``CoupledPinned`` bodies are not supported on this route. + ``CoupledPinned``/``VesselPinned`` bodies are pinned to the platform like ``CoupledPinned`` rods: + the node at the body reference point follows the platform position only, the body turns about + it with its own three rotations (its inertia about the node, its weight and buoyancy at the + centre of gravity, the node acceleration and the moments of its lines; MoorDyn-F's coupled pinned + body), and the node returns the body's net load less its inertia, with zero moment, the angular + acceleration again solved for the node's current acceleration. ``PtfmInit`` moves and turns such + a body with the platform before the static solve balances it about its node (MoorDyn-F's + driver keeps the deck orientation of a coupled pinned body: with ``bodyIC deck`` and a + ``PtfmInit`` rotation the start poses differ). Its inertias ``Ixx``/``Iyy``/``Izz`` must be + positive. Linearisation fails closed on decks with bodies. The force follows MoorDyn-F's + coupled pinned body with ``inertialF 1`` (CableDyn always includes the inertia), with the + differences given in :doc:`theory` (the centripetal force of the structural mass only, the + wetted buoyancy, the lines' consistent end-node inertia). Each is a separate qualification: a successful ordinary run does not qualify restart, linearisation, control, failure, or farm behaviour for a new model. diff --git a/doc/options.rst b/doc/options.rst index 5c304764..90482631 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -757,10 +757,13 @@ Ambient fluid and prescribed motion - standalone - ``6.2832 WvHiCOff`` * - ``Currents`` - - ``0`` or ``1`` + - ``0``, ``1``, ``2`` or ``5`` - ``0`` - - ``1`` reads the MoorDyn-C steady profile ``current_profile.txt`` in the deck folder; the - other MoorDyn-C modes fail closed by name. ``current`` and a WaterKin table are the other + - the MoorDyn-C current file in the deck folder: ``1`` the steady profile + ``current_profile.txt``, ``2`` the depth profile in time ``current_profile_dynamic.txt``, + ``5`` the grid in x, y, z and time ``current_profile_4d.txt``, each interpolated as + MoorDyn-C v2.7.1 does (:ref:`moordyn-c-wavekin`); ``3`` and ``4`` (no current source in + MoorDyn-C v2.7.1) fail closed by name. ``current`` and a WaterKin table are the other sources; two sources in one deck are rejected - standalone - ``1 Currents`` @@ -788,6 +791,13 @@ These names exist so a migrated MoorDyn deck fails less often at the syntax boun * - ``WriteLog`` - plain number - Parsed strictly and ignored; reporting uses the normal CableDyn/OpenFAST diagnostics. + * - ``inertialF``, ``inertialF_rampT`` + - plain number + - ``inertialF 1`` is accepted without effect: CableDyn always returns the inertia of coupled + bodies and rods (``Coupled``/``Vessel`` and ``CoupledPinned``/``VesselPinned``) with + their coupled loads, as MoorDyn-F's ``inertialF 1``. ``0`` (MoorDyn-F's default, no + inertia) and ``2`` (the inertia ramped in) are rejected by name. ``inertialF_rampT``, the + ramp time of ``inertialF 2``, is parsed strictly and ignored. * - ``dtOut`` - plain number - Parsed strictly and ignored. Standalone output follows ``dtM``; coupled ``.CD.out`` @@ -802,9 +812,9 @@ These names exist so a migrated MoorDyn deck fails less often at the syntax boun ``frictionMu``, ``frictionMuLateral`` and ``frictionMuAxial``, with no static-to-kinetic ratio or friction damping. Remove the row. -Other MoorDyn constructs that fail by name rather than as unknown input: ``CoupledPinned`` bodies, -and ``CoupledPinned``/``VesselPinned`` rods outside a coupled host (they run in OpenFAST, see -:doc:`openfast`). Line-node output channels start at node 1 (``N0`` is rejected; MoorDyn numbers from 0, see +Other MoorDyn constructs that fail by name rather than as unknown input: +``CoupledPinned``/``VesselPinned`` rods and bodies outside a coupled host (they run in OpenFAST, +see :doc:`openfast`). Line-node output channels start at node 1 (``N0`` is rejected; MoorDyn numbers from 0, see :ref:`node numbering `), and a number with a sign inside its mantissa (such as ``1+2``) is rejected instead of being read up to the sign. diff --git a/doc/python.rst b/doc/python.rst index 276ce877..a5ec813c 100644 --- a/doc/python.rst +++ b/doc/python.rst @@ -631,7 +631,8 @@ the default permissions of a newly created file. The MoorDyn-C kinematics files are read by fixed name from the folder of the deck being run: ``3 WaveKin`` reads ``wave_elevation.txt``, ``7 WaveKin`` reads ``wave_frequencies.txt`` and -``1 Currents`` reads ``current_profile.txt``. ``generate_deck_cases`` copies these files next to +``1 Currents`` reads ``current_profile.txt``, ``2 Currents`` ``current_profile_dynamic.txt`` and +``5 Currents`` ``current_profile_4d.txt``. ``generate_deck_cases`` copies these files next to the generated decks, and ``cases.json`` records their SHA-256 under ``companion_files``; ``DeckModel.save(rebase=True)`` copies them too. diff --git a/doc/theory.rst b/doc/theory.rst index faecf21e..f1098f58 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -757,7 +757,9 @@ The slow strain is eliminated implicitly in every in-step evaluation: a projecte backward-Euler solve, :math:`\varepsilon_\text{slow}^{n+1} = \varepsilon_\text{slow}^{n} + \Delta t\,\dot\varepsilon_\text{slow}(\varepsilon_\text{slow}^{n+1}, \varepsilon, \dot\varepsilon)` constrained to :math:`\varepsilon_\text{slow} \ge 0`, gives the slow strain that the force -uses. The tangent carries :math:`\partial\varepsilon_\text{slow}^{n+1}/\partial(\varepsilon, \dot\varepsilon)` +uses (safeguarded Newton steps, finished by bisection where they stall next to a kink of the +interpolated curves, as at the top of the working curve; a residual so steep that it changes +sign between two adjacent reals gives the root to machine precision). The tangent carries :math:`\partial\varepsilon_\text{slow}^{n+1}/\partial(\varepsilon, \dot\varepsilon)` from the implicit-function theorem. The step commits that same slow strain, so the force applied to the nodes equals the reported tension. The working curve is the one regenerated at the committed :math:`T_\text{max}`. The branch follows the evaluated slow strain: the working curve @@ -2303,7 +2305,15 @@ body's position and a rotation-vector increment on SO(3) (for a free rod only th normal to its axis), each pinned rod's two rotations about its pin, and each point's position. A pinned rod's residual rows are its moment about the pin; its net force acts on its parent body at the pin (a rod pinned to a fixed point has none, and a ``CoupledPinned`` rod in OpenFAST is -balanced about its pin at the platform's initial pose). A free or pinned rod that no line +balanced about its pin at the platform's initial pose). A ``CoupledPinned`` body in OpenFAST +keeps its position unknowns held at its node (their force rows carry the host's reaction, not a +residual) and balances the moment about the node with its three rotations. Its lines and its +centre of gravity may lie on one axis through the node, about which it then turns neutrally: the +Jacobian has that spin as a null vector, to which the residual is orthogonal, and the Newton +step of a deck with such a body is the minimum-norm Gauss-Newton step +:math:`(\mathbf{J}^T\mathbf{J} + 10^{-10}\mathbf{D})\,\delta\mathbf{x} = -\mathbf{J}^T\mathbf{r}` +(:math:`\mathbf{D}` the floored diagonal of :math:`\mathbf{J}^T\mathbf{J}`), which does not spin it. +A free or pinned rod that no line attaches to (nor, for a rod pinned to a body, any line of its body) is not an unknown: it keeps its deck pose and starts at rest there. A deck with pinned rods takes the central-difference Jacobian of the full residual. A finite-EI line enters with its axial @@ -2542,6 +2552,41 @@ the same pin acceleration term in its rotation equation and returns the same for call evaluates the rod's state derivative at the current input first (its lumped line mass has no interior coupling). +A ``CoupledPinned`` body is pinned the same way at its reference point, which is its node: its +translation is the host's, :math:`\mathbf{a} = \mathbf{a}_p`, and its rotation solves the moment +equation about the node, +:math:`\mathbf{M}_{rr}\boldsymbol{\alpha} = \mathbf{M} - \mathbf{M}_{rt}\mathbf{a}_p - \boldsymbol{\omega}\times(\mathbf{I}_p\boldsymbol{\omega})`, +with :math:`\mathbf{I}_p = \mathbf{R}\mathbf{J}\mathbf{R}^T - m[\mathbf{c}]_\times^2` the inertia +about the node for the centre of gravity at :math:`\mathbf{c}`, +:math:`\mathbf{M}_{rr} = \mathbf{I}_p` plus the attached lines' end-node inertia through their +arms, and :math:`\mathbf{M}_{rt} = m[\mathbf{c}]_\times` (MoorDyn-F's +:math:`\mathbf{M}_{(4:6,4:6)}\mathbf{a}_{(4:6)} = \mathbf{F}_{(4:6)} - \mathbf{M}_{(4:6,1:3)}\mathbf{a}_{(1:3)}`). +The node receives +:math:`\mathbf{F} - (m + m_a)\mathbf{a}_p - m(\boldsymbol{\alpha}\times\mathbf{c} + \boldsymbol{\omega}\times(\boldsymbol{\omega}\times\mathbf{c}))` +and no moment, :math:`m_a` the body's translational added mass, with the angular acceleration +solved again for the current node acceleration as for the rod. This is MoorDyn-F's coupled pinned +body with ``inertialF 1`` (its default ``inertialF 0`` leaves the inertia out of the coupled +force; CableDyn always includes it) but for three modelling differences, where CableDyn keeps the +consistent form: MoorDyn-F's centripetal force :math:`-\mathbf{M}_{(1:3,1:3)}\,\boldsymbol{\omega}\times(\boldsymbol{\omega}\times\mathbf{c})` +takes its translational mass block, with the added mass :math:`\rho V C_a` and the attached +points' masses, at the centre of gravity, where CableDyn takes the structural mass there and the +added mass and line ends at their own points; MoorDyn-F applies the full buoyancy +:math:`\rho g V` at any elevation, CableDyn the wetted one (``bodyWetting moordyn`` restores +MoorDyn's); and the attached ``EI = 0`` lines carry their consistent end-node inertia +(:math:`m l/3` of the end element, less with the interior following in a step) against +MoorDyn-F's lumped :math:`m l/2`. The aggregate solves the start accelerations of its bodies and +rods at initialisation and, before the first step, at a committed transfer of the step-start +kinematics and at new host fluid fields (with the line interior accelerations in those fields), so +the first step starts from the accelerations in the host's field and the state mirror the OpenFAST +shell restores after its first output call (its ``t = 0`` field is set at initialisation) already +carries them. The sub-step estimate +takes the diagonal of :math:`\mathbf{I}_p` against the line springs through their arms from the +node, the waterplane restoring, and the swing stiffness of the weight and buoyancy turning with +the body, :math:`|\mathbf{K}_{kk}|` of :math:`\mathbf{K} = -\sum_i[\mathbf{f}_i]_\times[\mathbf{p}_i]_\times` +at the step-start and end-of-step node poses, plus :math:`|\mathbf{a}_p|\,m|\mathbf{c}|`; the +node moves linearly within the sub-steps from the committed reference-point motion, and that +motion, which the body state mirror carries, starts the next step. + **Mixed topologies.** One step marches every object of a deck together: bodies with their fixed and pinned rods, free and pinned rods, the ``EI = 0`` lines with their ``Free``/``Connect`` points, and the finite-EI cables. In the monolithic scheme the points are junctions of the @@ -2753,6 +2798,45 @@ of the step to 3e-8 N, where applying the whole change in the first sub-step dep line-system step halved after a failure, which take their sub-steps as given, apply the whole change in their first part. +A Syrope segment keeps its states over a length change as MoorDyn-F and MoorDyn-C keep them. +Their state is the segment's slow stretch :math:`\Delta l_1 = \varepsilon_\text{slow} L_0`, which a +change of :math:`L_0` leaves as it is, and the mean tension reads the slow strain +:math:`\Delta l_1/L_0` at the new length. CableDyn stores the slow strain of the committed state, +a strain of :math:`L_{0,c}`, and reads it at the present length, + +.. math:: + + \varepsilon_\text{slow}(L_0) = \varepsilon_\text{slow}\,\frac{L_{0,c}}{L_0}, + +so the step's backward-Euler update +:math:`\varepsilon_\text{slow}^{n+1} = \varepsilon_\text{slow}^{n} L_{0,c}/L_0 + \Delta t\,\dot\varepsilon_\text{slow}` +is that of MoorDyn's :math:`\mathrm{d}\Delta l_1/\mathrm{d}t = L_0\,\dot\varepsilon_\text{slow}`; the +committed force of the force blend reads the state at :math:`L_{0,c}` as it is. The running +maximum, a tension, is kept, and the slow-strain rate takes the chord rate +:math:`\dot\varepsilon = \mathbf{t}\cdot\Delta\mathbf{v}/L_0` without the paid-out term, as +MoorDyn's Syrope rate does. A slow pay-out therefore unloads the segment along the working curve +of its load history, and a haul-in beyond :math:`T_\text{max}` follows the OWC and raises it. On a +taut 100 m polyester line whose fairlead segment is paid out by 0.5 m, hauled in to −1 m and paid +back over 80 s, every element's tension follows the rest curve of its history at the line strain +to 2.5e-4 of the initial tension along the ramps and to 6e-7 at rest; after a length step it is +MoorDyn's at the carried stretch to round-off, where carrying the strain instead would be off by +0.4 to 2.4 %. + +A viscoelastic segment keeps its slow-branch stretch :math:`\Delta l_1` over a length change, as +MoorDyn-F (``MD_CalcContStateDeriv`` sets the controlled segment's ``l`` and ``ld``, +``Line_GetStateDeriv`` reads ``dl_1`` against ``l``) and MoorDyn-C +(``Line::setUnstretchedLength``, ``Line::getStateDeriv``) keep it: :math:`\Delta l_1` is a +stretch, so no rescaling arises, and the law reads it at the present length, +:math:`T = EA_1\,\Delta l_1/L_0 + BA\,\dot{\Delta l}_1/L_0` with +:math:`\dot{\Delta l}_1 = (EA_D (l - L_0) - (EA_D + EA_1)\Delta l_1 + BA_D\,\dot l)/(BA_D + BA)` +and, for the load-dependent stiffness, :math:`EA_D(\Delta l_1, L_0)`; the committed force of the +force blend reads the same :math:`\Delta l_1` at :math:`L_{0,c}`. The rate :math:`\dot l` is the +chord rate, without the paid-out term, as in MoorDyn. On the taut 100 m line above with +:math:`E_s = 10^8` N, the same pay-out and haul-in cycle follows the static law +:math:`E_s(D/L - 1)` to 1.7e-4 of the initial tension along the ramps (4.6e-4 with the +load-dependent stiffness) and to 4e-9 at rest; after a length step the tension is MoorDyn's at +the carried stretch to round-off, where carrying the strain instead would be off by 0.4 to 4.6 %. + On a finite-EI cable, whose fairlead is End A, the command acts on the cable elements that make up the End-A segment of the deck mesh, of initial length :math:`S`. Each element scales by :math:`\lambda = (S + \Delta L)/S`, :math:`L_{0,e} = \lambda L_{0,e,\text{base}}`, with rate diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 56f485e3..ae8d59fa 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -2615,8 +2615,9 @@ def save( Syrope files) so they still resolve from the target folder, and copy the MoorDyn-C kinematics files the solver reads by fixed name from the deck folder (``wave_elevation.txt`` for ``WaveKin 3``, - ``wave_frequencies.txt`` for ``WaveKin 7``, ``current_profile.txt`` - for ``Currents 1``) into it. + ``wave_frequencies.txt`` for ``WaveKin 7``, ``current_profile.txt``, + ``current_profile_dynamic.txt`` and ``current_profile_4d.txt`` for + ``Currents 1``, ``2`` and ``5``) into it. Returns ------- diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 7ec699f9..474539f4 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -294,6 +294,8 @@ "writelog", "dtout", "currents", + "inertialf", + "inertialf_rampt", } # Native CD_DECK_NAMELEN: the longest OUTPUTS channel name the reader stores. _NATIVE_NAME_LENGTH = 64 @@ -337,6 +339,22 @@ _PINNED_END_CONNECTIONS = frozenset({"pinned", "free", "zero"}) # Host-driven (platform-borne) BODIES types, MoorDyn aliases included (native append_body) _HOST_BODY_TYPES = frozenset({"coupled", "vessel", "cpld", "ves"}) +# native apply_option: MoorDyn-F's inertialF other than 1 +_INERTIAL_F_MESSAGE = ( + "CableDyn returns the inertia of coupled bodies and rods with their coupled loads, as " + "MoorDyn-F's inertialF 1; inertialF 0 (MoorDyn-F's default: no inertia) and 2 (the inertia " + "ramped in) are not supported: use 1 or remove the row" +) +# Bodies pinned to a host node (MoorDyn CoupledPinned/VesselPinned): coupled hosts only +_PINNED_BODY_TYPES = frozenset({"coupledpinned", "cpldpin", "vesselpinned", "vespin"}) +_PINNED_BODY_HOST_MESSAGE = ( + "CoupledPinned/VesselPinned BODY requires a coupled host (OpenFAST CompMooring = 5); in a " + "standalone deck use a Free body, or a Coupled body with a motionFile" +) +_RIGID6_DYNAMIC_MESSAGE = "Rigid6 BODY requires a dynamic deck with dtM and TMax" +_PINNED_BODY_VALUE_MESSAGE = ( + "CoupledPinned/VesselPinned BODY requires Ixx/Iyy/Izz > 0 and non-negative Mass/Vol/CdA/Ca" +) # MoorDyn RODS attachment aliases (native append_rod) _ROD_ATTACHMENT_ALIASES = { @@ -360,9 +378,13 @@ _TORSION_NORMAL_PARALLEL_TOL = 1.0e-3 _WATERKIN_FILENAME_LETTERS = frozenset("abcdfghijklmnopqrstuvwxyzABCDFGHIJKLMNOPQRSTUVWXYZ") # MoorDyn-C kinematics files the native reader opens by fixed name in the deck folder -# (read_moordyn_c_kinematics): WaveKin 3, WaveKin 7 and Currents 1. +# (read_moordyn_c_kinematics): WaveKin 3, WaveKin 7 and Currents 1, 2 and 5. _MOORDYN_C_WAVE_FILES = {3: "wave_elevation.txt", 7: "wave_frequencies.txt"} -_MOORDYN_C_CURRENT_FILE = "current_profile.txt" +_MOORDYN_C_CURRENT_FILES = { + 1: "current_profile.txt", + 2: "current_profile_dynamic.txt", + 5: "current_profile_4d.txt", +} def _moordyn_c_wave_kin(value: str | None) -> int: @@ -379,10 +401,11 @@ def _moordyn_c_wave_kin(value: str | None) -> int: def _moordyn_c_currents(value: str | None) -> int: - """Return the MoorDyn-C ``Currents`` mode (0 or 1) of a validated row value.""" + """Return the MoorDyn-C ``Currents`` mode (0, 1, 2 or 5) of a validated row value.""" if value is None: return 0 - return 1 if round(_native_float(value)) == 1 else 0 + mode = round(_native_float(value)) + return mode if mode in _MOORDYN_C_CURRENT_FILES else 0 def _comment_position(text: str) -> int | None: @@ -1147,7 +1170,16 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: lower, upper = 0.0, None elif key == "rhoinf": lower, upper = 0.0, 1.0 - elif raw in {"dtic", "tmaxic", "cdscaleic", "threshic", "writelog", "dtout"}: + elif raw in { + "dtic", + "tmaxic", + "cdscaleic", + "threshic", + "writelog", + "dtout", + "inertialf", + "inertialf_rampt", + }: lower, upper = None, None else: lower = upper = None @@ -1180,6 +1212,8 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "dtout", "dtwave", "wvhicoff", + "inertialf", + "inertialf_rampt", }: try: numeric = _native_float(value) @@ -1361,9 +1395,13 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: numeric = _native_float(value) except ValueError: return "must be numeric" + # native apply_option: 0 none and the MoorDyn-C current files 1, 2 and 5; 3 and 4 + # (MoorDyn-C's node approaches) have no current source in MoorDyn-C v2.7.1 if not math.isfinite(numeric) or abs(numeric - round(numeric)) > 1.0e-9: - return "supports only mode 0 or 1" - return None if round(numeric) in {0, 1} else "supports only mode 0 or 1" + return "supports only mode 0, 1, 2 or 5" + if round(numeric) in {3, 4}: + return f"{round(numeric)} has no current source in MoorDyn-C v2.7.1; use 1, 2 or 5" + return None if round(numeric) in {0, 1, 2, 5} else "supports only mode 0, 1, 2 or 5" if key == "waterkin": lowered = value.lower() if lowered in {"none", "seastate"} or any( @@ -1567,7 +1605,9 @@ class DeckFile: rule depends on the host and is checked when OpenFAST initialises the module: the current is kept as a steady field when SeaState carries no waves or current and is rejected otherwise. The native C API (:class:`cabledyn.CableDyn`) reads decks with the - standalone rules. + standalone rules, so it rejects the ``CoupledPinned``/``VesselPinned`` bodies and rods + that ``caller_driven=True`` accepts; FAST.Farm, in turn, refuses bodies and rods when it + initialises the module. """ def __init__( @@ -1855,15 +1895,18 @@ def _check_moordyn_body_row( row: DeckRecord, numeric: Callable[[str, DeckRecord, str], float], has_motion_file: bool = False, + has_dtm: bool = True, ) -> None: """Validate a 14-column MoorDyn BODIES row as the native reader does.""" attachment = row.tokens[1].lower() - if attachment not in {"free", *_HOST_BODY_TYPES}: + if attachment not in {"free", *_HOST_BODY_TYPES, *_PINNED_BODY_TYPES}: raise DeckFormatError( f"{self._at(row)}: BODIES attachment {row.tokens[1]!r} is not supported in the " - "14-column MoorDyn row (Free, Coupled, or Vessel bodies)" + "14-column MoorDyn row (Free, Coupled, Vessel, CoupledPinned or VesselPinned " + "bodies)" ) host = attachment in _HOST_BODY_TYPES + pinned = attachment in _PINNED_BODY_TYPES if host and not (has_motion_file or self.caller_driven): raise DeckFormatError( f"{self._at(row)}: Coupled/Vessel BODY requires a motionFile (or a coupled host)" @@ -1897,6 +1940,16 @@ def _check_moordyn_body_row( coordinates + lists["CG"], [mass, volume, cda[0], *lists["I"]], ca[0] ): raise DeckFormatError(f"{self._at(row)}: {_BODY_RANGE_MESSAGE}") + if pinned: + # native finalize_checks: the Rigid6 dynamic-deck rule first, then only a coupled + # host moves the reference point; the rotation is integrated + if not (has_dtm or self.caller_driven): + raise DeckFormatError(f"{self._at(row)}: {_RIGID6_DYNAMIC_MESSAGE}") + if not self.caller_driven: + raise DeckFormatError(f"{self._at(row)}: {_PINNED_BODY_HOST_MESSAGE}") + if min(mass, volume, cda[0], ca[0]) < 0.0 or any(v <= 0.0 for v in lists["I"]): + raise DeckFormatError(f"{self._at(row)}: {_PINNED_BODY_VALUE_MESSAGE}") + return if host: # a platform-borne body may be a massless attachment frame if min(mass, volume, cda[0], ca[0], *lists["I"]) < 0.0: @@ -2293,6 +2346,9 @@ def _option_row(self, index: int) -> OptionRecord | None: raise DeckFormatError(f"{where}: unknown OPTION keyword {keyword!r}") if error := _scalar_option_value_error(keyword, tokens[0]): raise DeckFormatError(f"{where}: OPTION {keyword} {error}") + if keyword.lower() == "inertialf" and _native_float(tokens[0]) != 1.0: + # native apply_option: CableDyn always returns the coupled objects' inertia + raise DeckFormatError(f"{where}: OPTION inertialF {tokens[0]}: {_INERTIAL_F_MESSAGE}") _raise_option_defect(where, tokens) value = _strip_quotes(tokens[0]) if keyword.lower() in _PATH_OPTIONS else tokens[0] return OptionRecord(index, keyword, (value,), description, False, tuple(tokens[2:])) @@ -2351,7 +2407,7 @@ def validate(self) -> None: that depend on their contents stay with the solver: for example the anchor height on a bathymetry surface, whether a WaterKin file carries waves (``WaveKinMod``) for ``vesselRAO``, and whether its current - doubles a ``current`` row or ``Currents 1``. + doubles a ``current`` row or ``Currents 1``, ``2`` or ``5``. Raises ------ @@ -2450,8 +2506,8 @@ def effective(key: str, default: float) -> float: raise DeckFormatError( f"{self._label}: OPTION TMax must be an integer multiple of dtM" ) - # MoorDyn-C WaveKin 3/7 and Currents 1 (native read_moordyn_c_kinematics): component - # waves and a steady current profile read from fixed-name files in the deck folder. + # MoorDyn-C WaveKin 3/7 and Currents 1/2/5 (native read_moordyn_c_kinematics): component + # waves and a current profile or grid read from fixed-name files in the deck folder. # The coupled aggregate takes its water kinematics from the host and rejects both. waterkin_row = option_by_key.get("waterkin") currents_row = option_by_key.get("currents") @@ -2459,8 +2515,8 @@ def effective(key: str, default: float) -> float: mdc_currents = _moordyn_c_currents(None if currents_row is None else currents_row.values[0]) if self.caller_driven and (mdc_wave_kin or mdc_currents): raise DeckFormatError( - f"{self._label}: the MoorDyn-C WaveKin 3/7 and Currents 1 files are not supported " - "on the coupled route (coupled runs take water kinematics from the host)" + f"{self._label}: the MoorDyn-C WaveKin 3/7 and Currents 1/2/5 files are not " + "supported on the coupled route (coupled runs take water kinematics from the host)" ) # Native apply_option: motionFile, vesselMotion and vesselRAO are alternative # sources of one prescribed motion; activating a second one is an error, and a @@ -2578,7 +2634,7 @@ def effective(key: str, default: float) -> float: ): raise DeckFormatError(f"{self._label}: a wave train needs |direction| <= 1e6 deg") # native read_moordyn_c_kinematics: WaveKin 3/7 components add to no other deck sea, - # and Currents 1 to no other current; each then needs the dynamic sea/current setup. + # and Currents 1/2/5 to no other current; each then needs the dynamic sea/current setup. if mdc_wave_kin: if has_waves or trains: raise DeckFormatError( @@ -2592,11 +2648,13 @@ def effective(key: str, default: float) -> float: if mdc_currents: if current is not None and current.values[0].lower() != "none": raise DeckFormatError( - f"{self._label}: the deck declares both a current OPTION and Currents 1 " - "(double-counting); keep one" + f"{self._label}: the deck declares both a current OPTION and Currents " + f"{mdc_currents} (double-counting); keep one" ) if not has_dtm: - raise DeckFormatError(f"{self._label}: standalone Currents 1 requires dtM and TMax") + raise DeckFormatError( + f"{self._label}: standalone Currents {mdc_currents} requires dtM and TMax" + ) friction = option_by_key.get("friction") friction_active = False iso = 0.0 @@ -3302,15 +3360,32 @@ def end_key(token: str) -> str: bodies = self._rows("BODIES") for row in bodies: if len(row.tokens) == 14: - self._check_moordyn_body_row(row, numeric, has_motion_file) + self._check_moordyn_body_row(row, numeric, has_motion_file, has_dtm) continue if len(row.tokens) not in {15, 18}: raise DeckFormatError(f"{self._at(row)}: BODIES row needs 14, 15 or 18 fields") body_type = row.tokens[1].lower() - if body_type in {"coupledpinned", "cpldpin"}: - raise DeckFormatError( - f"{self._at(row)}: CoupledPinned BODY is not supported (use Coupled or Free)" - ) + if body_type in _PINNED_BODY_TYPES: + # native finalize_checks: the host moves the reference point of a CoupledPinned + # body, so only a coupled host runs it; its rotation is integrated + values = [ + numeric(row.tokens[index], row, f"BODIES column {index + 1}") + for index in range(2, len(row.tokens)) + ] + if _body_outside_admissible_range( + values[:6], values[6:12] + values[13:], values[12] + ): + raise DeckFormatError(f"{self._at(row)}: {_BODY_RANGE_MESSAGE}") + if not (has_dtm or self.caller_driven): + raise DeckFormatError(f"{self._at(row)}: {_RIGID6_DYNAMIC_MESSAGE}") + if not self.caller_driven: + raise DeckFormatError(f"{self._at(row)}: {_PINNED_BODY_HOST_MESSAGE}") + inertia = values[13:16] if len(values) >= 16 else [0.0, 0.0, 0.0] + if min(values[6], values[7], values[11], values[12]) < 0.0 or any( + value <= 0.0 for value in inertia + ): + raise DeckFormatError(f"{self._at(row)}: {_PINNED_BODY_VALUE_MESSAGE}") + continue if body_type in _HOST_BODY_TYPES: if not (has_motion_file or self.caller_driven): raise DeckFormatError( @@ -3356,7 +3431,8 @@ def end_key(token: str) -> str: body_types = { str(_native_int(row.tokens[0])): ( "rigid6" - if len(row.tokens) == 14 or row.tokens[1].lower() in _HOST_BODY_TYPES + if len(row.tokens) == 14 + or row.tokens[1].lower() in _HOST_BODY_TYPES | _PINNED_BODY_TYPES else row.tokens[1].lower() ) for row in bodies @@ -4818,9 +4894,10 @@ def _companion_files(self) -> tuple[str, ...]: """Return the fixed-name kinematics files this deck reads from its own folder. MoorDyn-C ``WaveKin 3`` reads ``wave_elevation.txt``, ``WaveKin 7`` reads - ``wave_frequencies.txt`` and ``Currents 1`` reads ``current_profile.txt``; - the native reader opens them by name next to the deck, so a deck written - to another folder needs them copied there. + ``wave_frequencies.txt``, ``Currents 1`` reads ``current_profile.txt``, + ``Currents 2`` ``current_profile_dynamic.txt`` and ``Currents 5`` + ``current_profile_4d.txt``; the native reader opens them by name next to the + deck, so a deck written to another folder needs them copied there. """ effective = {_option_key(record.keyword): record for record in self.options} names: list[str] = [] @@ -4829,8 +4906,9 @@ def _companion_files(self) -> tuple[str, ...]: if mode: names.append(_MOORDYN_C_WAVE_FILES[mode]) currents = effective.get("currents") - if _moordyn_c_currents(None if currents is None else currents.values[0]): - names.append(_MOORDYN_C_CURRENT_FILE) + mode = _moordyn_c_currents(None if currents is None else currents.values[0]) + if mode: + names.append(_MOORDYN_C_CURRENT_FILES[mode]) return tuple(names) def _rebase_relative_inputs(self, target_directory: str | os.PathLike[str]) -> None: @@ -4949,7 +5027,8 @@ def generate_deck_cases( rewritten so they still resolve from the new location. The MoorDyn-C kinematics files that the solver reads by fixed name from the deck folder (``wave_elevation.txt`` for ``WaveKin 3``, ``wave_frequencies.txt`` for - ``WaveKin 7``, ``current_profile.txt`` for ``Currents 1``) are copied into + ``WaveKin 7``, ``current_profile.txt``, ``current_profile_dynamic.txt`` and + ``current_profile_4d.txt`` for ``Currents 1``, ``2`` and ``5``) are copied into ``output_directory``. A ``cases.json`` manifest records the source deck, its SHA-256 digest, and every case's changes and digest (with the digests of the copied kinematics files it reads); :func:`cabledyn.run_study` diff --git a/python/cabledyn/study.py b/python/cabledyn/study.py index c8a3fb1e..a03aaf41 100644 --- a/python/cabledyn/study.py +++ b/python/cabledyn/study.py @@ -28,7 +28,15 @@ _CASE_NAME = re.compile(r"[A-Za-z0-9][A-Za-z0-9_.-]*") # Suffixes the native driver appends to an output root (``..out``). # Fixed-name MoorDyn-C kinematics files that generate_deck_cases copies next to the cases. -_COMPANION_FILES = frozenset({"wave_elevation.txt", "wave_frequencies.txt", "current_profile.txt"}) +_COMPANION_FILES = frozenset( + { + "wave_elevation.txt", + "wave_frequencies.txt", + "current_profile.txt", + "current_profile_dynamic.txt", + "current_profile_4d.txt", + } +) _OUTPUT_SUFFIX = re.compile(r"\.(?:static|elements|Line\d+\.[pt]|Rod-?\d+\.p)$", re.IGNORECASE) diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 37f0bec3..0cf7ff28 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -653,8 +653,10 @@ def test_unknown_scalar_option_keyword_fails_closed(tmp_path): ("x", "dtWave", "must be numeric"), ("0", "WvHiCOff", "must be positive"), ("off", "WvHiCOff", "must be numeric"), - ("2", "Currents", "supports only mode 0 or 1"), - ("1.5", "Currents", "supports only mode 0 or 1"), + ("3", "Currents", "no current source in MoorDyn-C v2.7.1"), + ("4", "Currents", "no current source in MoorDyn-C v2.7.1"), + ("6", "Currents", "supports only mode 0, 1, 2 or 5"), + ("1.5", "Currents", "supports only mode 0, 1, 2 or 5"), ("4", "WaterKin", "numeric mode 0, 3 or 7"), ("1", "WaterKin", "numeric mode 0"), ("1e0", "WaterKin", "numeric mode 0"), @@ -1535,13 +1537,65 @@ def test_coupled_rods_and_bodies_need_a_motion_file_or_a_coupled_host(tmp_path): for row, message in ( ("1 Coupled 0 0 0 0 0 0 -1 0 0 0 0 0 0\n", "requires non-negative"), ("1 Coupled 0 0 -20 0 0 0 -1 0 0 0 0 0\n", "requires non-negative"), - ("1 CoupledPinned 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "CoupledPinned BODY is not supported"), ): path.write_text(source.replace(marker, bodies + row + marker), encoding="utf-8") with pytest.raises(DeckFormatError, match=message): DeckFile.read(path, caller_driven=True) +@pytest.mark.parametrize("kind", ["CoupledPinned", "CpldPin", "VesselPinned", "VesPin"]) +def test_coupled_pinned_bodies_need_a_coupled_host_and_inertia(tmp_path, kind): + # native finalize_checks: the host moves the reference point of a CoupledPinned body and + # its rotation is integrated, so the standalone driver refuses it and the coupled route + # takes it with positive inertias (18- and 14-column rows) + static = (ROOT / "examples/chain_catenary_r3_100m.dat").read_text(encoding="utf-8") + marker = "--------------------- POINTS -------------------------------------------" + clock = "--------------------- OUTPUTS ------------------------------------------" + dynamic = static.replace(clock, "0.01 dtM\n1.0 TMax\n" + clock) + bodies = "--------------------- BODIES -------------------------------------------\n" + path = tmp_path / "pinned.dat" + for row in ( + f"1 {kind} 0 0 -20 0 0 0 10 0 0 0 0 0 0 1 1 1\n", + f"1 {kind} 0 0 -20 0 0 0 10 0|0|-1 1|2|3 0 0 0\n", + ): + path.write_text(dynamic.replace(marker, bodies + row + marker), encoding="utf-8") + with pytest.raises(DeckFormatError, match="requires a coupled host"): + DeckFile.read(path) + DeckFile.read(path, caller_driven=True) + # without a clock the native Rigid6 dynamic-deck rule comes first + path.write_text(static.replace(marker, bodies + row + marker), encoding="utf-8") + with pytest.raises(DeckFormatError, match="Rigid6 BODY requires a dynamic deck"): + DeckFile.read(path) + DeckFile.read(path, caller_driven=True) + source = dynamic + for row in ( + f"1 {kind} 0 0 -20 0 0 0 10 0 0 0 0 0 0\n", + f"1 {kind} 0 0 -20 0 0 0 10 0 0 0 0 0 0 1 0 1\n", + f"1 {kind} 0 0 -20 0 0 0 -1 0 0 0 0 0 0 1 1 1\n", + f"1 {kind} 0 0 -20 0 0 0 10 0 0 0 0 0\n", + ): + path.write_text(source.replace(marker, bodies + row + marker), encoding="utf-8") + with pytest.raises(DeckFormatError, match=r"requires Ixx/Iyy/Izz > 0"): + DeckFile.read(path, caller_driven=True) + + +@pytest.mark.parametrize( + "value, accepted", [("1", True), ("1.0", True), ("0", False), ("2", False)] +) +def test_moordyn_inertial_f_option(tmp_path, value, accepted): + # native apply_option: CableDyn always returns the coupled objects' inertia (inertialF 1) + source = (ROOT / "examples/chain_catenary_r3_100m.dat").read_text(encoding="utf-8") + clock = "--------------------- OUTPUTS ------------------------------------------" + path = tmp_path / "inertial.dat" + text = source.replace(clock, f"{value} inertialF\n30.0 inertialF_rampT\n" + clock) + path.write_text(text, encoding="utf-8") + if accepted: + DeckFile.read(path) + else: + with pytest.raises(DeckFormatError, match=r"inertialF 0 \(MoorDyn-F's default"): + DeckFile.read(path) + + @pytest.mark.parametrize( "rod_row, message", [ @@ -3354,7 +3408,7 @@ def test_moordyn_body_rows_are_accepted(row): @pytest.mark.parametrize( ("row", "message"), [ - (_MD_BODY.replace("Free", "Fixed"), "Free, Coupled, or Vessel bodies"), + (_MD_BODY.replace("Free", "Fixed"), "Free, Coupled, Vessel, CoupledPinned or VesselPinned"), (_MD_BODY.replace("Free", "Coupled"), "Coupled/Vessel BODY requires a motionFile"), (_MD_BODY.replace("0|0|-0.5", "0|-0.5"), "BODIES CG has 2 entries"), (_MD_BODY.replace("8|0", "8|1"), "isotropic without rotational drag"), @@ -3510,6 +3564,23 @@ def test_control_rows_may_name_finite_ei_cables_on_the_coupled_route(): assert [row.tokens for row in deck._rows("CONTROL")] == [("1", "4"), ("2", "1,3")] +@pytest.mark.parametrize( + "example", ["syrope_polyester_mooring.dat", "ve_polyester_catenary_mooring.dat"] +) +def test_control_rows_may_name_syrope_and_viscoelastic_lines_on_the_coupled_route(example): + # native CD_Init_Deck_Aggregate controls a Syrope or viscoelastic segment too (its slow + # stretch carries over the length change, as in MoorDyn-F/C), so the mirror accepts the row + source = (ROOT / "examples" / example).read_text(encoding="utf-8") + marker = "--------------------- OPTIONS" + assert source.count(marker) == 1 + block = ( + "--------------------- CONTROL ----------------------------------------\n" + "ChannelID Lines\n(-) (-)\n1 1\n" + ) + deck = DeckFile.from_text(source.replace(marker, block + marker, 1), caller_driven=True) + assert [row.tokens for row in deck._rows("CONTROL")] == [("1", "1")] + + # --------------------------------------------------------------------------- # Editing API error contract # --------------------------------------------------------------------------- diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index be2879ca..1d55158f 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -98,9 +98,13 @@ def test_dtwave_must_be_positive(value): (("7 WaterKin",), None), (("3 WaveKin", "0.1 dtWave"), None), (("1 Currents",), None), + (("2 Currents",), None), + (("5 Currents",), None), (("airy 2 8 0 waves", "7 WaterKin"), r"both a waves \(or wavetrain\) OPTION and WaveKin 7"), (("airy 2 8 0 wavetrain", "3 WaveKin"), "double-counting"), (("uniform 0.1 0 0 current", "1 Currents"), "both a current OPTION and Currents 1"), + (("uniform 0.1 0 0 current", "2 Currents"), "both a current OPTION and Currents 2"), + (("uniform 0.1 0 0 current", "5 Currents"), "both a current OPTION and Currents 5"), ], ) def test_moordyn_c_kinematics_follow_the_native_rules(rows, message): @@ -116,9 +120,10 @@ def test_moordyn_c_kinematics_need_the_dynamic_sea_setup(): no_depth = _edit(_HELD, ("50.0 WtrDpth\n", "7 WaterKin\n")) _rejects(no_depth.replace("-50.0", "-80.0"), "WaveKin 7 waves require dtM, TMax and WtrDpth") _rejects(_options(_STATIC, "1 Currents"), "standalone Currents 1 requires dtM and TMax") + _rejects(_options(_STATIC, "5 Currents"), "standalone Currents 5 requires dtM and TMax") -@pytest.mark.parametrize("row", ["7 WaterKin", "1 Currents"]) +@pytest.mark.parametrize("row", ["7 WaterKin", "1 Currents", "2 Currents", "5 Currents"]) def test_moordyn_c_kinematics_are_not_certified_for_the_coupled_route(row): _rejects(_options(_HELD, row), "not supported on the coupled route", caller_driven=True) @@ -601,6 +606,19 @@ def test_generated_cases_carry_the_fixed_name_kinematics_files(tmp_path): run_study(out / "cases.json", executable=tmp_path / "missing.exe") +@pytest.mark.parametrize( + ("mode", "name"), [("2", "current_profile_dynamic.txt"), ("5", "current_profile_4d.txt")] +) +def test_generated_cases_carry_the_moordyn_c_current_tables(tmp_path, mode, name): + table = "a MoorDyn-C current table\n" + base = _kinematic_base(tmp_path / "src", f"{mode} Currents", files={name: table}) + out = tmp_path / "cases" + generate_deck_cases(base, out, {"a": {"option.dtM": 0.05}}) + assert (out / name).read_text(encoding="utf-8") == table + manifest = json.loads((out / "cases.json").read_text(encoding="utf-8")) + assert set(manifest["cases"][0]["companion_files"]) == {name} + + def test_study_manifest_companion_entries_are_checked(tmp_path): base = _kinematic_base( tmp_path / "src", "7 WaterKin", files={"wave_frequencies.txt": _WAVE_FREQUENCIES} diff --git a/python/tests/test_native_model.py b/python/tests/test_native_model.py index a742d41d..9e8b1e61 100644 --- a/python/tests/test_native_model.py +++ b/python/tests/test_native_model.py @@ -58,20 +58,54 @@ def test_array_shapes_are_validated_before_the_library(): def test_failed_initialization_in_the_constructor_releases_the_handle(monkeypatch): - closed: list[bool] = [] - original = model_module.CableDyn.close + # The constructor's own instance is captured when it calls init_deck, and only its closes + # count: instances other tests left behind may be finalized (and closed) at any point, with + # or without the cyclic collector running. + own: list[model_module.CableDyn] = [] + closes: list[tuple[model_module.CableDyn, bool]] = [] + original_init_deck = model_module.CableDyn.init_deck + original_close = model_module.CableDyn.close + + def tracking_init_deck(self: model_module.CableDyn, deck: str | os.PathLike[str]) -> None: + own.append(self) + original_init_deck(self, deck) def tracking_close(self: model_module.CableDyn) -> None: - closed.append(bool(self._handle)) - original(self) + closes.append((self, bool(self._handle))) + original_close(self) + monkeypatch.setattr(model_module.CableDyn, "init_deck", tracking_init_deck) monkeypatch.setattr(model_module.CableDyn, "close", tracking_close) with pytest.raises(CableDynError, match="CableDyn_InitDeck failed") as caught: cabledyn.CableDyn("no_such_deck_anywhere.dat") - assert closed[0] is True + assert len(own) == 1 + own_closes = [held for instance, held in closes if instance is own[0]] + # the failed constructor closed its instance while it still held the handle + assert own_closes and own_closes[0] is True + assert not own[0]._handle assert caught.value.status != 0 and caught.value.detail +def test_a_deck_current_that_varies_in_time_is_refused_without_a_clock(tmp_path): + # The C ABI has no simulation clock: a MoorDyn-C Currents 2 table that varies in time is + # refused like deck waves; the same deck with a table constant in time applies it steadily. + case = REPO / "tests" / "data" / "currents_mdc" / "tension_c2" + deck = tmp_path / "tension.dat" + deck.write_bytes((case / "tension.dat").read_bytes()) + table = tmp_path / "current_profile_dynamic.txt" + table.write_bytes((case / "current_profile_dynamic.txt").read_bytes()) + with cabledyn.CableDyn() as m: + with pytest.raises(CableDynError): + m.init_deck(deck) + assert "no simulation clock" in m.last_error() + assert "Currents 2" in m.last_error() + table.write_text( + "h\nh\n\n\n-50.0 0.0\nt ux\n0.0 0.4 0.6\n10.0 0.4 0.6\n", encoding="utf-8", newline="\n" + ) + with cabledyn.CableDyn(deck) as m: + assert m.n_lines == 1 + + def test_last_error_reports_the_library_diagnostic(): with cabledyn.CableDyn() as m: with pytest.raises(CableDynError) as caught: diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 6ca7bfce..b922d085 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -134,7 +134,8 @@ MODULE CableDyn_DeckDriver 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, & - CD_Current_Profile_Velocity, & + CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_Resample, & + CD_Current_Grid_Velocity, & CD_JONSWAP_COMPONENTS, CD_JONSWAP_Random_Components, & CD_Solve_Dispersion_Wavenumber, & CD_Morison_Drag_Element_Load, & @@ -212,6 +213,7 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Rigid6_GetRefPositions, CD_Rigid6_SetHeldFluid PUBLIC :: CD_Rigid6_NHost, CD_Rigid6_AllHost, CD_Rigid6_SetHostKinematics, CD_Rigid6_GetHostKinematics PUBLIC :: CD_Rigid6_ScatterHostPoints, CD_Rigid6_HostWrench, CD_Rigid6_Stage, CD_Rigid6_Unstage + PUBLIC :: CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations PUBLIC :: CD_RodRuntimeType PUBLIC :: CD_Init_Deck_Aggregate_Rod, CD_Step_Aggregate_Rod PUBLIC :: CD_Rod_NRods, CD_Rod_Snapshot, CD_Rod_Restore, CD_Rod_End @@ -455,6 +457,9 @@ MODULE CableDyn_DeckDriver ! Coupled/Vessel body (MoorDyn "Coupled"): a Rigid6 body whose pose follows the host (the ! coupled platform, or motionFile rows standalone) instead of being integrated. LOGICAL :: host_coupled = .FALSE. + ! CoupledPinned/VesselPinned body (MoorDyn "CoupledPinned"): a Rigid6 body whose reference + ! point follows a host node (the coupled aggregate only) while its rotation is integrated. + LOGICAL :: host_pinned = .FALSE. END TYPE TYPE :: DeckRodType @@ -663,6 +668,11 @@ MODULE CableDyn_DeckDriver REAL(wp) :: vessel_ref(3) = CD_ZERO LOGICAL :: has_current = .FALSE. LOGICAL :: has_current_profile = .FALSE. + ! MoorDyn-C Currents 2 and 5 (read_moordyn_c_kinematics): a current grid in space and time + ! (CD_CurrentGridType), sampled at every node's position and time (deck_current_velocity); + ! has_current is then set and has_current_profile is not. + LOGICAL :: has_current_grid = .FALSE. + TYPE(CD_CurrentGridType), ALLOCATABLE :: current_grid ! MoorDyn WaterKin OPTION: a filename declaring file-driven water kinematics ! for STANDALONE runs (coupled runs consume SeaState). CHARACTER(CD_DECK_PATHLEN) :: waterkin_file = '' @@ -676,7 +686,8 @@ MODULE CableDyn_DeckDriver INTEGER :: waterkin_wave_mode = -1 INTEGER :: waterkin_current_mode = -1 ! MoorDyn-C numeric WaveKin / Currents OPTIONS (0: none): WaveKin 3 reads wave_elevation.txt, - ! WaveKin 7 wave_frequencies.txt, Currents 1 current_profile.txt, all in the deck folder + ! WaveKin 7 wave_frequencies.txt, Currents 1 current_profile.txt, Currents 2 + ! current_profile_dynamic.txt and Currents 5 current_profile_4d.txt, all in the deck folder ! (read_moordyn_c_kinematics); dtWave is the WaveKin 3 resampling step. INTEGER :: mdc_wave_kin = 0 INTEGER :: mdc_currents = 0 @@ -870,6 +881,14 @@ MODULE CableDyn_DeckDriver INTEGER :: body_index = 0 ! Host-driven (Coupled/Vessel) body: its state is imposed, never integrated. LOGICAL :: is_prescribed = .FALSE. + ! CoupledPinned/VesselPinned body (coupled aggregate): the reference point is pinned to a host + ! node. The host prescribes its translation (pin, pin_v, pin_a), which r, v and a always + ! equal (body_snap_pinned), and the body's rotation about it stays its own degree of freedom + ! (MoorDyn-F's coupled pinned body). pin0, pin0_v and pin0_a are the committed translation at + ! the start of the coming step (set_body_pin_start; see RodState%pin0). + LOGICAL :: is_host_pinned = .FALSE. + REAL(wp) :: pin(3) = CD_ZERO, pin_v(3) = CD_ZERO, pin_a(3) = CD_ZERO + REAL(wp) :: pin0(3) = CD_ZERO, pin0_v(3) = CD_ZERO, pin0_a(3) = CD_ZERO INTEGER, ALLOCATABLE :: point_indices(:) REAL(wp) :: r_ref(3) = CD_ZERO REAL(wp) :: rot_ref(3, 3) = CD_ZERO @@ -1293,6 +1312,17 @@ SUBROUTINE CD_Init_Deck_System(deck_path, system, dtM, gravity, rho_water, ErrSt 'fluid kinematics with CableDyn_UpdatePointFluidFields') RETURN END IF + ! Without a clock a current is held at its t = 0 value, the steady field the embedded system + ! applies (as Currents 1): a Currents 2/5 table that varies in time is refused like waves, + ! one constant in time (a steady depth profile or grid) is applied. + IF (opts%has_current_grid) THEN + IF (current_grid_varies_in_time(opts%current_grid)) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_System does not apply a deck current that varies in time '// & + '(Currents '//TRIM(int_to_str(opts%mdc_currents))//'): the embedded system has no simulation '// & + 'clock; supply time-varying fluid kinematics with CableDyn_UpdatePointFluidFields') + RETURN + END IF + END IF dtM = MERGE(opts%dtM, CD_ZERO, opts%has_dtm) gravity = opts%g rho_water = opts%rhoW @@ -1976,7 +2006,24 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! of that plane, which the dynamics (endpoints held, every other DOF free) follow: the ! static equilibrium is then solved in 3D as well. IF (opts%has_current) THEN - IF (opts%has_current_profile) THEN + IF (opts%has_current_grid) THEN + ! a current grid (Currents 2 and 5): the static start takes its t = 0 sample, every point + ! of it; the march is free out of the plane whatever the later samples hold (its held + ! DOFs are the end translations only) + BLOCK + INTEGER :: ix, iy, iz + DO iz = 1, SIZE(opts%current_grid%z) + DO iy = 1, SIZE(opts%current_grid%y) + DO ix = 1, SIZE(opts%current_grid%x) + IF (ABS(-frame_cs(2)*opts%current_grid%velocity(1, ix, iy, iz, 1) + & + frame_cs(1)*opts%current_grid%velocity(2, ix, iy, iz, 1)) > & + 64.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, NORM2(opts%current_grid%velocity(:, ix, iy, iz, 1)))) & + require_3d_static = .TRUE. + END DO + END DO + END DO + END BLOCK + ELSE IF (opts%has_current_profile) THEN DO i = 1, SIZE(opts%current_profile_z) IF (ABS(-frame_cs(2)*opts%current_profile_velocity(1, i) + frame_cs(1)*opts%current_profile_velocity(2, i)) & > 64.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, NORM2(opts%current_profile_velocity(:, i)))) & @@ -2271,6 +2318,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, cur_obj%drag = .FALSE. IF (ALLOCATED(cur_obj%profile_z)) DEALLOCATE (cur_obj%profile_z) IF (ALLOCATED(cur_obj%profile_velocity)) DEALLOCATE (cur_obj%profile_velocity) + IF (ALLOCATED(cur_obj%grid)) DEALLOCATE (cur_obj%grid) END IF IF (as_laid) THEN CALL as_laid_reference(es, em) @@ -3467,7 +3515,7 @@ SUBROUTINE torsion_after_attachments(est, emt) !! The torsion stage of a line with ATTACHMENTS, on its discrete equilibrium (after the !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes and, !! in a deck current, their drag at the twisted state as nodal loads. The drag depends on - !! the node's depth and line tangent, so the stage is repeated, each time a fresh torsion + !! the node's position and line tangent, so the stage is repeated, each time a fresh torsion !! solve from the last state, with the drag of the last solution until the solution stops !! moving (fixed point, as in attachment_static_polish). INTEGER, INTENT(OUT) :: est @@ -3812,6 +3860,7 @@ SUBROUTINE still_water_compression(text) opts_sw = opts opts_sw%has_current = .FALSE. opts_sw%has_current_profile = .FALSE. + opts_sw%has_current_grid = .FALSE. 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, & @@ -4063,6 +4112,22 @@ LOGICAL FUNCTION symmetric_current_retry() RESULT(retry) cur_obj%profile_velocity(1:2, k) = cur_obj%profile_velocity(1:2, k) + SYM_BREAK*uh*nrm END DO END IF + IF (ALLOCATED(cur_obj%grid)) THEN + BLOCK + INTEGER :: ix, iy, iz, it + DO it = 1, cur_obj%grid%nt + DO iz = 1, SIZE(cur_obj%grid%z) + DO iy = 1, SIZE(cur_obj%grid%y) + DO ix = 1, SIZE(cur_obj%grid%x) + uh = NORM2(cur_obj%grid%velocity(1:2, ix, iy, iz, it)) + cur_obj%grid%velocity(1:2, ix, iy, iz, it) = cur_obj%grid%velocity(1:2, ix, iy, iz, it) + & + SYM_BREAK*uh*nrm + END DO + END DO + END DO + END DO + END BLOCK + END IF retry = .TRUE. END FUNCTION symmetric_current_retry @@ -4604,6 +4669,7 @@ SUBROUTINE still_water_reference(esr, emr) opts_sw = opts opts_sw%has_current = .FALSE. opts_sw%has_current_profile = .FALSE. + opts_sw%has_current_grid = .FALSE. 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, & @@ -5063,9 +5129,9 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att !! Newton solves the element weights move from w_smear to w_bare while the lumped nodal !! forces -(m - rho V) g e_z and, in a deck current, the attachment current drag grow from !! zero to full, with the contact, dry-buoyancy, end-connection and line current terms of - !! the builder's static problem. The drag depends on the node's depth (profile current) - !! and line tangent, so the full-load solve is repeated with the drag of the last solution - !! until the solution stops moving (fixed point). + !! the builder's static problem. The drag depends on the node's position (profile current, + !! current grid) and line tangent, so the full-load solve is repeated with the drag of the + !! last solution until the solution stops moving (fixed point). !! !! The load fraction advances in steps of 1/NSTEP. A step whose damped Newton solve does !! not converge is repeated from the last converged state with pseudo-transient @@ -5284,7 +5350,10 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM IF (.NOT. (att(4, k) > CD_ZERO .OR. att(6, k) > CD_ZERO)) CYCLE base = 6*(node(k) - 1) IF (q(base + 3) > CD_ZERO) CYCLE - ug = deck_current_velocity(opts, q(base + 3), es, em) + ! the node's global position (the solve frame is the global one turned by frame_cs) + ug = deck_current_velocity(opts, [frame_cs(1)*q(base + 1) - frame_cs(2)*q(base + 2), & + frame_cs(2)*q(base + 1) + frame_cs(1)*q(base + 2), q(base + 3)], & + CD_ZERO, es, em) IF (es /= CD_HYDRO_OK) THEN CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN END IF @@ -5433,6 +5502,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia LOGICAL :: tensile, refine_all, planar_bed, walk_needed, laid REAL(wp) :: h_target REAL(wp) :: origin(2), a_l(3), f_l(3), seabed_z, seabed_slope, horizontal_tension, grounded_length + TYPE(CD_HermiteStaticCurrentType), ALLOCATABLE :: cur_s REAL(wp) :: lambda0, ratio, span(2), span_len, t, xg, yg, zf, sx, sz, sxx, sxz, xl, yl REAL(wp) :: res_cont, cont_tol, phi, penetration, zfit(NFIT), fit_misfit, fine_limit, seed_bed, anchor_bed REAL(wp), ALLOCATABLE :: pos(:), q_seed(:), q_cont(:), curv_cont(:), knnode(:), tdir(:, :), stretch(:) @@ -5468,6 +5538,12 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia IF (.NOT. PRESENT(bathymetry)) origin = anchor(1:2) a_l = [anchor(1) - origin(1), anchor(2) - origin(2), anchor(3)] f_l = [fairlead(1) - origin(1), fairlead(2) - origin(2), fairlead(3)] + ! the solves below run in the frame translated to origin: the current they take knows it, so + ! a current grid is sampled at the nodes' global positions (CD_HermiteStaticCurrentType) + IF (PRESENT(cur_obj)) THEN + ALLOCATE (cur_s, SOURCE=cur_obj) + cur_s%origin = origin + END IF ! Seabed plane under the line. A structured bathymetry is represented by its ! least-squares plane along the horizontal chord; the contact solve itself always @@ -5749,7 +5825,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_s) ELSE CALL CD_HermiteCable_Static_Solve_Continuation(l0, ea, ei, w, q_seed, fixed_dofs, contact_z, CD_ZERO, & STAGE_MAX_ITER, cont_tol, lambda0, budget_cont, & @@ -5759,7 +5835,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, & dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj) + water_weight=opts%rhoW*opts%g, current=cur_s) END IF iters = cont_iters IF (es /= CD_HCSTAT_OK) THEN @@ -6090,7 +6166,7 @@ SUBROUTINE walk_anchor() bending_quadrature_order=opts%bending_quadrature_order, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj, & + water_weight=opts%rhoW*opts%g, current=cur_s, & energy_minimization=energy) total_it = total_it + it_w IF (es_w /= CD_HCSTAT_OK) THEN @@ -6144,7 +6220,7 @@ SUBROUTINE walk_anchor() bending_quadrature_order=opts%bending_quadrature_order, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj, & + water_weight=opts%rhoW*opts%g, current=cur_s, & energy_minimization=energy) total_it = total_it + it_w IF (es_w == CD_HCSTAT_OK .AND. .NOT. folded) THEN @@ -6448,7 +6524,7 @@ SUBROUTINE polish(tol_polish) refine_non_axial=refine_all, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj, & + water_weight=opts%rhoW*opts%g, current=cur_s, & local_refinement=.TRUE.) ELSE IF (contact_enabled) THEN CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_cont, fixed_dofs, contact_z, CD_ZERO, & @@ -6467,7 +6543,7 @@ SUBROUTINE polish(tol_polish) refine_non_axial=refine_all, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj, & + water_weight=opts%rhoW*opts%g, current=cur_s, & local_refinement=.TRUE.) ELSE CALL CD_HermiteCable_Static_Solve_AutoMesh(l0, ea, ei, w, q_cont, fixed_dofs, contact_z, CD_ZERO, & @@ -6484,7 +6560,7 @@ SUBROUTINE polish(tol_polish) refine_non_axial=refine_all, & endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry_b, & - water_weight=opts%rhoW*opts%g, current=cur_obj, & + water_weight=opts%rhoW*opts%g, current=cur_s, & local_refinement=.TRUE.) END IF iters = iters + polish_iters @@ -6514,7 +6590,10 @@ SUBROUTINE hermite_static_current(ln, sections, types, opts, l0, frame_cs, cur) cur%rho = opts%rhoW cur%waterline_z = CD_ZERO cur%frame_cs = frame_cs - IF (opts%has_current_profile) THEN + IF (opts%has_current_grid) THEN + ! sampled at the node positions at t = 0 (the static start) + ALLOCATE (cur%grid, SOURCE=opts%current_grid) + ELSE IF (opts%has_current_profile) THEN cur%profile_z = opts%current_profile_z cur%profile_velocity = opts%current_profile_velocity ELSE @@ -7252,7 +7331,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi RETURN END IF IF (opts%mdc_wave_kin > 0 .OR. opts%mdc_currents > 0) THEN - CALL fail(ErrStat, ErrMsg, 'the MoorDyn-C WaveKin 3/7 and Currents 1 files are not supported on the '// & + CALL fail(ErrStat, ErrMsg, 'the MoorDyn-C WaveKin 3/7 and Currents 1/2/5 files are not supported on the '// & 'aggregate route (coupled runs take water kinematics from the host; standalone mixed '// & 'EI=0/finite-EI decks reject deck water kinematics)') RETURN @@ -7408,7 +7487,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi n_rod = SIZE(rods) n_host_rod = COUNT(rods%rod_type == 'coupled' .OR. rods%rod_type == 'vessel' .OR. & rods%rod_type == 'coupledpinned') - n_host_body = COUNT(bodies%host_coupled) + n_host_body = COUNT(bodies%host_coupled .OR. bodies%host_pinned) IF (opts%has_motion_file) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the coupled boundary is driven by the host, '// & 'not a deck motionFile; remove the motionFile OPTION'); RETURN @@ -7480,13 +7559,14 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: line FAILURE on a coupled Rigid6 deck is not '// & 'supported (the failure trigger is not evaluated against the post-body-march state)'); RETURN END IF - ! Coupled/Vessel bodies become 6-DOF host nodes. They may share a deck with Free bodies: when - ! the free-body march sub-cycles, the host-driven bodies follow the host path interpolated - ! from the step start (interp_host_rigid). The linearization probe places translational - ! moving points only. + ! Coupled/Vessel bodies become 6-DOF host nodes, CoupledPinned ones translational host nodes + ! with a rotation of their own. They may share a deck with Free bodies: when the body march + ! sub-cycles, the host-driven bodies follow the host path interpolated from the step start + ! (interp_host_rigid, interp_host_body_pins). The linearization probe places translational + ! moving points only and holds every body, so it carries neither. IF (n_host_body > 0 .AND. PRESENT(coupled_positions)) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: coupled_positions (the linearization probe) '// & - 'does not support Coupled/Vessel BODIES'); RETURN + 'does not support Coupled/Vessel or CoupledPinned BODIES'); RETURN END IF END IF @@ -7894,7 +7974,8 @@ SUBROUTINE build_aggregate_control_table(ctrls, lines, points, rods, sections, t !! UnstrLen and N, summed over the line's sections), from which the apply takes !! MoorDyn-F's command bounds. Every capability check runs here (a finite-EI line also !! needs the force-blended generalised-alpha), so the apply loop cannot fail for input - !! reasons after its prevalidation. + !! reasons after its prevalidation. An EI = 0 segment may be linear-elastic, viscoelastic + !! or Syrope (the slow stretch of the last two carries over the length change). TYPE(DeckControl), INTENT(IN) :: ctrls(:) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckPoint), INTENT(IN) :: points(:) @@ -7981,22 +8062,9 @@ SUBROUTINE build_aggregate_control_table(ctrls, lines, points, rods, sections, t IF (agg%sys%lines(obj)%has_seabed .AND. .NOT. agg%sys%lines(obj)%has_seabed_recompute) THEN CALL fail(ErrStat, ErrMsg, 'CONTROL line was built without the seabed recompute inputs'); RETURN END IF - IF (agg%sys%lines(obj)%has_viscoelastic) THEN - IF (agg%sys%lines(obj)%ve_mode(e) /= 0) THEN - ! the runtime length update fails closed on a viscoelastic element (the - ! dl_1 state has no rescaling law), so a deck composing CONTROL with a - ! viscoelastic controlled segment must not start at all - CALL fail(ErrStat, ErrMsg, 'CONTROL targets a viscoelastic (ElasticMod 2) '// & - 'segment; active line control is not supported on the viscoelastic model'); RETURN - END IF - END IF - IF (agg%sys%lines(obj)%has_syrope) THEN - IF (agg%sys%lines(obj)%syrope_is(e)) THEN - ! the same rule for the Syrope working-curve states - CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' targets a Syrope segment; active '// & - 'line control is not supported on the Syrope model'); RETURN - END IF - END IF + ! A viscoelastic or Syrope controlled segment carries its slow stretch over each + ! length change, as MoorDyn-F/C do (CD_Update_Model_SegmentLength), so it needs no + ! check here. ELSE ! the coupled cable builder makes End A the host-driven fairlead and End B the ! Fixed anchor; any other arrangement would control a segment that is not the @@ -9145,7 +9213,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er ALLOCATE (fluid_velocity(3, SIZE(l0) + 1), drag_waterline(SIZE(l0) + 1)) DO i = 1, SIZE(l0) + 1 IF (opts%has_current) THEN - fluid_velocity(:, i) = deck_current_velocity(opts, line_node_z(anchor, fairlead, l0, i), es, em) + fluid_velocity(:, i) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, l0, i), CD_ZERO, es, em) IF (es /= CD_HYDRO_OK) THEN CALL fail(ErrStat, ErrMsg, 'current profile for model init: '//TRIM(em)); RETURN END IF @@ -9186,7 +9254,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & fluid_acceleration=fluid_acceleration, fk_waterline_z=waterline, fk_rho=opts%rhoW, & @@ -9216,7 +9284,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & added_mass_waterline_z=waterline, added_mass_rho=opts%rhoW, & @@ -9244,7 +9312,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & added_mass_waterline_z=waterline, added_mass_rho=opts%rhoW, & @@ -9273,7 +9341,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & fluid_acceleration=fluid_acceleration, fk_waterline_z=waterline, fk_rho=opts%rhoW, & @@ -9304,7 +9372,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & added_mass_waterline_z=waterline, added_mass_rho=opts%rhoW, & @@ -9333,7 +9401,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er as_laid_tension=laid_t, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & added_mass_waterline_z=waterline, added_mass_rho=opts%rhoW, & @@ -9347,7 +9415,7 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet, & current_profile_z=opts%current_profile_z, & - current_profile_velocity=opts%current_profile_velocity, & + current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt) ELSE @@ -11071,7 +11139,7 @@ SUBROUTINE finite_environment_node(opts, time, x, eta, fluid_velocity, fluid_acc END IF END IF IF (opts%has_current) THEN - current_velocity = deck_current_velocity(opts, x(3), es, em) + current_velocity = deck_current_velocity(opts, x, time, es, em) IF (es /= CD_HYDRO_OK) THEN ErrStat = es ErrMsg = em @@ -11663,8 +11731,13 @@ LOGICAL FUNCTION deck_current_on_line(opts, z) RESULT(on) CHARACTER(512) :: em on = .FALSE. IF (.NOT. opts%has_current) RETURN + IF (opts%has_current_grid) THEN + ! a current grid (Currents 2 and 5) counts wherever it is non-zero + on = ANY(ABS(opts%current_grid%velocity) > CD_ZERO) + RETURN + END IF DO k = 1, SIZE(z) - u = deck_current_velocity(opts, z(k), es, em) + u = deck_current_velocity(opts, [CD_ZERO, CD_ZERO, z(k)], CD_ZERO, es, em) IF (es /= CD_HYDRO_OK) CYCLE IF (NORM2(u) > CD_ZERO) THEN on = .TRUE. @@ -11867,7 +11940,8 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg cur%waterline_z = CD_ZERO ALLOCATE (cur%node_velocity(3, ne + 1), cur%elem_diameter(ne), cur%elem_cdn(ne), cur%elem_cdt(ne)) DO i = 1, ne + 1 - cur%node_velocity(:, i) = deck_current_velocity(opts, line_node_z(anchor, fairlead, l0, i), es, em) + cur%node_velocity(:, i) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, l0, i), CD_ZERO, & + es, em) IF (es /= CD_HYDRO_OK) THEN CALL fail(ErrStat, ErrMsg, 'current profile: '//TRIM(em)); RETURN END IF @@ -11885,6 +11959,8 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg cur%profile_z = opts%current_profile_z cur%profile_velocity = opts%current_profile_velocity END IF + ! a current grid (Currents 2 and 5) at the node positions, at t = 0 + IF (opts%has_current_grid) ALLOCATE (cur%grid, SOURCE=opts%current_grid) ! file order is End A (fairlead) -> End B; the mesh runs anchor -> fairlead cur%elem_diameter = cur%elem_diameter(ne:1:-1) cur%elem_cdn = cur%elem_cdn(ne:1:-1) @@ -12341,7 +12417,7 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti 'driver has no host SeaState field') RETURN END IF - ! MoorDyn-C WaveKin 3/7 and Currents 1: their fixed-name files in the deck folder + ! MoorDyn-C WaveKin 3/7 and Currents 1/2/5: their fixed-name files in the deck folder IF (opts%mdc_wave_kin > 0 .OR. opts%mdc_currents > 0) THEN CALL read_moordyn_c_kinematics(deck_dir(path), opts, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN @@ -13217,6 +13293,19 @@ SUBROUTINE read_moordyn_c_kinematics(dir, opts, ErrStat, ErrMsg) !! must share one direction beta. !! - Currents 1, current_profile.txt (`z ux uy uz` rows after its header rows): the steady !! profile, linear in z and held beyond its ends, as MoorDyn-C's current grid. + !! - Currents 2, current_profile_dynamic.txt (constructDynamicCurrentGrid of MoorDyn-C's + !! source/Waves/WaveGrid.cpp): lines 1-4 and 6 are free text, line 5 lists the depths + !! z(1:nz) (read in single precision, as MoorDyn-C's stof), and every later row is + !! `t ux(1:nz) [uy(1:nz) [uz(1:nz)]]` (missing components zero). A depth profile in time. + !! - Currents 5, current_profile_4d.txt (construct4DCurrentGrid): line 1 is `nx ny nz nt`, + !! lines 2-5 the x, y, z and t coordinates, and the rows `x y z t ux uy uz` give every grid + !! point once, from line 6 (a text line 6 is a header, as MoorDyn-C reads its rows from line + !! 7). A row's coordinates are matched by value. + !! Both are resampled in time as MoorDyn-C does and evaluated at every node position and + !! time (CD_Current_Grid_Resample, CD_Current_Grid_Velocity), with no fluid acceleration. + !! The static start takes the t = 0 current, as MoorDyn-C's default stationary initial + !! condition does (its legacy dynamic relaxation, ICgenDynamic 1, samples the current over + !! the relaxation time instead). CHARACTER(*), INTENT(IN) :: dir TYPE(DeckOptions), INTENT(INOUT) :: opts INTEGER, INTENT(OUT) :: ErrStat @@ -13225,7 +13314,10 @@ SUBROUTINE read_moordyn_c_kinematics(dir, opts, ErrStat, ErrMsg) REAL(wp) :: dt, tl, frac, ca, sa, angle, scale, beta, mean_level, arg INTEGER :: n, nt, j, k, nc, bracket INTEGER(KIND=8) :: kj - CHARACTER(24) :: fname + CHARACTER(32) :: fname + ! the longest row of a MoorDyn-C current table (a time and 3 nz velocities per row) + INTEGER, PARAMETER :: LONG_ROW = 65536 + INTEGER, PARAMETER :: SP = SELECTED_REAL_KIND(6, 37) ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -13376,9 +13468,401 @@ SUBROUTINE read_moordyn_c_kinematics(dir, opts, ErrStat, ErrMsg) opts%has_current = .TRUE. opts%has_current_profile = .TRUE. END IF + IF (opts%mdc_currents == 2 .OR. opts%mdc_currents == 5) THEN + IF (opts%has_current) THEN + CALL fail(ErrStat, ErrMsg, 'the deck declares BOTH a current OPTION (or a WaterKin current) and '// & + 'Currents '//TRIM(int_to_str(opts%mdc_currents))//' (double-counting); keep one'); RETURN + END IF + IF (ALLOCATED(opts%current_grid)) DEALLOCATE (opts%current_grid) + ALLOCATE (opts%current_grid) + IF (opts%mdc_currents == 2) THEN + fname = 'current_profile_dynamic.txt' + CALL read_dynamic_profile() + ELSE + fname = 'current_profile_4d.txt' + CALL read_4d_grid() + END IF + IF (ErrStat /= CD_DECKDRV_OK) RETURN + opts%has_current = .TRUE. + opts%has_current_grid = .TRUE. + opts%has_current_profile = .FALSE. + ! past its last sample MoorDyn-C's grid repeats (CD_Current_Grid_Velocity) + IF (opts%has_tmax .AND. opts%current_grid%nt > 1) THEN + tl = REAL(opts%current_grid%nt - 1, wp)*opts%current_grid%dt + IF (opts%tmax > tl) WRITE (error_unit, '(A)') ' Note: Currents '//TRIM(int_to_str(opts%mdc_currents))// & + ': TMax outlasts the last sample of '//TRIM(fname)//' (t = '//TRIM(real_to_str(tl))//' s); as in '// & + 'MoorDyn-C the current then repeats with period '// & + TRIM(real_to_str(REAL(opts%current_grid%nt, wp)*opts%current_grid%dt))// & + ' s, holding its t = 0 value over the last interval of each period.' + END IF + END IF CONTAINS + SUBROUTINE open_table(name, unit, ok) + !! Open the kinematics file name in the deck folder. + CHARACTER(*), INTENT(IN) :: name + INTEGER, INTENT(OUT) :: unit + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ios + CHARACTER(1024) :: why + CHARACTER(CD_DECK_PATHLEN) :: fpath + fpath = path_join(dir, TRIM(name)) + CALL CD_Open_Input(unit, TRIM(fpath), ios, why) + ok = ios == 0 + IF (.NOT. ok) CALL fail(ErrStat, ErrMsg, 'cannot open the MoorDyn-C kinematics file '//TRIM(fpath)// & + input_open_reason(TRIM(fpath), why)) + END SUBROUTINE open_table + + SUBROUTINE next_row(unit, buf, lineno, ios) + !! The next whole record of a current table (lineno counts every line, blank ones too, as + !! MoorDyn-C's fileToLines does); a record longer than buf fails (ios = 1, ErrStat set). + INTEGER, INTENT(IN) :: unit + CHARACTER(*), INTENT(OUT) :: buf + INTEGER, INTENT(INOUT) :: lineno + INTEGER, INTENT(OUT) :: ios + LOGICAL :: overflow + CALL read_whole_record(unit, buf, ios, overflow) + IF (ios /= 0) RETURN + lineno = lineno + 1 + IF (lineno == 1) CALL CD_Strip_BOM(buf) + IF (overflow) THEN + ios = 1 + CALL fail(ErrStat, ErrMsg, TRIM(fname)//' rows must be at most '//TRIM(int_to_str(LEN(buf)))// & + ' characters long') + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + END IF + END SUBROUTINE next_row + + SUBROUTINE row_tokens(line, lo, hi, ntok) + !! The whitespace tokens of a row as MoorDyn-C splits it (moordyn::str::split): up to the + !! first token holding '#', which starts a comment. + CHARACTER(*), INTENT(IN) :: line + INTEGER, ALLOCATABLE, INTENT(INOUT) :: lo(:), hi(:) + INTEGER, INTENT(OUT) :: ntok + INTEGER, ALLOCATABLE :: grown(:) + INTEGER :: pos, a, b + ntok = 0 + pos = 1 + DO + CALL token_bounds(line, pos, a, b) + IF (a == 0) EXIT + IF (INDEX(line(a:b), '#') > 0) EXIT + ntok = ntok + 1 + IF (ntok > SIZE(lo)) THEN + ALLOCATE (grown(2*SIZE(lo))) + grown(1:SIZE(lo)) = lo + CALL MOVE_ALLOC(grown, lo) + ALLOCATE (grown(2*SIZE(hi))) + grown(1:SIZE(hi)) = hi + CALL MOVE_ALLOC(grown, hi) + END IF + lo(ntok) = a + hi(ntok) = b + END DO + END SUBROUTINE row_tokens + + LOGICAL FUNCTION table_number(tok, x, lineno) RESULT(ok) + !! tok read as a plain finite number; otherwise fail naming the file line. + CHARACTER(*), INTENT(IN) :: tok + REAL(wp), INTENT(OUT) :: x + INTEGER, INTENT(IN) :: lineno + CALL parse_real_token(tok, x, ok) + IF (.NOT. ok) THEN + CALL fail(ErrStat, ErrMsg, TRIM(fname)//' value "'//tok//'" is not a plain finite number') + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + END IF + END FUNCTION table_number + + LOGICAL FUNCTION strictly_increasing(c) RESULT(ok) + REAL(wp), INTENT(IN) :: c(:) + INTEGER :: k + ok = .TRUE. + DO k = 2, SIZE(c) + IF (.NOT. c(k) > c(k - 1)) ok = .FALSE. + END DO + END FUNCTION strictly_increasing + + SUBROUTINE read_dynamic_profile() + !! Currents 2: current_profile_dynamic.txt into opts%current_grid (nx = ny = 1). + CHARACTER(:), ALLOCATABLE :: buf + INTEGER, ALLOCATABLE :: lo(:), hi(:) + REAL(wp), ALLOCATABLE :: zc(:), tc(:), uu(:, :, :), grow_u(:, :, :), grow_t(:), v5(:, :, :, :, :) + REAL(wp) :: x + REAL(SP) :: z4 + INTEGER :: unit, ios, lineno, nz, ntok, m, k, ncomp, rios + LOGICAL :: ok + CHARACTER(512) :: em_g + INTEGER :: es_g + ALLOCATE (CHARACTER(LONG_ROW) :: buf) + ALLOCATE (lo(64), hi(64)) + CALL open_table(fname, unit, ok) + IF (.NOT. ok) RETURN + nz = 0 + m = 0 + lineno = 0 + ALLOCATE (tc(16), zc(0), uu(3, 0, 16)) + DO + CALL next_row(unit, buf, lineno, ios) + IF (ios /= 0) EXIT + ! lines 1-4 and 6 are free text (MoorDyn-C skips them by position) + IF (lineno <= 4 .OR. lineno == 6) CYCLE + CALL row_tokens(buf, lo, hi, ntok) + IF (lineno == 5) THEN + IF (ntok < 1) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 2: line 5 of '//TRIM(fname)//' must list the depths') + RETURN + END IF + nz = ntok + DEALLOCATE (zc, uu) + ALLOCATE (zc(nz), uu(3, nz, 16)) + DO k = 1, nz + IF (.NOT. table_number(buf(lo(k):hi(k)), x, lineno)) THEN + CLOSE (unit); RETURN + END IF + ! MoorDyn-C reads the depths in single precision (stof) + READ (buf(lo(k):hi(k)), *, IOSTAT=rios) z4 + IF (rios /= 0 .OR. .NOT. IEEE_IS_FINITE(z4)) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, TRIM(fname)//' depth "'//buf(lo(k):hi(k))//'" is not a single-precision '// & + 'number') + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + RETURN + END IF + zc(k) = REAL(z4, wp) + END DO + CYCLE + END IF + IF (ntok == 0) CYCLE + IF (ntok == 1 + nz) THEN + ncomp = 1 + ELSE IF (ntok == 1 + 2*nz) THEN + ncomp = 2 + ELSE IF (ntok == 1 + 3*nz) THEN + ncomp = 3 + ELSE + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 2: a '//TRIM(fname)//' row is the time and the x, the x and y, or '// & + 'the x, y and z velocities at the '//TRIM(int_to_str(nz))//' depths ('// & + TRIM(int_to_str(1 + nz))//', '//TRIM(int_to_str(1 + 2*nz))//' or '// & + TRIM(int_to_str(1 + 3*nz))//' numbers); found '//TRIM(int_to_str(ntok))) + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + RETURN + END IF + m = m + 1 + IF (m > SIZE(tc)) THEN + ALLOCATE (grow_t(2*SIZE(tc)), grow_u(3, nz, 2*SIZE(tc))) + grow_t(1:m - 1) = tc(1:m - 1) + grow_u(:, :, 1:m - 1) = uu(:, :, 1:m - 1) + CALL MOVE_ALLOC(grow_t, tc) + CALL MOVE_ALLOC(grow_u, uu) + END IF + IF (.NOT. table_number(buf(lo(1):hi(1)), tc(m), lineno)) THEN + CLOSE (unit); RETURN + END IF + uu(:, :, m) = CD_ZERO + DO k = 1, ncomp*nz + IF (.NOT. table_number(buf(lo(k + 1):hi(k + 1)), x, lineno)) THEN + CLOSE (unit); RETURN + END IF + ! the x velocities depth by depth, then the y ones, then the z ones + uu((k - 1)/nz + 1, MOD(k - 1, nz) + 1, m) = x + END DO + END DO + CLOSE (unit) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (nz == 0 .OR. lineno < 7) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 2: '//TRIM(fname)//' needs at least 7 lines (4 header lines, the '// & + 'depths, a header line and the time rows)'); RETURN + END IF + IF (m < 2) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 2: '//TRIM(fname)//' needs at least two time rows'); RETURN + END IF + IF (.NOT. strictly_increasing(zc)) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 2: '//TRIM(fname)//' depths must be strictly increasing'); RETURN + END IF + IF (.NOT. strictly_increasing(tc(1:m))) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 2: '//TRIM(fname)//' times must be strictly increasing'); RETURN + END IF + ALLOCATE (v5(3, 1, 1, nz, m)) + v5(:, 1, 1, :, :) = uu(:, :, 1:m) + CALL CD_Current_Grid_Resample([CD_ZERO], [CD_ZERO], zc, tc(1:m), v5, opts%current_grid, es_g, em_g) + IF (es_g /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 2: '//TRIM(fname)//': '//TRIM(em_g)); RETURN + END IF + END SUBROUTINE read_dynamic_profile + + SUBROUTINE read_4d_grid() + !! Currents 5: current_profile_4d.txt into opts%current_grid. + INTEGER(int64), PARAMETER :: MAX_POINTS = 2000000_int64 + CHARACTER(:), ALLOCATABLE :: buf + INTEGER, ALLOCATABLE :: lo(:), hi(:) + REAL(wp), ALLOCATABLE :: xc(:), yc(:), zc(:), tc(:), v5(:, :, :, :, :) + LOGICAL, ALLOCATABLE :: seen(:, :, :, :) + REAL(wp) :: row(7) + INTEGER :: unit, ios, lineno, ntok, k, dims(4), ix, iy, iz, it + INTEGER(int64) :: nrow, npts + LOGICAL :: ok + CHARACTER(512) :: em_g + INTEGER :: es_g + ALLOCATE (CHARACTER(LONG_ROW) :: buf) + ALLOCATE (lo(64), hi(64)) + CALL open_table(fname, unit, ok) + IF (.NOT. ok) RETURN + lineno = 0 + nrow = 0 + npts = 0 + dims = 0 + ALLOCATE (xc(0), yc(0), zc(0), tc(0), v5(3, 0, 0, 0, 0), seen(0, 0, 0, 0)) + DO + CALL next_row(unit, buf, lineno, ios) + IF (ios /= 0) EXIT + CALL row_tokens(buf, lo, hi, ntok) + SELECT CASE (lineno) + CASE (1) + ! nx ny nz nt + ok = ntok == 4 + DO k = 1, MIN(ntok, 4) + IF (ok) CALL parse_int_token(buf(lo(k):hi(k)), dims(k), ok) + END DO + IF (ok) ok = ALL(dims >= 1) + IF (.NOT. ok) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 5: line 1 of '//TRIM(fname)//' must be the four positive '// & + 'grid sizes `nx ny nz nt`') + RETURN + END IF + npts = PRODUCT(INT(dims, int64)) + IF (npts > MAX_POINTS) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//' declares more than 2e6 grid points') + RETURN + END IF + DEALLOCATE (xc, yc, zc, tc, v5, seen) + ALLOCATE (xc(dims(1)), yc(dims(2)), zc(dims(3)), tc(dims(4))) + ALLOCATE (v5(3, dims(1), dims(2), dims(3), dims(4)), seen(dims(1), dims(2), dims(3), dims(4))) + v5 = CD_ZERO + seen = .FALSE. + CASE (2:5) + IF (ntok /= dims(lineno - 1)) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 5: line '//TRIM(int_to_str(lineno))//' of '//TRIM(fname)// & + ' must list the '//TRIM(int_to_str(dims(lineno - 1)))//' '// & + axis_name(lineno - 1)//' coordinates declared on line 1; found '//TRIM(int_to_str(ntok))) + RETURN + END IF + DO k = 1, ntok + SELECT CASE (lineno) + CASE (2) + ok = table_number(buf(lo(k):hi(k)), xc(k), lineno) + CASE (3) + ok = table_number(buf(lo(k):hi(k)), yc(k), lineno) + CASE (4) + ok = table_number(buf(lo(k):hi(k)), zc(k), lineno) + CASE DEFAULT + ok = table_number(buf(lo(k):hi(k)), tc(k), lineno) + END SELECT + IF (.NOT. ok) THEN + CLOSE (unit); RETURN + END IF + END DO + CASE DEFAULT + IF (ntok == 0) CYCLE + ! a text line 6 is a header (MoorDyn-C reads its rows from line 7) + IF (lineno == 6) THEN + IF (.NOT. numeric_token_shape(buf(lo(1):hi(1)))) CYCLE + END IF + IF (ntok /= 7) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 5: a '//TRIM(fname)//' row is `x y z t ux uy uz` (7 numbers); '// & + 'found '//TRIM(int_to_str(ntok))) + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + RETURN + END IF + DO k = 1, 7 + IF (.NOT. table_number(buf(lo(k):hi(k)), row(k), lineno)) THEN + CLOSE (unit); RETURN + END IF + END DO + ix = FINDLOC(xc, row(1), DIM=1) + iy = FINDLOC(yc, row(2), DIM=1) + iz = FINDLOC(zc, row(3), DIM=1) + it = FINDLOC(tc, row(4), DIM=1) + IF (ix == 0 .OR. iy == 0 .OR. iz == 0 .OR. it == 0) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 5: a '//TRIM(fname)//' row names a point off the grid of lines '// & + '2-5 (its x, y, z and t must each equal one of the listed coordinates)') + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + RETURN + END IF + IF (seen(ix, iy, iz, it)) THEN + CLOSE (unit) + CALL fail(ErrStat, ErrMsg, 'Currents 5: a '//TRIM(fname)//' row repeats a grid point') + CALL add_file_line(TRIM(fname), lineno, ErrMsg) + RETURN + END IF + seen(ix, iy, iz, it) = .TRUE. + v5(:, ix, iy, iz, it) = row(5:7) + nrow = nrow + 1 + END SELECT + END DO + CLOSE (unit) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + IF (lineno < 5) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//' needs the grid sizes, the x, y, z and t '// & + 'coordinates (lines 1-5) and a row per grid point'); RETURN + END IF + IF (.NOT. (strictly_increasing(xc) .AND. strictly_increasing(yc) .AND. strictly_increasing(zc))) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//' x, y and z coordinates must be strictly '// & + 'increasing'); RETURN + END IF + IF (.NOT. strictly_increasing(tc)) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//' times must be strictly increasing'); RETURN + END IF + IF (SIZE(tc) < 2) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//' needs at least two times (MoorDyn-C reads '// & + 'before its table with one)'); RETURN + END IF + IF (nrow < npts) THEN + ! the first missing point + DO it = 1, SIZE(tc) + DO iz = 1, SIZE(zc) + DO iy = 1, SIZE(yc) + DO ix = 1, SIZE(xc) + IF (seen(ix, iy, iz, it)) CYCLE + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//' has no row for the grid point (x, y, z, '// & + 't) = ('//TRIM(real_to_str(xc(ix)))//', '//TRIM(real_to_str(yc(iy)))//', '// & + TRIM(real_to_str(zc(iz)))//', '//TRIM(real_to_str(tc(it)))//')') + RETURN + END DO + END DO + END DO + END DO + END IF + CALL CD_Current_Grid_Resample(xc, yc, zc, tc, v5, opts%current_grid, es_g, em_g) + IF (es_g /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'Currents 5: '//TRIM(fname)//': '//TRIM(em_g)); RETURN + END IF + END SUBROUTINE read_4d_grid + + FUNCTION axis_name(k) RESULT(name) + INTEGER, INTENT(IN) :: k + CHARACTER(1) :: name + CHARACTER(4), PARAMETER :: AXES = 'xyzt' + name = AXES(k:k) + END FUNCTION axis_name + + FUNCTION real_to_str(x) RESULT(t) + !! x in G0.6 (asterisks never abort: the WRITE carries IOSTAT). + REAL(wp), INTENT(IN) :: x + CHARACTER(32) :: t + INTEGER :: ios + t = '' + WRITE (t, '(G0.6)', IOSTAT=ios) x + t = ADJUSTL(t) + END FUNCTION real_to_str + SUBROUTINE install_components() !! The component waves (omega, amplitude, phase in CableDyn's cos(k d - omega t + phase) !! convention), their direction beta [rad] and the mean level. @@ -13916,8 +14400,9 @@ SUBROUTINE append_body(line, bodies, nb, ErrStat, ErrMsg) CASE ('coupled', 'vessel', 'cpld', 'ves') b%btype = 'rigid6' b%host_coupled = .TRUE. - CASE ('coupledpinned', 'cpldpin') - CALL fail(ErrStat, ErrMsg, 'CoupledPinned BODY is not supported (use Coupled or Free)'); RETURN + CASE ('coupledpinned', 'cpldpin', 'vesselpinned', 'vespin') + b%btype = 'rigid6' + b%host_pinned = .TRUE. END SELECT CALL grow_bodies(bodies, nb) nb = nb + 1 @@ -13928,8 +14413,9 @@ SUBROUTINE parse_moordyn_body_row(line, b, ErrStat, ErrMsg) !! MoorDyn v2 BODIES row: ID Attachment X0 Y0 Z0 r0 p0 y0 Mass CG* I* Volume CdA* Ca*, with !! bar lists CG = z | x|y|z, I = I (all axes) | Ixx|Iyy|Izz about the CG, CdA = CdA | CdA|CdA_rot !! (or 3/6 entries) and Ca = Ca | Cax|Cay|Caz. A Free body becomes a Rigid6 body with its CG - !! (also the centre of buoyancy, as in MoorDyn). The body model is isotropic: 3-entry CdA/Ca - !! lists must be equal, and rotational drag and other attachments fail closed by name. + !! (also the centre of buoyancy, as in MoorDyn); Coupled/Vessel and CoupledPinned/VesselPinned + !! bodies are host-driven. The body model is isotropic: 3-entry CdA/Ca lists must be equal, and + !! rotational drag and other attachments fail closed by name. CHARACTER(*), INTENT(IN) :: line TYPE(DeckBody), INTENT(OUT) :: b INTEGER, INTENT(OUT) :: ErrStat @@ -13954,9 +14440,12 @@ SUBROUTINE parse_moordyn_body_row(line, b, ErrStat, ErrMsg) CASE ('coupled', 'vessel', 'cpld', 'ves') b%btype = 'rigid6' b%host_coupled = .TRUE. + CASE ('coupledpinned', 'cpldpin', 'vesselpinned', 'vespin') + b%btype = 'rigid6' + b%host_pinned = .TRUE. CASE DEFAULT CALL fail(ErrStat, ErrMsg, 'BODIES attachment "'//TRIM(tok(2))//'" is not supported in the '// & - '14-column MoorDyn row (Free, Coupled, or Vessel bodies)'); RETURN + '14-column MoorDyn row (Free, Coupled, Vessel, CoupledPinned or VesselPinned bodies)'); RETURN END SELECT READ (line, *, IOSTAT=ios) tok(1), tok(2), b%pos(1), b%pos(2), b%pos(3), b%rot(1), b%rot(2), b%rot(3), b%mass IF (ios == 0) THEN @@ -15472,6 +15961,9 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) opts%current_velocity = [x1, x2, x3] opts%has_current = .TRUE. opts%has_current_profile = .FALSE. + ! last row wins: an earlier profile row leaves no levels behind + IF (ALLOCATED(opts%current_profile_z)) DEALLOCATE (opts%current_profile_z) + IF (ALLOCATED(opts%current_profile_velocity)) DEALLOCATE (opts%current_profile_velocity) RETURN ELSE IF (to_lower(TRIM(kw)) == 'waves' .OR. to_lower(TRIM(kw)) == 'wave') THEN IF (to_lower(TRIM(mode)) /= 'airy' .AND. to_lower(TRIM(mode)) /= 'stream' .AND. & @@ -15837,6 +16329,8 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) opts%has_current = .FALSE. opts%current_velocity = CD_ZERO opts%has_current_profile = .FALSE. + IF (ALLOCATED(opts%current_profile_z)) DEALLOCATE (opts%current_profile_z) + IF (ALLOCATED(opts%current_profile_velocity)) DEALLOCATE (opts%current_profile_velocity) ELSE CALL fail(ErrStat, ErrMsg, 'OPTION current supports "none current" or "uniform vx vy vz current"') END IF @@ -15903,6 +16397,23 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CASE ('writelog') ! Stock MoorDyn log-verbosity switch; CableDyn reports through ErrStat/ErrMsg. CALL rd(val, x1, ErrStat, ErrMsg) + CASE ('inertialf') + ! MoorDyn-F's switch for the inertia of the coupled objects in their coupled loads: 0 none + ! (its default), 1 included, 2 ramped in over inertialF_rampT. CableDyn always includes it + ! (the coupled body, rod and pinned object loads net of their inertia): 1 is accepted + ! without effect, 0 and 2 are refused by name. + CALL rd(val, x1, ErrStat, ErrMsg) + IF (ErrStat /= 0) RETURN + IF (ABS(x1 - CD_ONE) > CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION inertialF '//TRIM(val)//': CableDyn returns the inertia of '// & + 'coupled bodies and rods with their coupled loads, as MoorDyn-F''s inertialF 1; '// & + 'inertialF 0 (MoorDyn-F''s default: no inertia) and 2 (the inertia ramped in) are not '// & + 'supported: use 1 or remove the row') + RETURN + END IF + CASE ('inertialf_rampt') + ! the ramp time of MoorDyn-F's inertialF 2 (refused above): accepted without effect + CALL rd(val, x1, ErrStat, ErrMsg) CASE ('dtout') ! Stock MoorDyn output-file cadence; CableDyn's output cadence is governed by ! the caller (driver print interval / OpenFAST glue), not the deck. @@ -15980,29 +16491,25 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) END IF CASE ('currents') ! Stock MoorDyn-C switch selecting where current kinematics come from: 0 none, 1 the steady - ! depth table current_profile.txt in the deck folder (read_moordyn_c_kinematics); the - ! time-varying and gridded tables fail closed by name (CableDyn decks may also declare - ! current via the "current" option) + ! depth table current_profile.txt, 2 the time-varying depth table + ! current_profile_dynamic.txt, 5 the grid in x, y, z and time current_profile_4d.txt, each + ! in the deck folder (read_moordyn_c_kinematics). 3 and 4 (MoorDyn-C's node approaches) + ! have no current source in MoorDyn-C v2.7.1 and fail closed by name (CableDyn decks may + ! also declare current via the "current" option) CALL rd(val, x1, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN opts%mdc_currents = 0 IF (ABS(x1 - ANINT(x1)) > 1.0e-9_wp .OR. x1 < -0.5_wp .OR. x1 > 5.5_wp) THEN - CALL fail(ErrStat, ErrMsg, 'Currents '//TRIM(val)//' not supported (0 none, or 1 for the MoorDyn-C '// & - 'steady profile current_profile.txt)') + CALL fail(ErrStat, ErrMsg, 'Currents '//TRIM(val)//' not supported (0 none, or the MoorDyn-C current '// & + 'files: 1 current_profile.txt, 2 current_profile_dynamic.txt, 5 current_profile_4d.txt)') RETURN END IF SELECT CASE (NINT(x1)) - CASE (1) - opts%mdc_currents = 1 - CASE (2) - CALL fail(ErrStat, ErrMsg, 'Currents 2 (the MoorDyn-C time-varying profile current_profile_dynamic.txt) '// & - 'is not supported; use Currents 1 or the "current" option') + CASE (1, 2, 5) + opts%mdc_currents = NINT(x1) CASE (3, 4) CALL fail(ErrStat, ErrMsg, 'Currents '//TRIM(int_to_str(NINT(x1)))//' is not supported '// & - '(no current source in MoorDyn-C v2.7.1); use Currents 1') - CASE (5) - CALL fail(ErrStat, ErrMsg, 'Currents 5 (the MoorDyn-C 4-D current grid current_profile_4d.txt) is not '// & - 'supported; use Currents 1 or the "current" option') + '(no current source in MoorDyn-C v2.7.1); use Currents 1, 2 or 5') END SELECT CASE DEFAULT ! per-line static friction rows: layAzimuth, asLaidTension (line ID suffix) @@ -16108,7 +16615,8 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) rule = 'finite' CASE ('rhoinf', 'rho_inf') rule = 'unit' - CASE ('kbot', 'kb', 'cbot', 'cb', 'dtic', 'tmaxic', 'cdscaleic', 'threshic', 'writelog', 'dtout') + CASE ('kbot', 'kb', 'cbot', 'cb', 'dtic', 'tmaxic', 'cdscaleic', 'threshic', 'writelog', 'dtout', 'inertialf', & + 'inertialf_rampt') rule = 'finite' CASE DEFAULT RETURN @@ -16662,6 +17170,10 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio IF (opts%has_current) THEN ! A caller-driven (coupled) deck takes its clock from the host, as for frictionMu. IF (.NOT. caller_driven .AND. .NOT. opts%has_dtm) THEN + IF (opts%mdc_currents > 0) THEN + CALL fail(ErrStat, ErrMsg, 'standalone Currents '//TRIM(int_to_str(opts%mdc_currents))// & + ' requires dtM and TMax'); RETURN + END IF CALL fail(ErrStat, ErrMsg, 'standalone OPTION current requires dtM and TMax'); RETURN END IF IF (.NOT. ALL(IEEE_IS_FINITE(opts%current_velocity))) THEN @@ -16693,6 +17205,18 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio END DO END BLOCK END IF + IF (opts%has_current_grid) THEN + IF (.NOT. ALLOCATED(opts%current_grid)) THEN + CALL fail(ErrStat, ErrMsg, 'current grid declared without grid data'); RETURN + END IF + ! read_moordyn_c_kinematics has checked that the grid is finite and increasing + IF (ANY(ABS(opts%current_grid%x) > MAX_COORDINATE) .OR. ANY(ABS(opts%current_grid%y) > MAX_COORDINATE) & + .OR. ANY(ABS(opts%current_grid%z) > MAX_COORDINATE) .OR. & + ANY(ABS(opts%current_grid%velocity) > MAX_FLUID_SPEED)) THEN + CALL fail(ErrStat, ErrMsg, 'current grid coordinates must be at most 1e6 m and velocities at most '// & + '1e3 m/s in magnitude'); RETURN + END IF + END IF END IF IF (opts%has_wave) THEN IF (.NOT. opts%has_dtm) THEN @@ -16912,6 +17436,22 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio IF (.NOT. opts%has_dtm .AND. .NOT. caller_driven) THEN CALL fail(ErrStat, ErrMsg, 'Rigid6 BODY requires a dynamic deck with dtM and TMax'); RETURN END IF + IF (bodies(i)%host_pinned) THEN + ! The host moves the reference point of a CoupledPinned body and takes its force; a + ! motionFile cannot stand in for it (its Body rows prescribe the whole pose), so the + ! body needs the coupled aggregate. Its rotation is integrated: Ixx/Iyy/Izz > 0. + IF (.NOT. opts%host_coupled_objects) THEN + CALL fail(ErrStat, ErrMsg, 'CoupledPinned/VesselPinned BODY requires a coupled host (OpenFAST '// & + 'CompMooring = 5); in a standalone deck use a Free body, or a Coupled body with a '// & + 'motionFile'); RETURN + END IF + IF (bodies(i)%mass < CD_ZERO .OR. bodies(i)%vol < CD_ZERO .OR. bodies(i)%cda < CD_ZERO .OR. & + bodies(i)%ca < CD_ZERO .OR. ANY(bodies(i)%inertia <= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'CoupledPinned/VesselPinned BODY requires Ixx/Iyy/Izz > 0 and '// & + 'non-negative Mass/Vol/CdA/Ca'); RETURN + END IF + CYCLE + END IF IF (bodies(i)%host_coupled) THEN IF (.NOT. (opts%has_motion_file .OR. opts%host_coupled_objects)) THEN CALL fail(ErrStat, ErrMsg, 'Coupled/Vessel BODY requires a motionFile (or a coupled host)'); RETURN @@ -19484,11 +20024,12 @@ SUBROUTINE rigid_coupled_acceleration(dload_da, dt, a_points, bases, arms, mass_ REAL(wp), INTENT(OUT) :: acc(3), alpha(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - ! pin_arm: the reference point turns about a pin at -pin_arm from it (a pinned rod): with + ! pin_arm: the reference point turns about a pin at -pin_arm from it (a pinned rod; zero for + ! a CoupledPinned body, which turns about its reference point): with ! x = T y + b, T = [-[r]x; I], b = [a_p + w x (w x r); 0], the rotational acceleration y ! solves T^T m6 T y = T^T (rhs - m6 b). a_p is pin_acc, the pin acceleration (zero when - ! absent: a fixed pin); a moving pin (a CoupledPinned rod) thus loads the rotation with the - ! inertia of its acceleration. + ! absent: a fixed pin); a moving pin (a CoupledPinned rod or body) thus loads the rotation with + ! the inertia of its acceleration. REAL(wp), INTENT(IN), OPTIONAL :: pin_arm(3), pin_acc(3) ! m6_out/rhs_out: return the assembled system m6 x = rhs instead of solving it (the pinned- ! child group solve of mb_group_solve); acc and alpha are then zero @@ -19566,7 +20107,7 @@ SUBROUTINE rigid_coupled_acceleration(dload_da, dt, a_points, bases, arms, mass_ CALL solve_sym3(MATMUL(TRANSPOSE(t63), MATMUL(m6, t63)), MATMUL(TRANSPOSE(t63), rhs - MATMUL(m6, b6)), y, ok) IF (.NOT. ok) THEN ErrStat = CD_DECKDRV_SOLVEFAIL - ErrMsg = 'CableDyn_DeckDriver: pinned rod rotational inertia is singular' + ErrMsg = 'CableDyn_DeckDriver: pinned rod or body rotational inertia is singular' RETURN END IF alpha = y @@ -23263,18 +23804,117 @@ END SUBROUTINE step_rod_system SUBROUTINE save_host_end_rigid(rigid, hk) !! Record the t + dt kinematics of the host-driven bodies (columns: r, v, a, omega, alpha, - !! rot_mat) before sub-stepping moves them along the interpolated host path. + !! rot_mat; rows 25 to 33 the pin, pin velocity and pin acceleration of a host-pinned body) + !! before sub-stepping moves them along the interpolated host path. TYPE(RigidBodyState), INTENT(IN) :: rigid(:) REAL(wp), ALLOCATABLE, INTENT(INOUT) :: hk(:, :) INTEGER :: ib IF (ALLOCATED(hk)) DEALLOCATE (hk) - ALLOCATE (hk(24, SIZE(rigid))) + ALLOCATE (hk(33, SIZE(rigid))) DO ib = 1, SIZE(rigid) hk(:, ib) = [rigid(ib)%r, rigid(ib)%v, rigid(ib)%a, rigid(ib)%omega, rigid(ib)%alpha, & - RESHAPE(rigid(ib)%rot_mat, [9])] + RESHAPE(rigid(ib)%rot_mat, [9]), rigid(ib)%pin, rigid(ib)%pin_v, rigid(ib)%pin_a] END DO END SUBROUTINE save_host_end_rigid + SUBROUTINE interp_host_body_pins(rigid, hk, s) + !! Place the node of every host-pinned body at fraction s of its step and move the body's + !! reference point with it (body_snap_pinned); the body keeps its own rotation. Position, + !! velocity and acceleration are each linear between the step-start pin (pin0, the committed + !! reference-point motion) and the t + dt host values in hk (rows 25 to 33), as for the pins + !! of host-pinned rods (interp_host_pins); s = 1 restores the t + dt pin. + TYPE(RigidBodyState), INTENT(INOUT) :: rigid(:) + REAL(wp), INTENT(IN) :: hk(:, :), s + INTEGER :: ib + DO ib = 1, SIZE(rigid) + IF (.NOT. rigid(ib)%is_host_pinned) CYCLE + IF (s >= CD_ONE) THEN + rigid(ib)%pin = hk(25:27, ib) + rigid(ib)%pin_v = hk(28:30, ib) + rigid(ib)%pin_a = hk(31:33, ib) + ELSE + rigid(ib)%pin = rigid(ib)%pin0 + s*(hk(25:27, ib) - rigid(ib)%pin0) + rigid(ib)%pin_v = rigid(ib)%pin0_v + s*(hk(28:30, ib) - rigid(ib)%pin0_v) + rigid(ib)%pin_a = rigid(ib)%pin0_a + s*(hk(31:33, ib) - rigid(ib)%pin0_a) + END IF + CALL body_snap_pinned(rigid(ib)) + END DO + END SUBROUTINE interp_host_body_pins + + SUBROUTINE body_snap_pinned(body) + !! A host-pinned body keeps its reference point on the host node: its position, velocity and + !! acceleration are the node's (pin, pin_v, pin_a). Every other body is left unchanged. + TYPE(RigidBodyState), INTENT(INOUT) :: body + IF (.NOT. body%is_host_pinned) RETURN + body%r = body%pin + body%v = body%pin_v + body%a = body%pin_a + END SUBROUTINE body_snap_pinned + + SUBROUTINE set_body_pin_start(body) + !! Record the committed reference-point motion of a host-pinned body as the pin kinematics its + !! next step starts from (RigidBodyState%pin0). The checkpoint mirror carries it (r, v, a), + !! so a restored run takes the same values bit for bit. + TYPE(RigidBodyState), INTENT(INOUT) :: body + body%pin0 = body%r + body%pin0_v = body%v + body%pin0_a = body%a + END SUBROUTINE set_body_pin_start + + SUBROUTINE pinned_body_estimate_terms(body, opts, time, mass6, k6, ErrStat, ErrMsg) + !! The sub-step estimate terms of a host-pinned body (step_rigid6_system), whose rotation is + !! its only degree of freedom: mass6(1:3) = 0 (the host prescribes the translation) and + !! mass6(4:6) the diagonal of its rotational inertia about the pin (its reference point), + !! I_p = R J R^T - m [c]x [c]x for the CG at c = R cg; k6(4:6) the diagonal of its swing + !! stiffness about the pin. Vertical loads f_i at p_i from the pin that turn with the body + !! have the rotational stiffness K = -sum_i [f_i]x [p_i]x: the weight -m g e3 at c and the + !! buoyancy rhoW g phi V e3 at the centre of buoyancy (|K_kk| taken, so an upright buoyant + !! body counts too). The pin acceleration a_p loads the body with -m a_p at c, a stiffness + !! of at most |a_p| m |c|, |a_p| the larger of the step-start and end-of-step host values. + !! The buoyancy is taken at the larger of the body at its step-start pin and at the t + dt + !! pin the host has placed (a straight pin path crosses the surface monotonically; see + !! pinned_swing_omega2). The waterplane restoring C44/C55 is added as for a free body. + TYPE(RigidBodyState), INTENT(INOUT) :: body + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(IN) :: time + REAL(wp), INTENT(OUT) :: mass6(6), k6(6) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: c(3), cb(3), ip(3, 3), kg(3, 3), kd(3), phi, a_pin, r_end(3) + INTEGER :: k, pose + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + c = MATMUL(body%rot_mat, body%cg) + cb = MATMUL(body%rot_mat, body%cb) + ip = CD_ZERO + DO k = 1, 3 + ip(k, k) = body%inertia(k) + END DO + ip = MATMUL(body%rot_mat, MATMUL(ip, TRANSPOSE(body%rot_mat))) - body%mass*MATMUL(skew3(c), skew3(c)) + mass6(1:3) = CD_ZERO + DO k = 1, 3 + mass6(3 + k) = ip(k, k) + END DO + k6 = [CD_ZERO, CD_ZERO, CD_ZERO, body%c44, body%c55, CD_ZERO] + kd = CD_ZERO + r_end = body%r + DO pose = 1, 2 + ! pose 1: the body at its step-start pin (the state is put back exactly after it) + IF (pose == 1) body%r = body%pin0 + CALL rigid6_wet_fraction(body, opts, time, phi, ErrStat, ErrMsg) + body%r = r_end + IF (ErrStat /= CD_DECKDRV_OK) RETURN + kg = -MATMUL(skew3([CD_ZERO, CD_ZERO, -body%mass*opts%g]), skew3(c)) - & + MATMUL(skew3([CD_ZERO, CD_ZERO, opts%rhoW*phi*body%vol*opts%g]), skew3(cb)) + DO k = 1, 3 + kd(k) = MAX(kd(k), ABS(kg(k, k))) + END DO + END DO + a_pin = MAX(NORM2(body%pin_a), NORM2(body%pin0_a)) + k6(4:6) = k6(4:6) + kd + a_pin*body%mass*NORM2(c) + END SUBROUTINE pinned_body_estimate_terms + SUBROUTINE interp_host_rigid(rigid, start, hk, s) !! Place every host-driven body at fraction s of its step: position, velocity, acceleration !! and angular rates linear between the staged step start and the t + dt values in hk, the @@ -24612,7 +25252,7 @@ SUBROUTINE fluid_at(xq, s, uq, duq, etaq, pdq, want_pdyn) END IF END IF IF (opts%has_current) THEN - uq = uq + deck_current_velocity(opts, xq(3), es, em) + uq = uq + deck_current_velocity(opts, xq, time, es, em) IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_DECKDRV_BADINPUT ErrMsg = 'CableDyn_DeckDriver: rod current profile failed: '//TRIM(em) @@ -24653,7 +25293,9 @@ SUBROUTINE init_rigid6_states(bodies, points, rigid, ErrStat, ErrMsg, rod_types, rigid(ir)%body_id = bodies(i)%id rigid(ir)%body_index = i rigid(ir)%is_prescribed = bodies(i)%host_coupled - ! a host-driven body starts at rest in the host's Init pose; its a/alpha are the host's + rigid(ir)%is_host_pinned = bodies(i)%host_pinned + ! a host-driven body starts at rest in the host's Init pose; its a/alpha are the host's (a + ! host-pinned body solves its own at the first step, like a free body) rigid(ir)%accel_valid = bodies(i)%host_coupled rigid(ir)%r_ref = bodies(i)%pos rigid(ir)%r = bodies(i)%pos @@ -24678,6 +25320,11 @@ SUBROUTINE init_rigid6_states(bodies, points, rigid, ErrStat, ErrMsg, rod_types, rigid(ir)%ext_f = bodies(i)%ext_f rigid(ir)%ext_blin = bodies(i)%ext_blin rigid(ir)%ext_bquad = bodies(i)%ext_bquad + ! a host-pinned body starts its first step from its pin at rest in its start pose + IF (rigid(ir)%is_host_pinned) THEN + rigid(ir)%pin = rigid(ir)%r + CALL set_body_pin_start(rigid(ir)) + END IF CALL collect_body_point_indices(points, bodies(i)%id, rigid(ir)%point_indices) no_pts = .FALSE. IF (PRESENT(allow_no_points)) no_pts = allow_no_points @@ -24804,7 +25451,8 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l ErrMsg, bathymetry, points_only, jac_check_err, ext_pt, ext_fm, & end_force_a, quiet, skipped, ext_km, ext_rot) !! Static equilibrium of the free objects of a deck: free Rigid6 bodies (six DOFs: position - !! and a rotation-vector increment on SO(3)), free rods (position and the two rotations + !! 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 !! normal to the axis; the rod is symmetric about it) and, jointly with them, the !! Free/Connect points. With points_only the bodies and rods are held and only the points !! move (the point initial condition, solve_point_equilibrium); otherwise the bodies and rods @@ -24899,9 +25547,9 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l INTEGER :: ibp REAL(wp), ALLOCATABLE :: lsc(:), base_r(:, :), base_rot(:, :, :), e1(:, :), e2(:, :) REAL(wp), ALLOCATABLE :: x(:), r(:), r_try(:), x_try(:), jac(:, :), a(:, :), g(:), dx(:), dxn(:) - REAL(wp), ALLOCATABLE :: dxc(:), jtry(:, :), rmask(:), base_rot0(:, :, :), e1_0(:, :), e2_0(:, :) + REAL(wp), ALLOCATABLE :: dxc(:), jtry(:, :), rmask(:), base_rot0(:, :, :), e1_0(:, :), e2_0(:, :), hold(:) INTEGER :: phase, kbad - LOGICAL :: unstable, silent + LOGICAL :: unstable, silent, pinned_body TYPE(LineStaticCache), ALLOCATABLE :: lc(:) LOGICAL, ALLOCATABLE :: lmove(:) TYPE(DeckOptions) :: opts_calm @@ -25081,6 +25729,17 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l ALLOCATE (x(n), r(n), r_try(n), x_try(n), jac(n, n), a(n, n), g(n), dx(n), dxn(n), dxc(n), jtry(n, n)) ALLOCATE (rmask(n)) rmask = CD_ONE + ! a CoupledPinned body turns about its host node, held at its initial pose: its translation + ! is held (the force rows carry the host's reaction, not a residual) and its three rotations + ! balance the moment about the node (min_norm_step) + pinned_body = .FALSE. + DO k = 1, nobj + IF (okind(k) /= OBJ_BODY) CYCLE + IF (.NOT. bodies(idx(k))%host_pinned) CYCLE + rmask(off(k) + 1:off(k) + 3) = CD_ZERO + pinned_body = .TRUE. + END DO + hold = rmask x = CD_ZERO IF (PRESENT(jac_check_err)) THEN CALL jacobian_check(jac_check_err) @@ -25120,7 +25779,11 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l ! rejected one (a warm line solve that cannot follow a long trial step counts as rejected) dxn = -r rnorm_try = rnorm - CALL CD_Solve_Dense_As_Banded(jac, dxn, info, lin_msg) + IF (pinned_body) THEN + CALL min_norm_step(jac, dxn, info) + ELSE + CALL CD_Solve_Dense_As_Banded(jac, dxn, info, lin_msg) + END IF IF (info == CD_LINALG_OK .AND. ALL(IEEE_IS_FINITE(dxn))) THEN IF (trust < CD_ZERO) trust = MIN(NORM2(dxn), step_cap) DO inner = 1, 8 @@ -25145,7 +25808,11 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l CALL analytic_jacobian(x_try, jtry, ok) IF (ok) THEN dxc = -r_try - CALL CD_Solve_Dense_As_Banded(jtry, dxc, info, lin_msg) + IF (pinned_body) THEN + CALL min_norm_step(jtry, dxc, info) + ELSE + CALL CD_Solve_Dense_As_Banded(jtry, dxc, info, lin_msg) + END IF ok = info == CD_LINALG_OK IF (ok) ok = ALL(IEEE_IS_FINITE(dxc)) IF (ok) ok = NORM2(dxc) <= 0.5_wp*NORM2(dxn) @@ -25210,7 +25877,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l END IF END DO IF (phase == 2) THEN - rmask = CD_ONE + rmask = hold phase = 3 CYCLE END IF @@ -25528,7 +26195,7 @@ SUBROUTINE own_loads(xs, fk, mk, cen, sc_out, good) fk(3, kk) = (opts%rhoW*pts(idx(kk))%vol - pts(idx(kk))%mass)*opts%g sc_out = MAX(sc_out, ABS(fk(3, kk))) IF (opts%has_current .AND. pts(idx(kk))%cda > CD_ZERO) THEN - u = deck_current_velocity(opts, pts(idx(kk))%pos(3), es_l, em_l) + u = deck_current_velocity(opts, pts(idx(kk))%pos, CD_ZERO, es_l, em_l) IF (es_l /= CD_HYDRO_OK) THEN CALL fail(ErrStat, ErrMsg, 'static equilibrium: current profile at point '// & TRIM(int_to_str(pts(idx(kk))%id))//': '//TRIM(em_l)); RETURN @@ -25649,6 +26316,29 @@ SUBROUTINE mask_jacobian(jm) END DO END SUBROUTINE mask_jacobian + SUBROUTINE min_norm_step(jm, step, info_s) + !! The Newton step of a solve with a CoupledPinned body, J step = -r (step holds -r on + !! entry): the minimum-norm Gauss-Newton step (J^T J + 1e-10 D) step = J^T (-r), D the + !! diagonal of J^T J floored at 1e-12 of its largest entry. Such a body may turn neutrally + !! (its lines and its CG on one axis through the node: the spin about the axis meets no + !! load, so J has that spin as a null vector); J^T r has no component along it, so the step + !! does not spin the body, where an LU solve of the near-singular J would (and the rotation + !! cap of the step would then leave the useful part of the step negligible). For a regular J + !! the step is the Newton step. + REAL(wp), INTENT(IN) :: jm(:, :) + REAL(wp), INTENT(INOUT) :: step(:) + INTEGER, INTENT(OUT) :: info_s + REAL(wp) :: nm(SIZE(step), SIZE(step)), dm + INTEGER :: ii + nm = MATMUL(TRANSPOSE(jm), jm) + step = MATMUL(TRANSPOSE(jm), step) + dm = MAX(MAXVAL([(nm(ii, ii), ii=1, SIZE(step))]), TINY(CD_ONE)) + DO ii = 1, SIZE(step) + nm(ii, ii) = nm(ii, ii) + 1.0e-10_wp*MAX(nm(ii, ii), 1.0e-12_wp*dm) + END DO + CALL CD_Solve_Dense_As_Banded(nm, step, info_s, lin_msg) + END SUBROUTINE min_norm_step + LOGICAL FUNCTION equilibrium_stable(kb) RESULT(stable) !! Whether the converged equilibrium x is statically stable: the symmetric part of the !! stiffness -dR/dx (analytic Jacobian, scaled unknowns: a congruence, so definiteness is @@ -25666,6 +26356,10 @@ LOGICAL FUNCTION equilibrium_stable(kb) RESULT(stable) ErrMsg = '' IF (.NOT. gd) RETURN s = -0.5_wp*(jtry + TRANSPOSE(jtry)) + ! a held unknown (the node translation of a CoupledPinned body) is no mode of the solve + DO ii = 1, n + IF (rmask(ii) <= CD_ZERO) s(ii, ii) = CD_ONE + END DO shift = CD_ZERO DO ii = 1, n shift = MAX(shift, ABS(s(ii, ii))) @@ -26060,8 +26754,8 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) curp%waterline_z = CD_ZERO ALLOCATE (curp%node_velocity(3, nn)) DO ii = 1, nn - curp%node_velocity(:, ii) = deck_current_velocity(opts, line_node_z(anchor, fairlead, lc(jl)%l0, ii), & - es_l, em_l) + curp%node_velocity(:, ii) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, lc(jl)%l0, ii), & + CD_ZERO, es_l, em_l) IF (es_l /= CD_HYDRO_OK) THEN CALL fail(es_out, em_out, 'current profile: '//TRIM(em_l)); RETURN END IF @@ -26073,6 +26767,7 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) curp%profile_z = opts%current_profile_z curp%profile_velocity = opts%current_profile_velocity END IF + IF (opts%has_current_grid) ALLOCATE (curp%grid, SOURCE=opts%current_grid) END IF ALLOCATE (q(3*nn)) conv = .FALSE. @@ -26511,10 +27206,12 @@ END SUBROUTINE solve_body_equilibrium SUBROUTINE CD_Init_Deck_Aggregate_Rigid6(bodies, points, opts, rt, ErrStat, ErrMsg, ptfm_init) !! Populate the opaque Rigid6 runtime for the coupled aggregate: build the body states and !! retain the deck options + points the per-step marcher needs (the aggregate keeps neither). - !! Coupled/Vessel bodies become host nodes (one per body, in deck BODY order) at their - !! reference point; ptfm_init (the host's initial platform displacement) moves them rigidly - !! with the platform (reference pose included), and the body frame in platform axes, O0 R, - !! then follows the host orientation. + !! Coupled/Vessel and CoupledPinned/VesselPinned bodies become host nodes (one per body, in + !! deck BODY order) at their reference point; ptfm_init (the host's initial platform + !! displacement) moves a Coupled body rigidly with the platform (reference pose included), and + !! the body frame in platform axes, O0 R, then follows the host orientation. A CoupledPinned + !! body takes only the position of its node and turns about it; its PtfmInit pose was set on + !! the deck body before the static solve (apply_ptfm_host_bodies). TYPE(DeckBody), INTENT(IN) :: bodies(:) TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -26535,14 +27232,14 @@ SUBROUTINE CD_Init_Deck_Aggregate_Rigid6(bodies, points, opts, rt, ErrStat, ErrM rt%host_o0(3, 3) = CD_ONE IF (PRESENT(ptfm_init)) rt%host_o0 = ptfm_zyx_dcm(ptfm_init(4:6)) mt = TRANSPOSE(rt%host_o0) - nh = COUNT(rt%rigid%is_prescribed) + nh = COUNT(rt%rigid%is_prescribed .OR. rt%rigid%is_host_pinned) ALLOCATE (rt%host_body(nh), rt%host_rrel(3, 3, nh)) k = 0 DO ib = 1, SIZE(rt%rigid) - IF (.NOT. rt%rigid(ib)%is_prescribed) CYCLE + IF (.NOT. (rt%rigid(ib)%is_prescribed .OR. rt%rigid(ib)%is_host_pinned)) CYCLE k = k + 1 rt%host_body(k) = ib - IF (PRESENT(ptfm_init)) THEN + IF (PRESENT(ptfm_init) .AND. rt%rigid(ib)%is_prescribed) THEN rt%rigid(ib)%r_ref = ptfm_init(1:3) + MATMUL(mt, rt%rigid(ib)%r_ref) rt%rigid(ib)%r = rt%rigid(ib)%r_ref rt%rigid(ib)%rot_ref = MATMUL(mt, rt%rigid(ib)%rot_ref) @@ -26556,30 +27253,40 @@ SUBROUTINE CD_Init_Deck_Aggregate_Rigid6(bodies, points, opts, rt, ErrStat, ErrM END SUBROUTINE CD_Init_Deck_Aggregate_Rigid6 PURE INTEGER FUNCTION CD_Rigid6_NHost(rt) RESULT(n) - !! Number of host-driven (Coupled/Vessel) bodies, i.e. the body host nodes (0 if unpopulated). + !! Number of host-driven (Coupled/Vessel and CoupledPinned/VesselPinned) bodies, i.e. the body + !! host nodes (0 if unpopulated). TYPE(CD_Rigid6RuntimeType), INTENT(IN) :: rt n = 0 IF (ALLOCATED(rt%host_body)) n = SIZE(rt%host_body) END FUNCTION CD_Rigid6_NHost PURE LOGICAL FUNCTION CD_Rigid6_AllHost(rt) RESULT(all_host) - !! Whether every body of the runtime is host-driven (no body is integrated). + !! Whether every body of the runtime is host-prescribed (no body is integrated; a + !! CoupledPinned body integrates its rotation). TYPE(CD_Rigid6RuntimeType), INTENT(IN) :: rt - all_host = CD_Rigid6_NBodies(rt) > 0 .AND. CD_Rigid6_NHost(rt) == CD_Rigid6_NBodies(rt) + all_host = .FALSE. + IF (CD_Rigid6_NBodies(rt) > 0) all_host = ALL(rt%rigid%is_prescribed) END FUNCTION CD_Rigid6_AllHost SUBROUTINE CD_Rigid6_SetHostKinematics(rt, position, velocity, acceleration, ErrStat, ErrMsg, orientation, & - angular_velocity, angular_acceleration) + angular_velocity, angular_acceleration, step_start) !! Impose the host node kinematics (reference-point position/velocity/acceleration, the host !! orientation and angular rates, all global; arrays shaped (3[,3], NHost)) on every !! Coupled/Vessel body: R = O^T (O0 R0). Without an orientation the Init orientation is held; - !! without angular rates they are zero. Validates every shape before any change. + !! without angular rates they are zero. A CoupledPinned body takes the node translation as + !! the motion of its reference point and ignores the orientation and angular rates: it keeps + !! its own rotation (body_snap_pinned). Validates every shape before any change. + !! + !! step_start: the kinematics are those of the committed time (a transfer that does not + !! advance), not the t + dt input of a coming step; the next step of a CoupledPinned body + !! then starts from them (RigidBodyState%pin0). Default .FALSE. TYPE(CD_Rigid6RuntimeType), INTENT(INOUT) :: rt REAL(wp), INTENT(IN) :: position(:, :), velocity(:, :), acceleration(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(IN), OPTIONAL :: orientation(:, :, :) REAL(wp), INTENT(IN), OPTIONAL :: angular_velocity(:, :), angular_acceleration(:, :) + LOGICAL, INTENT(IN), OPTIONAL :: step_start INTEGER :: k, ib, nh REAL(wp) :: o(3, 3) @@ -26608,6 +27315,16 @@ SUBROUTINE CD_Rigid6_SetHostKinematics(rt, position, velocity, acceleration, Err END IF DO k = 1, nh ib = rt%host_body(k) + IF (rt%rigid(ib)%is_host_pinned) THEN + rt%rigid(ib)%pin = position(:, k) + rt%rigid(ib)%pin_v = velocity(:, k) + rt%rigid(ib)%pin_a = acceleration(:, k) + CALL body_snap_pinned(rt%rigid(ib)) + IF (PRESENT(step_start)) THEN + IF (step_start) CALL set_body_pin_start(rt%rigid(ib)) + END IF + CYCLE + END IF o = rt%host_o0 IF (PRESENT(orientation)) o = orientation(:, :, k) rt%rigid(ib)%rot_mat = MATMUL(TRANSPOSE(o), rt%host_rrel(:, :, k)) @@ -26628,7 +27345,9 @@ END SUBROUTINE CD_Rigid6_SetHostKinematics SUBROUTINE CD_Rigid6_GetHostKinematics(rt, k, position, velocity, acceleration, orientation, angular_velocity, & angular_acceleration) !! The committed kinematics of host node k (the k-th Coupled/Vessel body's reference point) - !! and the host orientation O = (O0 R0) R^T it implies. + !! and the host orientation O = (O0 R0) R^T it implies. A CoupledPinned body implies no host + !! orientation or angular rates: its node reports the Init orientation and zero rates, which + !! CD_Rigid6_SetHostKinematics ignores for it. TYPE(CD_Rigid6RuntimeType), INTENT(IN) :: rt INTEGER, INTENT(IN) :: k REAL(wp), INTENT(OUT) :: position(3), velocity(3), acceleration(3), orientation(3, 3) @@ -26652,6 +27371,10 @@ SUBROUTINE CD_Rigid6_GetHostKinematics(rt, k, position, velocity, acceleration, position = rt%rigid(ib)%r velocity = rt%rigid(ib)%v acceleration = rt%rigid(ib)%a + IF (rt%rigid(ib)%is_host_pinned) THEN + orientation = rt%host_o0 + RETURN + END IF orientation = MATMUL(rt%host_rrel(:, :, k), TRANSPOSE(rt%rigid(ib)%rot_mat)) angular_velocity = rt%rigid(ib)%omega angular_acceleration = rt%rigid(ib)%alpha @@ -26690,16 +27413,28 @@ SUBROUTINE CD_Rigid6_HostWrench(system, rt, loads, k, force, moment, ErrStat, Er !! seabed contact and external loads -- the loads rigid6_body_acceleration integrates for a !! free body -- minus the rigid-body and added-mass inertia M a (CG offset, velocity and !! gyroscopic terms included) at the host-prescribed acceleration. - TYPE(CD_SystemType), INTENT(IN) :: system - TYPE(CD_Rigid6RuntimeType), INTENT(IN) :: rt + !! + !! A CoupledPinned body returns a force and no moment (MoorDyn-F's coupled pinned body): the + !! load it exerts on its node, its net load less its inertia, F - (m + m_a) a_p + !! - m (alpha x c + w x (w x c)) for the CG at c (pin_load of rigid_coupled_acceleration). As + !! for a CoupledPinned rod (CD_Rod_HostWrench) the node acceleration a_p is the reference-point + !! acceleration of the body state (the host's, an output probe's included), the rotation and + !! angular velocity are the committed ones, the angular acceleration is solved again for a_p + !! (rigid6_body_acceleration at dt = 0), and the attached lines' end-node inertia moves to the + !! re-solved end accelerations with their coupled mass block at a frozen interior. The force + !! thereby depends on the checkpointed body state and the line states only. + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(CD_Rigid6RuntimeType), INTENT(INOUT) :: rt REAL(wp), INTENT(IN) :: loads(:, :) INTEGER, INTENT(IN) :: k REAL(wp), INTENT(OUT) :: force(3), moment(3) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: ib, ip, pidx, base, j + INTEGER :: ib, ip, pidx, base, j, n, es REAL(wp) :: f_env(3), mass_eff, drag3(3, 3), f_h(3), m_h(3), cg6(6, 6), f_bias(3), m_bias(3) REAL(wp) :: f_sb(3), m_sb(3), load_dv(6, 6), f_ext(3), arm(3), ig(3, 3), m6(6, 6), acc6(6), w6(6) + REAL(wp) :: acc(3), alpha(3) + CHARACTER(1024) :: em force = CD_ZERO moment = CD_ZERO @@ -26709,6 +27444,27 @@ SUBROUTINE CD_Rigid6_HostWrench(system, rt, loads, k, force, moment, ErrStat, Er CALL fail(ErrStat, ErrMsg, 'CD_Rigid6_HostWrench: host node index out of range'); RETURN END IF ib = rt%host_body(k) + IF (rt%rigid(ib)%is_host_pinned) THEN + n = system%n_system_coupled_dof + IF (3*SIZE(loads, 2) /= n .OR. SIZE(loads, 1) /= 3) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Rigid6_HostWrench: load array does not cover the coupled points'); RETURN + END IF + ! the step workspace serves as scratch between steps (a step refills it before use) + CALL ensure_rigid_step_workspace(rt%work, n, SIZE(rt%rigid), SIZE(system%points)) + rt%work%loads(1:n) = RESHAPE(loads, [n]) + CALL CD_Get_System_CoupledMotion(system, rt%work%q(1:n), rt%work%v(1:n), rt%work%a(1:n), es, em) + ! the end-node inertia moves with the line interior held (an output evaluation keeps the + ! committed interior state, accelerations included) + IF (es == CD_SYSTEM_OK) CALL CD_Calc_System_CoupledAccelDerivative(system, rt%work%dload_da, es, em, & + frozen_interior=.TRUE.) + IF (es /= CD_SYSTEM_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'CD_Rigid6_HostWrench: pinned-body line query failed: '//TRIM(em)); RETURN + END IF + CALL rigid6_body_acceleration(system, rt%points, rt%opts, rt%rigid(ib), CD_ZERO, CD_ZERO, & + [CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO], rt%work, ib, acc, & + alpha, ErrStat, ErrMsg, pin_load=force) + RETURN + END IF CALL rigid6_environment_force(rt%rigid(ib), rt%opts, CD_ZERO, f_env, mass_eff, drag3, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL rigid6_hydrostatics(rt%rigid(ib), rt%opts, CD_ZERO, f_h, m_h, ErrStat, ErrMsg) @@ -26760,6 +27516,84 @@ SUBROUTINE CD_Rigid6_Unstage(rt) IF (ALLOCATED(rt%stage_rigid)) rt%rigid = rt%stage_rigid END SUBROUTINE CD_Rigid6_Unstage + SUBROUTINE CD_Rigid6_StartAccelerations(system, rt, ErrStat, ErrMsg, pinned) + !! Solve the accelerations of every integrated (Free and CoupledPinned) body at the current + !! state, as the start of the first step does (rigid_start_accelerations from the current line + !! loads; a CoupledPinned body with its node at its step-start pose, pin0), and mark them + !! committed. The aggregate calls it at Init and at a transfer of the step-start host + !! kinematics before the first step, so the state mirror carries the start accelerations from + !! t = 0: a mirror restore (the OpenFAST shell restores it after every CalcOutput) marks the + !! accelerations committed, and the first step would otherwise start from zero. Only the + !! accelerations change; the state is solved on a copy. pinned: a CoupledPinned body was + !! solved (its line ends then move with it). + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(CD_Rigid6RuntimeType), INTENT(INOUT) :: rt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(OUT), OPTIONAL :: pinned + TYPE(RigidBodyState), ALLOCATABLE :: trial(:) + REAL(wp), ALLOCATABLE :: hk(:, :) + INTEGER :: ib + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (PRESENT(pinned)) pinned = .FALSE. + IF (.NOT. ALLOCATED(rt%rigid)) RETURN + IF (PRESENT(pinned)) pinned = ANY(rt%rigid%is_host_pinned) + IF (ALL(rt%rigid%is_prescribed)) RETURN + trial = rt%rigid + DO ib = 1, SIZE(trial) + IF (.NOT. trial(ib)%is_prescribed) trial(ib)%accel_valid = .FALSE. + END DO + CALL save_host_end_rigid(trial, hk) + CALL interp_host_body_pins(trial, hk, CD_ZERO) + CALL rigid_start_accelerations(system, rt%points, rt%opts, trial, CD_ZERO, rt%work, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO ib = 1, SIZE(trial) + IF (rt%rigid(ib)%is_prescribed) CYCLE + rt%rigid(ib)%a = trial(ib)%a + rt%rigid(ib)%alpha = trial(ib)%alpha + rt%rigid(ib)%accel_valid = .TRUE. + END DO + END SUBROUTINE CD_Rigid6_StartAccelerations + + SUBROUTINE CD_Rod_StartAccelerations(system, rt, ErrStat, ErrMsg, pinned) + !! Rod twin of CD_Rigid6_StartAccelerations for the Free, Pinned and CoupledPinned rods + !! (rod_start_accelerations; a CoupledPinned rod with its pin at its step-start pose, pin0, as + !! the first step of step_rod_system takes it). A pinned rod keeps its centre acceleration of + !! that pose with the solved angular one, consistent with its committed End A motion. pinned: + !! a CoupledPinned rod was solved. + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(CD_RodRuntimeType), INTENT(INOUT) :: rt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(OUT), OPTIONAL :: pinned + TYPE(RodState), ALLOCATABLE :: trial(:) + REAL(wp), ALLOCATABLE :: hk(:, :) + INTEGER :: ir + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (PRESENT(pinned)) pinned = .FALSE. + IF (.NOT. ALLOCATED(rt%rods)) RETURN + IF (PRESENT(pinned)) pinned = ANY(rt%rods%is_host_pinned) + IF (.NOT. ANY(rt%rods%is_free .OR. rt%rods%is_pinned)) RETURN + trial = rt%rods + DO ir = 1, SIZE(trial) + IF (trial(ir)%is_free .OR. trial(ir)%is_pinned) trial(ir)%accel_valid = .FALSE. + END DO + CALL save_host_end_rod(trial, hk) + CALL interp_host_pins(trial, hk, CD_ZERO) + CALL rod_start_accelerations(system, rt%points, rt%opts, trial, CD_ZERO, rt%work, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO ir = 1, SIZE(trial) + IF (.NOT. (trial(ir)%is_free .OR. trial(ir)%is_pinned)) CYCLE + rt%rods(ir)%a = trial(ir)%a + rt%rods(ir)%alpha = trial(ir)%alpha + rt%rods(ir)%accel_valid = .TRUE. + END DO + END SUBROUTINE CD_Rod_StartAccelerations + SUBROUTINE CD_Step_Aggregate_Rigid6(system, rt, time, dt, converged, stalled, n_iter, ErrStat, ErrMsg, host_mask, & host_q, host_v, host_a, interp_hosts) !! Advance the aggregate's Rigid6 bodies one mooring step over its EI=0 system (flat seabed; @@ -27386,7 +28220,7 @@ SUBROUTINE CD_Deck_Fluid_Probe(deck_path, pos, times, eta, vel, acc, ErrStat, Er CALL deck_wave_kinematics(opts, pos(1, i), pos(2, i), pos(3, i), times(i), eta(i), vel(:, i), acc(:, i), & ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN - vel(:, i) = vel(:, i) + deck_current_velocity(opts, pos(3, i), ErrStat, ErrMsg) + vel(:, i) = vel(:, i) + deck_current_velocity(opts, pos(:, i), times(i), ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO END SUBROUTINE CD_Deck_Fluid_Probe @@ -27692,6 +28526,15 @@ SUBROUTINE CD_Rigid6_Set_States(rt, states, ErrStat, ErrMsg) rt%rigid(ib)%rot_mat = RESHAPE(states(k + 16:k + 24), [3, 3]) rt%rigid(ib)%eta = CD_Log_SO3(MATMUL(rt%rigid(ib)%rot_mat, TRANSPOSE(rt%rigid(ib)%rot_ref))) rt%rigid(ib)%accel_valid = .TRUE. + ! A CoupledPinned body's node is its reference point, whose motion the mirror carries: the + ! pin and the step-start pin are that motion, as the continuing run has them (the pin is + ! replaced by the host transfer before the next step or output evaluation). + IF (rt%rigid(ib)%is_host_pinned) THEN + rt%rigid(ib)%pin = rt%rigid(ib)%r + rt%rigid(ib)%pin_v = rt%rigid(ib)%v + rt%rigid(ib)%pin_a = rt%rigid(ib)%a + CALL set_body_pin_start(rt%rigid(ib)) + END IF END DO END SUBROUTINE CD_Rigid6_Set_States @@ -27699,7 +28542,8 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, work, bathymetry, host_mask, host_q, host_v, host_a, host_start) !! Advance Rigid6 bodies and lines from time - dt to time: step_rigid6_once, sub-cycled so !! that the explicit central-difference body position resolves the stiffest body-mooring - !! mode (rigid_substep_count). converged is the AND and stalled the OR over the sub-steps. + !! mode and the swing of a CoupledPinned body about its node (rigid_substep_count). converged + !! is the AND and stalled the OR over the sub-steps. TYPE(CD_SystemType), INTENT(INOUT) :: system TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -27718,12 +28562,13 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, LOGICAL, INTENT(IN), OPTIONAL :: host_mask(:) REAL(wp), INTENT(IN), OPTIONAL :: host_q(:), host_v(:), host_a(:) ! host_start: the step-start state of the host-driven (is_prescribed) bodies, which hold their - ! t + dt pose on entry; sub-steps then move them along the interpolated host path + ! t + dt pose on entry; sub-steps then move them along the interpolated host path (a + ! host-pinned body carries its step-start pin itself, RigidBodyState%pin0) TYPE(RigidBodyState), INTENT(IN), OPTIONAL :: host_start(:) REAL(wp), ALLOCATABLE :: q0h(:), v0h(:), a0h(:) INTEGER :: ib, ip, nsub, isub, it REAL(wp), ALLOCATABLE :: hk_end(:, :) - LOGICAL :: conv_s, stall_s + LOGICAL :: conv_s, stall_s, host_pins REAL(wp) :: omega2, mass6(6), k6c(6) converged = .TRUE. @@ -27739,12 +28584,22 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, att_base(ip) = system_point_base(system, points(rigid(ib)%point_indices(ip))%id) att_arm(:, ip) = MATMUL(rigid(ib)%rot_mat, points(rigid(ib)%point_indices(ip))%body_offset) END DO - ! structural mass and inertia plus the submerged body's translational added mass - mass6(1:3) = rigid(ib)%mass - IF (rigid(ib)%r(3) < CD_ZERO) mass6(1:3) = mass6(1:3) + opts%rhoW*rigid(ib)%vol*MAX(CD_ZERO, rigid(ib)%ca) - mass6(4:6) = global_inertia_diag(rigid(ib)%rot_mat, rigid(ib)%inertia) - ! hydrostatic restoring plus the seabed contact that acts within the step - k6c = [CD_ZERO, CD_ZERO, rigid(ib)%c33, rigid(ib)%c44, rigid(ib)%c55, CD_ZERO] + IF (rigid(ib)%is_host_pinned) THEN + ! a host-pinned body only turns about its reference point: its line ends act through + ! their arms on its rotational inertia about the pin (the translational entries stay + ! zero, so rigid_omega2_estimate skips them), and its weight, buoyancy and pin + ! acceleration make it a compound pendulum (pinned_body_estimate_terms) + CALL pinned_body_estimate_terms(rigid(ib), opts, time - dt, mass6, k6c, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + ELSE + ! structural mass and inertia plus the submerged body's translational added mass + mass6(1:3) = rigid(ib)%mass + IF (rigid(ib)%r(3) < CD_ZERO) mass6(1:3) = mass6(1:3) + opts%rhoW*rigid(ib)%vol*MAX(CD_ZERO, rigid(ib)%ca) + mass6(4:6) = global_inertia_diag(rigid(ib)%rot_mat, rigid(ib)%inertia) + ! hydrostatic restoring + k6c = [CD_ZERO, CD_ZERO, rigid(ib)%c33, rigid(ib)%c44, rigid(ib)%c55, CD_ZERO] + END IF + ! plus the seabed contact that acts within the step CALL rigid6_contact_stiffness(rigid(ib), opts, time - dt, dt, k6c, ErrStat, ErrMsg, bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN omega2 = MAX(omega2, rigid_omega2_estimate(system, att_base, att_arm, mass6, k6c)) @@ -27753,10 +28608,23 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, nsub = rigid_substep_count(omega2, dt) CALL host_substep_start(system, nsub, q0h, v0h, a0h, ErrStat, ErrMsg, host_mask) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! A host-pinned body without a committed acceleration (the first step) takes its starting + ! acceleration with its pin at the step start: the host has already placed the pin at + ! t + dt, so the bodies go back to their step-start pin (pin0) for it, together with every + ! other body without one, and return to t + dt after it (see step_rod_system). + host_pins = ANY(rigid%is_host_pinned) + IF (ANY(rigid%is_host_pinned .AND. .NOT. rigid%accel_valid)) THEN + CALL save_host_end_rigid(rigid, hk_end) + CALL interp_host_body_pins(rigid, hk_end, CD_ZERO) + CALL rigid_start_accelerations(system, points, opts, rigid, time - dt, work, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL interp_host_body_pins(rigid, hk_end, CD_ONE) + END IF DO isub = 1, nsub - IF (nsub > 1 .AND. PRESENT(host_start)) THEN + IF (nsub > 1 .AND. (PRESENT(host_start) .OR. host_pins)) THEN IF (isub == 1) CALL save_host_end_rigid(rigid, hk_end) - CALL interp_host_rigid(rigid, host_start, hk_end, REAL(isub, wp)/REAL(nsub, wp)) + IF (PRESENT(host_start)) CALL interp_host_rigid(rigid, host_start, hk_end, REAL(isub, wp)/REAL(nsub, wp)) + IF (host_pins) CALL interp_host_body_pins(rigid, hk_end, REAL(isub, wp)/REAL(nsub, wp)) END IF IF (.NOT. PRESENT(host_mask)) THEN CALL step_rigid6_once(system, points, opts, rigid, time - dt + REAL(isub, wp)*dt/REAL(nsub, wp), & @@ -27777,6 +28645,10 @@ SUBROUTINE step_rigid6_system(system, points, opts, rigid, time, dt, converged, n_iter = n_iter + it IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO + ! the committed pin of a host-pinned body starts its next step + DO ib = 1, SIZE(rigid) + IF (rigid(ib)%is_host_pinned) CALL set_body_pin_start(rigid(ib)) + END DO END SUBROUTINE step_rigid6_system SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & @@ -27795,7 +28667,9 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st !! never displaced from the positions the lines were solved with. Position-dependent body !! loads (hydrostatic restoring, seabed springs) act explicitly: stable for !! dt*SQRT(k/m) < 2. The Body point records are finally set to the corrected motion (the - !! same map a checkpoint restore applies). + !! same map a checkpoint restore applies). A host-pinned (CoupledPinned) body advances its + !! rotation only: its reference point follows the host node (body_snap_pinned) and the + !! corrector solves its angular acceleration about it. TYPE(CD_SystemType), INTENT(INOUT) :: system TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -27834,22 +28708,8 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st END DO ! 0. a body without a committed acceleration (the first step) gets the instantaneous one ! from the current line loads, so the predictor starts from the actual a_0 - IF (.NOT. ALL(rigid%accel_valid)) THEN - CALL rigid_start_loads(system, work%q(1:system%n_system_coupled_dof), work%v(1:system%n_system_coupled_dof), & - work%a(1:system%n_system_coupled_dof), work%loads(1:system%n_system_coupled_dof), & - work%dload_da, ErrStat, ErrMsg) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - DO ib = 1, SIZE(rigid) - IF (rigid(ib)%accel_valid) CYCLE - CALL rigid6_body_acceleration(system, points, opts, rigid(ib), time - dt, CD_ZERO, & - [CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO], work, ib, & - acc, alpha, ErrStat, ErrMsg, bathymetry) - IF (ErrStat /= CD_DECKDRV_OK) RETURN - rigid(ib)%a = acc - rigid(ib)%alpha = alpha - rigid(ib)%accel_valid = .TRUE. - END DO - END IF + CALL rigid_start_accelerations(system, points, opts, rigid, time - dt, work, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN work%old_rigid = rigid work%old_points = system%points CALL CD_Get_System_CoupledMotion(system, work%q(1:system%n_system_coupled_dof), & @@ -27863,7 +28723,8 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st CALL overlay_host_motion(work%q(1:system%n_system_coupled_dof), work%v(1:system%n_system_coupled_dof), & work%a(1:system%n_system_coupled_dof), host_mask, host_q, host_v, host_a) ! 1. predictor (previous acceleration held) and the line step to t + dt; a host-driven - ! body already carries its t + dt state + ! body already carries its t + dt state, and a host-pinned body advances its rotation only + ! (its reference point stays on the t + dt pin the host has placed) DO ib = 1, SIZE(rigid) IF (rigid(ib)%is_prescribed) CYCLE CALL CD_Rigid_Advance_Newmark(rigid(ib)%r, rigid(ib)%v, rigid(ib)%rot_mat, rigid(ib)%omega, rigid(ib)%a, & @@ -27875,6 +28736,7 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st ErrMsg = 'CableDyn_DeckDriver: Rigid6 finite-rotation update failed: '//TRIM(em) RETURN END IF + CALL body_snap_pinned(rigid(ib)) rigid(ib)%eta = CD_Log_SO3(MATMUL(rigid(ib)%rot_mat, TRANSPOSE(rigid(ib)%rot_ref))) END DO CALL scatter_rigid6_point_motion(system, points, rigid, work%q(1:system%n_system_coupled_dof), & @@ -27934,6 +28796,8 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st END IF DO ib = 1, SIZE(rigid) IF (rigid(ib)%is_prescribed) CYCLE + ! (a host-pinned body: old_rigid%a is the t + dt pin acceleration, so the translational + ! velocity change dv0 + gamma dt a_p of the reduced solve is zero, as it is) dv0(1:3) = -CD_RIGID_NEWMARK_GAMMA*dt*work%old_rigid(ib)%a dv0(4:6) = -CD_RIGID_NEWMARK_GAMMA*dt*work%old_rigid(ib)%alpha CALL rigid6_body_acceleration(system, points, opts, rigid(ib), time, dt, dv0, work, ib, acc, alpha, & @@ -27957,6 +28821,7 @@ SUBROUTINE step_rigid6_once(system, points, opts, rigid, time, dt, converged, st END IF rigid(ib)%a = acc rigid(ib)%alpha = alpha + CALL body_snap_pinned(rigid(ib)) rigid(ib)%eta = CD_Log_SO3(MATMUL(rigid(ib)%rot_mat, TRANSPOSE(rigid(ib)%rot_ref))) END DO ! the Body point records follow the corrected bodies @@ -27996,13 +28861,56 @@ SUBROUTINE rigid_start_loads(system, q, v, a, loads, dload_da, ErrStat, ErrMsg) END IF END SUBROUTINE rigid_start_loads + SUBROUTINE rigid_start_accelerations(system, points, opts, rigid, time, work, ErrStat, ErrMsg, bathymetry) + !! The instantaneous acceleration of every Rigid6 body without a committed one (the first + !! step) from the current line loads at time, so the predictor starts from the actual a_0 + !! (rigid6_body_acceleration at dt = 0; a host-pinned body keeps its pin acceleration and + !! solves its angular one). + TYPE(CD_SystemType), INTENT(INOUT) :: system + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckOptions), INTENT(IN) :: opts + TYPE(RigidBodyState), INTENT(INOUT) :: rigid(:) + REAL(wp), INTENT(IN) :: time + TYPE(RigidStepWorkspace), INTENT(INOUT) :: work + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: ib + REAL(wp) :: acc(3), alpha(3) + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (ALL(rigid%accel_valid)) RETURN + CALL ensure_rigid_step_workspace(work, system%n_system_coupled_dof, SIZE(rigid), SIZE(system%points)) + CALL rigid_start_loads(system, work%q(1:system%n_system_coupled_dof), work%v(1:system%n_system_coupled_dof), & + work%a(1:system%n_system_coupled_dof), work%loads(1:system%n_system_coupled_dof), & + work%dload_da, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + DO ib = 1, SIZE(rigid) + IF (rigid(ib)%accel_valid) CYCLE + CALL rigid6_body_acceleration(system, points, opts, rigid(ib), time, CD_ZERO, & + [CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO, CD_ZERO], work, ib, & + acc, alpha, ErrStat, ErrMsg, bathymetry) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + rigid(ib)%a = acc + rigid(ib)%alpha = alpha + rigid(ib)%accel_valid = .TRUE. + END DO + END SUBROUTINE rigid_start_accelerations + SUBROUTINE rigid6_body_acceleration(system, points, opts, body, time, dt, dv0, work, ib, acc, alpha, & - ErrStat, ErrMsg, bathymetry) + ErrStat, ErrMsg, bathymetry, pin_load) !! The acceleration of Rigid6 body ib at its current state and time from every body load !! and the line loads in work%loads (evaluated with the attachment accelerations work%a, !! end-node inertia derivative work%dload_da): rigid_coupled_acceleration with the step dt !! and velocity offset dv0 (dt = 0, dv0 = 0: the instantaneous acceleration). Stores the - !! environment force and effective mass in work%f_env(:, ib) / work%mass_eff(ib). + !! environment force and effective mass in work%f_env(:, ib) / work%mass_eff(ib). A + !! host-pinned body turns about its reference point, which moves with body%a (the host's pin + !! acceleration): acc = body%a, and alpha solves the moment equation about the pin, + !! M_rr alpha = M_ext - M_rt a_p - w x (I_p w), + !! with M_rr = R J R^T - m [c]x [c]x plus the line end-node inertia through the arms (I_p the + !! inertia about the pin) and M_rt = m [c]x for the CG at c = R cg (MoorDyn-F's + !! M(4:6,4:6) a(4:6) = F(4:6) - M(4:6,1:3) a(1:3)). TYPE(CD_SystemType), INTENT(IN) :: system TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -28014,6 +28922,8 @@ SUBROUTINE rigid6_body_acceleration(system, points, opts, body, time, dt, dv0, w INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + ! pin_load (a host-pinned body): the force the body exerts on its node (rigid_coupled_acceleration) + REAL(wp), INTENT(OUT), OPTIONAL :: pin_load(3) ! Rigid6 added mass is the isotropic translational rhoW*phi*Vol*Ca already folded into ! mass_eff (MoorDyn Body semantics: no rotational added inertia); body%inertia is about the CG. @@ -28065,9 +28975,16 @@ SUBROUTINE rigid6_body_acceleration(system, points, opts, body, time, dt, dv0, w f_body = f_body + f_attach m_global = m_global + cross3(arm, f_attach) END DO - CALL rigid_coupled_acceleration(work%dload_da, dt, work%a(1:system%n_system_coupled_dof), att_base, att_arm, & - work%mass_eff(ib), cg6, body%inertia, body%rot_mat, body%omega, & - f_body, m_global, dv0, load_dv, acc, alpha, ErrStat, ErrMsg) + IF (body%is_host_pinned) THEN + CALL rigid_coupled_acceleration(work%dload_da, dt, work%a(1:system%n_system_coupled_dof), att_base, att_arm, & + work%mass_eff(ib), cg6, body%inertia, body%rot_mat, body%omega, & + f_body, m_global, dv0, load_dv, acc, alpha, ErrStat, ErrMsg, & + pin_arm=[CD_ZERO, CD_ZERO, CD_ZERO], pin_acc=body%a, pin_load=pin_load) + ELSE + CALL rigid_coupled_acceleration(work%dload_da, dt, work%a(1:system%n_system_coupled_dof), att_base, att_arm, & + work%mass_eff(ib), cg6, body%inertia, body%rot_mat, body%omega, & + f_body, m_global, dv0, load_dv, acc, alpha, ErrStat, ErrMsg) + END IF END SUBROUTINE rigid6_body_acceleration SUBROUTINE step_prescribed_rigid6_system(system, points, opts, motion, rigid, time_index, time, dt, converged, & @@ -28776,7 +29693,7 @@ SUBROUTINE rigid6_environment_force(body, opts, time, force, effective_mass, dra END IF END IF IF (opts%has_current) THEN - fluid_velocity = fluid_velocity + deck_current_velocity(opts, body%r(3), es, em) + fluid_velocity = fluid_velocity + deck_current_velocity(opts, body%r, time, es, em) IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_DECKDRV_BADINPUT ErrMsg = 'CableDyn_DeckDriver: Rigid6 current profile failed: '//TRIM(em) @@ -29271,7 +30188,7 @@ SUBROUTINE update_hermite_deck_fluid(cables, opts, time, ErrStat, ErrMsg) fv = CD_ZERO; fa = CD_ZERO; wl = CD_ZERO DO j = 1, nn IF (opts%has_current) THEN - fv(:, j) = deck_current_velocity(opts, xyz(3, j), es, em_k) + fv(:, j) = deck_current_velocity(opts, xyz(:, j), time, es, em_k) IF (es /= CD_HYDRO_OK) THEN CALL hermite_fluid_fail('current profile', em_k); RETURN END IF @@ -29699,11 +30616,11 @@ SUBROUTINE write_finite_dynamic_out(out_root, channels, lines, points, opts, mod 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, z, ErrStat, ErrMsg) RESULT(velocity) - !! Return the deck current velocity at elevation z, with two-point profile - !! interpolation when a profile current is active. + 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. TYPE(DeckOptions), INTENT(IN) :: opts - REAL(wp), INTENT(IN) :: z + REAL(wp), INTENT(IN) :: pos(3), time INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: velocity(3) @@ -29712,24 +30629,40 @@ FUNCTION deck_current_velocity(opts, z, ErrStat, ErrMsg) RESULT(velocity) ErrMsg = '' IF (.NOT. opts%has_current) THEN velocity = CD_ZERO + ELSE IF (opts%has_current_grid) THEN + CALL CD_Current_Grid_Velocity(opts%current_grid, pos, time, velocity, ErrStat, ErrMsg) ELSE IF (.NOT. opts%has_current_profile) THEN velocity = opts%current_velocity ELSE - CALL CD_Current_Profile_Velocity(z, opts%current_profile_z, opts%current_profile_velocity, & + CALL CD_Current_Profile_Velocity(pos(3), opts%current_profile_z, opts%current_profile_velocity, & velocity, ErrStat, ErrMsg) END IF END FUNCTION deck_current_velocity - PURE REAL(wp) FUNCTION line_node_z(anchor, fairlead, l0, node_id) RESULT(z) - !! Straight-line elevation estimate for initial environment fields before + PURE LOGICAL FUNCTION current_grid_varies_in_time(grid) RESULT(varies) + !! Whether a current grid holds a sample that differs from its t = 0 sample. + TYPE(CD_CurrentGridType), INTENT(IN) :: grid + INTEGER :: n + varies = .FALSE. + DO n = 2, grid%nt + IF (ANY(ABS(grid%velocity(:, :, :, :, n) - grid%velocity(:, :, :, :, 1)) > CD_ZERO)) THEN + varies = .TRUE. + RETURN + END IF + END DO + END FUNCTION current_grid_varies_in_time + + PURE FUNCTION line_node_pos(anchor, fairlead, l0, node_id) RESULT(x) + !! Straight-line position estimate for initial environment fields before !! the persistent line model exposes its static equilibrium state. REAL(wp), INTENT(IN) :: anchor(3), fairlead(3), l0(:) INTEGER, INTENT(IN) :: node_id + REAL(wp) :: x(3) REAL(wp) :: total, s total = SUM(l0) IF (total <= CD_ZERO) THEN - z = anchor(3) + x = anchor RETURN END IF IF (node_id <= 1) THEN @@ -29739,8 +30672,8 @@ PURE REAL(wp) FUNCTION line_node_z(anchor, fairlead, l0, node_id) RESULT(z) ELSE s = SUM(l0(1:node_id - 1)) END IF - z = anchor(3) + (fairlead(3) - anchor(3))*s/total - END FUNCTION line_node_z + x = anchor + (fairlead - anchor)*s/total + END FUNCTION line_node_pos SUBROUTINE deck_wave_kinematics(opts, x, y, z, time, eta, velocity, acceleration, ErrStat, ErrMsg, pdyn) !! Dispatch the active deck wave model to the hydro kinematics primitive. During the @@ -30262,7 +31195,7 @@ SUBROUTINE update_system_point_hydro(system, points, opts, time, work, ErrStat, DO i = 1, SIZE(points) IF (opts%has_current) THEN work%fluid_velocity(:, i) = work%fluid_velocity(:, i) + & - deck_current_velocity(opts, system%points(i)%q(3), es, em) + deck_current_velocity(opts, system%points(i)%q(1:3), time, es, em) IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_DECKDRV_BADINPUT ErrMsg = 'CableDyn_DeckDriver: point current profile failed: '//TRIM(em) @@ -30369,7 +31302,8 @@ SUBROUTINE update_system_line_hydro(system, opts, time, work, ErrStat, ErrMsg, i END IF work%fluid_velocity(:, j) = wave_velocity IF (opts%has_current) THEN - work%fluid_velocity(:, j) = work%fluid_velocity(:, j) + deck_current_velocity(opts, work%q(3*j), es, em) + work%fluid_velocity(:, j) = work%fluid_velocity(:, j) + & + deck_current_velocity(opts, work%q(3*j - 2:3*j), time, es, em) IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_DECKDRV_BADINPUT ErrMsg = 'CableDyn_DeckDriver: system-line current profile failed: '//TRIM(em) @@ -30465,7 +31399,8 @@ SUBROUTINE update_wave_models(models, opts, time, work, ErrStat, ErrMsg, initial work%waterline(j) = eta work%fluid_velocity(:, j) = wave_velocity IF (opts%has_current) THEN - work%fluid_velocity(:, j) = work%fluid_velocity(:, j) + deck_current_velocity(opts, work%q(3*j), es, em) + work%fluid_velocity(:, j) = work%fluid_velocity(:, j) + & + deck_current_velocity(opts, work%q(3*j - 2:3*j), time, es, em) IF (es /= CD_HYDRO_OK) THEN ErrStat = CD_DECKDRV_BADINPUT ErrMsg = 'CableDyn_DeckDriver: model current profile failed: '//TRIM(em) @@ -36470,21 +37405,53 @@ SUBROUTINE apply_ptfm_init(points, ptfm_init) END SUBROUTINE apply_ptfm_init SUBROUTINE apply_ptfm_host_bodies(bodies, points, ptfm_init) - !! Rigid-transform the Body attachment points of every Coupled/Vessel BODY by the initial - !! platform displacement (the body pose itself moves in CD_Init_Deck_Aggregate_Rigid6). - TYPE(DeckBody), INTENT(IN) :: bodies(:) + !! Rigid-transform the Body attachment points of every Coupled/Vessel and CoupledPinned BODY + !! by the initial platform displacement (the pose of a Coupled body moves in + !! CD_Init_Deck_Aggregate_Rigid6). The pose of a CoupledPinned body moves here, before the + !! static solve turns it about its node: its reference point to r + M^T p and its orientation + !! to M^T R (MoorDyn-F also turns a coupled pinned body with PtfmInit), written back as the + !! deck's x-y'-z'' angles (body_rotation_angles). + TYPE(DeckBody), INTENT(INOUT) :: bodies(:) TYPE(DeckPoint), INTENT(INOUT) :: points(:) REAL(wp), INTENT(IN) :: ptfm_init(6) INTEGER :: i, j + REAL(wp) :: dcm(3, 3) + dcm = ptfm_zyx_dcm(ptfm_init(4:6)) DO i = 1, SIZE(bodies) - IF (.NOT. bodies(i)%host_coupled) CYCLE + IF (.NOT. (bodies(i)%host_coupled .OR. bodies(i)%host_pinned)) CYCLE DO j = 1, SIZE(points) IF (points(j)%body_id == bodies(i)%id .AND. starts_with(TRIM(points(j)%ptype), 'body')) & CALL apply_ptfm_point(points(j), ptfm_init) END DO + IF (.NOT. bodies(i)%host_pinned) CYCLE + bodies(i)%pos = ptfm_init(1:3) + MATMUL(TRANSPOSE(dcm), bodies(i)%pos) + bodies(i)%rot = body_rotation_angles(MATMUL(TRANSPOSE(dcm), CD_Body_Rotation(bodies(i)%rot(1), & + bodies(i)%rot(2), & + bodies(i)%rot(3)))) END DO END SUBROUTINE apply_ptfm_host_bodies + PURE FUNCTION body_rotation_angles(rot) RESULT(ang) + !! The deck angles [deg] of a body rotation, the inverse of CD_Body_Rotation: for + !! R = Rx(a) Ry(b) Rz(c), R13 = sin b, (R23, R33) = cos b (-sin a, cos a) and + !! (R12, R11) = cos b (-sin c, cos c); at cos b = 0 only a + c (b = 90 deg) or a - c (b = -90 + !! deg) is defined, taken with c = 0 from R32 = sin a, R22 = cos a. + REAL(wp), INTENT(IN) :: rot(3, 3) + REAL(wp) :: ang(3) + REAL(wp), PARAMETER :: R2D = 180.0_wp/3.14159265358979323846264338327950288_wp + REAL(wp) :: sb + sb = MAX(-CD_ONE, MIN(CD_ONE, rot(1, 3))) + ang(2) = ASIN(sb) + IF (SQRT(rot(2, 3)**2 + rot(3, 3)**2) > 1.0e-12_wp) THEN + ang(1) = ATAN2(-rot(2, 3), rot(3, 3)) + ang(3) = ATAN2(-rot(1, 2), rot(1, 1)) + ELSE + ang(1) = ATAN2(rot(3, 2), rot(2, 2)) + ang(3) = CD_ZERO + END IF + ang = ang*R2D + END FUNCTION body_rotation_angles + SUBROUTINE apply_ptfm_host_rods(rods, points, ptfm_init) !! Rigid-transform every Coupled/Vessel and CoupledPinned ROD (its End A/B and its RodA/B !! attachment points) by the initial platform displacement, p' = r + M^T p (apply_ptfm_init). diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index eb5c46ef..29f2b3bb 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -49,7 +49,7 @@ MODULE CableDyn_HermiteCableStatic CD_Bathymetry_Rotate_Curvature USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK 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_Hydro, ONLY: CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_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, & @@ -159,9 +159,12 @@ MODULE CableDyn_HermiteCableStatic ! static solvers): the Morison drag of the relative velocity u_f - 0 on every element, ! through CD_HermiteCable_Drag_Element with the element fluid velocity taken as the mean ! of the current at its two nodes -- the held-field drag of the dynamic path. The current - ! is uniform (velocity) or a depth profile (profile_z, profile_velocity) sampled at the - ! iterate's node elevations. frame_cs = (cos, sin) rotates the global current into the - ! solve frame (global x = c xl - s yl, y = s xl + c yl). The section properties are given + ! is uniform (velocity), a depth profile (profile_z, profile_velocity) sampled at the + ! iterate's node elevations, or a current grid (grid, MoorDyn-C Currents 2 and 5) sampled at + ! the iterate's node positions at t = 0, the static start. frame_cs = (cos, sin) rotates the + ! global current into the solve frame (global x = c xl - s yl, y = s xl + c yl), and the solve + ! frame's node positions, shifted by origin (the solve frame's horizontal origin in the turned + ! frame, where a solve translates it), into the global ones the grid is sampled at. The section properties are given ! per reference-arc interval (arc_end, the cumulative rest length at each interval end, ! with diam/cdn/cdt), so a refined or coarsened mesh of the same line looks them up by ! its element midpoints. load_factor scales the drag load (a continuation parameter; 1 is @@ -209,9 +212,11 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: waterline_z = 0.0_wp REAL(wp) :: velocity(3) = 0.0_wp REAL(wp) :: frame_cs(2) = [1.0_wp, 0.0_wp] + REAL(wp) :: origin(2) = [0.0_wp, 0.0_wp] ! drag = .FALSE.: a zero-velocity carrier of the as-laid seabed friction in still water LOGICAL :: drag = .TRUE. REAL(wp), ALLOCATABLE :: profile_z(:), profile_velocity(:, :) + TYPE(CD_CurrentGridType), ALLOCATABLE :: grid REAL(wp), ALLOCATABLE :: arc_end(:), diam(:), cdn(:), cdt(:) ! Seabed friction held by the line against the current (allocated: active). TYPE(CD_HermiteStaticFrictionType), ALLOCATABLE :: friction @@ -2961,7 +2966,15 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, ve = CD_ZERO ! no drag on a friction-only carrier (current_element_props) IF (.NOT. current%drag) RETURN - IF (ALLOCATED(current%profile_z)) THEN + IF (ALLOCATED(current%grid)) THEN + CALL CD_Current_Grid_Velocity(current%grid, global_position(qe(1:3)), 0.0_wp, ua, es, em) + IF (es == CD_HYDRO_OK) CALL CD_Current_Grid_Velocity(current%grid, global_position(qe(7:9)), 0.0_wp, ub, & + es, em) + IF (es /= CD_HYDRO_OK) THEN + ErrStat = CD_HCSTAT_NOCONVERGE; ErrMsg = TRIM(em); RETURN + END IF + ug = 0.5_wp*(ua + ub) + ELSE IF (ALLOCATED(current%profile_z)) THEN CALL CD_Current_Profile_Velocity(qe(3), current%profile_z, current%profile_velocity, ua, es, em) IF (es == CD_HYDRO_OK) CALL CD_Current_Profile_Velocity(qe(9), current%profile_z, current%profile_velocity, & ub, es, em) @@ -2986,6 +2999,18 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, END IF fd = current%load_factor*fd IF (want_jac) djq = current%load_factor*djq + + CONTAINS + + PURE FUNCTION global_position(xl) RESULT(xg) + !! The global position of a solve-frame node position xl (shifted by the frame's origin, + !! then turned back by frame_cs). + REAL(wp), INTENT(IN) :: xl(3) + REAL(wp) :: xg(3), xs(2) + xs = xl(1:2) + current%origin + xg = [current%frame_cs(1)*xs(1) - current%frame_cs(2)*xs(2), & + current%frame_cs(2)*xs(1) + current%frame_cs(1)*xs(2), xl(3)] + END FUNCTION global_position END SUBROUTINE current_element_load SUBROUTINE CD_HermiteCable_Current_Load(l0, q, current, load, ErrStat, ErrMsg) diff --git a/src/CableDyn_Hydro.f90 b/src/CableDyn_Hydro.f90 index 52d069f6..7cc03891 100644 --- a/src/CableDyn_Hydro.f90 +++ b/src/CableDyn_Hydro.f90 @@ -26,6 +26,8 @@ MODULE CableDyn_Hydro PUBLIC :: CD_Froude_Krylov_Per_Length PUBLIC :: CD_Solve_Dispersion_Wavenumber PUBLIC :: CD_Current_Profile_Velocity + PUBLIC :: CD_CurrentGridType, CD_Current_Grid_Resample, CD_Current_Grid_Velocity + PUBLIC :: CD_Current_Grid_Gradient, CD_Current_Profile_Gradient PUBLIC :: CD_SeaState_Steady_Current PUBLIC :: CD_Airy_Wave_Kinematics PUBLIC :: CD_Airy_Wave_Kinematics_Precomputed @@ -61,6 +63,24 @@ MODULE CableDyn_Hydro REAL(wp), PARAMETER :: DEG2RAD = PI/180.0_wp REAL(wp), PARAMETER :: MIN_TANGENT_NORM = 1.0e-12_wp INTEGER, PARAMETER :: CD_JONSWAP_COMPONENTS = 200 + ! largest resampled current grid (nx ny nz nt samples of three velocity components, 48 MB): + ! every static current object (each line's static solve) holds its own copy of the grid + INTEGER(INT64), PARAMETER :: MAX_CURRENT_GRID_SAMPLES = 2000000_INT64 + + ! A current tabulated on a rectilinear grid in space and time, as MoorDyn-C (v2.7.1) holds its + ! time-varying currents (moordyn::waves::CurrentGrid of source/Waves.hpp): coordinates x, y, z + ! (each strictly increasing; a single coordinate makes the current uniform along that axis) and + ! velocity(:, i, j, k, n) at (x(i), y(j), z(k)) and time (n - 1) dt, n = 1..nt. The MoorDyn-C + ! tables are resampled onto this uniform time base by CD_Current_Grid_Resample and evaluated by + ! CD_Current_Grid_Velocity, which mirror constructDynamicCurrentGrid / construct4DCurrentGrid + ! (source/Waves/WaveGrid.cpp) and CurrentGrid::getCurrentKin (source/Waves.cpp). The fluid + ! acceleration of such a current is zero, as MoorDyn-C sets it. + TYPE :: CD_CurrentGridType + REAL(wp), ALLOCATABLE :: x(:), y(:), z(:) + REAL(wp) :: dt = 1.0_wp + INTEGER :: nt = 1 + REAL(wp), ALLOCATABLE :: velocity(:, :, :, :, :) + END TYPE CD_CurrentGridType CONTAINS @@ -1666,6 +1686,285 @@ SUBROUTINE CD_Current_Profile_Velocity(z, z_profile, velocity_profile, velocity, velocity = (CD_ONE - alpha)*velocity_profile(:, seg) + alpha*velocity_profile(:, seg + 1) END SUBROUTINE CD_Current_Profile_Velocity + SUBROUTINE CD_Current_Grid_Resample(x, y, z, t_in, v_in, grid, ErrStat, ErrMsg) + !! Build a current grid from velocities v_in(3, nx, ny, nz, m) tabulated at the times t_in(m), + !! as MoorDyn-C v2.7.1 does (constructDynamicCurrentGrid, construct4DCurrentGrid): the time + !! step is the smallest interval of t_in, dt = min(t_in(n+1) - t_in(n)), the grid holds + !! nt = floor(t_in(m)/dt) + 1 samples at the times (n - 1) dt from t = 0, and each sample is + !! the table interpolated linearly in time, a (1 - f) + b f, held at the end rows (the value + !! of the first row before t_in(1)). x, y, z and t_in must be strictly increasing, with at + !! least two times (MoorDyn-C reads before its table with one). + REAL(wp), INTENT(IN) :: x(:), y(:), z(:), t_in(:), v_in(:, :, :, :, :) + TYPE(CD_CurrentGridType), INTENT(OUT) :: grid + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: dt, ts, f + INTEGER(INT64) :: nt64 + INTEGER :: m, n, iu + + ErrStat = CD_HYDRO_OK + ErrMsg = '' + m = SIZE(t_in) + IF (SIZE(x) < 1 .OR. SIZE(y) < 1 .OR. SIZE(z) < 1) THEN + CALL fail(ErrStat, ErrMsg, 'current grid needs at least one x, y and z coordinate'); RETURN + END IF + IF (m < 2) THEN + CALL fail(ErrStat, ErrMsg, 'current grid needs at least two times'); RETURN + END IF + IF (SIZE(v_in, 1) /= 3 .OR. SIZE(v_in, 2) /= SIZE(x) .OR. SIZE(v_in, 3) /= SIZE(y) .OR. & + SIZE(v_in, 4) /= SIZE(z) .OR. SIZE(v_in, 5) /= m) THEN + CALL fail(ErrStat, ErrMsg, 'current grid velocities must be shaped (3, nx, ny, nz, nt)'); RETURN + END IF + IF (.NOT. (CD_All_Finite(x) .AND. CD_All_Finite(y) .AND. CD_All_Finite(z) .AND. CD_All_Finite(t_in))) THEN + CALL fail(ErrStat, ErrMsg, 'current grid coordinates and times must be finite'); RETURN + END IF + IF (.NOT. (increasing(x) .AND. increasing(y) .AND. increasing(z))) THEN + CALL fail(ErrStat, ErrMsg, 'current grid x, y and z coordinates must be strictly increasing'); RETURN + END IF + IF (.NOT. increasing(t_in)) THEN + CALL fail(ErrStat, ErrMsg, 'current grid times must be strictly increasing'); RETURN + END IF + dt = HUGE(dt) + DO n = 2, m + IF (t_in(n) - t_in(n - 1) < dt) dt = t_in(n) - t_in(n - 1) + END DO + IF (t_in(m) < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: the last time must not be negative (MoorDyn-C samples from t = 0)') + RETURN + END IF + ! range first, without dividing by dt (a tiny dt would overflow) + IF (.NOT. (t_in(m)/REAL(MAX_CURRENT_GRID_SAMPLES, wp) < dt)) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: the last time over the smallest time interval exceeds the '// & + 'sample limit'); RETURN + END IF + nt64 = FLOOR(t_in(m)/dt, KIND=INT64) + 1_INT64 + IF (nt64*INT(SIZE(x), INT64)*INT(SIZE(y), INT64)*INT(SIZE(z), INT64) > MAX_CURRENT_GRID_SAMPLES) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: more than 2e6 resampled space-time samples; coarsen the grid or '// & + 'its smallest time interval'); RETURN + END IF + IF (.NOT. CD_All_Finite(RESHAPE(v_in, [SIZE(v_in)]))) THEN + CALL fail(ErrStat, ErrMsg, 'current grid velocities must be finite'); RETURN + END IF + grid%x = x + grid%y = y + grid%z = z + grid%dt = dt + grid%nt = INT(nt64) + ALLOCATE (grid%velocity(3, SIZE(x), SIZE(y), SIZE(z), grid%nt)) + DO n = 1, grid%nt + ts = REAL(n - 1, wp)*dt + CALL grid_factor(t_in, ts, iu, f) + grid%velocity(:, :, :, :, n) = v_in(:, :, :, :, iu - 1)*(CD_ONE - f) + v_in(:, :, :, :, iu)*f + END DO + + CONTAINS + + LOGICAL FUNCTION increasing(c) + REAL(wp), INTENT(IN) :: c(:) + INTEGER :: k + increasing = .TRUE. + DO k = 2, SIZE(c) + IF (.NOT. c(k) > c(k - 1)) increasing = .FALSE. + END DO + END FUNCTION increasing + END SUBROUTINE CD_Current_Grid_Resample + + SUBROUTINE CD_Current_Grid_Velocity(grid, pos, time, velocity, ErrStat, ErrMsg) + !! The current of a grid at pos and time, as MoorDyn-C v2.7.1 evaluates it + !! (CurrentGrid::getCurrentKin with interp_factor and interp4Vec, source/Util/Interp.hpp): + !! - in x, y and z, linear between the bracketing coordinates and held beyond the end ones, + !! the node elevation taken as it is (no stretching); + !! - in time, with q = time/dt, n = floor(q) and f = q - n, the samples n and n + 1 + !! (0-based) blended a (1 - f) + b f, the upper index taken modulo nt: past the last sample + !! the grid repeats with period nt dt, and over [(nt - 1) dt, nt dt) of each period it holds + !! the first sample (both indices are 0 there); + !! - blended in time at the 8 corners first, then in x, y and z, in MoorDyn-C's order. + !! A time before 0 takes the t = 0 sample (MoorDyn-C's runs start at t = 0). + TYPE(CD_CurrentGridType), INTENT(IN) :: grid + REAL(wp), INTENT(IN) :: pos(3), time + REAL(wp), INTENT(OUT) :: velocity(3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: fx, fy, fz, ft, q + REAL(wp) :: c000(3), c001(3), c010(3), c011(3), c100(3), c101(3), c110(3), c111(3) + REAL(wp) :: c00(3), c01(3), c10(3), c11(3), c0(3), c1(3) + INTEGER :: ix, iy, iz, ix0, iy0, iz0, it, it0 + INTEGER(INT64) :: n + + velocity = CD_ZERO + ErrStat = CD_HYDRO_OK + ErrMsg = '' + IF (.NOT. (CD_All_Finite(pos) .AND. CD_Is_Finite(time))) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: position and time must be finite'); RETURN + END IF + IF (.NOT. ALLOCATED(grid%velocity)) THEN + CALL fail(ErrStat, ErrMsg, 'current grid is not set'); RETURN + END IF + CALL grid_factor(grid%x, pos(1), ix, fx) + CALL grid_factor(grid%y, pos(2), iy, fy) + CALL grid_factor(grid%z, pos(3), iz, fz) + ! 1-based upper (it) and lower (it0) time samples + it = 1 + ft = CD_ZERO + IF (grid%nt > 1) THEN + ! range first, without dividing by dt + IF (.NOT. MAX(time, CD_ZERO)/1.0e18_wp < grid%dt) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: time beyond 1e18 grid time steps'); RETURN + END IF + q = MAX(time, CD_ZERO)/grid%dt + n = FLOOR(q, KIND=INT64) + ft = q - REAL(n, wp) + it = INT(MOD(n + 1_INT64, INT(grid%nt, INT64))) + 1 + END IF + it0 = MAX(it - 1, 1) + ix0 = MAX(ix - 1, 1) + iy0 = MAX(iy - 1, 1) + iz0 = MAX(iz - 1, 1) + c000 = grid%velocity(:, ix0, iy0, iz0, it0)*(CD_ONE - ft) + grid%velocity(:, ix0, iy0, iz0, it)*ft + c001 = grid%velocity(:, ix0, iy0, iz, it0)*(CD_ONE - ft) + grid%velocity(:, ix0, iy0, iz, it)*ft + c010 = grid%velocity(:, ix0, iy, iz0, it0)*(CD_ONE - ft) + grid%velocity(:, ix0, iy, iz0, it)*ft + c011 = grid%velocity(:, ix0, iy, iz, it0)*(CD_ONE - ft) + grid%velocity(:, ix0, iy, iz, it)*ft + c100 = grid%velocity(:, ix, iy0, iz0, it0)*(CD_ONE - ft) + grid%velocity(:, ix, iy0, iz0, it)*ft + c101 = grid%velocity(:, ix, iy0, iz, it0)*(CD_ONE - ft) + grid%velocity(:, ix, iy0, iz, it)*ft + c110 = grid%velocity(:, ix, iy, iz0, it0)*(CD_ONE - ft) + grid%velocity(:, ix, iy, iz0, it)*ft + c111 = grid%velocity(:, ix, iy, iz, it0)*(CD_ONE - ft) + grid%velocity(:, ix, iy, iz, it)*ft + c00 = c000*(CD_ONE - fx) + c100*fx + c01 = c001*(CD_ONE - fx) + c101*fx + c10 = c010*(CD_ONE - fx) + c110*fx + c11 = c011*(CD_ONE - fx) + c111*fx + c0 = c00*(CD_ONE - fy) + c10*fy + c1 = c01*(CD_ONE - fy) + c11*fy + velocity = c0*(CD_ONE - fz) + c1*fz + END SUBROUTINE CD_Current_Grid_Velocity + + SUBROUTINE CD_Current_Profile_Gradient(z, z_profile, velocity_profile, gradient) + !! The gradient d(velocity)/d(position) (3 x 3, column j the derivative along x_j) of the + !! depth profile of CD_Current_Profile_Velocity at elevation z: (u_(k+1) - u_k)/(z_(k+1) - z_k) + !! in the z column inside a segment, zero where the profile is held beyond its end levels. + !! For a Newton tangent: the caller has validated the profile. + REAL(wp), INTENT(IN) :: z, z_profile(:), velocity_profile(:, :) + REAL(wp), INTENT(OUT) :: gradient(3, 3) + INTEGER :: n, k, seg + REAL(wp) :: denom, alpha + gradient = CD_ZERO + n = SIZE(z_profile) + IF (n < 2) RETURN + seg = 1 + DO k = 2, n - 1 + IF (z >= z_profile(k)) seg = k + END DO + denom = z_profile(seg + 1) - z_profile(seg) + alpha = (z - z_profile(seg))/denom + IF (alpha > CD_ZERO .AND. alpha < CD_ONE) & + gradient(:, 3) = (velocity_profile(:, seg + 1) - velocity_profile(:, seg))/denom + END SUBROUTINE CD_Current_Profile_Gradient + + SUBROUTINE CD_Current_Grid_Gradient(grid, pos, time, gradient, ErrStat, ErrMsg) + !! The gradient d(velocity)/d(position) (3 x 3, column j the derivative along x_j) of the + !! current of CD_Current_Grid_Velocity at pos and time: the derivative of its trilinear + !! blend, zero along an axis where the grid is held beyond its end coordinates (or has a + !! single coordinate). For a Newton tangent. + TYPE(CD_CurrentGridType), INTENT(IN) :: grid + REAL(wp), INTENT(IN) :: pos(3), time + REAL(wp), INTENT(OUT) :: gradient(3, 3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: f(3), g(3), ft, q, c(3, 0:1, 0:1, 0:1), w(0:1, 3), dw(0:1, 3) + INTEGER :: iu(3), il(3), it, it0, i, j, k, a + INTEGER(INT64) :: n + + gradient = CD_ZERO + ErrStat = CD_HYDRO_OK + ErrMsg = '' + IF (.NOT. (CD_All_Finite(pos) .AND. CD_Is_Finite(time))) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: position and time must be finite'); RETURN + END IF + IF (.NOT. ALLOCATED(grid%velocity)) THEN + CALL fail(ErrStat, ErrMsg, 'current grid is not set'); RETURN + END IF + CALL axis(grid%x, pos(1), 1) + CALL axis(grid%y, pos(2), 2) + CALL axis(grid%z, pos(3), 3) + it = 1 + ft = CD_ZERO + IF (grid%nt > 1) THEN + IF (.NOT. MAX(time, CD_ZERO)/1.0e18_wp < grid%dt) THEN + CALL fail(ErrStat, ErrMsg, 'current grid: time beyond 1e18 grid time steps'); RETURN + END IF + q = MAX(time, CD_ZERO)/grid%dt + n = FLOOR(q, KIND=INT64) + ft = q - REAL(n, wp) + it = INT(MOD(n + 1_INT64, INT(grid%nt, INT64))) + 1 + END IF + it0 = MAX(it - 1, 1) + DO k = 0, 1 + DO j = 0, 1 + DO i = 0, 1 + c(:, i, j, k) = grid%velocity(:, MERGE(iu(1), il(1), i == 1), MERGE(iu(2), il(2), j == 1), & + MERGE(iu(3), il(3), k == 1), it0)*(CD_ONE - ft) + & + grid%velocity(:, MERGE(iu(1), il(1), i == 1), MERGE(iu(2), il(2), j == 1), & + MERGE(iu(3), il(3), k == 1), it)*ft + END DO + END DO + END DO + DO a = 1, 3 + w(0, a) = CD_ONE - f(a) + w(1, a) = f(a) + dw(0, a) = -g(a) + dw(1, a) = g(a) + END DO + DO k = 0, 1 + DO j = 0, 1 + DO i = 0, 1 + gradient(:, 1) = gradient(:, 1) + dw(i, 1)*w(j, 2)*w(k, 3)*c(:, i, j, k) + gradient(:, 2) = gradient(:, 2) + w(i, 1)*dw(j, 2)*w(k, 3)*c(:, i, j, k) + gradient(:, 3) = gradient(:, 3) + w(i, 1)*w(j, 2)*dw(k, 3)*c(:, i, j, k) + END DO + END DO + END DO + + CONTAINS + + SUBROUTINE axis(xp, x, a_) + !! Bracket, factor and d(factor)/dx along axis a_ (zero where the grid is held). + REAL(wp), INTENT(IN) :: xp(:), x + INTEGER, INTENT(IN) :: a_ + CALL grid_factor(xp, x, iu(a_), f(a_)) + il(a_) = MAX(iu(a_) - 1, 1) + g(a_) = CD_ZERO + IF (SIZE(xp) > 1) THEN + IF (x > xp(1) .AND. x < xp(SIZE(xp))) g(a_) = CD_ONE/(xp(iu(a_)) - xp(il(a_))) + END IF + END SUBROUTINE axis + END SUBROUTINE CD_Current_Grid_Gradient + + PURE SUBROUTINE grid_factor(xp, x, iu, f) + !! MoorDyn-C's interp_factor (source/Util/Interp.hpp) on 1-based coordinates xp: the upper + !! bracketing index iu and the factor f of the blend a (1 - f) + b f between xp(iu - 1) and + !! xp(iu): iu = 1, f = 0 for a single coordinate; iu = 2, f = 0 at or below xp(1); iu = n, + !! f = 1 at or above xp(n); else the first iu with x <= xp(iu). + REAL(wp), INTENT(IN) :: xp(:), x + INTEGER, INTENT(OUT) :: iu + REAL(wp), INTENT(OUT) :: f + INTEGER :: n, i + n = SIZE(xp) + iu = 1 + f = CD_ZERO + IF (n == 1) RETURN + iu = 2 + IF (x <= xp(1)) RETURN + iu = n + f = CD_ONE + IF (x >= xp(n)) RETURN + DO i = 2, n + IF (x <= xp(i)) THEN + iu = i + f = (x - xp(i - 1))/(xp(i) - xp(i - 1)) + RETURN + END IF + END DO + END SUBROUTINE grid_factor + SUBROUTINE CD_JONSWAP_Wave_Kinematics(x, y, z, t, hs, tp, gamma, depth, gravity, direction_deg, & stretch, eta, velocity, acceleration, ErrStat, ErrMsg) !! Evaluate deterministic irregular-wave kinematics from a discretized diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 90d7b613..02038957 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -47,7 +47,7 @@ MODULE CableDyn_Model USE CableDyn_Syrope, ONLY: CD_SyropeType, CD_Syrope_Init, CD_Syrope_End, CD_Syrope_Is_Ready, & CD_Syrope_Working_Curve, CD_Syrope_Rate_And_Tension, CD_Syrope_Branch_Divider, & CD_Syrope_Element_Load, CD_Syrope_Check_Range, CD_SYROPE_OK, CD_SYROPE_NWC - USE CableDyn_Hydro, ONLY: CD_Cable_Morison_Drag_Load, CD_Cable_Morison_Drag_Force, & + USE CableDyn_Hydro, ONLY: CD_CurrentGridType, CD_Cable_Morison_Drag_Load, CD_Cable_Morison_Drag_Force, & CD_Morison_Drag_Element_Load, CD_Morison_Drag_Element_Force, & CD_Cable_Froude_Krylov_Load, CD_Cable_Froude_Krylov_Force, & CD_Froude_Krylov_Element_Load, CD_Froude_Krylov_Element_Force, & @@ -303,6 +303,8 @@ MODULE CableDyn_Model ! (the static-branch dashpot Bs lives inside the series law). ve_dt carries the ! active step size into the contributors; 0 = the instantaneous ! (committed-state) limit used by IC, coupled-load, and tension queries. + ! ve_dl_1 is a stretch [m], so an unstretched-length change (active line control) leaves + ! it as it is, as MoorDyn's dl_1 (CD_Update_Model_SegmentLength). ! ve_dl_1_rollback is the system-level rollback twin of q_rollback: a line ! whose step committed (advancing dl_1) can be rolled back when a sibling ! line or the coupled point solve fails. @@ -328,7 +330,9 @@ MODULE CableDyn_Model ! load-history-dependent alternative to the series-Kelvin law. syrope_is(:) marks the Syrope ! elements; syrope_type(:) holds each element's constitutive data (OWC ! table + working-curve shape + spring/dashpot constants -- immutable after - ! init). syrope_slow is the committed slow-spring static strain (the STATE) + ! init). syrope_slow is the committed slow-spring static strain (the STATE), a strain of + ! the unstretched length the committed state was reached with (l0_c; after a length change + ! by active line control the element reads it at its present length, model_syrope_slow), ! and syrope_tmax the running maximum mean tension (a second, monotone STATE ! whose growth regenerates the working curve on demand). Syrope elements ! share the ea_dyn/ba_dyn masking with the viscoelastic path (their elastic @@ -1464,7 +1468,7 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra ve_ea_d, ve_ba, ve_ba_d, ve_alpha_mbl, ve_vbeta, & syrope_is, syrope_type, syrope_slow0, syrope_tmax0, & current_profile_z, current_profile_velocity, & - static_friction, lay_azimuth, as_laid_tension) + static_friction, lay_azimuth, as_laid_tension, current_grid) !! Initialise a persistent EI=0 dynamic model from an OrcaFlex-style line object: !! line types + sections + end points. This routine builds the mesh, assembles !! submerged-weight loads, obtains a static initial condition by load continuation, @@ -1537,6 +1541,10 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra ! then samples the current at each node's own elevation, as the dynamic march does, so the ! march starts from rest. Without it the static drag uses fluid_velocity as given. REAL(wp), INTENT(IN), OPTIONAL :: current_profile_z(:), current_profile_velocity(:, :) + ! A current grid in space and time (MoorDyn-C Currents 2 and 5): the static initial condition + ! then samples it at each node's own position at t = 0, in place of the depth profile. + TYPE(CD_CurrentGridType), INTENT(IN), OPTIONAL :: current_grid + LOGICAL :: field_on ! Static seabed friction (with seabed_mu > 0 on a seabed): the policy ! (CD_STATIC_FRICTION_AS_LAID or CD_STATIC_FRICTION_NONE, the default), the lay azimuth ! [rad, from global +x toward +y; default: the horizontal direction of the chord from @@ -1715,10 +1723,20 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra ! strut. A steady current enters as Morison drag on the line at rest, with the node ! velocities and element hydrodynamics the dynamic model is built with, so the first ! dynamic step starts from equilibrium. + ! The static start carries the current wherever the field is non-zero: in the node + ! velocities, in the depth profile or in the current grid at t = 0 (the node velocities are + ! sampled on the straight chord, where a current below the chord would be missed). use_current = .FALSE. IF (PRESENT(fluid_velocity) .AND. PRESENT(drag_rho)) THEN IF (SIZE(fluid_velocity, 1) == 3 .AND. SIZE(fluid_velocity, 2) == n_elem + 1) THEN - IF (ANY(ABS(fluid_velocity) > CD_ZERO)) THEN + field_on = ANY(ABS(fluid_velocity) > CD_ZERO) + IF (PRESENT(current_profile_z) .AND. PRESENT(current_profile_velocity)) & + field_on = field_on .OR. ANY(ABS(current_profile_velocity) > CD_ZERO) + IF (PRESENT(current_grid)) THEN + IF (ALLOCATED(current_grid%velocity)) & + field_on = field_on .OR. ANY(ABS(current_grid%velocity(:, :, :, :, 1)) > CD_ZERO) + END IF + IF (field_on) THEN IF (PRESENT(drag_diameter_elem) .AND. PRESENT(drag_cdn_elem) .AND. PRESENT(drag_cdt_elem)) THEN use_current = .TRUE. cur%elem_diameter = drag_diameter_elem @@ -1740,6 +1758,9 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra cur%profile_z = current_profile_z cur%profile_velocity = current_profile_velocity END IF + IF (PRESENT(current_grid)) THEN + ALLOCATE (cur%grid, SOURCE=current_grid) + END IF IF (PRESENT(drag_waterline_z)) cur%node_waterline = drag_waterline_z ! Without the as-laid policy a frictional seabed holds the line against the current ! from its still-water laid shape: solve the line without the current first; that @@ -3773,7 +3794,9 @@ END FUNCTION CD_Model_Has_Syrope SUBROUTINE CD_Get_Model_Syrope_State(model, slow, tmax, ErrStat, ErrMsg) !! Copy the per-element Syrope committed states -- the slow-spring static strain !! slow and the running-maximum tension tmax (each size n_elem) -- for the coupled - !! checkpoint mirror. A non-Syrope model returns zeros (total accessor). + !! checkpoint mirror. A non-Syrope model returns zeros (total accessor). The slow strain + !! is that of the lengths the committed state was reached with (l0_c), the lengths a + !! checkpoint restart re-applies as committed (CD_Update_Model_SegmentLength, restored). TYPE(CD_ModelType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: slow(:), tmax(:) INTEGER, INTENT(OUT) :: ErrStat @@ -4936,7 +4959,9 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E !! term. restored = .TRUE. (a checkpoint restart re-applying the command of !! the committed state) makes the new length and rate the committed ones as well. A rate !! of -0 is stored as +0, so a zero command of either sign leaves an uncontrolled model - !! bit-identical (the committed-length test compares bits). + !! bit-identical (the committed-length test compares bits). On a Syrope element the slow + !! stretch eps_slow*l0 is carried over the change (model_syrope_slow); on a viscoelastic + !! element the slow-branch stretch dl_1 is, as it is (both as in MoorDyn-F/C). TYPE(CD_ModelType), INTENT(INOUT) :: model INTEGER, INTENT(IN) :: elem REAL(wp), INTENT(IN) :: l0_new, l0_dot @@ -4967,26 +4992,18 @@ SUBROUTINE CD_Update_Model_SegmentLength(model, elem, l0_new, l0_dot, ErrStat, E 'recompute scalars (kBot + contact diameter) supplied at init') RETURN END IF - IF (model%has_viscoelastic) THEN - IF (model%ve_mode(elem) /= 0) THEN - ! the dl_1 state partitions the stretch against the INIT-time natural - ! length; MoorDyn defines no rescaling law for a controlled - ! viscoelastic segment, so this composition fails closed by name - CALL fail(ErrStat, ErrMsg, 'segment-length update on a viscoelastic (ElasticMod > 1) element '// & - 'is not supported: the dl_1 state has no length-rescaling law') - RETURN - END IF - END IF - IF (model%has_syrope) THEN - IF (model%syrope_is(elem)) THEN - ! the Syrope strain states partition against the INIT-time natural - ! length; no rescaling law for a controlled Syrope segment, so this - ! composition fails closed by name (same rule as the viscoelastic path) - CALL fail(ErrStat, ErrMsg, 'segment-length update on a Syrope element is not supported: '// & - 'the working-curve strain states have no length-rescaling law') - RETURN - END IF - END IF + ! A viscoelastic element keeps its slow-branch stretch dl_1 as it is, and every law + ! evaluation reads it with the present l0: MagT = EA_1 dl_1/l0, MagTd = BA ld_1/l0, the ODE + ! ld_1 = (EA_D dl - (EA_D + EA_1) dl_1 + BA_D lstrd)/(BA_D + BA) with dl = lstr - l0, and the + ! ElasticMod 3 EA_D(dl_1, l0). That is MoorDyn's rule: MoorDyn-F (MD_CalcContStateDeriv sets + ! l(N), ld(N) of a controlled line; Line_GetStateDeriv reads Line%dl_1 against Line%l) and + ! MoorDyn-C (Line::setUnstretchedLength sets every l[i]; Line::getStateDeriv reads dl_1[i] + ! against l[i]) never touch dl_1 on a length change. The force blend's committed force reads + ! the same dl_1 at l0_c. + ! A Syrope element keeps its states as they are: the slow strain stays the committed state's, + ! a strain of l0_c, and the element reads it at its present length (model_syrope_slow), so + ! its slow STRETCH carries over the length change as MoorDyn-F/C carry it; the running + ! maximum, a tension, does not depend on the length. ! The update is atomic: every length-dependent quantity is built from a trial ! length vector first, and the committed fields are mutated only once all builds ! succeeded. @@ -5643,9 +5660,9 @@ SUBROUTINE CD_Get_Model_Internal_Rates(model, ve_rate, syrope_rate, ErrStat, Err END IF slow_at = CD_Syrope_Branch_Divider(model%syrope_type(e), model%syrope_tmax(e)) CALL CD_Syrope_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), model%syrope_type(e), & - ws, wt, wsl, model%syrope_slow(e) < slow_at, model%syrope_slow(e), & - model%tension_only, f6, jq6, t_mean, dslow, es, em, dt=CD_ZERO, & - divider=slow_at) + ws, wt, wsl, model_syrope_slow(model, e) < slow_at, & + model_syrope_slow(model, e), model%tension_only, f6, jq6, t_mean, dslow, & + es, em, dt=CD_ZERO, divider=slow_at) IF (es /= CD_SYROPE_OK) THEN CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN END IF @@ -7449,14 +7466,15 @@ SUBROUTINE model_syrope_element(model, e, q2, v2, force, jac_q, jac_v, t_mean, d !! selects the branch by the evaluated slow strain vs the branch divider at !! that maximum, and calls the element load. Inside a step (ve_dt > 0) the !! slow strain is eliminated by the same backward-Euler solve the commit makes; - !! outside (ve_dt = 0) the committed state is used as is. + !! outside (ve_dt = 0) the committed state is used as is. The slow strain is the committed + !! one at the element's present length (model_syrope_slow). TYPE(CD_ModelType), INTENT(IN) :: model INTEGER, INTENT(IN) :: e REAL(wp), INTENT(IN) :: q2(6), v2(6) REAL(wp), INTENT(OUT) :: force(6), jac_q(6, 6), jac_v(6, 6), t_mean, dslow INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC), slow_at + REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC), slow_at, slow LOGICAL :: on_wc INTEGER :: es CHARACTER(200) :: em @@ -7471,9 +7489,10 @@ SUBROUTINE model_syrope_element(model, e, q2, v2, force, jac_q, jac_v, t_mean, d END IF ! the branch follows the evaluated slow strain against the continuous divider slow_at = CD_Syrope_Branch_Divider(model%syrope_type(e), model%syrope_tmax(e)) - on_wc = model%syrope_slow(e) < slow_at + slow = model_syrope_slow(model, e) + on_wc = slow < slow_at CALL CD_Syrope_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), model%syrope_type(e), & - ws, wt, wsl, on_wc, model%syrope_slow(e), model%tension_only, & + ws, wt, wsl, on_wc, slow, model%tension_only, & force, jac_q, t_mean, dslow, es, em, jac_v=jac_v, dt=model%ve_dt, & divider=slow_at) IF (es /= CD_SYROPE_OK) THEN @@ -7488,7 +7507,9 @@ SUBROUTINE model_syrope_state_next(model, e, q2, v2, dt, slow_next, t_mean, ErrS !! caller invokes this for every element before the atomic commit pass. The !! candidate comes from the element load's own implicit elimination, so the !! committed slow strain is bit-identical to the one the converged in-step - !! force was evaluated at. A candidate beyond the OWC table fails the step. + !! force was evaluated at. A candidate beyond the OWC table fails the step. The advance + !! starts from the committed slow strain at the element's present length + !! (model_syrope_slow), so after a length change it integrates MoorDyn's slow stretch. TYPE(CD_ModelType), INTENT(IN) :: model INTEGER, INTENT(IN) :: e REAL(wp), INTENT(IN) :: q2(6), v2(6), dt @@ -7496,12 +7517,13 @@ SUBROUTINE model_syrope_state_next(model, e, q2, v2, dt, slow_next, t_mean, ErrS INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC) - REAL(wp) :: chord(3), length, eps, slow_at, f6(6), jq6(6, 6), dslow + REAL(wp) :: chord(3), length, eps, slow_at, f6(6), jq6(6, 6), dslow, slow LOGICAL :: on_wc INTEGER :: es CHARACTER(200) :: em - slow_next = model%syrope_slow(e) + slow = model_syrope_slow(model, e) + slow_next = slow t_mean = CD_ZERO chord = q2(4:6) - q2(1:3) length = NORM2(chord) @@ -7519,9 +7541,9 @@ SUBROUTINE model_syrope_state_next(model, e, q2, v2, dt, slow_next, t_mean, ErrS CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN END IF slow_at = CD_Syrope_Branch_Divider(model%syrope_type(e), model%syrope_tmax(e)) - on_wc = model%syrope_slow(e) < slow_at + on_wc = slow < slow_at CALL CD_Syrope_Element_Load(q2(1:3), q2(4:6), v2(1:3), v2(4:6), model%l0(e), model%syrope_type(e), & - ws, wt, wsl, on_wc, model%syrope_slow(e), model%tension_only, & + ws, wt, wsl, on_wc, slow, model%tension_only, & f6, jq6, t_mean, dslow, es, em, dt=dt, slow_next=slow_next, divider=slow_at) IF (es /= CD_SYROPE_OK) THEN CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN @@ -7547,6 +7569,25 @@ SUBROUTINE model_syrope_state_next(model, e, q2, v2, dt, slow_next, t_mean, ErrS ErrMsg = '' END SUBROUTINE model_syrope_state_next + PURE REAL(wp) FUNCTION model_syrope_slow(model, e) RESULT(slow) + !! The slow strain of Syrope element e at its present unstretched length l0(e). The state + !! syrope_slow is a strain of the length the committed state was reached with, l0_c(e). + !! MoorDyn-F and MoorDyn-C keep the slow STRETCH of a segment, dl_1 = eps_slow*l, as its + !! state, and an unstretched-length change leaves it as it is (MoorDyn-F sets l(N) and ld(N) + !! of a controlled line; MoorDyn-C's setUnstretchedLength sets every l[i]); their mean + !! tension reads the slow strain dl_1/l at the new length. So after a length change + !! eps_slow(l0) = eps_slow*l0_c/l0, + !! the stretch carried over, and a step from it, eps_slow^{n+1} = eps_slow^n l0_c/l0 + dt + !! d(eps_slow)/dt, is the backward-Euler step of MoorDyn's d(dl_1)/dt = l0 d(eps_slow)/dt + !! (with the chord rate, no paid-out term, as MoorDyn's Syrope rate takes it). The running + !! maximum, a tension, does not depend on the length. An element whose length is the + !! committed one (bit for bit, every element of an uncontrolled line) reads the state as is. + TYPE(CD_ModelType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: e + slow = model%syrope_slow(e) + IF (.NOT. bits_equal(model%l0(e), model%l0_c(e))) slow = slow*(model%l0_c(e)/model%l0(e)) + END FUNCTION model_syrope_slow + SUBROUTINE model_contributor_load(model, q, v, force, jac_q, jac_v, ErrStat, ErrMsg) !! Assemble all configured non-structural model load contributors and tangents. TYPE(CD_ModelType), INTENT(INOUT) :: model diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 81fb7426..53446968 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -20,7 +20,10 @@ MODULE CableDyn_OpenFAST_Aggregate !! (translation in, force out, zero moment; the rod !! turns about it on its own), !! last nhost_body columns -> the k-th Coupled/Vessel BODY's reference point - !! (6-DOF host node, force and moment about it), + !! (6-DOF host node, force and moment about it) or + !! CoupledPinned BODY's reference point (translation + !! in, force out, zero moment; the body turns about + !! it on its own), !! with ncp_total = ncp_sys + ncable + nhost_rod + nhost_body. All facade arrays are shaped !! (3, ncp_total). !! @@ -78,6 +81,7 @@ MODULE CableDyn_OpenFAST_Aggregate CD_Rod_GetFluidPositions, CD_Rod_SetHeldFluid, & CD_Rod_NHost, CD_Rod_SetHostKinematics, CD_Rod_GetHostKinematics, & CD_Rod_ScatterHostPoints, CD_Rod_HostWrench, CD_Rod_Stage, CD_Rod_Unstage, & + CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations, & CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & @@ -235,12 +239,18 @@ MODULE CableDyn_OpenFAST_Aggregate ! the full EI=0 coupled-block scratch (3, n_system_coupled_dof/3) their RodA/B points are ! overlaid on. INTEGER :: nhost_rod = 0 - INTEGER :: nhost_body = 0 ! Coupled/Vessel bodies: the trailing host nodes after the rods + INTEGER :: nhost_body = 0 ! Coupled/Vessel and CoupledPinned bodies: the trailing host nodes ! Body/rod marches: the host fairleads' t + dt motion as a flat coupled-DOF overlay ! (hf_mask marks the moving DOFs), passed into the march as the line step's end motion. LOGICAL, ALLOCATABLE :: hf_mask(:) REAL(wp), ALLOCATABLE :: hf_q(:), hf_v(:), hf_a(:) REAL(wp), ALLOCATABLE :: hb_pos(:, :), hb_vel(:, :), hb_acc(:, :), hb_load(:, :) + ! The bodies and rods carry the accelerations of a committed step or of a restored state mirror; + ! until then a transfer of the step-start host kinematics or new host fluid fields re-solve + ! their start accelerations (start_object_accelerations), so the mirror carries them from + ! t = 0, in the host's field. snap_objects_committed joins the aggregate snapshot. + LOGICAL :: objects_committed = .FALSE. + LOGICAL :: snap_objects_committed = .FALSE. LOGICAL :: initialized = .FALSE. END TYPE CD_AGG_ModuleType @@ -518,6 +528,13 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi CALL CD_AGG_End(candidate, es, em) RETURN END IF + ! the bodies and rods start from their accelerations at the initial state, the host at rest in its + ! Init pose (the first step's start; the state mirror then carries them from t = 0) + CALL start_object_accelerations(candidate, ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) THEN + CALL CD_AGG_End(candidate, es, em) + RETURN + END IF candidate%dt = dt ! freeze the coupling step for the fixed-dt Step_Moving guard candidate%initialized = .TRUE. CALL CD_AGG_End(self, es, em) @@ -717,7 +734,8 @@ SUBROUTINE CD_AGG_GetMovingPointMesh(self, position, velocity, acceleration, loa IF (PRESENT(moment)) moment(:, col) = y_fair END DO END IF - ! Host body nodes: the reference-point kinematics and the wrench about it. + ! Host body nodes: the reference-point kinematics and the wrench about it (a CoupledPinned + ! body: its force, with zero moment). IF (self%nhost_body > 0) THEN CALL CD_FMF_GetPointMesh(self%sys, self%hb_pos, self%hb_vel, self%hb_acc, self%hb_load, es, em) IF (es /= CD_FMF_OK) THEN @@ -863,7 +881,7 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er END IF IF (self%nhost_rod + self%nhost_body > 0) THEN ! a transfer without advancing: the host kinematics of the committed time, from which the - ! next step of a CoupledPinned rod starts (an output probe is restored by its caller) + ! next step of a CoupledPinned rod or body starts (an output probe is restored by its caller) IF (PRESENT(orientation)) THEN CALL set_host_objects(self, position, velocity, acceleration, ErrStat, ErrMsg, orientation=orientation, & angular_velocity=self%mv_omega, angular_acceleration=self%mv_alpha, step_start=.TRUE.) @@ -875,6 +893,12 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er CALL overlay_host_objects(self, is_output_probe, ErrStat, ErrMsg) IF (ErrStat /= CD_AGG_OK) RETURN END IF + ! before the first step, a committed (non-probe) transfer of the step-start kinematics moves + ! the start of the first step: the start accelerations follow it + IF (.NOT. (is_output_probe .OR. self%objects_committed)) THEN + CALL start_object_accelerations(self, ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) RETURN + END IF DO c = 1, self%ncable col = self%ncp_sys + c IF (PRESENT(orientation)) THEN @@ -1044,7 +1068,8 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver ! start the generalized-alpha step from the t + dt end state and corrupt the ends' history. CALL host_fairlead_motion(self, position, velocity, acceleration) ! The step-start bodies are staged before anything moves them: host-driven - ! (Coupled/Vessel) bodies take the t+dt host kinematics before the march, and a check + ! (Coupled/Vessel) bodies take the t+dt host kinematics before the march (CoupledPinned ones + ! their t+dt node translation), and a check ! after a successful march (plausibility, FAILURE rows) can still reject the step, so ! every failure path below un-stages them together with the system rewind. CALL CD_Rigid6_Stage(self%rigid6) @@ -1230,6 +1255,7 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver RETURN END IF END IF + IF (self%has_rigid6 .OR. self%has_rod) self%objects_committed = .TRUE. ErrStat = CD_AGG_OK ErrMsg = '' @@ -1280,6 +1306,9 @@ SUBROUTINE CD_AGG_Snapshot(self, ErrStat, ErrMsg) ! only sys%fast%system); capture them so a correction rewind un-advances the body too. IF (self%has_rigid6) CALL CD_Rigid6_Snapshot(self%rigid6) IF (self%has_rod) CALL CD_Rod_Snapshot(self%rod) + ! a rewind to a state before the first step takes the start accelerations open again (new + ! fluid fields re-solve them) + self%snap_objects_committed = self%objects_committed ErrStat = CD_AGG_OK ErrMsg = '' END SUBROUTINE CD_AGG_Snapshot @@ -1314,6 +1343,7 @@ SUBROUTINE CD_AGG_Restore(self, ErrStat, ErrMsg) IF (ALLOCATED(self%snap_failures)) self%failures = self%snap_failures IF (self%has_rigid6) CALL CD_Rigid6_Restore(self%rigid6) IF (self%has_rod) CALL CD_Rod_Restore(self%rod) + self%objects_committed = self%snap_objects_committed ErrStat = CD_AGG_OK ErrMsg = '' END SUBROUTINE CD_AGG_Restore @@ -1533,6 +1563,9 @@ SUBROUTINE CD_AGG_SetFluidFields(self, fluid_velocity, fluid_acceleration, water !! drag configuration, so the model layer alone cannot catch them). !! dynamic_pressure (optional, Pa, shaped (nfluid)): the wave dynamic pressure at the nodes; !! the rod blocks use it for the end-cap pressure (other blocks ignore it). + !! Before the first committed step (and before a state mirror is restored) the integrated + !! bodies and rods re-solve their start accelerations in the new fields: the accelerations + !! solved at Init saw the zero fields of the build, and the first step starts from them. TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: fluid_velocity(:, :), fluid_acceleration(:, :), waterline_z(:) INTEGER, INTENT(OUT) :: ErrStat @@ -1657,10 +1690,51 @@ SUBROUTINE CD_AGG_SetFluidFields(self, fluid_velocity, fluid_acceleration, water RETURN END IF END IF + ! the start of the first step: the bodies' and rods' accelerations in the host's field (the + ! OpenFAST shell sets its t = 0 field at Init, before the output call and its mirror restore) + IF (.NOT. self%objects_committed .AND. (self%has_rigid6 .OR. self%has_rod)) THEN + CALL start_in_fluid_fields(self, ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) RETURN + END IF ErrStat = CD_AGG_OK ErrMsg = '' END SUBROUTINE CD_AGG_SetFluidFields + SUBROUTINE start_in_fluid_fields(self, ErrStat, ErrMsg) + !! The start of the first step in new host fluid fields (CD_AGG_SetFluidFields before the first + !! committed step): a committed transfer of the EI=0 system's present moving-point kinematics, + !! which solves the line interior accelerations in the fields (the end-node loads on the + !! objects carry their consistent inertia), then the bodies' and rods' start accelerations -- + !! the start a step-start transfer (CD_AGG_UpdateStates_Moving) gives in the same fields. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :) + INTEGER :: n, es, stat + CHARACTER(1024) :: em + ErrStat = CD_AGG_OK + ErrMsg = '' + IF (.NOT. self%has_sys) RETURN + n = CD_FMF_NMovingPoints(self%sys, es, em) + IF (es /= CD_FMF_OK) THEN + CALL map_fmf_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), load(3, n), STAT=stat) + IF (stat /= 0) THEN + ErrStat = CD_AGG_ALLOCFAIL + ErrMsg = 'CableDyn_OpenFAST_Aggregate: start-state workspace allocation failed' + RETURN + END IF + CALL CD_FMF_GetMovingPointMesh(self%sys, pos, vel, acc, load, es, em) + IF (es == CD_FMF_OK) CALL CD_FMF_UpdateStates_Moving(self%sys, pos, vel, acc, es, em) + IF (es /= CD_FMF_OK) THEN + CALL map_fmf_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + CALL start_object_accelerations(self, ErrStat, ErrMsg) + END SUBROUTINE start_in_fluid_fields + SUBROUTINE CD_AGG_CalcOutput(self, ErrStat, ErrMsg) !! Compute the EI=0 system loads at the current committed state (stored in the system's !! output/point mesh). Each cable's fairlead reaction is read on demand in @@ -2418,11 +2492,55 @@ SUBROUTINE overlay_host_objects(self, output_probe, ErrStat, ErrMsg) IF (es /= CD_FMF_OK) CALL map_fmf_status(es, em, ErrStat, ErrMsg) END SUBROUTINE overlay_host_objects + SUBROUTINE start_object_accelerations(self, ErrStat, ErrMsg) + !! Solve the start accelerations of the integrated bodies and rods at the current state + !! (CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations), in the held fluid fields: at + !! Init and, before the first step, at a committed transfer of the step-start kinematics and + !! at new host fluid fields (CD_AGG_SetFluidFields). The OpenFAST shell restores + !! the state mirror after every CalcOutput, which marks the object accelerations committed; + !! solved here, the mirror carries the start accelerations, and the first step starts from them + !! instead of from zero. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + LOGICAL :: pin_b, pin_r + CHARACTER(1024) :: em + ErrStat = CD_AGG_OK + ErrMsg = '' + pin_b = .FALSE. + pin_r = .FALSE. + IF (.NOT. self%has_sys) RETURN + IF (self%has_rigid6) THEN + CALL CD_Rigid6_StartAccelerations(self%sys%fast%system, self%rigid6, es, em, pinned=pin_b) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + END IF + IF (self%has_rod) THEN + CALL CD_Rod_StartAccelerations(self%sys%fast%system, self%rod, es, em, pinned=pin_r) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + END IF + ! the line ends on a CoupledPinned rod or body move with its solved acceleration (a mirror + ! restore puts them there too, CD_AGG_Set_Rigid6_States, CD_AGG_Set_Rod_States), and the line + ! interior accelerations follow them (a committed transfer); Coupled/Vessel objects keep the + ! host's (Init) motion + IF (.NOT. (pin_b .OR. pin_r)) RETURN + CALL overlay_host_objects(self, .FALSE., ErrStat, ErrMsg) + IF (ErrStat == CD_AGG_OK) CALL CD_FMF_Refresh_PointMesh(self%sys, ErrStat, ErrMsg) + END SUBROUTINE start_object_accelerations + SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, ErrMsg, orientation, & angular_velocity, angular_acceleration, step_start) - !! Impose the host-rod columns (the trailing nhost_rod moving columns) on the rod runtime. + !! Impose the host-rod and host-body columns (the trailing nhost_rod + nhost_body moving + !! columns) on the rod and Rigid6 runtimes. !! step_start: a transfer that does not advance (CD_AGG_UpdateStates_Moving), whose host - !! kinematics the next step of a CoupledPinned rod starts from (CD_Rod_SetHostKinematics). + !! kinematics the next step of a CoupledPinned rod or body starts from + !! (CD_Rod_SetHostKinematics, CD_Rigid6_SetHostKinematics). TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self REAL(wp), INTENT(IN) :: position(:, :), velocity(:, :), acceleration(:, :) INTEGER, INTENT(OUT) :: ErrStat @@ -2443,12 +2561,13 @@ SUBROUTINE set_host_objects(self, position, velocity, acceleration, ErrStat, Err IF (PRESENT(orientation)) THEN CALL CD_Rigid6_SetHostKinematics(self%rigid6, position(:, c0:c1), velocity(:, c0:c1), & acceleration(:, c0:c1), es, em, orientation(:, :, c0:c1), & - angular_velocity(:, c0:c1), angular_acceleration(:, c0:c1)) + angular_velocity(:, c0:c1), angular_acceleration(:, c0:c1), & + step_start=at_start) ELSE CALL CD_Rigid6_SetHostKinematics(self%rigid6, position(:, c0:c1), velocity(:, c0:c1), & acceleration(:, c0:c1), es, em, & angular_velocity=angular_velocity(:, c0:c1), & - angular_acceleration=angular_acceleration(:, c0:c1)) + angular_acceleration=angular_acceleration(:, c0:c1), step_start=at_start) END IF IF (es /= CD_DECKDRV_OK) THEN CALL map_deck_status(es, em, ErrStat, ErrMsg) @@ -2647,7 +2766,9 @@ SUBROUTINE CD_AGG_Set_Rigid6_States(self, states, ErrStat, ErrMsg) ErrMsg = '' IF (.NOT. self%has_rigid6) RETURN CALL CD_Rigid6_Set_States(self%rigid6, states, ErrStat, ErrMsg) - IF (ErrStat /= CD_AGG_OK .OR. self%nhost_body == 0) RETURN + IF (ErrStat /= CD_AGG_OK) RETURN + self%objects_committed = .TRUE. + IF (self%nhost_body == 0) RETURN ! Host-driven bodies: their Body line ends follow the restored body state exactly. CALL overlay_host_objects(self, .TRUE., ErrStat, ErrMsg) IF (ErrStat == CD_AGG_OK) CALL CD_FMF_Refresh_PointMesh(self%sys, ErrStat, ErrMsg) @@ -2681,6 +2802,7 @@ SUBROUTINE CD_AGG_Set_Rod_States(self, states, ErrStat, ErrMsg) IF (.NOT. self%has_rod) RETURN CALL CD_Rod_Set_States(self%rod, states, ErrStat, ErrMsg) IF (ErrStat /= CD_AGG_OK) RETURN + self%objects_committed = .TRUE. CALL CD_Rod_Apply_States(self%sys%fast%system, self%rod, ErrStat, ErrMsg) IF (ErrStat /= CD_AGG_OK) RETURN ! Host-driven rods: their RodA/B line ends follow the restored rod state exactly (an diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index e3e1af9d..a64d2849 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -33,7 +33,8 @@ MODULE CableDyn_Static USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor_Gradient, CD_BATHY_OK USE CableDyn_Hydro, ONLY: CD_Cable_Morison_Drag_Force, CD_Morison_Drag_Element_Load, CD_Current_Profile_Velocity, & - CD_HYDRO_OK + CD_CurrentGridType, CD_Current_Grid_Velocity, CD_Current_Grid_Gradient, & + CD_Current_Profile_Gradient, CD_HYDRO_OK USE CableDyn_Linalg, ONLY: CD_Solve_Banded USE CableDyn_Mesh, ONLY: CD_Partition_Free_Dofs USE CableDyn_Catenary, ONLY: CD_Catenary_Seed, CD_CAT_OK @@ -90,6 +91,11 @@ MODULE CableDyn_Static ! residual evaluation (the dynamic march samples it at the actual node depths too), so the ! static state is an equilibrium of the marched model. It replaces node_velocity/velocity. REAL(wp), ALLOCATABLE :: profile_z(:), profile_velocity(:, :) + ! A current grid in space and time (MoorDyn-C Currents 2 and 5, CD_CurrentGridType): when + ! allocated, each node's current is its value at the node's own position at t = 0 (the + ! static start), re-sampled in every residual evaluation like the depth profile, which it + ! replaces. + TYPE(CD_CurrentGridType), ALLOCATABLE :: grid ! drag = .FALSE.: the object carries only the static seabed friction below (a line in ! still water); the drag fields are then ignored and need not be set. LOGICAL :: drag = .TRUE. @@ -397,8 +403,8 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix fluidvel(:, k) = current%velocity END DO END IF - profile_active = ALLOCATED(current%profile_z) - IF (profile_active) THEN + profile_active = ALLOCATED(current%profile_z) .OR. ALLOCATED(current%grid) + IF (profile_active .AND. .NOT. ALLOCATED(current%grid)) THEN IF (.NOT. ALLOCATED(current%profile_velocity)) THEN CALL fail(ErrStat, ErrMsg, 'current profile_z requires profile_velocity') RETURN @@ -408,6 +414,8 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix CALL fail(ErrStat, ErrMsg, 'current profile_velocity must have shape (3, SIZE(profile_z))') RETURN END IF + END IF + IF (profile_active) THEN CALL sample_profile(q0, es, em) IF (es /= CD_HYDRO_OK) THEN CALL fail(ErrStat, ErrMsg, 'current profile: '//TRIM(em)) @@ -972,13 +980,21 @@ SUBROUTINE add_friction(qe, f_contact, add_tangent, node, normal, dnormal_dz) END SUBROUTINE add_friction SUBROUTINE sample_profile(qe, es_out, em_out) - !! Current of every node at its own elevation in state qe (depth-profile current). + !! Current of every node at its own elevation in state qe (depth-profile current), or at + !! its own position at t = 0 (current grid). REAL(wp), INTENT(IN) :: qe(:) INTEGER, INTENT(OUT) :: es_out CHARACTER(*), INTENT(OUT) :: em_out INTEGER :: i es_out = CD_HYDRO_OK em_out = '' + IF (ALLOCATED(current%grid)) THEN + DO i = 1, n_nodes + CALL CD_Current_Grid_Velocity(current%grid, qe(3*i - 2:3*i), CD_ZERO, fluidvel(:, i), es_out, em_out) + IF (es_out /= CD_HYDRO_OK) RETURN + END DO + RETURN + END IF DO i = 1, n_nodes CALL CD_Current_Profile_Velocity(qe(3*i), current%profile_z, current%profile_velocity, fluidvel(:, i), & es_out, em_out) @@ -1027,7 +1043,7 @@ SUBROUTINE eval_drag_tangent(qe, es_out, em_out) INTEGER, INTENT(OUT) :: es_out CHARACTER(*), INTENT(OUT) :: em_out INTEGER :: e, a, b, i, j, fi, fj, gmap(6) - REAL(wp) :: f2(6), jq2(6, 6), jv2(6, 6), de, cn, ct + REAL(wp) :: f2(6), jq2(6, 6), jv2(6, 6), de, cn, ct, grad_a(3, 3), grad_b(3, 3) drag_kq_band = CD_ZERO es_out = CD_HYDRO_OK @@ -1048,6 +1064,23 @@ SUBROUTINE eval_drag_tangent(qe, es_out, em_out) fluidvel(:, a), fluidvel(:, b), waterln(a), waterln(b), & current%rho, de, cn, ct, f2, jq2, jv2, es_out, em_out) IF (es_out /= CD_HYDRO_OK) RETURN + IF (profile_active) THEN + ! A current re-sampled at the node positions moves with them: the load depends on + ! position through the fluid velocity too, d(load)/du_a = -d(load)/dv_a, so + ! -d(load)/dq_a gains -(jac_v block a) G_a with G = du/dx the field's gradient at the node + ! (without it the Newton iteration can fail in a current sheared across the line). + IF (ALLOCATED(current%grid)) THEN + CALL CD_Current_Grid_Gradient(current%grid, qe(3*a - 2:3*a), CD_ZERO, grad_a, es_out, em_out) + IF (es_out == CD_HYDRO_OK) & + CALL CD_Current_Grid_Gradient(current%grid, qe(3*b - 2:3*b), CD_ZERO, grad_b, es_out, em_out) + IF (es_out /= CD_HYDRO_OK) RETURN + ELSE + CALL CD_Current_Profile_Gradient(qe(3*a), current%profile_z, current%profile_velocity, grad_a) + CALL CD_Current_Profile_Gradient(qe(3*b), current%profile_z, current%profile_velocity, grad_b) + END IF + jq2(:, 1:3) = jq2(:, 1:3) - MATMUL(jv2(:, 1:3), grad_a) + jq2(:, 4:6) = jq2(:, 4:6) - MATMUL(jv2(:, 4:6), grad_b) + END IF DO i = 1, 3 gmap(i) = 3*a - 3 + i gmap(3 + i) = 3*b - 3 + i @@ -2532,7 +2565,14 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, a = elem_conn(1, e) b = elem_conn(2, e) IF (.NOT. (ANY(ends == a) .OR. ANY(ends == b))) CYCLE - IF (ALLOCATED(current%profile_z) .AND. ALLOCATED(current%profile_velocity)) THEN + IF (ALLOCATED(current%grid)) THEN + CALL CD_Current_Grid_Velocity(current%grid, q(3*a - 2:3*a), CD_ZERO, va, es, em) + IF (es == CD_HYDRO_OK) CALL CD_Current_Grid_Velocity(current%grid, q(3*b - 2:3*b), CD_ZERO, vb, es, em) + IF (es /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'end forces: '//TRIM(em)) + RETURN + END IF + ELSE IF (ALLOCATED(current%profile_z) .AND. ALLOCATED(current%profile_velocity)) THEN CALL CD_Current_Profile_Velocity(q(3*a), current%profile_z, current%profile_velocity, va, es, em) IF (es == CD_HYDRO_OK) CALL CD_Current_Profile_Velocity(q(3*b), current%profile_z, & current%profile_velocity, vb, es, em) diff --git a/src/CableDyn_Syrope.f90 b/src/CableDyn_Syrope.f90 index 511ef818..3fd1718c 100644 --- a/src/CableDyn_Syrope.f90 +++ b/src/CableDyn_Syrope.f90 @@ -575,8 +575,10 @@ SUBROUTINE CD_Syrope_State_Advance(td, on_wc, wc_strain, wc_tension, wc_slow, sl END IF IF (residual < CD_ZERO) THEN lo = x + rlo = residual ELSE hi = x + rhi = residual END IF ! Safeguarded numerical Newton step. Near a kink or a flat derivative, @@ -597,6 +599,46 @@ SUBROUTINE CD_Syrope_State_Advance(td, on_wc, wc_strain, wc_tension, wc_slow, sl END IF x = trial END DO + ! The safeguarded Newton step can creep along one side of the bracket when the root lies + ! closer to a kink of the rate than its difference interval h, where the slope of + ! T_mean(eps_slow) changes (the top sample of the working curve, beyond which its + ! interpolation clamps at T_max, as when a rope rests on its OWC at its running maximum): + ! the difference quotient straddles the kink, and every step lands inside the bracket and + ! moves only that end. Finish then by bisection, which halves the bracket every iteration + ! (R is continuous on it, so the bracket closes on its root) until the residual test is met. + ! A steep R (a light BA_s + BA_d, R' = 1 - dt d(rate)/d(eps_slow) of order 1e6) can change + ! sign between two adjacent reals with |R| above the test on both: the root is then located + ! to machine precision, and the end with the smaller |R| is taken (R(lo) < 0 <= R(hi)). + ! A solve that converged above never gets here, so its result is unchanged. The switch comes + ! only after the 80 Newton iterations: many solves that converge creep for a while first, + ! and switching on creeping iterations (two to eight in a row) changed 6e3 to 4e4 of 4.4e5 + ! fuzzed solves that converge without it. + DO iter = 1, 200 + x = 0.5_wp*(lo + hi) + IF (.NOT. (x > lo .AND. x < hi)) THEN + x = hi + IF (ABS(rlo) < ABS(rhi)) x = lo + CALL eval_rate(x, rate, tension, t_mean) + IF (ErrStat /= CD_SYROPE_OK) RETURN + slow_next = x + RETURN + END IF + CALL eval_rate(x, rate, tension, t_mean) + IF (ErrStat /= CD_SYROPE_OK) RETURN + residual = x - slow_old - dt*rate + tol = RTOL*MAX(CD_ONE, ABS(x), ABS(slow_old), ABS(dt*rate)) + IF (ABS(residual) <= tol) THEN + slow_next = x + RETURN + END IF + IF (residual < CD_ZERO) THEN + lo = x + rlo = residual + ELSE + hi = x + rhi = residual + END IF + END DO CALL fail(ErrStat, ErrMsg, 'Syrope backward-Euler state solve did not converge') CONTAINS diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 14916202..01d7957a 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -40,9 +40,10 @@ MODULE CableDyn !! construct is routed into the corresponding CableDyn feature (bodies and rods, !! viscoelastic and Syrope ropes, line failures, active tension through the CONTROL !! section, SeaState water kinematics), or, where CableDyn has no counterpart (for - !! example a CoupledPinned body), fails closed with a named error. A CoupledPinned rod - !! is a coupling-mesh node like a Coupled rod but takes only the translation of its - !! node and returns force with zero moment: it turns about the node on its own. + !! example a rotational body drag area), fails closed with a named error. A CoupledPinned + !! rod or body is a coupling-mesh node like a Coupled rod or body but takes only the + !! translation of its node and returns force with zero moment: it turns about the node on + !! its own. !! !! Supported coupled surface (each verified against stock MoorDyn or a named gate): !! Fixed/Coupled(Vessel) points, EI=0 mooring lines (BA damping + the Morison set), diff --git a/tests/data/currents_mdc/c1/current_profile.txt b/tests/data/currents_mdc/c1/current_profile.txt new file mode 100644 index 00000000..6440dce8 --- /dev/null +++ b/tests/data/currents_mdc/c1/current_profile.txt @@ -0,0 +1,14 @@ +--------------------- MoorDyn steady currents File ---------------------------------- +Tabulated file with the water currents components +z (m), ux (m/s), uy (m/s), uz (m/s) +-50.0 0.2 -0.1 0.0 +-45.0 0.22 -0.0995 0.001 +-40.0 0.24000000000000002 -0.098 0.002 +-35.0 0.26 -0.0955 0.003 +-30.0 0.28 -0.092 0.004 +-25.0 0.30000000000000004 -0.08750000000000001 0.005 +-20.0 0.32 -0.082 0.006 +-15.0 0.34 -0.07550000000000001 0.007 +-10.0 0.36 -0.068 0.008 +-5.0 0.38 -0.0595 0.009000000000000001 +0.0 0.4 -0.05 0.01 diff --git a/tests/data/currents_mdc/c1/currents.dat b/tests/data/currents_mdc/c1/currents.dat new file mode 100644 index 00000000..80f43806 --- /dev/null +++ b/tests/data/currents_mdc/c1/currents.dat @@ -0,0 +1,26 @@ +--------------------- MoorDyn Input File ------------------------------------ +Shared current parity deck (MoorDyn-C WaveKin 0, Currents 1): steady profile +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed -30.0 0.0 -20.0 0 0 0 0 +2 Vessel 30.0 0.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 chain 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +10.0 TMax simulation length (s) +3.0e6 kBot bottom stiffness (Pa/m) +3.0e5 cBot bottom damping (Pa-s/m) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +0.0 TmaxIC max time for ic gen (s) +0 WaveKin MoorDyn-C water kinematics mode (-) +1 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/c1/points.txt b/tests/data/currents_mdc/c1/points.txt new file mode 100644 index 00000000..8fd9d0fe --- /dev/null +++ b/tests/data/currents_mdc/c1/points.txt @@ -0,0 +1,45 @@ +0.0 3.625747096391059 1.204796483183113 -61.0 +0.0 29.240222818749317 -9.25239045413613 -50.0 +0.0 23.46046359355391 1.8229666122879866 -47.5 +0.0 -19.043779590969727 -4.599139224969835 -33.3 +0.0 -12.856308645593106 -1.749412098253556 -30.0 +0.0 38.36488703383566 -7.038199728668184 -12.3 +0.0 -33.361464723920776 -4.316260942636896 -2.0 +0.0 13.865936011298075 8.422021827334497 0.0 +0.0 -4.702829992963025 -1.6717186681526446 1.5 +0.5 -14.07536799232922 9.54041437133462 -61.0 +0.5 -1.266200937440189 -2.1387238980221905 -50.0 +0.5 21.991887387430154 -6.313315647241533 -47.5 +0.5 9.065590048206033 -3.9266969732113344 -33.3 +0.5 32.59611361428382 -2.471527225465257 -30.0 +0.5 8.548136741557208 7.73235531958516 -12.3 +0.5 10.767468921776384 -9.901710084464543 -2.0 +0.5 33.170979663189556 -6.387110542603544 0.0 +0.5 -18.832109881530876 1.3939569631943698 1.5 +3.0 -23.84629742780436 -7.411284659684765 -61.0 +3.0 16.2776411086751 -7.986057426728303 -50.0 +3.0 -1.5453992830454126 -8.544058084292184 -47.5 +3.0 33.748083410629704 -2.1145711101399893 -33.3 +3.0 7.1129995867811076 8.077716999122323 -30.0 +3.0 -21.206744257784713 -8.287889299555204 -12.3 +3.0 19.018417993166082 8.575850333694412 -2.0 +3.0 -34.24034673398577 9.933110274458684 0.0 +3.0 -31.67357968747993 -1.3198406078312601 1.5 +7.7 -18.474195005654472 -5.552630906546348 -61.0 +7.7 -14.846582951132675 6.974335055539811 -50.0 +7.7 7.399286028033458 -4.889381691061896 -47.5 +7.7 26.668381073668257 0.43097649083227907 -33.3 +7.7 -23.89846830191276 0.7687996394637064 -30.0 +7.7 -18.75050881328726 8.739373633670333 -12.3 +7.7 26.194471802351387 2.9173305077171037 -2.0 +7.7 -33.4763574363689 9.123955477562177 0.0 +7.7 16.227574118222492 6.727258469164298 1.5 +10.0 -2.3242607964400293 -6.98799947972778 -61.0 +10.0 25.87157786708798 -9.163031820079166 -50.0 +10.0 26.779122526321913 4.0438763545298855 -47.5 +10.0 -10.986895134543175 6.050656948172406 -33.3 +10.0 37.52443736070754 8.039683536558893 -30.0 +10.0 -11.120433344512115 -3.612516949673248 -12.3 +10.0 16.37635004074521 -2.4287988814413364 -2.0 +10.0 -25.014363736779465 -8.657988727363897 0.0 +10.0 -33.30484432612042 4.748403474389418 1.5 diff --git a/tests/data/currents_mdc/c1/ref_moordyn_c.csv b/tests/data/currents_mdc/c1/ref_moordyn_c.csv new file mode 100644 index 00000000..0a8e60f0 --- /dev/null +++ b/tests/data/currents_mdc/c1/ref_moordyn_c.csv @@ -0,0 +1,46 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,3.6257470963910592,1.2047964831831131,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,29.240222818749317,-9.2523904541361297,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,23.460463593553911,1.8229666122879866,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0,-19.043779590969727,-4.5991392249698348,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0,-12.856308645593106,-1.7494120982535559,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0,38.364887033835657,-7.0381997286681841,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0,-33.361464723920776,-4.3162609426368963,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0,13.865936011298075,8.4220218273344969,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0,-4.7028299929630251,-1.6717186681526446,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.49999999999999994,-14.07536799232922,9.5404143713346201,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,-1.266200937440189,-2.1387238980221905,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,21.991887387430154,-6.3133156472415326,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0.5,9.0655900482060332,-3.9266969732113344,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0.5,32.596113614283823,-2.4715272254652572,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0.5,8.548136741557208,7.7323553195851602,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0.5,10.767468921776384,-9.9017100844645434,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0.5,33.170979663189556,-6.3871105426035442,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.5,-18.832109881530876,1.3939569631943698,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +2.9999999999998335,-23.846297427804359,-7.4112846596847648,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,16.277641108675098,-7.9860574267283031,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,-1.5453992830454126,-8.5440580842921836,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +3,33.748083410629704,-2.1145711101399893,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +3,7.1129995867811076,8.0777169991223232,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +3,-21.206744257784713,-8.2878892995552036,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +3,19.018417993166082,8.5758503336944116,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +3,-34.240346733985767,9.9331102744586843,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +3,-31.673579687479929,-1.3198406078312601,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000014222,-18.474195005654472,-5.5526309065463479,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000014222,-14.846582951132675,6.9743350555398109,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000014222,7.3992860280334583,-4.8893816910618959,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +7.7000000000014222,26.668381073668257,0.43097649083227907,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +7.7000000000014222,-23.898468301912761,0.76879963946370644,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +7.7000000000014222,-18.750508813287261,8.7393736336703327,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +7.7000000000014222,26.194471802351387,2.9173305077171037,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +7.7000000000014222,-33.4763574363689,9.123955477562177,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000014222,16.227574118222492,6.7272584691642976,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +9.9999999999990248,-2.3242607964400293,-6.9879994797277796,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,25.871577867087979,-9.1630318200791656,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,26.779122526321913,4.0438763545298855,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +10,-10.986895134543175,6.0506569481724064,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +10,37.524437360707537,8.0396835365588935,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +10,-11.120433344512115,-3.6125169496732479,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +10,16.376350040745209,-2.4287988814413364,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +10,-25.014363736779465,-8.6579887273638967,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +10,-33.304844326120417,4.7484034743894181,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 diff --git a/tests/data/currents_mdc/c1/ref_python.csv b/tests/data/currents_mdc/c1/ref_python.csv new file mode 100644 index 00000000..cc47eeef --- /dev/null +++ b/tests/data/currents_mdc/c1/ref_python.csv @@ -0,0 +1,46 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,3.6257470963910592,1.2047964831831131,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,29.240222818749317,-9.2523904541361297,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,23.460463593553911,1.8229666122879866,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0,-19.043779590969727,-4.5991392249698348,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0,-12.856308645593106,-1.7494120982535559,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0,38.364887033835657,-7.0381997286681841,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0,-33.361464723920776,-4.3162609426368963,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0,13.865936011298075,8.4220218273344969,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0,-4.7028299929630251,-1.6717186681526446,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.5,-14.07536799232922,9.5404143713346201,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,-1.266200937440189,-2.1387238980221905,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,21.991887387430154,-6.3133156472415326,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0.5,9.0655900482060332,-3.9266969732113344,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0.5,32.596113614283823,-2.4715272254652572,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0.5,8.548136741557208,7.7323553195851602,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0.5,10.767468921776384,-9.9017100844645434,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0.5,33.170979663189556,-6.3871105426035442,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.5,-18.832109881530876,1.3939569631943698,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +3,-23.846297427804359,-7.4112846596847648,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,16.277641108675098,-7.9860574267283031,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,-1.5453992830454126,-8.5440580842921836,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +3,33.748083410629704,-2.1145711101399893,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +3,7.1129995867811076,8.0777169991223232,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +3,-21.206744257784713,-8.2878892995552036,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +3,19.018417993166082,8.5758503336944116,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +3,-34.240346733985767,9.9331102744586843,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +3,-31.673579687479929,-1.3198406078312601,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000000002,-18.474195005654472,-5.5526309065463479,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000000002,-14.846582951132675,6.9743350555398109,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000000002,7.3992860280334583,-4.8893816910618959,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +7.7000000000000002,26.668381073668257,0.43097649083227907,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +7.7000000000000002,-23.898468301912761,0.76879963946370644,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +7.7000000000000002,-18.750508813287261,8.7393736336703327,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +7.7000000000000002,26.194471802351387,2.9173305077171037,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +7.7000000000000002,-33.4763574363689,9.123955477562177,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000000002,16.227574118222492,6.7272584691642976,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +10,-2.3242607964400293,-6.9879994797277796,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,25.871577867087979,-9.1630318200791656,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,26.779122526321913,4.0438763545298855,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +10,-10.986895134543175,6.0506569481724064,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +10,37.524437360707537,8.0396835365588935,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +10,-11.120433344512115,-3.6125169496732479,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +10,16.376350040745209,-2.4287988814413364,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +10,-25.014363736779465,-8.6579887273638967,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +10,-33.304844326120417,4.7484034743894181,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 diff --git a/tests/data/currents_mdc/c2/current_profile_dynamic.txt b/tests/data/currents_mdc/c2/current_profile_dynamic.txt new file mode 100644 index 00000000..8e9e922f --- /dev/null +++ b/tests/data/currents_mdc/c2/current_profile_dynamic.txt @@ -0,0 +1,11 @@ +--------------------- MoorDyn dynamic currents File ---------------------------------- +a depth profile that varies in time (uneven times) + +header line 4 + -50.0 -30.0 -12.5 -5.0 0.0 +time ux... uy... uz... +0.0 0.000000 0.603832 0.838656 0.939295 1.006387 0.000000 0.210000 0.175000 0.160000 0.150000 0.000000 -0.000000 -0.000000 -0.000000 0.000000 +4.0 0.433036 0.779465 1.082590 1.212501 1.299108 0.216636 0.176636 0.141636 0.126636 0.116636 0.005440 0.002794 -0.005985 -0.008415 0.000000 +7.0 0.459627 0.827328 1.149067 1.286955 1.378881 0.155749 0.115749 0.080749 0.065749 0.055749 0.009756 0.008797 0.009436 -0.009840 0.000000 +15.0 0.353575 0.636435 0.883938 0.990010 1.060725 -0.024508 -0.064508 -0.099508 -0.114508 -0.124508 0.001978 0.004872 -0.000498 0.005716 0.000000 +30.0 0.517385 0.931293 1.293462 1.448678 1.552155 0.156697 0.116697 0.081697 0.066697 0.056697 0.003878 -0.008509 0.000994 -0.009380 0.000000 diff --git a/tests/data/currents_mdc/c2/currents.dat b/tests/data/currents_mdc/c2/currents.dat new file mode 100644 index 00000000..3386698a --- /dev/null +++ b/tests/data/currents_mdc/c2/currents.dat @@ -0,0 +1,26 @@ +--------------------- MoorDyn Input File ------------------------------------ +Shared current parity deck (MoorDyn-C WaveKin 0, Currents 2): time-varying profile +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed -30.0 0.0 -20.0 0 0 0 0 +2 Vessel 30.0 0.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 chain 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +72.0 TMax simulation length (s) +3.0e6 kBot bottom stiffness (Pa/m) +3.0e5 cBot bottom damping (Pa-s/m) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +0.0 TmaxIC max time for ic gen (s) +0 WaveKin MoorDyn-C water kinematics mode (-) +2 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/c2/points.txt b/tests/data/currents_mdc/c2/points.txt new file mode 100644 index 00000000..0da5d957 --- /dev/null +++ b/tests/data/currents_mdc/c2/points.txt @@ -0,0 +1,170 @@ +0.0 -7.02274407112499 5.111191447569773 -70.0 +0.0 31.485198909702078 -2.714340560540456 -50.0 +0.0 -20.809732103447978 -0.11709455529188517 -41.0 +0.0 39.37280373726867 8.147073783375749 -30.0 +0.0 22.655718499009495 9.007258842943656 -20.0 +0.0 -18.7537186637282 -6.33128609556366 -12.5 +0.0 -12.854524951559121 -9.226121975251093 -7.3 +0.0 -14.582842600996724 9.948139588388933 -1.0 +0.0 36.632586546811126 8.810295057781655 0.0 +0.0 -29.96197077630681 -7.427336525682544 2.0 +0.7 -28.02076086210656 -6.523047821498196 -70.0 +0.7 -36.14628172153602 -9.284919940469585 -50.0 +0.7 3.3553280663774103 -4.097783379274052 -41.0 +0.7 -31.972033235176774 5.452151169515091 -30.0 +0.7 34.37959677019529 -8.721812201917752 -20.0 +0.7 11.16126785635651 2.5043531721859065 -12.5 +0.7 -29.348708093264236 0.9562592119631503 -7.3 +0.7 -22.203587385333094 -2.037888397728058 -1.0 +0.7 18.190400780927327 7.693202911420261 0.0 +0.7 -24.12915133518095 1.4288192371581143 2.0 +2.9999 -22.69698324330357 4.7645721603939695 -70.0 +2.9999 29.60912871286267 -4.595171802377718 -50.0 +2.9999 25.618852234935133 7.654491368813606 -41.0 +2.9999 10.53684893278772 -6.745087112276895 -30.0 +2.9999 -20.11730365275597 -8.15528754041507 -20.0 +2.9999 28.877993020518687 3.6868449410257362 -12.5 +2.9999 34.88947203636303 -8.649918397237435 -7.3 +2.9999 -17.050722524734745 6.410433238769084 -1.0 +2.9999 -16.690651040342416 -9.102290200816356 0.0 +2.9999 9.341015495959546 -0.6708157716698366 2.0 +3.0 -10.836166288895548 -2.811508683337676 -70.0 +3.0 16.77544370038276 -6.71317237580249 -50.0 +3.0 15.42782093757721 9.244832796080779 -41.0 +3.0 7.630055290347471 -3.3308172468554282 -30.0 +3.0 -27.412426819126992 9.635807381611084 -20.0 +3.0 17.20368294581285 6.804029695690261 -12.5 +3.0 -38.99039508391235 -8.600796918063523 -7.3 +3.0 -29.23184990330986 7.16677430254904 -1.0 +3.0 -35.203358965445574 -9.06927555629794 0.0 +3.0 -36.116039280277235 -3.882238256345685 2.0 +4.4 1.1124388464913793 5.20525876471501 -70.0 +4.4 34.909765359536976 4.649206520776003 -50.0 +4.4 33.38247618905423 6.2852042478643355 -41.0 +4.4 21.11808898951169 7.146451792665914 -30.0 +4.4 -16.79152348675787 1.797590082510812 -20.0 +4.4 7.904121174278195 -0.05464630281863947 -12.5 +4.4 38.84417503848353 7.184393131716664 -7.3 +4.4 -8.721368622618133 2.939017904926253 -1.0 +4.4 -31.500770648871857 -4.191686418096204 0.0 +4.4 -31.018717744515953 4.28736024868326 2.0 +6.99 25.984579991006967 6.148921133070914 -70.0 +6.99 25.581854432298712 9.711080199082648 -50.0 +6.99 36.400293065186446 -6.478819272190939 -41.0 +6.99 -16.131052630013 -9.933801481428981 -30.0 +6.99 11.949152372833652 -0.6496388177203514 -20.0 +6.99 1.7948777433545473 1.053663708101407 -12.5 +6.99 -5.967658939612022 -1.1771128513667843 -7.3 +6.99 24.096936358151595 3.474822206122692 -1.0 +6.99 34.277818838471035 0.919347914896818 0.0 +6.99 29.82452168463881 -6.78566161845475 2.0 +10.1 -38.71377810637341 -2.6909196691918824 -70.0 +10.1 21.585287827692134 -1.5231418564411054 -50.0 +10.1 33.277869171065134 -8.813343938797555 -41.0 +10.1 33.31326330797876 2.9080081138450176 -30.0 +10.1 -4.615604223592669 5.469048364129481 -20.0 +10.1 14.431288479807982 -6.086644825390774 -12.5 +10.1 -22.287438378876743 -5.993156351656794 -7.3 +10.1 24.79879938034503 -3.9029596822975527 -1.0 +10.1 -22.749879023039252 8.395813095968222 0.0 +10.1 22.027009649720995 1.515237560299898 2.0 +15.0 13.876708886608398 0.7419805953356473 -70.0 +15.0 -2.7469521472092566 -3.5314995308744734 -50.0 +15.0 29.646585258486994 9.962368830173471 -41.0 +15.0 37.053032151947576 9.81812850654958 -30.0 +15.0 21.02986346698144 -5.0995662461400215 -20.0 +15.0 32.84519682282985 -2.3039314011475254 -12.5 +15.0 36.13609205407985 7.003867378567644 -7.3 +15.0 -11.799015997376479 9.143553865208155 -1.0 +15.0 -13.440509756587147 3.6347630909713775 0.0 +15.0 0.9221939903324099 -3.9009838610955754 2.0 +22.2 36.86710835794585 4.323452802889294 -70.0 +22.2 -32.32894301793878 -1.8016757645856387 -50.0 +22.2 -35.80139720077473 -5.159978650043689 -41.0 +22.2 -26.22368089792042 8.239591500764341 -30.0 +22.2 23.990432529791548 4.278286793812818 -20.0 +22.2 2.887023810869664 6.482848982697266 -12.5 +22.2 32.434164811981134 -7.850777221993363 -7.3 +22.2 27.646650826375748 6.677775432800441 -1.0 +22.2 0.7439691736044267 5.562222983029244 0.0 +22.2 25.152845672099858 7.842833299939155 2.0 +27.0 34.17743485462587 5.976624160118602 -70.0 +27.0 22.493094807101244 -0.3077505481058491 -50.0 +27.0 25.88581939047276 -5.8243899747383665 -41.0 +27.0 -28.483027801526923 -9.30702194503688 -30.0 +27.0 9.021346610391355 -3.454486553556011 -20.0 +27.0 -7.8579344021051085 4.308805042569695 -12.5 +27.0 3.846277922265557 2.544877826817034 -7.3 +27.0 18.177235829689387 4.683102526838535 -1.0 +27.0 -0.7580107998057599 -8.798399170974848 0.0 +27.0 21.20569224848559 -8.59787987749832 2.0 +29.9 1.406890943436487 -8.376998968552357 -70.0 +29.9 35.73493492274133 1.1619742971977622 -50.0 +29.9 37.799493650061336 0.41397227450426044 -41.0 +29.9 20.183925874373905 1.0212616773877166 -30.0 +29.9 -17.81588963423217 -1.0721355449493082 -20.0 +29.9 10.672238679317502 -7.289743184122948 -12.5 +29.9 -26.973218729797495 0.3614691414785991 -7.3 +29.9 37.135747505861445 -5.539721977770158 -1.0 +29.9 14.740809994223198 9.11256286402461 0.0 +29.9 -11.677147320143256 -9.247415795948292 2.0 +30.0 -8.650754310000881 9.16934613710388 -70.0 +30.0 -21.52834483255002 -2.4498442073934967 -50.0 +30.0 -37.91365942204985 1.7869178293190444 -41.0 +30.0 8.448105983536863 -0.7104286343268011 -30.0 +30.0 -10.984575041640863 -1.482566812128896 -20.0 +30.0 17.47171695947599 -3.3085417618235073 -12.5 +30.0 -9.969297911143286 6.476991369519826 -7.3 +30.0 19.28656187456903 -9.71700139622218 -1.0 +30.0 26.75939860221601 -2.596169523828566 0.0 +30.0 -27.572206265855908 -8.028149162705635 2.0 +31.5 12.32596528400471 -4.333836550439541 -70.0 +31.5 13.765699540806267 -1.3972193507397392 -50.0 +31.5 30.07191375299493 -0.2767730234363128 -41.0 +31.5 19.43154862585076 -9.795994592560435 -30.0 +31.5 -28.793376785410032 -8.456781239044686 -20.0 +31.5 -36.30974966959437 4.593534942927555 -12.5 +31.5 -2.239900235497096 0.13376092702809217 -7.3 +31.5 -23.449608268622228 2.8363753799615417 -1.0 +31.5 37.40950389700063 4.018053153001375 0.0 +31.5 -29.032706522727636 -0.2497391911787421 2.0 +33.0 -39.85412472901931 3.8768432788161906 -70.0 +33.0 17.684325638275766 3.5714735876826005 -50.0 +33.0 -0.4594188146910767 6.52802352390988 -41.0 +33.0 38.256746798218416 -3.2436924925503297 -30.0 +33.0 -27.521341499367054 -2.7390553415641 -20.0 +33.0 -12.987076895057115 -7.1632817430584605 -12.5 +33.0 -12.696516486637286 -6.258068783689041 -7.3 +33.0 -15.027932615069012 -1.6160955882136356 -1.0 +33.0 -30.393098056862947 -6.300330717877102 0.0 +33.0 17.451886515299904 -7.455914823927974 2.0 +35.2 -12.175965967280263 6.783113370124319 -70.0 +35.2 4.618081470479673 0.8154909897060758 -50.0 +35.2 35.55926111218679 4.137211499995836 -41.0 +35.2 -5.401121673640503 9.606615354240503 -30.0 +35.2 -12.10973856338616 0.03748479100456059 -20.0 +35.2 11.75197738317857 -9.52412923600807 -12.5 +35.2 21.03837088156746 3.5302548364859625 -7.3 +35.2 -15.973711330369085 3.4445876816223553 -1.0 +35.2 -20.73709617203651 -6.918272024152479 0.0 +35.2 24.68259701174533 2.2417909878109477 2.0 +40.0 -28.53669579612899 -4.9250282768244125 -70.0 +40.0 -37.79487475670331 -3.100688797868414 -50.0 +40.0 -34.489431309685216 0.3955085003395453 -41.0 +40.0 -22.625244513000098 -1.5039685698797065 -30.0 +40.0 -8.384812969166795 -6.875514272293152 -20.0 +40.0 -24.046467454115312 9.193786772436233 -12.5 +40.0 -7.158361636532753 -9.175947291231326 -7.3 +40.0 -37.56341961594708 -7.950113084987189 -1.0 +40.0 16.627586727950444 -1.701836685221103 0.0 +40.0 -20.29979488321547 2.246366688187342 2.0 +70.3 -27.25943988546411 1.3303422268762404 -70.0 +70.3 -18.329419181105777 8.499933068799717 -50.0 +70.3 -28.279731776551642 0.4043904563369196 -41.0 +70.3 7.2620474241576645 1.7805222100826015 -30.0 +70.3 5.56942953748969 7.433773413905932 -20.0 +70.3 -32.08471351381484 5.214401425367065 -12.5 +70.3 30.99699708402197 -7.629852384347919 -7.3 +70.3 16.420688115163323 0.3052507316806885 -1.0 +70.3 -12.057577684522364 -8.488938632238991 0.0 +70.3 -7.35147907642898 0.5750754838162742 2.0 diff --git a/tests/data/currents_mdc/c2/ref_moordyn_c.csv b/tests/data/currents_mdc/c2/ref_moordyn_c.csv new file mode 100644 index 00000000..e142d6be --- /dev/null +++ b/tests/data/currents_mdc/c2/ref_moordyn_c.csv @@ -0,0 +1,171 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,-7.0227440711249898,5.1111914475697731,-70,0,0,0,0,0,0,0 +0,31.485198909702078,-2.7143405605404558,-50,0,0,0,0,0,0,0 +0,-20.809732103447978,-0.11709455529188517,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +0,39.372803737268669,8.1470737833757489,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +0,22.655718499009495,9.0072588429436564,-20,0,0.73801714285714282,0.19,0,0,0,0 +0,-18.753718663728201,-6.3312860955636596,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +0,-12.854524951559121,-9.2261219752510932,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +0,-14.582842600996724,9.9481395883889334,-1,0,0.99296859999999998,0.152,0,0,0,0 +0,36.632586546811126,8.810295057781655,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,-29.96197077630681,-7.4273365256825441,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0.69999999999999984,-28.02076086210656,-6.5230478214981957,-70,0,0.075781299999999982,0.037911299999999988,0.00095199999999999983,0,0,0 +0.69999999999999996,-36.14628172153602,-9.2849199404695852,-50,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,3.3553280663774103,-4.0977833792740519,-41,0,0.32723521375000003,0.11272379999999999,0.00074362750000000002,0,0,0 +0.69999999999999996,-31.972033235176774,5.4521511695150906,-30,0,0.63456777500000006,0.20416129999999999,0.00048894999999999993,0,0,0 +0.69999999999999996,34.379596770195292,-8.7218122019177518,-20,0,0.7755830178571429,0.18416129999999997,-0.00038894999999999999,0,0,0 +0.69999999999999996,11.16126785635651,2.5043531721859065,-12.5,0,0.88134445000000006,0.16916129999999999,-0.0010473749999999999,0,0,0 +0.69999999999999996,-29.348708093264236,0.95625921196315034,-7.2999999999999998,0,0.95467249266666676,0.15876129999999999,-0.0013422149999999999,0,0,0 +0.69999999999999996,-22.203587385333094,-2.0378883977280582,-1,0,1.04351175,0.14616129999999999,-0.00029452499999999991,0,0,0 +0.69999999999999996,18.190400780927327,7.6932029114202614,0,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,-24.12915133518095,1.4288192371581143,2,0,1.057613175,0.14416129999999999,0,0,0,0 +2.9998999999998115,-22.696983243303571,4.7645721603939695,-70,0,0.3247661740999796,0.16247158409998977,0.004079863999999744,0,0,0 +2.9998999999999998,29.60912871286267,-4.5951718023777177,-50,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,25.618852234935133,7.6544913688136056,-41,0,0.50961995738374999,0.17259939659999998,0.0031868687675,0,0,0 +2.9998999999999998,10.53684893278772,-6.7450871122768952,-30,0,0.73555235917499995,0.18497783409999999,0.00209543015,0,0,0 +2.9998999999999998,-20.117303652755972,-8.1552875404150704,-20,0,0.89900838344642864,0.1649778341,-0.0016668730071428565,0,0,0 +2.9998999999999998,28.877993020518687,3.6868449410257362,-12.5,0,1.02160040165,0.14997783410000001,-0.0044886003749999995,0,0,0 +2.9998999999999998,34.889472036363031,-8.6499183972374354,-7.2999999999999998,0,1.1065977076019999,0.13957783410000002,-0.0057521582550000006,0,0,0 +2.9998999999999998,-17.050722524734745,6.4104332387690839,-1,0,1.2095748795499999,0.12697783410000002,-0.0012622079249999998,0,0,0 +2.9998999999999998,-16.690651040342416,-9.1022902008163555,0,0,1.2259204319749999,0.1249778341,0,0,0,0 +2.9998999999999998,9.3410154959595459,-0.67081577166983664,2,0,1.2259204319749999,0.1249778341,0,0,0,0 +3,-10.836166288895548,-2.8115086833376761,-70,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,16.775443700382759,-6.7131723758024897,-50,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,15.427820937577209,9.2448327960807788,-41,0,0.50962788749999999,0.17260199999999998,0.0031869750000000003,0,0,0 +3,7.630055290347471,-3.3308172468554282,-30,0,0.73555674999999998,0.18497699999999997,0.0020955000000000001,0,0,0 +3,-27.412426819126992,9.6358073816110839,-20,0,0.89901374999999994,0.16497699999999998,-0.0016669285714285709,0,0,0 +3,17.203682945812851,6.8040296956902608,-12.5,0,1.0216065000000001,0.14997700000000003,-0.0044887499999999997,0,0,0 +3,-38.990395083912347,-8.6007969180635229,-7.2999999999999998,0,1.1066043133333334,0.13957700000000001,-0.0057523500000000007,0,0,0 +3,-29.231849903309861,7.1667743025490402,-1,0,1.2095820999999998,0.12697700000000001,-0.0012622499999999999,0,0,0 +3,-35.203358965445574,-9.0692755562979404,0,0,1.2259277499999999,0.124977,0,0,0,0 +3,-36.116039280277235,-3.8822382563456852,2,0,1.2259277499999999,0.124977,0,0,0,0 +4.4000000000000217,1.1124388464913793,5.2052587647150101,-70,0,0.3835706222222231,0.16880857777777786,0.0060574222222222534,0,0,0 +4.4000000000000217,34.909765359536976,4.6492065207760032,-50,0,0.3835706222222231,0.16880857777777786,0.0060574222222222534,0,0,0 +4.4000000000000217,33.382476189054231,6.2852042478643355,-41,0,0.55788593222222294,0.16580857777777769,0.0052616622222222548,0,0,0 +4.4000000000000217,21.118088989511691,7.1464517926659141,-30,0,0.77093797777777828,0.16214191111111076,0.0042890666666667004,0,0,0 +4.4000000000000217,-16.791523486757871,1.797590082510812,-20,0,0.94225753333333406,0.1421419111111108,0.0016156825396825905,0,0,0 +4.4000000000000217,7.9041211742781954,-0.054646302818639469,-12.5,0,1.0707472000000009,0.12714191111111078,-0.00038935555555549188,0,0,0 +4.4000000000000217,38.844175038483527,7.1843931317166643,-7.2999999999999998,0,1.1598334613333343,0.11674191111111076,-0.005483260148148145,0,0,0 +4.4000000000000217,-8.7213686226181331,2.9390179049262528,-1,0,1.2677648400000008,0.10414191111111076,-0.0015472666666666709,0,0,0 +4.4000000000000217,-31.500770648871857,-4.1916864180962037,0,0,1.2848968000000007,0.10214191111111076,0,0,0,0 +4.4000000000000217,-31.018717744515953,4.2873602486832603,2,0,1.2848968000000007,0.10214191111111076,0,0,0,0 +6.9900000000009292,25.984579991006967,6.1489211330709139,-70,0,0.44493905333332784,0.15447589416664645,0.0081504083333331784,0,0,0 +6.9900000000009292,25.581854432298712,9.7110801990826481,-50,0,0.44493905333332784,0.15447589416664645,0.0081504083333331784,0,0,0 +6.9900000000009292,36.400293065186446,-6.4788192721909388,-41,0,0.60511694520832593,0.13647589416664646,0.0076923574583333907,0,0,0 +6.9900000000009292,-16.131052630012999,-9.933801481428981,-30,0,0.80088992416665683,0.11447589416664644,0.0071325175000003151,0,0,0 +6.9900000000009292,11.949152372833652,-0.64963881772035137,-20,0,0.97886558321427375,0.094475894166646451,0.0060124627380958428,0,0,0 +6.9900000000009292,1.7948777433545473,1.0536637081014071,-12.5,0,1.1123473274999864,0.079475894166646438,0.0051724216666674885,0,0,0 +6.9900000000009292,-5.9676589396120221,-1.1771128513667843,-7.2999999999999998,0,1.2048946048333187,0.069075894166646432,-0.0041257341555545717,0,0,0 +6.9900000000009292,24.096936358151595,3.4748222061226919,-1,0,1.3170195234999837,0.056475894166646431,-0.0016476759999997884,0,0,0 +6.9900000000009292,34.277818838471035,0.919347914896818,0,0,1.3348171599999836,0.054475894166646437,0,0,0,0 +6.9900000000009292,29.82452168463881,-6.7856616184547498,2,0,1.3348171599999836,0.054475894166646437,0,0,0,0 +10.099999999999296,-38.713778106373411,-2.6909196691918824,-70,0,0.41853185000000936,0.085899412500015843,0.0067420250000006848,0,0,0 +10.1,21.585287827692134,-1.5231418564411054,-50,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,33.277869171065134,-8.813343938797555,-41,0,0.56920315062499993,0.067899412500000006,0.0069823418750000008,0,0,0 +10.1,33.313263307978758,2.9080081138450176,-30,0,0.75335696249999995,0.045899412500000007,0.0072760624999999995,0,0,0 +10.1,-4.6156042235926691,5.4690483641294811,-20,0,0.92076984821428576,0.025899412500000003,0.006310641071428571,0,0,0 +10.1,14.431288479807982,-6.0866448253907741,-12.5,0,1.0463295125000001,0.010899412499999999,0.0055865749999999999,0,0,0 +10.1,-22.287438378876743,-5.9931563516567943,-7.2999999999999998,0,1.1333839605,0.00049941249999999743,-0.00092980500000000013,0,0,0 +10.1,24.798799380345031,-3.9029596822975527,-1,0,1.2388542025,-0.012100587499999999,-0.00076240999999999972,0,0,0 +10.1,-22.749879023039252,8.3958130959682222,0,0,1.25559555,-0.014100587499999997,0,0,0,0 +10.1,22.027009649720995,1.515237560299898,2,0,1.25559555,-0.014100587499999997,0,0,0,0 +14.999999999997604,13.876708886608398,0.74198059533564731,-70,0,0.35357500000003173,-0.024507999999946024,0.001978000000002329,0,0,0 +15,-2.7469521472092566,-3.5314995308744734,-50,0,0.35357499999999997,-0.024507999999999999,0.0019780000000000002,0,0,0 +15,29.646585258486994,9.962368830173471,-41,0,0.48086200000000001,-0.042507999999999997,0.0032802999999999999,0,0,0 +15,37.053032151947576,9.8181285065495807,-30,0,0.63643499999999997,-0.064507999999999996,0.0048719999999999996,0,0,0 +15,21.029863466981439,-5.0995662461400215,-20,0,0.7778652857142857,-0.084508,0.0018034285714285715,0,0,0 +15,32.845196822829848,-2.3039314011475254,-12.5,0,0.883938,-0.099507999999999999,-0.00049799999999999996,0,0,0 +15,36.136092054079853,7.0038673785676444,-7.2999999999999998,0,0.95748125333333334,-0.10990800000000001,0.0038103733333333333,0,0,0 +15,-11.799015997376479,9.1435538652081547,-1,0,1.0465819999999999,-0.12250799999999999,0.0011431999999999996,0,0,0 +15,-13.440509756587147,3.6347630909713775,0,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,0.9221939903324099,-3.9009838610955754,2,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +22.200000000007591,36.867108357945853,4.3234528028892942,-70,0,0.43220380000008285,0.062470400000091728,0.0028900000000009617,0,0,0 +22.200000000007591,-32.328943017938776,-1.8016757645856387,-50,0,0.43220380000008285,0.062470400000091728,0.0028900000000009617,0,0,0 +22.200000000007591,-35.80139720077473,-5.1599786500436888,-41,0,0.58779716800011284,0.044470400000091725,0.00089160399999748123,0,0,0 +22.200000000007591,-26.223680897920421,8.239591500764341,-30,0,0.77796684000014937,0.022470400000091713,-0.0015508800000067729,0,0,0 +22.200000000007591,23.990432529791548,4.2782867938128177,-20,0,0.95084837142875389,0.0024704000000917194,-0.00054000000000247112,0,0,0 +22.200000000007591,2.887023810869664,6.4828489826972664,-12.5,0,1.0805095200002073,-0.012529599999908278,0.00021816000000075529,0,0,0 +22.200000000007591,32.434164811981134,-7.8507772219933631,-7.2999999999999998,0,1.1704078965335578,-0.02292959999990828,-0.0009939530666717327,0,0,0 +22.200000000007591,27.646650826375748,6.6777754328004413,-1,0,1.2793232480002454,-0.035529599999908276,-0.00030601600000152812,0,0,0 +22.200000000007591,0.74396917360442671,5.562222983029244,0,0,1.2966114000002487,-0.037529599999908278,0,0,0,0 +22.200000000007591,25.152845672099858,7.842833299939155,2,0,1.2966114000002487,-0.037529599999908278,0,0,0,0 +27.000000000006168,34.177434854625872,5.9766241601186021,-70,0,0.48462300000006731,0.12045600000007449,0.0034980000000007809,0,0,0 +27.000000000006168,22.493094807101244,-0.30775054810584912,-50,0,0.48462300000006731,0.12045600000007449,0.0034980000000007809,0,0,0 +27.000000000006168,25.885819390472761,-5.8243899747383665,-41,0,0.65908728000009154,0.10245600000007449,-0.00070086000000204522,0,0,0 +27.000000000006168,-28.483027801526923,-9.3070219450368796,-30,0,0.87232140000012126,0.080456000000074482,-0.0058328000000054999,0,0,0 +27.000000000006168,9.0213466103913547,-3.454486553556011,-20,0,1.0661704285715765,0.060456000000074492,-0.0021022857142877212,0,0,0 +27.000000000006168,-7.8579344021051085,4.3088050425696949,-12.5,0,1.2115572000001682,0.045456000000074492,0.00069560000000061354,0,0,0 +27.000000000006168,3.846277922265557,2.544877826817034,-7.2999999999999998,0,1.3123589920001824,0.035056000000074493,-0.0041968373333374481,0,0,0 +27.000000000006168,18.177235829689387,4.6831025268385353,-1,0,1.4344840800001994,0.022456000000074486,-0.0012721600000012408,0,0,0 +27.000000000006168,-0.75801079980575992,-8.7983991709748484,0,0,1.4538690000002021,0.020456000000074488,0,0,0,0 +27.000000000006168,21.20569224848559,-8.5978798774983201,2,0,1.4538690000002021,0.020456000000074488,0,0,0,0 +29.900000000003637,1.4068909434364869,-8.3769989685523569,-70,0,0.51629293333337301,0.15548896666671058,0.0038653333333337936,0,0,0 +29.900000000003637,35.734934922741331,1.1619742971977622,-50,0,0.51629293333337301,0.15548896666671058,0.0038653333333337936,0,0,0 +29.900000000003637,37.799493650061336,0.41397227450426044,-41,0,0.70215838933338737,0.13748896666671057,-0.0016629736666678723,0,0,0 +29.900000000003637,20.183925874373905,1.0212616773877166,-30,0,0.92932728000007148,0.11548896666671057,-0.0084197933333365754,0,0,0 +29.900000000003637,-17.815889634232171,-1.0721355449493082,-20,0,1.1358441714286587,0.095488966666710584,-0.0030461666666678497,0,0,0 +29.900000000003637,10.672238679317502,-7.2897431841229476,-12.5,0,1.2907318400000991,0.080488966666710585,0.00098405333333369499,0,0,0 +29.900000000003637,-26.973218729797495,0.3614691414785991,-7.2999999999999998,0,1.3981211121778852,0.070088966666710592,-0.0061319132444468691,0,0,0 +29.900000000003637,37.135747505861445,-5.5397219777701583,-1,0,1.5282270826667841,0.057488966666710578,-0.0018558720000007309,0,0,0 +29.900000000003637,14.740809994223198,9.1125628640246106,0,0,1.548878800000119,0.055488966666710576,0,0,0,0 +29.900000000003637,-11.677147320143256,-9.2474157959482923,2,0,1.548878800000119,0.055488966666710576,0,0,0,0 +30.000000000000121,-8.650754310000881,9.1693461371038794,-70,0,0,0,0,0,0,0 +30.000000000000121,-21.528344832550019,-2.4498442073934967,-50,0,0,0,0,0,0,0 +30.000000000000121,-37.913659422049847,1.7869178293190444,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +30.000000000000121,8.4481059835368626,-0.71042863432680114,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +30.000000000000121,-10.984575041640863,-1.482566812128896,-20,0,0.73801714285714282,0.19,0,0,0,0 +30.000000000000121,17.471716959475991,-3.3085417618235073,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +30.000000000000121,-9.9692979111432862,6.4769913695198262,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +30.000000000000121,19.286561874569031,-9.7170013962221802,-1,0,0.99296859999999998,0.152,0,0,0,0 +30.000000000000121,26.75939860221601,-2.596169523828566,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +30.000000000000121,-27.572206265855908,-8.0281491627056347,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.500000000001826,12.32596528400471,-4.3338365504395409,-70,0,0,0,0,0,0,0 +31.500000000001826,13.765699540806267,-1.3972193507397392,-50,0,0,0,0,0,0,0 +31.500000000001826,30.071913752994931,-0.27677302343631283,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +31.500000000001826,19.431548625850759,-9.7959945925604348,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +31.500000000001826,-28.793376785410032,-8.4567812390446857,-20,0,0.73801714285714282,0.19,0,0,0,0 +31.500000000001826,-36.309749669594368,4.5935349429275547,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +31.500000000001826,-2.239900235497096,0.13376092702809217,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +31.500000000001826,-23.449608268622228,2.8363753799615417,-1,0,0.99296859999999998,0.152,0,0,0,0 +31.500000000001826,37.409503897000633,4.0180531530013752,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.500000000001826,-29.032706522727636,-0.2497391911787421,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +32.999999999998288,-39.854124729019311,3.8768432788161906,-70,0,0,0,0,0,0,0 +33,17.684325638275766,3.5714735876826005,-50,0,0,0,0,0,0,0 +33,-0.4594188146910767,6.5280235239098801,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +33,38.256746798218416,-3.2436924925503297,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +33,-27.521341499367054,-2.7390553415641001,-20,0,0.73801714285714282,0.19,0,0,0,0 +33,-12.987076895057115,-7.1632817430584605,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +33,-12.696516486637286,-6.2580687836890414,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +33,-15.027932615069012,-1.6160955882136356,-1,0,0.99296859999999998,0.152,0,0,0,0 +33,-30.393098056862947,-6.3003307178771024,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,17.451886515299904,-7.4559148239279738,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +35.199999999994901,-12.175965967280263,6.7831133701243189,-70,0,0.23816979999944818,0.11914979999972393,0.0029919999999930683,0,0,0 +35.200000000000003,4.6180814704796731,0.81549098970607581,-50,0,0.23816980000000029,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,35.559261112186789,4.1372114999958356,-41,0,0.44618695750000026,0.15177480000000004,0.0023371150000000033,0,0,0 +35.200000000000003,-5.4011216736405032,9.6066153542405033,-30,0,0.70043015000000008,0.19164979999999995,0.0015367000000000022,0,0,0 +35.200000000000003,-12.109738563386159,0.037484791004560591,-20,0,0.85608132142857163,0.17164979999999999,-0.0012224142857142867,0,0,0 +35.200000000000003,11.75197738317857,-9.5241292360080703,-12.5,0,0.97281970000000029,0.15664980000000001,-0.0032917500000000039,0,0,0 +35.200000000000003,21.038370881567459,3.5302548364859625,-7.2999999999999998,0,1.053758462666667,0.14624979999999999,-0.0042183900000000059,0,0,0 +35.200000000000003,-15.973711330369085,3.4445876816223553,-1,0,1.1518185000000001,0.13364979999999999,-0.00092565000000000106,0,0,0 +35.200000000000003,-20.737096172036509,-6.9182720241524791,0,0,1.16738355,0.13164979999999998,0,0,0,0 +35.200000000000003,24.682597011745329,2.2417909878109477,2,0,1.16738355,0.13164979999999998,0,0,0,0 +39.999999999989114,-28.536695796128988,-4.9250282768244125,-70,0,0.44488022222228624,0.15425802777801495,0.0081487222222240592,0,0,0 +40,-37.794874756703308,-3.1006887978684139,-50,0,0.44488022222222223,0.15425802777777775,0.0081487222222222239,0,0,0 +40,-34.489431309685216,0.39550850033954532,-41,0,0.6050369347222222,0.13625802777777773,0.0076929597222222239,0,0,0 +40,-22.625244513000098,-1.5039685698797065,-30,0,0.8007840277777778,0.11425802777777774,0.0071359166666666671,0,0,0 +40,-8.384812969166795,-6.8755142722931524,-20,0,0.9787361547619049,0.094258027777777739,0.0060189801587301603,0,0,0 +40,-24.046467454115312,9.1937867724362334,-12.5,0,1.1122002500000001,0.07925802777777774,0.0051812777777777794,0,0,0 +40,-7.1583616365327529,-9.175947291231326,-7.2999999999999998,0,1.2047352899999999,0.068858027777777747,-0.0041151281481481465,0,0,0 +40,-37.563419615947083,-7.9501130849871888,-1,0,1.3168453833333331,0.056258027777777747,-0.0016453999999999993,0,0,0 +40,16.627586727950444,-1.7018366852211031,0,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,-20.299794883215469,2.2463666881873419,2,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +70.299999999980059,-27.259439885464111,1.3303422268762404,-70,0,0.37937107777694035,0.16835632222213204,0.0059161777777496137,0,0,0 +70.300000000000011,-18.329419181105777,8.4999330687997166,-50,0,0.37937107777777823,0.16835632222222227,0.0059161777777777943,0,0,0 +70.300000000000011,-28.279731776551642,0.40439045633691961,-41,0,0.55443892902777825,0.16629382222222217,0.0051134702777777949,0,0,0 +70.300000000000011,7.2620474241576645,1.7805222100826015,-30,0,0.76841074722222258,0.16377298888888869,0.0041323833333333504,0,0,0 +70.300000000000011,5.5694295374896896,7.4337734139059322,-20,0,0.93916869166666705,0.1437729888888887,0.0013812103174603439,0,0,0 +70.300000000000011,-32.08471351381484,5.2144014253670647,-12.5,0,1.0672371500000004,0.12877298888888872,-0.00068216944444441123,0,0,0 +70.300000000000011,30.99699708402197,-7.6298523843479193,-7.2999999999999998,0,1.1560313793333339,0.11837298888888871,-0.00550248085185185,0,0,0 +70.300000000000011,16.420688115163323,0.3052507316806885,-1,0,1.2636089300000006,0.10577298888888871,-0.0015269083333333353,0,0,0 +70.300000000000011,-12.057577684522364,-8.488938632238991,0,0,1.2806847250000004,0.10377298888888871,0,0,0,0 +70.300000000000011,-7.3514790764289799,0.57507548381627416,2,0,1.2806847250000004,0.10377298888888871,0,0,0,0 diff --git a/tests/data/currents_mdc/c2/ref_python.csv b/tests/data/currents_mdc/c2/ref_python.csv new file mode 100644 index 00000000..2848e7f2 --- /dev/null +++ b/tests/data/currents_mdc/c2/ref_python.csv @@ -0,0 +1,171 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,-7.0227440711249898,5.1111914475697731,-70,0,0,0,0,0,0,0 +0,31.485198909702078,-2.7143405605404558,-50,0,0,0,0,0,0,0 +0,-20.809732103447978,-0.11709455529188517,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +0,39.372803737268669,8.1470737833757489,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +0,22.655718499009495,9.0072588429436564,-20,0,0.73801714285714282,0.19,0,0,0,0 +0,-18.753718663728201,-6.3312860955636596,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +0,-12.854524951559121,-9.2261219752510932,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +0,-14.582842600996724,9.9481395883889334,-1,0,0.99296859999999998,0.152,0,0,0,0 +0,36.632586546811126,8.810295057781655,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,-29.96197077630681,-7.4273365256825441,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0.69999999999999996,-28.02076086210656,-6.5230478214981957,-70,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,-36.14628172153602,-9.2849199404695852,-50,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,3.3553280663774103,-4.0977833792740519,-41,0,0.32723521375000003,0.11272379999999999,0.00074362750000000002,0,0,0 +0.69999999999999996,-31.972033235176774,5.4521511695150906,-30,0,0.63456777500000006,0.20416129999999999,0.00048894999999999993,0,0,0 +0.69999999999999996,34.379596770195292,-8.7218122019177518,-20,0,0.77558301785714279,0.18416129999999997,-0.00038894999999999999,0,0,0 +0.69999999999999996,11.16126785635651,2.5043531721859065,-12.5,0,0.88134444999999995,0.16916129999999999,-0.0010473749999999999,0,0,0 +0.69999999999999996,-29.348708093264236,0.95625921196315034,-7.2999999999999998,0,0.95467249266666676,0.15876129999999999,-0.0013422149999999999,0,0,0 +0.69999999999999996,-22.203587385333094,-2.0378883977280582,-1,0,1.04351175,0.14616129999999999,-0.00029452499999999991,0,0,0 +0.69999999999999996,18.190400780927327,7.6932029114202614,0,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,-24.12915133518095,1.4288192371581143,2,0,1.057613175,0.14416129999999999,0,0,0,0 +2.9998999999999998,-22.696983243303571,4.7645721603939695,-70,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,29.60912871286267,-4.5951718023777177,-50,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,25.618852234935133,7.6544913688136056,-41,0,0.50961995738374999,0.17259939660000001,0.0031868687675,0,0,0 +2.9998999999999998,10.53684893278772,-6.7450871122768952,-30,0,0.73555235917499995,0.18497783410000002,0.00209543015,0,0,0 +2.9998999999999998,-20.117303652755972,-8.1552875404150704,-20,0,0.89900838344642842,0.1649778341,-0.0016668730071428565,0,0,0 +2.9998999999999998,28.877993020518687,3.6868449410257362,-12.5,0,1.0216004016499998,0.14997783409999998,-0.0044886003749999995,0,0,0 +2.9998999999999998,34.889472036363031,-8.6499183972374354,-7.2999999999999998,0,1.1065977076019999,0.13957783410000002,-0.0057521582550000006,0,0,0 +2.9998999999999998,-17.050722524734745,6.4104332387690839,-1,0,1.2095748795499999,0.12697783410000002,-0.0012622079249999998,0,0,0 +2.9998999999999998,-16.690651040342416,-9.1022902008163555,0,0,1.2259204319749999,0.1249778341,0,0,0,0 +2.9998999999999998,9.3410154959595459,-0.67081577166983664,2,0,1.2259204319749999,0.1249778341,0,0,0,0 +3,-10.836166288895548,-2.8115086833376761,-70,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,16.775443700382759,-6.7131723758024897,-50,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,15.427820937577209,9.2448327960807788,-41,0,0.50962788749999999,0.17260199999999998,0.0031869750000000003,0,0,0 +3,7.630055290347471,-3.3308172468554282,-30,0,0.73555674999999998,0.184977,0.0020955000000000001,0,0,0 +3,-27.412426819126992,9.6358073816110839,-20,0,0.89901374999999994,0.16497699999999998,-0.0016669285714285709,0,0,0 +3,17.203682945812851,6.8040296956902608,-12.5,0,1.0216064999999999,0.149977,-0.0044887499999999997,0,0,0 +3,-38.990395083912347,-8.6007969180635229,-7.2999999999999998,0,1.1066043133333334,0.13957700000000001,-0.0057523500000000007,0,0,0 +3,-29.231849903309861,7.1667743025490402,-1,0,1.2095820999999998,0.12697700000000001,-0.0012622499999999999,0,0,0 +3,-35.203358965445574,-9.0692755562979404,0,0,1.2259277499999999,0.124977,0,0,0,0 +3,-36.116039280277235,-3.8822382563456852,2,0,1.2259277499999999,0.124977,0,0,0,0 +4.4000000000000004,1.1124388464913793,5.2052587647150101,-70,0,0.38357062222222227,0.16880857777777775,0.0060574222222222231,0,0,0 +4.4000000000000004,34.909765359536976,4.6492065207760032,-50,0,0.38357062222222227,0.16880857777777775,0.0060574222222222231,0,0,0 +4.4000000000000004,33.382476189054231,6.2852042478643355,-41,0,0.55788593222222227,0.16580857777777774,0.0052616622222222235,0,0,0 +4.4000000000000004,21.118088989511691,7.1464517926659141,-30,0,0.77093797777777773,0.16214191111111109,0.0042890666666666674,0,0,0 +4.4000000000000004,-16.791523486757871,1.797590082510812,-20,0,0.94225753333333329,0.1421419111111111,0.0016156825396825409,0,0,0 +4.4000000000000004,7.9041211742781954,-0.054646302818639469,-12.5,0,1.0707472,0.12714191111111112,-0.00038935555555555433,0,0,0 +4.4000000000000004,38.844175038483527,7.1843931317166643,-7.2999999999999998,0,1.1598334613333334,0.11674191111111112,-0.0054832601481481485,0,0,0 +4.4000000000000004,-8.7213686226181331,2.9390179049262528,-1,0,1.2677648399999999,0.10414191111111112,-0.0015472666666666666,0,0,0 +4.4000000000000004,-31.500770648871857,-4.1916864180962037,0,0,1.2848967999999998,0.10214191111111112,0,0,0,0 +4.4000000000000004,-31.018717744515953,4.2873602486832603,2,0,1.2848967999999998,0.10214191111111112,0,0,0,0 +6.9900000000000002,25.984579991006967,6.1489211330709139,-70,0,0.44493905333333333,0.15447589416666666,0.0081504083333333345,0,0,0 +6.9900000000000002,25.581854432298712,9.7110801990826481,-50,0,0.44493905333333333,0.15447589416666666,0.0081504083333333345,0,0,0 +6.9900000000000002,36.400293065186446,-6.4788192721909388,-41,0,0.60511694520833337,0.13647589416666667,0.0076923574583333343,0,0,0 +6.9900000000000002,-16.131052630012999,-9.933801481428981,-30,0,0.80088992416666671,0.11447589416666666,0.0071325175000000003,0,0,0 +6.9900000000000002,11.949152372833652,-0.64963881772035137,-20,0,0.97886558321428574,0.094475894166666657,0.0060124627380952391,0,0,0 +6.9900000000000002,1.7948777433545473,1.0536637081014071,-12.5,0,1.1123473275,0.079475894166666658,0.005172421666666668,0,0,0 +6.9900000000000002,-5.9676589396120221,-1.1771128513667843,-7.2999999999999998,0,1.2048946048333333,0.069075894166666651,-0.0041257341555555552,0,0,0 +6.9900000000000002,24.096936358151595,3.4748222061226919,-1,0,1.3170195235,0.056475894166666665,-0.0016476759999999996,0,0,0 +6.9900000000000002,34.277818838471035,0.919347914896818,0,0,1.3348171600000001,0.054475894166666664,0,0,0,0 +6.9900000000000002,29.82452168463881,-6.7856616184547498,2,0,1.3348171600000001,0.054475894166666664,0,0,0,0 +10.1,-38.713778106373411,-2.6909196691918824,-70,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,21.585287827692134,-1.5231418564411054,-50,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,33.277869171065134,-8.813343938797555,-41,0,0.56920315062499993,0.067899412500000006,0.0069823418750000008,0,0,0 +10.1,33.313263307978758,2.9080081138450176,-30,0,0.75335696249999995,0.045899412500000007,0.0072760624999999995,0,0,0 +10.1,-4.6156042235926691,5.4690483641294811,-20,0,0.92076984821428576,0.025899412500000003,0.006310641071428571,0,0,0 +10.1,14.431288479807982,-6.0866448253907741,-12.5,0,1.0463295125000001,0.010899412499999999,0.0055865749999999999,0,0,0 +10.1,-22.287438378876743,-5.9931563516567943,-7.2999999999999998,0,1.1333839605,0.00049941250000000003,-0.00092980500000000013,0,0,0 +10.1,24.798799380345031,-3.9029596822975527,-1,0,1.2388542025,-0.012100587500000003,-0.00076240999999999972,0,0,0 +10.1,-22.749879023039252,8.3958130959682222,0,0,1.25559555,-0.014100587500000003,0,0,0,0 +10.1,22.027009649720995,1.515237560299898,2,0,1.25559555,-0.014100587500000003,0,0,0,0 +15,13.876708886608398,0.74198059533564731,-70,0,0.35357499999999997,-0.024507999999999999,0.0019780000000000002,0,0,0 +15,-2.7469521472092566,-3.5314995308744734,-50,0,0.35357499999999997,-0.024507999999999999,0.0019780000000000002,0,0,0 +15,29.646585258486994,9.962368830173471,-41,0,0.48086200000000001,-0.042507999999999997,0.0032802999999999999,0,0,0 +15,37.053032151947576,9.8181285065495807,-30,0,0.63643499999999997,-0.064507999999999996,0.0048719999999999996,0,0,0 +15,21.029863466981439,-5.0995662461400215,-20,0,0.7778652857142857,-0.084508,0.0018034285714285715,0,0,0 +15,32.845196822829848,-2.3039314011475254,-12.5,0,0.883938,-0.099507999999999999,-0.00049799999999999996,0,0,0 +15,36.136092054079853,7.0038673785676444,-7.2999999999999998,0,0.95748125333333334,-0.10990800000000001,0.0038103733333333333,0,0,0 +15,-11.799015997376479,9.1435538652081547,-1,0,1.0465819999999999,-0.12250799999999999,0.0011431999999999996,0,0,0 +15,-13.440509756587147,3.6347630909713775,0,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,0.9221939903324099,-3.9009838610955754,2,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +22.199999999999999,36.867108357945853,4.3234528028892942,-70,0,0.43220379999999997,0.062470399999999981,0.0028900000000000002,0,0,0 +22.199999999999999,-32.328943017938776,-1.8016757645856387,-50,0,0.43220379999999997,0.062470399999999981,0.0028900000000000002,0,0,0 +22.199999999999999,-35.80139720077473,-5.1599786500436888,-41,0,0.58779716800000004,0.044470399999999993,0.00089160400000000114,0,0,0 +22.199999999999999,-26.223680897920421,8.239591500764341,-30,0,0.77796683999999994,0.022470399999999988,-0.001550879999999998,0,0,0 +22.199999999999999,23.990432529791548,4.2782867938128177,-20,0,0.95084837142857137,0.0024703999999999872,-0.00053999999999999936,0,0,0 +22.199999999999999,2.887023810869664,6.4828489826972664,-12.5,0,1.0805095199999999,-0.012529600000000016,0.00021815999999999985,0,0,0 +22.199999999999999,32.434164811981134,-7.8507772219933631,-7.2999999999999998,0,1.1704078965333333,-0.022929600000000015,-0.00099395306666666535,0,0,0 +22.199999999999999,27.646650826375748,6.6777754328004413,-1,0,1.2793232479999999,-0.035529600000000015,-0.0003060159999999995,0,0,0 +22.199999999999999,0.74396917360442671,5.562222983029244,0,0,1.2966113999999997,-0.03752960000000001,0,0,0,0 +22.199999999999999,25.152845672099858,7.842833299939155,2,0,1.2966113999999997,-0.03752960000000001,0,0,0,0 +27,34.177434854625872,5.9766241601186021,-70,0,0.48462299999999997,0.12045600000000001,0.0034980000000000002,0,0,0 +27,22.493094807101244,-0.30775054810584912,-50,0,0.48462299999999997,0.12045600000000001,0.0034980000000000002,0,0,0 +27,25.885819390472761,-5.8243899747383665,-41,0,0.65908728000000005,0.10245600000000002,-0.00070085999999999955,0,0,0 +27,-28.483027801526923,-9.3070219450368796,-30,0,0.87232140000000002,0.080456000000000014,-0.0058327999999999991,0,0,0 +27,9.0213466103913547,-3.454486553556011,-20,0,1.0661704285714286,0.06045600000000001,-0.0021022857142857141,0,0,0 +27,-7.8579344021051085,4.3088050425696949,-12.5,0,1.2115571999999999,0.04545600000000001,0.00069559999999999999,0,0,0 +27,3.846277922265557,2.544877826817034,-7.2999999999999998,0,1.3123589919999998,0.035056000000000011,-0.0041968373333333324,0,0,0 +27,18.177235829689387,4.6831025268385353,-1,0,1.4344840799999998,0.022456000000000014,-0.0012721599999999994,0,0,0 +27,-0.75801079980575992,-8.7983991709748484,0,0,1.4538689999999999,0.020456000000000016,0,0,0,0 +27,21.20569224848559,-8.5978798774983201,2,0,1.4538689999999999,0.020456000000000016,0,0,0,0 +29.899999999999999,1.4068909434364869,-8.3769989685523569,-70,0,0.51629293333333337,0.15548896666666667,0.0038653333333333335,0,0,0 +29.899999999999999,35.734934922741331,1.1619742971977622,-50,0,0.51629293333333337,0.15548896666666667,0.0038653333333333335,0,0,0 +29.899999999999999,37.799493650061336,0.41397227450426044,-41,0,0.70215838933333341,0.13748896666666666,-0.0016629736666666666,0,0,0 +29.899999999999999,20.183925874373905,1.0212616773877166,-30,0,0.92932728000000009,0.11548896666666666,-0.0084197933333333332,0,0,0 +29.899999999999999,-17.815889634232171,-1.0721355449493082,-20,0,1.1358441714285714,0.095488966666666675,-0.0030461666666666666,0,0,0 +29.899999999999999,10.672238679317502,-7.2897431841229476,-12.5,0,1.2907318399999999,0.080488966666666675,0.00098405333333333352,0,0,0 +29.899999999999999,-26.973218729797495,0.3614691414785991,-7.2999999999999998,0,1.3981211121777775,0.070088966666666669,-0.006131913244444444,0,0,0 +29.899999999999999,37.135747505861445,-5.5397219777701583,-1,0,1.5282270826666664,0.057488966666666669,-0.0018558719999999993,0,0,0 +29.899999999999999,14.740809994223198,9.1125628640246106,0,0,1.5488787999999998,0.055488966666666667,0,0,0,0 +29.899999999999999,-11.677147320143256,-9.2474157959482923,2,0,1.5488787999999998,0.055488966666666667,0,0,0,0 +30,-8.650754310000881,9.1693461371038794,-70,0,0,0,0,0,0,0 +30,-21.528344832550019,-2.4498442073934967,-50,0,0,0,0,0,0,0 +30,-37.913659422049847,1.7869178293190444,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +30,8.4481059835368626,-0.71042863432680114,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +30,-10.984575041640863,-1.482566812128896,-20,0,0.73801714285714282,0.19,0,0,0,0 +30,17.471716959475991,-3.3085417618235073,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +30,-9.9692979111432862,6.4769913695198262,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +30,19.286561874569031,-9.7170013962221802,-1,0,0.99296859999999998,0.152,0,0,0,0 +30,26.75939860221601,-2.596169523828566,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +30,-27.572206265855908,-8.0281491627056347,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.5,12.32596528400471,-4.3338365504395409,-70,0,0,0,0,0,0,0 +31.5,13.765699540806267,-1.3972193507397392,-50,0,0,0,0,0,0,0 +31.5,30.071913752994931,-0.27677302343631283,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +31.5,19.431548625850759,-9.7959945925604348,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +31.5,-28.793376785410032,-8.4567812390446857,-20,0,0.73801714285714282,0.19,0,0,0,0 +31.5,-36.309749669594368,4.5935349429275547,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +31.5,-2.239900235497096,0.13376092702809217,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +31.5,-23.449608268622228,2.8363753799615417,-1,0,0.99296859999999998,0.152,0,0,0,0 +31.5,37.409503897000633,4.0180531530013752,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.5,-29.032706522727636,-0.2497391911787421,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,-39.854124729019311,3.8768432788161906,-70,0,0,0,0,0,0,0 +33,17.684325638275766,3.5714735876826005,-50,0,0,0,0,0,0,0 +33,-0.4594188146910767,6.5280235239098801,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +33,38.256746798218416,-3.2436924925503297,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +33,-27.521341499367054,-2.7390553415641001,-20,0,0.73801714285714282,0.19,0,0,0,0 +33,-12.987076895057115,-7.1632817430584605,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +33,-12.696516486637286,-6.2580687836890414,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +33,-15.027932615069012,-1.6160955882136356,-1,0,0.99296859999999998,0.152,0,0,0,0 +33,-30.393098056862947,-6.3003307178771024,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,17.451886515299904,-7.4559148239279738,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +35.200000000000003,-12.175965967280263,6.7831133701243189,-70,0,0.23816980000000029,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,4.6180814704796731,0.81549098970607581,-50,0,0.23816980000000029,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,35.559261112186789,4.1372114999958356,-41,0,0.44618695750000026,0.15177480000000007,0.0023371150000000033,0,0,0 +35.200000000000003,-5.4011216736405032,9.6066153542405033,-30,0,0.70043015000000008,0.19164979999999998,0.0015367000000000022,0,0,0 +35.200000000000003,-12.109738563386159,0.037484791004560591,-20,0,0.85608132142857141,0.17164979999999996,-0.0012224142857142867,0,0,0 +35.200000000000003,11.75197738317857,-9.5241292360080703,-12.5,0,0.97281970000000006,0.15664979999999995,-0.0032917500000000039,0,0,0 +35.200000000000003,21.038370881567459,3.5302548364859625,-7.2999999999999998,0,1.0537584626666667,0.14624979999999999,-0.0042183900000000059,0,0,0 +35.200000000000003,-15.973711330369085,3.4445876816223553,-1,0,1.1518185000000001,0.13364979999999999,-0.00092565000000000106,0,0,0 +35.200000000000003,-20.737096172036509,-6.9182720241524791,0,0,1.16738355,0.13164979999999998,0,0,0,0 +35.200000000000003,24.682597011745329,2.2417909878109477,2,0,1.16738355,0.13164979999999998,0,0,0,0 +40,-28.536695796128988,-4.9250282768244125,-70,0,0.44488022222222223,0.15425802777777772,0.0081487222222222239,0,0,0 +40,-37.794874756703308,-3.1006887978684139,-50,0,0.44488022222222223,0.15425802777777772,0.0081487222222222239,0,0,0 +40,-34.489431309685216,0.39550850033954532,-41,0,0.6050369347222222,0.13625802777777773,0.0076929597222222239,0,0,0 +40,-22.625244513000098,-1.5039685698797065,-30,0,0.8007840277777778,0.11425802777777774,0.0071359166666666671,0,0,0 +40,-8.384812969166795,-6.8755142722931524,-20,0,0.9787361547619049,0.094258027777777739,0.0060189801587301603,0,0,0 +40,-24.046467454115312,9.1937867724362334,-12.5,0,1.1122002500000001,0.07925802777777774,0.0051812777777777794,0,0,0 +40,-7.1583616365327529,-9.175947291231326,-7.2999999999999998,0,1.2047352899999999,0.068858027777777719,-0.0041151281481481465,0,0,0 +40,-37.563419615947083,-7.9501130849871888,-1,0,1.3168453833333331,0.05625802777777774,-0.0016453999999999993,0,0,0 +40,16.627586727950444,-1.7018366852211031,0,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,-20.299794883215469,2.2463666881873419,2,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +70.299999999999997,-27.259439885464111,1.3303422268762404,-70,0,0.37937107777777779,0.16835632222222222,0.0059161777777777796,0,0,0 +70.299999999999997,-18.329419181105777,8.4999330687997166,-50,0,0.37937107777777779,0.16835632222222222,0.0059161777777777796,0,0,0 +70.299999999999997,-28.279731776551642,0.40439045633691961,-41,0,0.5544389290277778,0.16629382222222222,0.0051134702777777801,0,0,0 +70.299999999999997,7.2620474241576645,1.7805222100826015,-30,0,0.76841074722222225,0.16377298888888889,0.0041323833333333348,0,0,0 +70.299999999999997,5.5694295374896896,7.4337734139059322,-20,0,0.93916869166666672,0.1437729888888889,0.0013812103174603197,0,0,0 +70.299999999999997,-32.08471351381484,5.2144014253670647,-12.5,0,1.06723715,0.12877298888888888,-0.0006821694444444418,0,0,0 +70.299999999999997,30.99699708402197,-7.6298523843479193,-7.2999999999999998,0,1.1560313793333334,0.11837298888888888,-0.0055024808518518518,0,0,0 +70.299999999999997,16.420688115163323,0.3052507316806885,-1,0,1.26360893,0.10577298888888889,-0.0015269083333333332,0,0,0 +70.299999999999997,-12.057577684522364,-8.488938632238991,0,0,1.280684725,0.10377298888888889,0,0,0,0 +70.299999999999997,-7.3514790764289799,0.57507548381627416,2,0,1.280684725,0.10377298888888889,0,0,0,0 diff --git a/tests/data/currents_mdc/c2const/current_profile_dynamic.txt b/tests/data/currents_mdc/c2const/current_profile_dynamic.txt new file mode 100644 index 00000000..56b37747 --- /dev/null +++ b/tests/data/currents_mdc/c2const/current_profile_dynamic.txt @@ -0,0 +1,9 @@ +--------------------- MoorDyn dynamic currents File ---------------------------------- +the steady profile of ../c1/current_profile.txt at three times + + +-50.0 -45.0 -40.0 -35.0 -30.0 -25.0 -20.0 -15.0 -10.0 -5.0 0.0 +t ux(z) uy(z) uz(z) +0.0 0.2 0.22 0.24000000000000002 0.26 0.28 0.30000000000000004 0.32 0.34 0.36 0.38 0.4 -0.1 -0.0995 -0.098 -0.0955 -0.092 -0.08750000000000001 -0.082 -0.07550000000000001 -0.068 -0.0595 -0.05 0.0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009000000000000001 0.01 +4.0 0.2 0.22 0.24000000000000002 0.26 0.28 0.30000000000000004 0.32 0.34 0.36 0.38 0.4 -0.1 -0.0995 -0.098 -0.0955 -0.092 -0.08750000000000001 -0.082 -0.07550000000000001 -0.068 -0.0595 -0.05 0.0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009000000000000001 0.01 +10.0 0.2 0.22 0.24000000000000002 0.26 0.28 0.30000000000000004 0.32 0.34 0.36 0.38 0.4 -0.1 -0.0995 -0.098 -0.0955 -0.092 -0.08750000000000001 -0.082 -0.07550000000000001 -0.068 -0.0595 -0.05 0.0 0.001 0.002 0.003 0.004 0.005 0.006 0.007 0.008 0.009000000000000001 0.01 diff --git a/tests/data/currents_mdc/c2const/currents.dat b/tests/data/currents_mdc/c2const/currents.dat new file mode 100644 index 00000000..681f5ff5 --- /dev/null +++ b/tests/data/currents_mdc/c2const/currents.dat @@ -0,0 +1,26 @@ +--------------------- MoorDyn Input File ------------------------------------ +Shared current parity deck (MoorDyn-C WaveKin 0, Currents 2): the steady profile of c1 at every time +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed -30.0 0.0 -20.0 0 0 0 0 +2 Vessel 30.0 0.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 chain 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +10.0 TMax simulation length (s) +3.0e6 kBot bottom stiffness (Pa/m) +3.0e5 cBot bottom damping (Pa-s/m) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +0.0 TmaxIC max time for ic gen (s) +0 WaveKin MoorDyn-C water kinematics mode (-) +2 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/c2const/points.txt b/tests/data/currents_mdc/c2const/points.txt new file mode 100644 index 00000000..8fd9d0fe --- /dev/null +++ b/tests/data/currents_mdc/c2const/points.txt @@ -0,0 +1,45 @@ +0.0 3.625747096391059 1.204796483183113 -61.0 +0.0 29.240222818749317 -9.25239045413613 -50.0 +0.0 23.46046359355391 1.8229666122879866 -47.5 +0.0 -19.043779590969727 -4.599139224969835 -33.3 +0.0 -12.856308645593106 -1.749412098253556 -30.0 +0.0 38.36488703383566 -7.038199728668184 -12.3 +0.0 -33.361464723920776 -4.316260942636896 -2.0 +0.0 13.865936011298075 8.422021827334497 0.0 +0.0 -4.702829992963025 -1.6717186681526446 1.5 +0.5 -14.07536799232922 9.54041437133462 -61.0 +0.5 -1.266200937440189 -2.1387238980221905 -50.0 +0.5 21.991887387430154 -6.313315647241533 -47.5 +0.5 9.065590048206033 -3.9266969732113344 -33.3 +0.5 32.59611361428382 -2.471527225465257 -30.0 +0.5 8.548136741557208 7.73235531958516 -12.3 +0.5 10.767468921776384 -9.901710084464543 -2.0 +0.5 33.170979663189556 -6.387110542603544 0.0 +0.5 -18.832109881530876 1.3939569631943698 1.5 +3.0 -23.84629742780436 -7.411284659684765 -61.0 +3.0 16.2776411086751 -7.986057426728303 -50.0 +3.0 -1.5453992830454126 -8.544058084292184 -47.5 +3.0 33.748083410629704 -2.1145711101399893 -33.3 +3.0 7.1129995867811076 8.077716999122323 -30.0 +3.0 -21.206744257784713 -8.287889299555204 -12.3 +3.0 19.018417993166082 8.575850333694412 -2.0 +3.0 -34.24034673398577 9.933110274458684 0.0 +3.0 -31.67357968747993 -1.3198406078312601 1.5 +7.7 -18.474195005654472 -5.552630906546348 -61.0 +7.7 -14.846582951132675 6.974335055539811 -50.0 +7.7 7.399286028033458 -4.889381691061896 -47.5 +7.7 26.668381073668257 0.43097649083227907 -33.3 +7.7 -23.89846830191276 0.7687996394637064 -30.0 +7.7 -18.75050881328726 8.739373633670333 -12.3 +7.7 26.194471802351387 2.9173305077171037 -2.0 +7.7 -33.4763574363689 9.123955477562177 0.0 +7.7 16.227574118222492 6.727258469164298 1.5 +10.0 -2.3242607964400293 -6.98799947972778 -61.0 +10.0 25.87157786708798 -9.163031820079166 -50.0 +10.0 26.779122526321913 4.0438763545298855 -47.5 +10.0 -10.986895134543175 6.050656948172406 -33.3 +10.0 37.52443736070754 8.039683536558893 -30.0 +10.0 -11.120433344512115 -3.612516949673248 -12.3 +10.0 16.37635004074521 -2.4287988814413364 -2.0 +10.0 -25.014363736779465 -8.657988727363897 0.0 +10.0 -33.30484432612042 4.748403474389418 1.5 diff --git a/tests/data/currents_mdc/c2const/ref_moordyn_c.csv b/tests/data/currents_mdc/c2const/ref_moordyn_c.csv new file mode 100644 index 00000000..0a8e60f0 --- /dev/null +++ b/tests/data/currents_mdc/c2const/ref_moordyn_c.csv @@ -0,0 +1,46 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,3.6257470963910592,1.2047964831831131,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,29.240222818749317,-9.2523904541361297,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,23.460463593553911,1.8229666122879866,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0,-19.043779590969727,-4.5991392249698348,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0,-12.856308645593106,-1.7494120982535559,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0,38.364887033835657,-7.0381997286681841,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0,-33.361464723920776,-4.3162609426368963,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0,13.865936011298075,8.4220218273344969,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0,-4.7028299929630251,-1.6717186681526446,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.49999999999999994,-14.07536799232922,9.5404143713346201,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,-1.266200937440189,-2.1387238980221905,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,21.991887387430154,-6.3133156472415326,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0.5,9.0655900482060332,-3.9266969732113344,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0.5,32.596113614283823,-2.4715272254652572,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0.5,8.548136741557208,7.7323553195851602,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0.5,10.767468921776384,-9.9017100844645434,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0.5,33.170979663189556,-6.3871105426035442,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.5,-18.832109881530876,1.3939569631943698,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +2.9999999999998335,-23.846297427804359,-7.4112846596847648,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,16.277641108675098,-7.9860574267283031,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,-1.5453992830454126,-8.5440580842921836,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +3,33.748083410629704,-2.1145711101399893,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +3,7.1129995867811076,8.0777169991223232,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +3,-21.206744257784713,-8.2878892995552036,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +3,19.018417993166082,8.5758503336944116,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +3,-34.240346733985767,9.9331102744586843,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +3,-31.673579687479929,-1.3198406078312601,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000014222,-18.474195005654472,-5.5526309065463479,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000014222,-14.846582951132675,6.9743350555398109,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000014222,7.3992860280334583,-4.8893816910618959,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +7.7000000000014222,26.668381073668257,0.43097649083227907,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +7.7000000000014222,-23.898468301912761,0.76879963946370644,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +7.7000000000014222,-18.750508813287261,8.7393736336703327,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +7.7000000000014222,26.194471802351387,2.9173305077171037,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +7.7000000000014222,-33.4763574363689,9.123955477562177,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000014222,16.227574118222492,6.7272584691642976,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +9.9999999999990248,-2.3242607964400293,-6.9879994797277796,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,25.871577867087979,-9.1630318200791656,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,26.779122526321913,4.0438763545298855,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +10,-10.986895134543175,6.0506569481724064,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +10,37.524437360707537,8.0396835365588935,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +10,-11.120433344512115,-3.6125169496732479,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +10,16.376350040745209,-2.4287988814413364,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +10,-25.014363736779465,-8.6579887273638967,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +10,-33.304844326120417,4.7484034743894181,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 diff --git a/tests/data/currents_mdc/c2const/ref_python.csv b/tests/data/currents_mdc/c2const/ref_python.csv new file mode 100644 index 00000000..cc47eeef --- /dev/null +++ b/tests/data/currents_mdc/c2const/ref_python.csv @@ -0,0 +1,46 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,3.6257470963910592,1.2047964831831131,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,29.240222818749317,-9.2523904541361297,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0,23.460463593553911,1.8229666122879866,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0,-19.043779590969727,-4.5991392249698348,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0,-12.856308645593106,-1.7494120982535559,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0,38.364887033835657,-7.0381997286681841,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0,-33.361464723920776,-4.3162609426368963,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0,13.865936011298075,8.4220218273344969,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0,-4.7028299929630251,-1.6717186681526446,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.5,-14.07536799232922,9.5404143713346201,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,-1.266200937440189,-2.1387238980221905,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +0.5,21.991887387430154,-6.3133156472415326,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +0.5,9.0655900482060332,-3.9266969732113344,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +0.5,32.596113614283823,-2.4715272254652572,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +0.5,8.548136741557208,7.7323553195851602,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +0.5,10.767468921776384,-9.9017100844645434,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +0.5,33.170979663189556,-6.3871105426035442,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +0.5,-18.832109881530876,1.3939569631943698,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +3,-23.846297427804359,-7.4112846596847648,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,16.277641108675098,-7.9860574267283031,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +3,-1.5453992830454126,-8.5440580842921836,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +3,33.748083410629704,-2.1145711101399893,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +3,7.1129995867811076,8.0777169991223232,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +3,-21.206744257784713,-8.2878892995552036,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +3,19.018417993166082,8.5758503336944116,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +3,-34.240346733985767,9.9331102744586843,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +3,-31.673579687479929,-1.3198406078312601,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000000002,-18.474195005654472,-5.5526309065463479,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000000002,-14.846582951132675,6.9743350555398109,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +7.7000000000000002,7.3992860280334583,-4.8893816910618959,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +7.7000000000000002,26.668381073668257,0.43097649083227907,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +7.7000000000000002,-23.898468301912761,0.76879963946370644,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +7.7000000000000002,-18.750508813287261,8.7393736336703327,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +7.7000000000000002,26.194471802351387,2.9173305077171037,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +7.7000000000000002,-33.4763574363689,9.123955477562177,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +7.7000000000000002,16.227574118222492,6.7272584691642976,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +10,-2.3242607964400293,-6.9879994797277796,-61,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,25.871577867087979,-9.1630318200791656,-50,0,0.20000000000000001,-0.10000000000000001,0,0,0,0 +10,26.779122526321913,4.0438763545298855,-47.5,0,0.21000000000000002,-0.099750000000000005,0.00050000000000000001,0,0,0 +10,-10.986895134543175,6.0506569481724064,-33.299999999999997,0,0.26680000000000004,-0.094310000000000005,0.0033400000000000005,0,0,0 +10,37.524437360707537,8.0396835365588935,-30,0,0.28000000000000003,-0.091999999999999998,0.0040000000000000001,0,0,0 +10,-11.120433344512115,-3.6125169496732479,-12.300000000000001,0,0.3508,-0.071450000000000014,0.0075399999999999998,0,0,0 +10,16.376350040745209,-2.4287988814413364,-2,0,0.39200000000000002,-0.053800000000000001,0.0096000000000000009,0,0,0 +10,-25.014363736779465,-8.6579887273638967,0,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 +10,-33.304844326120417,4.7484034743894181,1.5,0,0.40000000000000002,-0.050000000000000003,0.01,0,0,0 diff --git a/tests/data/currents_mdc/c2stof/current_profile_dynamic.txt b/tests/data/currents_mdc/c2stof/current_profile_dynamic.txt new file mode 100644 index 00000000..33ff2578 --- /dev/null +++ b/tests/data/currents_mdc/c2stof/current_profile_dynamic.txt @@ -0,0 +1,9 @@ +--------------------- MoorDyn dynamic currents File ---------------------------------- +x velocities only; depths that single precision rounds + + +-40.0 -12.3 -0.7 + +0.0 0.1 0.4 0.9 # comment +2.5 0.2 0.5 1.1 # comment +6.0 0.05 0.3 0.6 # comment diff --git a/tests/data/currents_mdc/c2stof/currents.dat b/tests/data/currents_mdc/c2stof/currents.dat new file mode 100644 index 00000000..8d6d6b1b --- /dev/null +++ b/tests/data/currents_mdc/c2stof/currents.dat @@ -0,0 +1,26 @@ +--------------------- MoorDyn Input File ------------------------------------ +Shared current parity deck (MoorDyn-C WaveKin 0, Currents 2): x velocities, single-precision depths +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed -30.0 0.0 -20.0 0 0 0 0 +2 Vessel 30.0 0.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 chain 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +10.0 TMax simulation length (s) +3.0e6 kBot bottom stiffness (Pa/m) +3.0e5 cBot bottom damping (Pa-s/m) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +0.0 TmaxIC max time for ic gen (s) +0 WaveKin MoorDyn-C water kinematics mode (-) +2 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/c2stof/points.txt b/tests/data/currents_mdc/c2stof/points.txt new file mode 100644 index 00000000..2baeb06a --- /dev/null +++ b/tests/data/currents_mdc/c2stof/points.txt @@ -0,0 +1,64 @@ +0.0 1.0 2.0 -45.0 +0.0 1.0 2.0 -40.0 +0.0 1.0 2.0 -25.0 +0.0 1.0 2.0 -12.3 +0.0 1.0 2.0 -12.29999999 +0.0 1.0 2.0 -6.0 +0.0 1.0 2.0 -0.7 +0.0 1.0 2.0 0.4 +1.1 1.0 2.0 -45.0 +1.1 1.0 2.0 -40.0 +1.1 1.0 2.0 -25.0 +1.1 1.0 2.0 -12.3 +1.1 1.0 2.0 -12.29999999 +1.1 1.0 2.0 -6.0 +1.1 1.0 2.0 -0.7 +1.1 1.0 2.0 0.4 +2.5 1.0 2.0 -45.0 +2.5 1.0 2.0 -40.0 +2.5 1.0 2.0 -25.0 +2.5 1.0 2.0 -12.3 +2.5 1.0 2.0 -12.29999999 +2.5 1.0 2.0 -6.0 +2.5 1.0 2.0 -0.7 +2.5 1.0 2.0 0.4 +4.2 1.0 2.0 -45.0 +4.2 1.0 2.0 -40.0 +4.2 1.0 2.0 -25.0 +4.2 1.0 2.0 -12.3 +4.2 1.0 2.0 -12.29999999 +4.2 1.0 2.0 -6.0 +4.2 1.0 2.0 -0.7 +4.2 1.0 2.0 0.4 +5.9 1.0 2.0 -45.0 +5.9 1.0 2.0 -40.0 +5.9 1.0 2.0 -25.0 +5.9 1.0 2.0 -12.3 +5.9 1.0 2.0 -12.29999999 +5.9 1.0 2.0 -6.0 +5.9 1.0 2.0 -0.7 +5.9 1.0 2.0 0.4 +6.0 1.0 2.0 -45.0 +6.0 1.0 2.0 -40.0 +6.0 1.0 2.0 -25.0 +6.0 1.0 2.0 -12.3 +6.0 1.0 2.0 -12.29999999 +6.0 1.0 2.0 -6.0 +6.0 1.0 2.0 -0.7 +6.0 1.0 2.0 0.4 +7.3 1.0 2.0 -45.0 +7.3 1.0 2.0 -40.0 +7.3 1.0 2.0 -25.0 +7.3 1.0 2.0 -12.3 +7.3 1.0 2.0 -12.29999999 +7.3 1.0 2.0 -6.0 +7.3 1.0 2.0 -0.7 +7.3 1.0 2.0 0.4 +9.9 1.0 2.0 -45.0 +9.9 1.0 2.0 -40.0 +9.9 1.0 2.0 -25.0 +9.9 1.0 2.0 -12.3 +9.9 1.0 2.0 -12.29999999 +9.9 1.0 2.0 -6.0 +9.9 1.0 2.0 -0.7 +9.9 1.0 2.0 0.4 diff --git a/tests/data/currents_mdc/c2stof/ref_moordyn_c.csv b/tests/data/currents_mdc/c2stof/ref_moordyn_c.csv new file mode 100644 index 00000000..7b5e8cc4 --- /dev/null +++ b/tests/data/currents_mdc/c2stof/ref_moordyn_c.csv @@ -0,0 +1,65 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +0,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +0,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +0,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +0,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +0,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +0,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +0,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +1.0999999999999892,1,2,-45,0,0.14399999999999957,0,0,0,0,0 +1.1000000000000001,1,2,-40,0,0.14400000000000002,0,0,0,0,0 +1.1000000000000001,1,2,-25,0,0.30645487476483063,0,0,0,0,0 +1.1000000000000001,1,2,-12.300000000000001,0,0.44400000894480723,0,0,0,0,0 +1.1000000000000001,1,2,-12.29999999,0,0.44400000941377271,0,0,0,0,0 +1.1000000000000001,1,2,-6,0,0.73944827964529836,0,0,0,0,0 +1.1000000000000001,1,2,-0.69999999999999996,0,0.98799999944094974,0,0,0,0,0 +1.1000000000000001,1,2,0.40000000000000002,0,0.9880000000000001,0,0,0,0,0 +2.499999999999845,1,2,-45,0,0.19999999999999382,0,0,0,0,0 +2.5,1,2,-40,0,0.20000000000000001,0,0,0,0,0 +2.5,1,2,-25,0,0.36245487476483063,0,0,0,0,0 +2.5,1,2,-12.300000000000001,0,0.50000000986559623,0,0,0,0,0 +2.5,1,2,-12.29999999,0,0.50000001038283759,0,0,0,0,0 +2.5,1,2,-6,0,0.82586207313819671,0,0,0,0,0 +2.5,1,2,-0.69999999999999996,0,1.0999999993834004,0,0,0,0,0 +2.5,1,2,0.40000000000000002,0,1.1000000000000001,0,0,0,0,0 +4.1999999999998998,1,2,-45,0,0.12714285714286144,0,0,0,0,0 +4.1999999999999993,1,2,-40,0,0.12714285714285717,0,0,0,0,0 +4.1999999999999993,1,2,-25,0,0.27644662299815387,0,0,0,0,0 +4.1999999999999993,1,2,-12.300000000000001,0,0.40285715032680852,0,0,0,0,0 +4.1999999999999993,1,2,-12.29999999,0,0.4028571507184342,0,0,0,0,0 +4.1999999999999993,1,2,-6,0,0.64958128394749182,0,0,0,0,0 +4.1999999999999993,1,2,-0.69999999999999996,0,0.8571428566760031,0,0,0,0,0 +4.1999999999999993,1,2,0.40000000000000002,0,0.85714285714285721,0,0,0,0,0 +5.9000000000005652,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +5.9000000000005652,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +5.9000000000005652,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +5.9000000000005652,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +5.9000000000005652,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +5.9000000000005652,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +5.9000000000005652,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +5.9000000000005652,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +6.000000000000032,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +6.000000000000032,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +6.000000000000032,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +6.000000000000032,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +6.000000000000032,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +6.000000000000032,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +6.000000000000032,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +6.000000000000032,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +7.3000000000004324,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +7.3000000000004324,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +7.3000000000004324,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +7.3000000000004324,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +7.3000000000004324,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +7.3000000000004324,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +7.3000000000004324,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +7.3000000000004324,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +9.8999999999992472,1,2,-45,0,0.19599999999996989,0,0,0,0,0 +9.9000000000000004,1,2,-40,0,0.19600000000000001,0,0,0,0,0 +9.9000000000000004,1,2,-25,0,0.35845487476483062,0,0,0,0,0 +9.9000000000000004,1,2,-12.300000000000001,0,0.49600000979982556,0,0,0,0,0 +9.9000000000000004,1,2,-12.29999999,0,0.49600001031361862,0,0,0,0,0 +9.9000000000000004,1,2,-6,0,0.81968965931727533,0,0,0,0,0 +9.9000000000000004,1,2,-0.69999999999999996,0,1.0919999993875111,0,0,0,0,0 +9.9000000000000004,1,2,0.40000000000000002,0,1.0920000000000001,0,0,0,0,0 diff --git a/tests/data/currents_mdc/c2stof/ref_python.csv b/tests/data/currents_mdc/c2stof/ref_python.csv new file mode 100644 index 00000000..9b0a5f78 --- /dev/null +++ b/tests/data/currents_mdc/c2stof/ref_python.csv @@ -0,0 +1,65 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +0,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +0,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +0,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +0,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +0,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +0,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +0,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +1.1000000000000001,1,2,-45,0,0.14400000000000002,0,0,0,0,0 +1.1000000000000001,1,2,-40,0,0.14400000000000002,0,0,0,0,0 +1.1000000000000001,1,2,-25,0,0.30645487476483063,0,0,0,0,0 +1.1000000000000001,1,2,-12.300000000000001,0,0.44400000894480723,0,0,0,0,0 +1.1000000000000001,1,2,-12.29999999,0,0.44400000941377271,0,0,0,0,0 +1.1000000000000001,1,2,-6,0,0.73944827964529836,0,0,0,0,0 +1.1000000000000001,1,2,-0.69999999999999996,0,0.98799999944094974,0,0,0,0,0 +1.1000000000000001,1,2,0.40000000000000002,0,0.9880000000000001,0,0,0,0,0 +2.5,1,2,-45,0,0.20000000000000001,0,0,0,0,0 +2.5,1,2,-40,0,0.20000000000000001,0,0,0,0,0 +2.5,1,2,-25,0,0.36245487476483063,0,0,0,0,0 +2.5,1,2,-12.300000000000001,0,0.50000000986559623,0,0,0,0,0 +2.5,1,2,-12.29999999,0,0.50000001038283759,0,0,0,0,0 +2.5,1,2,-6,0,0.82586207313819671,0,0,0,0,0 +2.5,1,2,-0.69999999999999996,0,1.0999999993834004,0,0,0,0,0 +2.5,1,2,0.40000000000000002,0,1.1000000000000001,0,0,0,0,0 +4.2000000000000002,1,2,-45,0,0.12714285714285711,0,0,0,0,0 +4.2000000000000002,1,2,-40,0,0.12714285714285711,0,0,0,0,0 +4.2000000000000002,1,2,-25,0,0.27644662299815381,0,0,0,0,0 +4.2000000000000002,1,2,-12.300000000000001,0,0.40285715032680847,0,0,0,0,0 +4.2000000000000002,1,2,-12.29999999,0,0.40285715071843414,0,0,0,0,0 +4.2000000000000002,1,2,-6,0,0.64958128394749171,0,0,0,0,0 +4.2000000000000002,1,2,-0.69999999999999996,0,0.85714285667600298,0,0,0,0,0 +4.2000000000000002,1,2,0.40000000000000002,0,0.8571428571428571,0,0,0,0,0 +5.9000000000000004,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +5.9000000000000004,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +5.9000000000000004,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +5.9000000000000004,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +5.9000000000000004,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +5.9000000000000004,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +5.9000000000000004,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +5.9000000000000004,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +6,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +6,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +6,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +6,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +6,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +6,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +6,1,2,-0.69999999999999996,0,0.89999999948616705,0,0,0,0,0 +6,1,2,0.40000000000000002,0,0.90000000000000013,0,0,0,0,0 +7.2999999999999998,1,2,-45,0,0.10000000000000001,0,0,0,0,0 +7.2999999999999998,1,2,-40,0,0.10000000000000001,0,0,0,0,0 +7.2999999999999998,1,2,-25,0,0.26245487476483065,0,0,0,0,0 +7.2999999999999998,1,2,-12.300000000000001,0,0.40000000822133014,0,0,0,0,0 +7.2999999999999998,1,2,-12.29999999,0,0.40000000865236468,0,0,0,0,0 +7.2999999999999998,1,2,-6,0,0.67155172761516391,0,0,0,0,0 +7.2999999999999998,1,2,-0.69999999999999996,0,0.89999999948616694,0,0,0,0,0 +7.2999999999999998,1,2,0.40000000000000002,0,0.90000000000000002,0,0,0,0,0 +9.9000000000000004,1,2,-45,0,0.19600000000000001,0,0,0,0,0 +9.9000000000000004,1,2,-40,0,0.19600000000000001,0,0,0,0,0 +9.9000000000000004,1,2,-25,0,0.35845487476483062,0,0,0,0,0 +9.9000000000000004,1,2,-12.300000000000001,0,0.49600000979982556,0,0,0,0,0 +9.9000000000000004,1,2,-12.29999999,0,0.49600001031361862,0,0,0,0,0 +9.9000000000000004,1,2,-6,0,0.81968965931727533,0,0,0,0,0 +9.9000000000000004,1,2,-0.69999999999999996,0,1.0919999993875111,0,0,0,0,0 +9.9000000000000004,1,2,0.40000000000000002,0,1.0920000000000001,0,0,0,0,0 diff --git a/tests/data/currents_mdc/c5/current_profile_4d.txt b/tests/data/currents_mdc/c5/current_profile_4d.txt new file mode 100644 index 00000000..2fc66ccb --- /dev/null +++ b/tests/data/currents_mdc/c5/current_profile_4d.txt @@ -0,0 +1,134 @@ +4 2 4 4 +-60.0 -20.0 10.0 50.0 +-30.0 30.0 +-50.0 -25.0 -10.0 0.0 +0.0 5.0 12.0 20.0 +x y z t ux uy uz +50.0 30.0 -25.0 0.0 0.543125 -0.040229 -0.011969 +-60.0 30.0 -50.0 5.0 0.073064 -0.040229 0.001662 +10.0 30.0 0.0 5.0 0.824311 0.228060 0.003973 +10.0 30.0 -25.0 5.0 0.566714 0.228060 -0.014914 +-60.0 -30.0 -10.0 20.0 -0.037638 -0.011940 0.009292 +-60.0 30.0 -25.0 12.0 0.069600 0.074560 0.015706 +50.0 -30.0 -10.0 12.0 0.415652 -0.289620 0.019709 +10.0 -30.0 0.0 12.0 0.288134 -0.145769 0.009236 +10.0 -30.0 -10.0 20.0 0.278520 -0.280229 -0.003973 +50.0 -30.0 -50.0 0.0 0.228750 -0.280229 0.019178 +-20.0 -30.0 0.0 0.0 0.190000 -0.011940 0.000000 +50.0 30.0 -25.0 12.0 0.422953 -0.049620 -0.001997 +-60.0 -30.0 -10.0 5.0 -0.065570 -0.280229 -0.016170 +10.0 30.0 0.0 20.0 0.473161 -0.040229 0.014347 +-20.0 -30.0 -25.0 0.0 0.130625 -0.011940 -0.011969 +50.0 -30.0 -25.0 20.0 0.360785 -0.162159 0.019950 +-20.0 -30.0 -25.0 12.0 0.101723 0.076013 0.006261 +10.0 -30.0 -10.0 12.0 0.252117 -0.145769 -0.009938 +-60.0 30.0 0.0 12.0 0.101236 0.074560 -0.005172 +-60.0 30.0 -50.0 12.0 0.037964 0.074560 -0.019993 +-60.0 -30.0 -50.0 20.0 -0.016130 -0.011940 0.007330 +50.0 30.0 -10.0 12.0 0.538304 -0.049620 0.019709 +-20.0 30.0 -10.0 12.0 0.252117 0.316013 -0.018504 +-20.0 -30.0 -25.0 5.0 0.195774 0.055517 -0.004785 +10.0 30.0 -50.0 0.0 0.206250 0.295517 0.019178 +50.0 -30.0 -25.0 12.0 0.326584 -0.289620 -0.001997 +50.0 30.0 0.0 12.0 0.615204 -0.049620 0.013509 +-20.0 30.0 -50.0 5.0 0.207951 0.295517 0.015455 +50.0 30.0 -50.0 5.0 0.444004 -0.077998 0.015136 +-60.0 30.0 0.0 20.0 0.111838 0.228060 0.019923 +10.0 -30.0 -25.0 12.0 0.198092 -0.145769 -0.018016 +10.0 -30.0 0.0 0.0 0.370000 0.055517 0.000000 +50.0 30.0 -50.0 20.0 0.254862 0.077841 -0.016829 +10.0 -30.0 -10.0 5.0 0.485220 -0.011940 -0.014347 +-60.0 30.0 -25.0 0.0 0.089375 -0.077998 -0.011969 +-20.0 30.0 -50.0 12.0 0.108050 0.316013 0.006352 +-60.0 -30.0 -25.0 20.0 -0.029573 -0.011940 -0.017009 +-20.0 30.0 -25.0 12.0 0.198092 0.316013 0.006261 +50.0 30.0 -25.0 5.0 0.814007 -0.077998 -0.019950 +-60.0 30.0 0.0 5.0 0.194837 -0.040229 -0.018641 +10.0 -30.0 -25.0 20.0 0.218837 -0.280229 -0.019833 +50.0 30.0 -50.0 0.0 0.296250 -0.040229 0.019178 +-20.0 30.0 -25.0 20.0 0.218837 0.228060 0.016366 +50.0 -30.0 0.0 5.0 0.914236 -0.317998 0.016829 +50.0 -30.0 -25.0 0.0 0.419375 -0.280229 -0.011969 +10.0 30.0 -10.0 5.0 0.721272 0.228060 -0.014347 +-20.0 -30.0 -50.0 0.0 0.071250 -0.011940 0.019178 +10.0 -30.0 -25.0 0.0 0.254375 0.055517 -0.011969 +-20.0 -30.0 -10.0 12.0 0.129465 0.076013 -0.018504 +-60.0 -30.0 -25.0 5.0 -0.051519 -0.280229 0.010597 +-20.0 -30.0 -25.0 20.0 0.112376 -0.011940 0.016366 +-20.0 -30.0 -10.0 0.0 0.166250 -0.011940 -0.016829 +-20.0 30.0 0.0 0.0 0.370000 0.228060 0.000000 +-60.0 30.0 -25.0 20.0 0.076889 0.228060 -0.017009 +50.0 -30.0 0.0 12.0 0.475031 -0.289620 0.013509 +-60.0 30.0 -50.0 20.0 0.041939 0.228060 0.007330 +50.0 30.0 -10.0 20.0 0.594677 0.077841 0.002822 +-60.0 -30.0 -25.0 12.0 -0.026769 -0.165440 0.015706 +-20.0 30.0 -50.0 0.0 0.138750 0.228060 0.019178 +-60.0 -30.0 -10.0 0.0 -0.043750 -0.317998 -0.016829 +-60.0 -30.0 -50.0 5.0 -0.028102 -0.280229 0.001662 +50.0 -30.0 -50.0 20.0 0.196792 -0.162159 -0.016829 +50.0 -30.0 -10.0 5.0 0.799956 -0.317998 0.000000 +-60.0 -30.0 0.0 5.0 -0.074937 -0.280229 -0.018641 +50.0 30.0 -10.0 0.0 0.691250 -0.040229 -0.016829 +50.0 -30.0 -50.0 12.0 0.178137 -0.289620 -0.010310 +10.0 30.0 -10.0 20.0 0.414016 -0.040229 -0.003973 +50.0 -30.0 -50.0 5.0 0.342838 -0.317998 0.015136 +-20.0 30.0 0.0 20.0 0.318308 0.228060 -0.019991 +10.0 30.0 -10.0 12.0 0.374769 0.094231 -0.009938 +50.0 -30.0 0.0 0.0 0.610000 -0.280229 0.000000 +-20.0 30.0 -10.0 20.0 0.278520 0.228060 -0.010310 +-60.0 -30.0 -50.0 12.0 -0.014601 -0.165440 -0.019993 +-20.0 30.0 -25.0 0.0 0.254375 0.228060 -0.011969 +-60.0 30.0 -25.0 5.0 0.133951 -0.040229 0.010597 +-20.0 30.0 -10.0 0.0 0.323750 0.228060 -0.016829 +10.0 30.0 0.0 0.0 0.550000 0.295517 0.000000 +50.0 30.0 0.0 20.0 0.679631 0.077841 -0.015136 +-60.0 -30.0 -25.0 0.0 -0.034375 -0.317998 -0.011969 +-20.0 30.0 0.0 5.0 0.554537 0.295517 -0.007788 +50.0 30.0 -10.0 5.0 1.036009 -0.077998 0.000000 +-60.0 30.0 -10.0 20.0 0.097858 0.228060 0.009292 +10.0 30.0 0.0 12.0 0.428307 0.094231 0.009236 +-20.0 -30.0 0.0 20.0 0.163456 -0.011940 -0.019991 +50.0 -30.0 -10.0 0.0 0.533750 -0.280229 -0.016829 +10.0 30.0 -25.0 20.0 0.325298 -0.040229 -0.019833 +10.0 -30.0 0.0 20.0 0.318308 -0.280229 0.014347 +10.0 -30.0 -25.0 5.0 0.381244 -0.011940 -0.014914 +10.0 30.0 -25.0 0.0 0.378125 0.295517 -0.011969 +-20.0 -30.0 -50.0 12.0 0.055485 0.076013 0.006352 +10.0 30.0 -50.0 20.0 0.177435 -0.040229 0.017432 +-20.0 30.0 -25.0 5.0 0.381244 0.295517 -0.004785 +10.0 30.0 -10.0 0.0 0.481250 0.295517 -0.016829 +-20.0 -30.0 0.0 12.0 0.147961 0.076013 -0.016384 +-60.0 30.0 -10.0 12.0 0.088582 0.074560 0.013462 +-20.0 -30.0 -50.0 20.0 0.061296 -0.011940 -0.006231 +-60.0 -30.0 -10.0 12.0 -0.034070 -0.165440 0.013462 +10.0 30.0 -25.0 12.0 0.294461 0.094231 -0.018016 +-20.0 -30.0 -10.0 5.0 0.249167 0.055517 -0.019709 +50.0 -30.0 -10.0 20.0 0.459181 -0.162159 0.002822 +50.0 -30.0 0.0 20.0 0.524778 -0.162159 -0.015136 +50.0 30.0 0.0 5.0 1.184011 -0.077998 0.016829 +50.0 30.0 -25.0 20.0 0.467246 0.077841 0.019950 +-60.0 -30.0 0.0 12.0 -0.038937 -0.165440 -0.005172 +10.0 30.0 -50.0 12.0 0.160615 0.094231 0.019631 +-20.0 30.0 0.0 12.0 0.288134 0.316013 -0.016384 +-60.0 -30.0 0.0 0.0 -0.050000 -0.317998 0.000000 +-60.0 -30.0 -50.0 0.0 -0.018750 -0.317998 0.019178 +50.0 30.0 0.0 0.0 0.790000 -0.040229 0.000000 +-60.0 30.0 0.0 0.0 0.130000 -0.077998 0.000000 +10.0 -30.0 0.0 5.0 0.554537 -0.011940 0.003973 +50.0 30.0 -50.0 12.0 0.230702 -0.049620 -0.010310 +-20.0 30.0 -50.0 20.0 0.119366 0.228060 -0.006231 +-60.0 -30.0 0.0 20.0 -0.043015 -0.011940 0.019923 +10.0 30.0 -50.0 5.0 0.309117 0.228060 0.019923 +10.0 -30.0 -50.0 0.0 0.138750 0.055517 0.019178 +10.0 -30.0 -50.0 20.0 0.119366 -0.280229 0.017432 +10.0 -30.0 -50.0 5.0 0.207951 -0.011940 0.019923 +-20.0 -30.0 -50.0 5.0 0.106786 0.055517 0.015455 +-60.0 30.0 -50.0 0.0 0.048750 -0.077998 0.019178 +-60.0 30.0 -10.0 0.0 0.113750 -0.077998 -0.016829 +-60.0 30.0 -10.0 5.0 0.170483 -0.040229 -0.016170 +10.0 -30.0 -10.0 0.0 0.323750 0.055517 -0.016829 +-20.0 -30.0 0.0 5.0 0.284762 0.055517 -0.007788 +50.0 -30.0 -25.0 5.0 0.628537 -0.317998 -0.019950 +-20.0 -30.0 -10.0 20.0 0.143024 -0.011940 -0.010310 +-20.0 30.0 -10.0 5.0 0.485220 0.295517 -0.019709 +10.0 -30.0 -50.0 12.0 0.108050 -0.145769 0.019631 diff --git a/tests/data/currents_mdc/c5/currents.dat b/tests/data/currents_mdc/c5/currents.dat new file mode 100644 index 00000000..a0ec6476 --- /dev/null +++ b/tests/data/currents_mdc/c5/currents.dat @@ -0,0 +1,26 @@ +--------------------- MoorDyn Input File ------------------------------------ +Shared current parity deck (MoorDyn-C WaveKin 0, Currents 5): sheared in x, y, z and varying in time +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed -30.0 0.0 -20.0 0 0 0 0 +2 Vessel 30.0 0.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 chain 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +52.0 TMax simulation length (s) +3.0e6 kBot bottom stiffness (Pa/m) +3.0e5 cBot bottom damping (Pa-s/m) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +0.0 TmaxIC max time for ic gen (s) +0 WaveKin MoorDyn-C water kinematics mode (-) +5 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/c5/points.txt b/tests/data/currents_mdc/c5/points.txt new file mode 100644 index 00000000..f17109d7 --- /dev/null +++ b/tests/data/currents_mdc/c5/points.txt @@ -0,0 +1,120 @@ +0.0 50.005736104870834 21.485148135208114 -12.03504529579837 +0.0 51.16739142159362 30.109157160400187 2.77804754336114 +0.0 6.023218242336341 1.2110045819180328 -25.537592572473756 +0.0 -43.999946793023526 -36.46357883420958 -38.8657305369626 +0.0 64.77659606874144 27.812081604590787 -44.96740181451075 +0.0 -9.396788772823712 -25.887530634381672 -36.13750087354212 +0.0 45.251982367198806 22.894432429909045 -10.025624589939213 +0.0 -47.69460592017943 -25.23463498455225 -49.737213382204075 +0.0 -20.0 30.0 -25.0 +0.0 80.0 -50.0 -60.0 +1.3 -58.899807932234665 -30.39142908919966 -8.965143194108066 +1.3 21.252373997194326 3.9151172762301627 -21.78579826961007 +1.3 -42.896718803798365 -31.6252023796892 -10.931938360694204 +1.3 40.95497251512482 -23.098472646607576 -47.04095807901918 +1.3 -58.40236409236805 -1.717741117922671 -32.240068899394885 +1.3 -39.28522613131827 -2.750033716563152 -2.764816725072336 +1.3 30.056521115539553 29.92851724372612 -8.577013349796445 +1.3 7.899360778110051 -35.74705662373262 -22.259781958060287 +1.3 -20.0 30.0 -25.0 +1.3 80.0 -50.0 -60.0 +5.0 0.7065075090763884 15.816164666472503 -53.09174711726344 +5.0 -57.270676763422955 -38.261003995975045 -55.52314392314601 +5.0 -55.58317946049503 -11.267112332013653 -3.740230508414733 +5.0 -55.75954299912635 -30.260916044615875 -4.71530844121822 +5.0 2.7409365902909713 28.60201112028858 -25.111807766941638 +5.0 -26.90563341915059 -18.420651494160794 -46.74319184047667 +5.0 -16.112072543782354 -28.66106348420395 -35.78742733945995 +5.0 47.653715716084676 -34.975665237240214 -12.915985400675432 +5.0 -20.0 30.0 -25.0 +5.0 80.0 -50.0 -60.0 +7.75 -23.782540347753034 31.640590099832778 -42.28125833560091 +7.75 50.69991606594928 21.248156177521807 -9.654421427071632 +7.75 -30.862612828868855 -29.963976322550394 -20.768673745665197 +7.75 -29.029779494510834 30.562070864728852 -24.577795503163962 +7.75 44.09726123487947 4.362778336534262 -51.969286230642126 +7.75 31.828650476772225 13.454382521358369 -37.5080521282738 +7.75 19.279805725190684 -29.432058008061055 -28.273968928784587 +7.75 -65.08849879000421 -4.109621333194227 -4.036982128899382 +7.75 -20.0 30.0 -25.0 +7.75 80.0 -50.0 -60.0 +12.0 38.748666590388865 -21.181534454098497 -53.13415238908913 +12.0 60.51738172018568 -8.000517269215315 -30.269613490802683 +12.0 45.4904736824882 -20.53496189527431 -11.965353621749735 +12.0 -30.60921802116391 -8.367142456949964 -28.048800274861485 +12.0 6.5945258766081025 0.5976011179957794 -53.35003655203993 +12.0 -45.00122797001535 2.7927463368735346 -12.885058684263356 +12.0 -57.750808960729856 14.274812330751992 -51.41621928615766 +12.0 -38.21431287489124 -5.611593819785831 -38.05239099506522 +12.0 -20.0 30.0 -25.0 +12.0 80.0 -50.0 -60.0 +14.1 52.04916595254974 0.8397829896256681 -50.5254792903469 +14.1 -50.08982512680857 17.159357032043026 0.08197299558629823 +14.1 55.566790108726224 -1.3303810172184072 -5.783035559534419 +14.1 -7.7626286311559625 -36.19363330763099 -40.13305866442997 +14.1 -38.482282748346435 -35.635152454396675 -7.835478838758128 +14.1 -32.11856910180703 32.395467883591024 -32.95814835720526 +14.1 -73.6535368892532 -5.30135437991148 2.6584938454922877 +14.1 22.808794396358067 -7.789530349394838 -20.30813130952022 +14.1 -20.0 30.0 -25.0 +14.1 80.0 -50.0 -60.0 +19.9 -22.942982304194317 30.544962591266923 -15.080061000458585 +19.9 -65.42200831328056 -17.318980426019834 -57.38657085664685 +19.9 -43.52656302826329 12.98234031670659 -19.490002308485693 +19.9 -45.75289814043507 -21.849395089813164 -14.954187063917864 +19.9 -46.40889670675177 -11.11361856588994 -11.869225071677462 +19.9 7.817324925898902 1.6818490920869351 -47.59117384546461 +19.9 64.1701804878239 36.58045738127423 -51.528910673324326 +19.9 1.046154571541365 2.3254772953772544 -41.800453413679875 +19.9 -20.0 30.0 -25.0 +19.9 80.0 -50.0 -60.0 +20.0 57.773196593431464 17.058190764761036 -24.207950794350978 +20.0 23.057160140338723 -37.34221341001789 -8.834977048711913 +20.0 -31.293205806228023 -39.39219742918535 -23.833023124277616 +20.0 40.574543650916894 -9.522886134103565 -19.788490814814573 +20.0 -35.56348448840908 -28.633726656316636 -12.438347765451326 +20.0 -14.200725792275222 8.404189797772268 -45.858535484595734 +20.0 32.4591132356357 -9.369352758588391 -28.147220365362394 +20.0 9.749103743740221 -20.448522155057933 -55.76107949098163 +20.0 -20.0 30.0 -25.0 +20.0 80.0 -50.0 -60.0 +22.5 52.955030493423436 27.395038157243647 -8.88208286321239 +22.5 43.86863288855157 11.787804359995498 -45.971185031226426 +22.5 -12.541703804709933 -29.44195004306782 -12.059168022088059 +22.5 3.2739774302568634 1.2193424360429432 -2.059393683204725 +22.5 -11.23086057249833 -30.278984685702213 -43.42321550481976 +22.5 -32.98010335458405 13.337287228011547 -49.1668254070279 +22.5 51.84530735485504 -12.92926670713549 -13.079923721627608 +22.5 -56.63621197037746 -29.049078574654985 0.6671267349769892 +22.5 -20.0 30.0 -25.0 +22.5 80.0 -50.0 -60.0 +25.0 -22.453078275656743 -8.614168218366327 -36.18129411612183 +25.0 18.544626904752903 -6.413485144547558 -3.134056229573595 +25.0 -72.79540507726888 -2.604892791153773 -17.33456187600241 +25.0 23.643734869303813 -14.318104711484274 -38.443908132957965 +25.0 54.15593720049384 -16.36815259911156 -41.970930547766 +25.0 -63.16075536328109 -31.55672696643327 -53.955593748659936 +25.0 -10.255299548027182 -11.332684738402683 -37.872136745137716 +25.0 61.98323913532661 9.271165380687961 -22.29875762275354 +25.0 -20.0 30.0 -25.0 +25.0 80.0 -50.0 -60.0 +31.4 24.450592872595692 32.49951397511472 -24.423911467133188 +31.4 -33.5130746533869 30.69218710941516 -10.399877719313537 +31.4 17.1726462947003 -28.057833796119702 -0.7198816827221464 +31.4 -16.00977467511688 7.604308980708758 -38.79594561730211 +31.4 49.56611755613564 24.29579555489832 -39.2383357640435 +31.4 38.788165897626385 -17.477565914614843 -0.5943161923928244 +31.4 -60.26063497484097 2.687179369261031 -39.94385912639674 +31.4 9.324310432071925 13.805370194256845 -52.20335890368953 +31.4 -20.0 30.0 -25.0 +31.4 80.0 -50.0 -60.0 +51.0 -14.136121752396775 -29.809806473708225 -47.36327497061714 +51.0 2.089085739222412 37.690841817195974 -19.510792555907237 +51.0 41.08115516665001 22.464695846937673 -49.82341698468653 +51.0 -53.55266041769373 -8.09311325716213 -6.87308478089318 +51.0 -58.45177522255305 -29.717639119292897 -10.922401606337985 +51.0 -54.24339530261055 -3.343601310862148 -53.34523254137063 +51.0 -22.39801804532383 -1.1037955731224685 -55.27030896441515 +51.0 -41.70627881523723 12.712612818433882 -5.202671781924252 +51.0 -20.0 30.0 -25.0 +51.0 80.0 -50.0 -60.0 diff --git a/tests/data/currents_mdc/c5/ref_moordyn_c.csv b/tests/data/currents_mdc/c5/ref_moordyn_c.csv new file mode 100644 index 00000000..861bd64b --- /dev/null +++ b/tests/data/currents_mdc/c5/ref_moordyn_c.csv @@ -0,0 +1,121 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,50.005736104870834,21.485148135208114,-12.035045295798369,0,0.6494522456551074,-0.074288407459167552,-0.01616964532416133,0,0,0 +0,51.167391421593621,30.109157160400187,2.77804754336114,0,0.79000000000000004,-0.040229000000000001,0,0,0,0 +0,6.0232182423363412,1.2110045819180328,-25.537592572473756,0,0.29938824301819683,0.17141895942678156,-0.011299224165806398,0,0,0 +0,-43.999946793023526,-36.463578834209578,-38.865730536962602,0,0.023652369088504571,-0.19557439288947986,0.0053060363613909658,0,0,0 +0,64.776596068741441,27.812081604590787,-44.967401814510751,0,0.34307258960636844,-0.048980673581636859,0.012907986572662657,0,0,0 +0,-9.3967887728237116,-25.887530634381672,-36.137500873542123,0,0.1458190555629508,0.028351904787527672,0.0019069895883286579,0,0,0 +0,45.251982367198806,22.894432429909045,-10.025624589939213,0,0.64743370257809252,-0.02879807207680209,-0.016820697632859694,0,0,0 +0,-47.694605920179427,-25.234634984552251,-49.737213382204075,0,0.014423417933480174,-0.20478243240616587,0.018850599408620414,0,0,0 +0,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +0,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +1.2999999999999667,-58.899807932234665,-30.391429089199661,-8.9651431941080659,0,-0.043532380456373761,-0.29954768913939644,-0.015450048069114644,0,0,0 +1.3,21.252373997194326,3.9151172762301627,-21.785798269610069,0,0.44329221989549045,0.081361553218357058,-0.013538302200104832,0,0,0 +1.3,-42.896718803798365,-31.625202379689199,-10.931938360694204,0,0.051320312603987527,-0.17401270471232957,-0.016477069886027169,0,0,0 +1.3,40.954972515124823,-23.098472646607576,-47.040958079019177,0,0.2682795810497054,-0.18826747268181909,0.01460242321768365,0,0,0 +1.3,-58.402364092368053,-1.7177411179226709,-32.240068899394885,0,0.029966052524806289,-0.1825164942098727,-0.00017162095013376934,0,0,0 +1.3,-39.285226131318268,-2.7500337165631521,-2.7648167250723361,0,0.17018076901868001,-0.036682767005740517,-0.0071866449499301916,0,0,0 +1.3,30.056521115539553,29.92851724372612,-8.5770133497964451,0,0.67586019929943131,0.11321517750616376,-0.011891051058805949,0,0,0 +1.3,7.8993607781100508,-35.747056623732618,-22.259781958060287,0,0.29140141425636956,0.035710934880143513,-0.013231880022575101,0,0,0 +1.3,-20,30,-25,0,0.28736094000000001,0.24559882,-0.01010116,0,0,0 +1.3,80,-50,-60,0,0.25841288000000001,-0.29004894000000003,0.01812708,0,0,0 +5.0000000000002229,0.70650750907638837,15.816164666472503,-53.091747117263438,0,0.25386219309811342,0.19222169609789505,0.018538889185018347,0,0,0 +5.0000000000002229,-57.270676763422955,-38.261003995975045,-55.523143923146009,0,-0.018898176181614594,-0.25732001601530163,0.0026031388850520166,0,0,0 +5.0000000000002229,-55.583179460495032,-11.267112332013653,-3.7402305084147329,0,0.046717367709064657,-0.16822420360663545,-0.017112782179504134,0,0,0 +5.0000000000002229,-55.759542999126353,-30.260916044615875,-4.7153084412182196,0,-0.034635512035943256,-0.24463608809461357,-0.017044727644028861,0,0,0 +5.0000000000002229,2.7409365902909713,28.60201112028858,-25.111807766941638,0,0.51646259509400116,0.23879053249544263,-0.012323092620119968,0,0,0 +5.0000000000002229,-26.90563341915059,-18.420651494160794,-46.743191840476669,0,0.1142067716651891,0.043870924074704637,0.011093208251581449,0,0,0 +5.0000000000002229,-16.112072543782354,-28.66106348420395,-35.787427339459953,0,0.18002507612677399,0.052130481982715075,0.0034520858110215717,0,0,0 +5.0000000000002229,47.653715716084676,-34.975665237240214,-12.915985400675432,0,0.74893985472186353,-0.30004552311583549,-0.0044987919875947562,0,0,0 +5.0000000000002229,-20,30,-25,0,0.38124399999999414,0.29551700000000058,-0.004784999999999648,0,0,0 +5.0000000000002229,80,-50,-60,0,0.3428379999999947,-0.31799799999999906,0.01513599999999919,0,0,0 +7.7500000000009992,-23.782540347753034,31.640590099832778,-42.28125833560091,0,0.19909993654757027,0.27532266043072745,0.0072307514105965746,0,0,0 +7.7500000000009992,50.699916065949282,21.248156177521807,-9.6544214270716324,0,0.81656011565714914,-0.10185687528990872,0.0080117469713994194,0,0,0 +7.7500000000009992,-30.862612828868855,-29.963976322550394,-20.768673745665197,0,0.11246834986653645,-0.017404097009267695,-0.0020752046858118467,0,0,0 +7.7500000000009992,-29.029779494510834,30.562070864728852,-24.577795503163962,0,0.26602890686414682,0.23613859757504346,0.0019820218823236846,0,0,0 +7.7500000000009992,44.097261234879468,4.3627783365342623,-51.969286230642126,0,0.30898976781412085,-0.13363755560770668,0.0073040284758879286,0,0,0 +7.7500000000009992,31.828650476772225,13.454382521358369,-37.508052128273803,0,0.40772739750874276,-0.022943655652622102,-0.0012734242766106957,0,0,0 +7.7500000000009992,19.279805725190684,-29.432058008061055,-28.273968928784587,0,0.33599236489156287,-0.11846418019119137,-0.011219190322896174,0,0,0 +7.7500000000009992,-65.088498790004209,-4.1096213331942266,-4.0369821288993819,0,0.031947302125072033,-0.13157180676133193,-0.0097886861315053669,0,0,0 +7.7500000000009992,-20,30,-25,0,0.3092914285714024,0.30356900000000286,-0.00044549999999842264,0,0,0 +7.7500000000009992,80,-50,-60,0,0.27813403571426221,-0.30684949999999594,0.0051393571428535101,0,0,0 +11.999999999998112,38.748666590388865,-21.181534454098497,-53.134152389089131,0,0.19509269599200257,-0.20285837903314458,0.00046557148201607172,0,0,0 +12,60.517381720185682,-8.0005172692153153,-30.269613490802683,0,0.38425095739903525,-0.18736771907686128,-0.0028666870862236161,0,0,0 +12,45.490473682488201,-20.534961895274311,-11.965353621749735,0,0.47539953906280819,-0.2225823741888657,0.0092083154199232749,0,0,0 +12,-30.609218021163912,-8.3671424569499635,-28.048800274861485,0,0.11356111033404216,0.087115973989754208,0.0062523360734655269,0,0,0 +12,6.5945258766081025,0.59760111799577942,-53.350036552039931,0,0.15134269600375758,0.002359031070255431,0.017838479320703017,0,0,0 +12,-45.00122797001535,2.7927463368735346,-12.885058684263356,0,0.10614796016930442,0.052095910868263831,0.00023866052549963287,0,0,0 +12,-57.750808960729856,14.274812330751992,-51.416219286157663,0,0.03302831981986494,0.027455382939537247,-0.011158470278916675,0,0,0 +12,-38.214312874891242,-5.6115938197858313,-38.052390995065217,0,0.073779482552374084,0.056044051364241745,0.0025077513783129421,0,0,0 +12,-20,30,-25,0,0.2326012357142857,0.29930645,0.0058831500000000002,0,0,0 +12,80,-50,-60,0,0.20916970714285715,-0.27536565000000002,-0.0069256785714285705,0,0,0 +14.099999999998847,52.049165952549743,0.83978298962566811,-50.525479290346901,0,0.22151677985593671,-0.12852605054151023,-0.011005941071426332,0,0,0 +14.099999999999998,-50.08982512680857,17.159357032043026,0.081972995586298225,0,0.12691654361572441,0.10712276023372644,-0.0028313030020003802,0,0,0 +14.099999999999998,55.566790108726224,-1.3303810172184072,-5.7830355595344187,0,0.54293066689332492,-0.13720670656887363,0.0098628800760606032,0,0,0 +14.099999999999998,-7.7626286311559625,-36.193633307630989,-40.133058664429967,0,0.11038125919679376,-0.045150281885480079,0.0048333389536111843,0,0,0 +14.099999999999998,-38.482282748346435,-35.635152454396675,-7.835478838758128,0,0.06000131236229421,-0.031586113723443721,-0.0047059041576073563,0,0,0 +14.099999999999998,-32.118569101807033,32.395467883591024,-32.95814835720526,0,0.14699059331736422,0.23578669364356092,0.004937513539957368,0,0,0 +14.099999999999998,-73.653536889253203,-5.30135437991148,2.6584938454922877,0,0.020260864434408211,-0.025347601805360262,0.0018520210714285633,0,0,0 +14.099999999999998,22.808794396358067,-7.7895303493948376,-20.30813130952022,0,0.32215795444074791,-0.11433544796613135,-0.0081790632881922135,0,0,0 +14.099999999999998,-20,30,-25,0,0.21389033321428574,0.28791337249999999,0.0088002074999999971,0,0,0 +14.099999999999998,80,-50,-60,0,0.19234374964285716,-0.25188518250000003,-0.011005941071428566,0,0,0 +19.90000000000413,-22.942982304194317,30.544962591266923,-15.080061000458585,0,0.24568816887805098,0.22893735252924668,-0.0012431259903816251,0,0,0 +19.90000000000413,-65.422008313280557,-17.318980426019834,-57.386570856646848,0,-0.0038525263084207804,0.036865328295999901,0.0069884625000141056,0,0,0 +19.90000000000413,-43.52656302826329,12.98234031670659,-19.490002308485693,0,0.11555007775630025,0.15931359900970951,-0.0015021336557131052,0,0,0 +19.90000000000413,-45.752898140435072,-21.849395089813164,-14.954187063917864,0,0.041873228265616874,0.019818671354937666,-7.4214162081936378e-05,0,0,0 +19.90000000000413,-46.408896706751769,-11.11361856588994,-11.869225071677462,0,0.064547778819663948,0.062712279693809839,0.0016252573467924903,0,0,0 +19.90000000000413,7.8173249258989017,1.6818490920869351,-47.59117384546461,0,0.15732383928080862,-0.13234355889556593,0.012573946251593863,0,0,0 +19.90000000000413,64.170180487823899,36.580457381274229,-51.528910673324326,0,0.25456000000001244,0.07624773750006579,-0.016747512500003364,0,0,0 +19.90000000000413,1.0461545715413649,2.3254772953772544,-41.800453413679875,0,0.16955712013674804,-0.069345906483920805,0.0040445175704328677,0,0,0 +19.90000000000413,-20,30,-25,0,0.21857768750001072,0.22915941249995458,0.016239687500005213,0,0,0 +19.90000000000413,80,-50,-60,0,0.19655881250000962,-0.16375226249993419,-0.016747512500003364,0,0,0 +20.000000000000117,57.773196593431464,17.058190764761036,-24.207950794350978,0,0.52386960874343758,-0.091996236940955864,-0.012225623942630283,0,0,0 +20.000000000000117,23.057160140338723,-37.342213410017891,-8.834977048711913,0,0.39882921372964608,-0.054080232211954134,-0.014868382875277279,0,0,0 +20.000000000000117,-31.293205806228023,-39.392197429185352,-23.833023124277616,0,0.08582367787700193,-0.098349399566063408,-0.012347100507734052,0,0,0 +20.000000000000117,40.574543650916894,-9.5228861341035653,-19.788490814814573,0,0.46278460853257941,-0.11920656285193283,-0.013657528976000078,0,0,0 +20.000000000000117,-35.563484488409081,-28.633726656316636,-12.438347765451326,0,0.08505835773364917,-0.12555813001410424,-0.01603897532399377,0,0,0 +20.000000000000117,-14.200725792275222,8.4041897977722684,-45.858535484595734,0,0.14510472993832618,0.15471681386543876,0.014018232189548133,0,0,0 +20.000000000000117,32.459113235635698,-9.3693527585883913,-28.147220365362394,0,0.3672775297072905,-0.050474346844647147,-0.0080479410912023021,0,0,0 +20.000000000000117,9.7491037437402213,-20.448522155057933,-55.761079490981629,0,0.14893089599897535,0.093158754421151055,0.019178000000000001,0,0,0 +20.000000000000117,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +20.000000000000117,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +22.500000000003109,52.955030493423436,27.395038157243647,-8.8820828632123892,0,0.69534220195786633,-0.050648847371025429,-0.014947657250500131,0,0,0 +22.500000000003109,43.868632888551574,11.787804359995498,-45.971185031226426,0,0.29714608221072569,-0.061613233005008941,0.014158580006704377,0,0,0 +22.500000000003109,-12.541703804709933,-29.44195004306782,-12.059168022088059,0,0.20078547878443889,0.0070626760425847911,-0.016161829560843471,0,0,0 +22.500000000003109,3.2739774302568634,1.2193424360429432,-2.0593936832047248,0,0.41240507636159257,0.16527045959459968,-0.0034657536294652306,0,0,0 +22.500000000003109,-11.230860572498329,-30.278984685702213,-43.423215504819758,0,0.11092588240464683,0.0077779946120326744,0.010984115733144839,0,0,0 +22.500000000003109,-32.980103354584053,13.337287228011547,-49.1668254070279,0,0.093320935566570007,0.062092537099614042,0.018139964438107919,0,0,0 +22.500000000003109,51.845307354855038,-12.92926670713549,-13.079923721627608,0,0.55310463565082357,-0.21194606682854197,-0.015831104714192655,0,0,0 +22.500000000003109,-56.63621197037746,-29.049078574654985,0.66712673497698916,0,-0.026964507546229716,-0.28845645837936457,0,0,0,0 +22.500000000003109,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +22.500000000003109,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +25.000000000003109,-22.453078275656743,-8.6141682183663271,-36.181294116121833,0,0.13114885304847251,0.054833721354301736,0.0019615507133953934,0,0,0 +25.000000000003109,18.544626904752903,-6.4134851445475576,-3.134056229573595,0,0.47275179045160198,0.078142451802692553,-0.0052743032287454542,0,0,0 +25.000000000003109,-72.795405077268882,-2.6048927911537731,-17.334561876002411,0,0.025211341011118087,-0.20841757116459161,-0.014452601952168149,0,0,0 +25.000000000003109,23.643734869303813,-14.318104711484274,-38.443908132957965,0,0.25915838290523485,0.0037238459682952807,0.0047804962646880323,0,0,0 +25.000000000003109,54.155937200493838,-16.368152599111561,-41.970930547766002,0,0.3094118972572793,-0.22570161039646974,0.0091747429508474074,0,0,0 +25.000000000003109,-63.160755363281091,-31.556726966433271,-53.955593748659936,0,-0.018750000000005814,-0.31799799999997652,0.01917799999998911,0,0,0 +25.000000000003109,-10.255299548027182,-11.332684738402683,-37.872136745137716,0,0.16033345976321967,0.084640869659361642,0.004068137728032625,0,0,0 +25.000000000003109,61.983239135326613,9.271165380687961,-22.298757622753541,0,0.52494678682921725,-0.12314433847727163,-0.012844202530230036,0,0,0 +25.000000000003109,-20,30,-25,0,0.2543750000000789,0.22806000000004195,-0.011968999999995534,0,0,0 +25.000000000003109,80,-50,-60,0,0.22875000000007095,-0.28022900000002349,0.019177999999997485,0,0,0 +31.400000000008301,24.450592872595692,32.499513975114724,-24.423911467133188,0,0.59922940346664688,0.10244614775531413,-0.015500010429039432,0,0,0 +31.400000000008301,-33.513074653386902,30.692187109415158,-10.399877719313537,0,0.340532321009405,0.19256312267712017,-0.01585666745889407,0,0,0 +31.400000000008301,17.1726462947003,-28.057833796119702,-0.71988168272214637,0,0.5623461839630014,-0.080001012488565379,0.0057728617842811797,0,0,0 +31.400000000008301,-16.00977467511688,7.6043089807087583,-38.79594561730211,0,0.22799700621150029,0.19695587144306304,0.0060544409604654393,0,0,0 +31.400000000008301,49.566117556135637,24.295795554898319,-39.238335764043498,0,0.53170491735409309,-0.09217128180312871,-0.0012556821051432632,0,0,0 +31.400000000008301,38.788165897626385,-17.477565914614843,-0.59431619239282441,0,0.78031385205614445,-0.18553906548709162,0.012211819395836746,0,0,0 +31.400000000008301,-60.260634974840968,2.6871793692610311,-39.943859126396738,0,0.032601393396397324,-0.12652248252281975,0.0030782051829418336,0,0,0 +31.400000000008301,9.3243104320719254,13.805370194256845,-52.203358903689526,0,0.25267479112199792,0.13873018576680027,0.019724277295129232,0,0,0 +31.400000000008301,-20,30,-25,0,0.34461359999978286,0.29961620000002426,-0.0025757999999869003,0,0,0 +31.400000000008301,80,-50,-60,0,0.30989779999980466,-0.31232239999996636,0.010046799999969824,0,0,0 +50.999999999956437,-14.136121752396775,-29.809806473708225,-47.363274970617141,0,0.10128512059791817,0.010223366803780573,0.015492908336962584,0,0,0 +51,2.089085739222412,37.690841817195974,-19.510792555907237,0,0.41787615073124457,0.27135266913421452,-0.013704080377416494,0,0,0 +51,41.081155166650007,22.464695846937673,-49.823416984686531,0,0.29614178902973093,-0.0043862680038635818,0.018357585250831317,0,0,0 +51,-53.55266041769373,-8.0931132571621305,-6.8730847808931799,0,0.0546912511121046,-0.17252811349401376,-0.012610915920695149,0,0,0 +51,-58.451775222553053,-29.717639119292897,-10.922401606337985,0,-0.037854428024012468,-0.29723877351781097,-0.016161947960753428,0,0,0 +51,-54.243395302610551,-3.3436013108621481,-53.345232541370628,0,0.026603789726054317,-0.15891772183032768,0.016071804242955477,0,0,0 +51,-22.39801804532383,-1.1037955731224685,-55.27030896441515,0,0.10817431972273717,0.098431940735969184,0.018268020685504247,0,0,0 +51,-41.706278815237233,12.712612818433882,-5.2026717819242521,0,0.19320446379057454,0.0030952642055547472,-0.010167724383337786,0,0,0 +51,-20,30,-25,0,0.27974879999999991,0.24155139999999994,-0.010532200000000005,0,0,0 +51,80,-50,-60,0,0.25156759999999989,-0.28778279999999995,0.018369600000000003,0,0,0 diff --git a/tests/data/currents_mdc/c5/ref_python.csv b/tests/data/currents_mdc/c5/ref_python.csv new file mode 100644 index 00000000..8982d040 --- /dev/null +++ b/tests/data/currents_mdc/c5/ref_python.csv @@ -0,0 +1,121 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,50.005736104870834,21.485148135208114,-12.035045295798369,0,0.64945224565510729,-0.074288407459167552,-0.016169645324161326,0,0,0 +0,51.167391421593621,30.109157160400187,2.77804754336114,0,0.79000000000000004,-0.040229000000000001,0,0,0,0 +0,6.0232182423363412,1.2110045819180328,-25.537592572473756,0,0.29938824301819678,0.17141895942678154,-0.011299224165806398,0,0,0 +0,-43.999946793023526,-36.463578834209578,-38.865730536962602,0,0.023652369088504571,-0.19557439288947984,0.0053060363613909658,0,0,0 +0,64.776596068741441,27.812081604590787,-44.967401814510751,0,0.34307258960636844,-0.048980673581636859,0.012907986572662655,0,0,0 +0,-9.3967887728237116,-25.887530634381672,-36.137500873542123,0,0.14581905556295077,0.028351904787527669,0.001906989588328659,0,0,0 +0,45.251982367198806,22.894432429909045,-10.025624589939213,0,0.64743370257809274,-0.02879807207680209,-0.016820697632859694,0,0,0 +0,-47.694605920179427,-25.234634984552251,-49.737213382204075,0,0.014423417933480176,-0.20478243240616589,0.018850599408620414,0,0,0 +0,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +0,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +1.3,-58.899807932234665,-30.391429089199661,-8.9651431941080659,0,-0.043532380456373886,-0.29954768913939617,-0.015450048069114652,0,0,0 +1.3,21.252373997194326,3.9151172762301627,-21.785798269610069,0,0.44329221989549045,0.081361553218357058,-0.013538302200104834,0,0,0 +1.3,-42.896718803798365,-31.625202379689199,-10.931938360694204,0,0.051320312603987527,-0.17401270471232957,-0.016477069886027165,0,0,0 +1.3,40.954972515124823,-23.098472646607576,-47.040958079019177,0,0.2682795810497054,-0.18826747268181912,0.014602423217683654,0,0,0 +1.3,-58.402364092368053,-1.7177411179226709,-32.240068899394885,0,0.029966052524806292,-0.18251649420987268,-0.00017162095013376936,0,0,0 +1.3,-39.285226131318268,-2.7500337165631521,-2.7648167250723361,0,0.17018076901868001,-0.036682767005740489,-0.0071866449499301916,0,0,0 +1.3,30.056521115539553,29.92851724372612,-8.5770133497964451,0,0.6758601992994312,0.11321517750616381,-0.011891051058805951,0,0,0 +1.3,7.8993607781100508,-35.747056623732618,-22.259781958060287,0,0.29140141425636956,0.035710934880143513,-0.013231880022575101,0,0,0 +1.3,-20,30,-25,0,0.28736094000000001,0.24559882,-0.01010116,0,0,0 +1.3,80,-50,-60,0,0.25841288000000001,-0.29004894000000003,0.01812708,0,0,0 +5,0.70650750907638837,15.816164666472503,-53.091747117263438,0,0.25386219309811731,0.1922216960978978,0.018538889185018444,0,0,0 +5,-57.270676763422955,-38.261003995975045,-55.523143923146009,0,-0.018898176181614885,-0.25732001601530508,0.0026031388850526792,0,0,0 +5,-55.583179460495032,-11.267112332013653,-3.7402305084147329,0,0.046717367709065385,-0.16822420360663878,-0.017112782179504668,0,0,0 +5,-55.759542999126353,-30.260916044615875,-4.7153084412182196,0,-0.034635512035943783,-0.24463608809461693,-0.017044727644029447,0,0,0 +5,2.7409365902909713,28.60201112028858,-25.111807766941638,0,0.51646259509400916,0.23879053249544574,-0.012323092620119979,0,0,0 +5,-26.90563341915059,-18.420651494160794,-46.743191840476669,0,0.11420677166519085,0.043870924074703464,0.011093208251581721,0,0,0 +5,-16.112072543782354,-28.66106348420395,-35.787427339459953,0,0.18002507612677668,0.052130481982715075,0.003452085811021517,0,0,0 +5,47.653715716084676,-34.975665237240214,-12.915985400675432,0,0.7489398547218753,-0.3000455231158361,-0.0044987919875953426,0,0,0 +5,-20,30,-25,0,0.38124400000000003,0.29551699999999997,-0.0047850000000000002,0,0,0 +5,80,-50,-60,0,0.34283799999999998,-0.317998,0.015136,0,0,0 +7.75,-23.782540347753034,31.640590099832778,-42.28125833560091,0,0.19909993654758706,0.27532266043072323,0.0072307514105971263,0,0,0 +7.75,50.699916065949282,21.248156177521807,-9.6544214270716324,0,0.81656011565721809,-0.10185687528991277,0.0080117469713967167,0,0,0 +7.75,-30.862612828868855,-29.963976322550394,-20.768673745665197,0,0.11246834986654598,-0.017404097009274287,-0.0020752046858131734,0,0,0 +7.75,-29.029779494510834,30.562070864728852,-24.577795503163962,0,0.2660289068641693,0.23613859757503752,0.0019820218823223073,0,0,0 +7.75,44.097261234879468,4.3627783365342623,-51.969286230642126,0,0.30898976781414694,-0.13363755560770732,0.0073040284758910312,0,0,0 +7.75,31.828650476772225,13.454382521358369,-37.508052128273803,0,0.40772739750877718,-0.022943655652615639,-0.0012734242766102937,0,0,0 +7.75,19.279805725190684,-29.432058008061055,-28.273968928784587,0,0.33599236489159123,-0.11846418019117765,-0.01121919032289628,0,0,0 +7.75,-65.088498790004209,-4.1096213331942266,-4.0369821288993819,0,0.031947302125074711,-0.13157180676134833,-0.0097886861315082188,0,0,0 +7.75,-20,30,-25,0,0.30929142857142855,0.30356899999999998,-0.00044550000000000015,0,0,0 +7.75,80,-50,-60,0,0.27813403571428569,-0.3068495,0.0051393571428571426,0,0,0 +12,38.748666590388865,-21.181534454098497,-53.134152389089131,0,0.19509269599198845,-0.2028583790331388,0.00046557148201333953,0,0,0 +12,60.517381720185682,-8.0005172692153153,-30.269613490802683,0,0.38425095739903531,-0.18736771907686126,-0.0028666870862236165,0,0,0 +12,45.490473682488201,-20.534961895274311,-11.965353621749735,0,0.47539953906280819,-0.2225823741888657,0.0092083154199232749,0,0,0 +12,-30.609218021163912,-8.3671424569499635,-28.048800274861485,0,0.11356111033404216,0.087115973989754181,0.0062523360734655243,0,0,0 +12,6.5945258766081025,0.59760111799577942,-53.350036552039931,0,0.1513426960037576,0.0023590310702554171,0.017838479320703017,0,0,0 +12,-45.00122797001535,2.7927463368735346,-12.885058684263356,0,0.10614796016930442,0.052095910868263852,0.00023866052549963287,0,0,0 +12,-57.750808960729856,14.274812330751992,-51.416219286157663,0,0.03302831981986494,0.027455382939537244,-0.011158470278916675,0,0,0 +12,-38.214312874891242,-5.6115938197858313,-38.052390995065217,0,0.073779482552374084,0.056044051364241752,0.0025077513783129416,0,0,0 +12,-20,30,-25,0,0.23260123571428576,0.29930645,0.0058831499999999993,0,0,0 +12,80,-50,-60,0,0.20916970714285713,-0.27536565000000002,-0.0069256785714285696,0,0,0 +14.1,52.049165952549743,0.83978298962566811,-50.525479290346901,0,0.22151677985592605,-0.12852605054149735,-0.01100594107142857,0,0,0 +14.1,-50.08982512680857,17.159357032043026,0.081972995586298225,0,0.12691654361572438,0.10712276023372647,-0.0028313030020003785,0,0,0 +14.1,55.566790108726224,-1.3303810172184072,-5.7830355595344187,0,0.5429306668933247,-0.13720670656887363,0.0098628800760606032,0,0,0 +14.1,-7.7626286311559625,-36.193633307630989,-40.133058664429967,0,0.11038125919679376,-0.045150281885480092,0.0048333389536111843,0,0,0 +14.1,-38.482282748346435,-35.635152454396675,-7.835478838758128,0,0.060001312362294196,-0.031586113723443693,-0.0047059041576073572,0,0,0 +14.1,-32.118569101807033,32.395467883591024,-32.95814835720526,0,0.14699059331736419,0.23578669364356092,0.0049375135399573672,0,0,0 +14.1,-73.653536889253203,-5.30135437991148,2.6584938454922877,0,0.02026086443440819,-0.025347601805360227,0.0018520210714285676,0,0,0 +14.1,22.808794396358067,-7.7895303493948376,-20.30813130952022,0,0.32215795444074791,-0.11433544796613135,-0.0081790632881922152,0,0,0 +14.1,-20,30,-25,0,0.21389033321428572,0.28791337249999999,0.0088002074999999989,0,0,0 +14.1,80,-50,-60,0,0.19234374964285716,-0.25188518250000003,-0.01100594107142857,0,0,0 +19.899999999999999,-22.942982304194317,30.544962591266923,-15.080061000458585,0,0.2456881688780389,0.22893735252928299,-0.0012431259903853287,0,0,0 +19.899999999999999,-65.422008313280557,-17.318980426019834,-57.386570856646848,0,-0.0038525263084205931,0.036865328295920631,0.0069884624999999919,0,0,0 +19.899999999999999,-43.52656302826329,12.98234031670659,-19.490002308485693,0,0.11555007775629458,0.15931359900968162,-0.0015021336557083501,0,0,0 +19.899999999999999,-45.752898140435072,-21.849395089813164,-14.954187063917864,0,0.04187322826561482,0.019818671354902808,-7.4214162079037709e-05,0,0,0 +19.899999999999999,-46.408896706751769,-11.11361856588994,-11.869225071677462,0,0.064547778819660798,0.062712279693772938,0.0016252573467936456,0,0,0 +19.899999999999999,7.8173249258989017,1.6818490920869351,-47.59117384546461,0,0.15732383928080093,-0.13234355889549823,0.012573946251595291,0,0,0 +19.899999999999999,64.170180487823899,36.580457381274229,-51.528910673324326,0,0.25455999999999995,0.076247737499999954,-0.016747512499999999,0,0,0 +19.899999999999999,1.0461545715413649,2.3254772953772544,-41.800453413679875,0,0.16955712013673971,-0.069345906483858549,0.0040445175704344116,0,0,0 +19.899999999999999,-20,30,-25,0,0.21857768750000001,0.22915941250000005,0.016239687499999999,0,0,0 +19.899999999999999,80,-50,-60,0,0.19655881250000001,-0.16375226250000005,-0.016747512499999999,0,0,0 +20,57.773196593431464,17.058190764761036,-24.207950794350978,0,0.52386960874343746,-0.091996236940955864,-0.012225623942630283,0,0,0 +20,23.057160140338723,-37.342213410017891,-8.834977048711913,0,0.39882921372964608,-0.054080232211954134,-0.014868382875277277,0,0,0 +20,-31.293205806228023,-39.392197429185352,-23.833023124277616,0,0.08582367787700193,-0.098349399566063395,-0.012347100507734052,0,0,0 +20,40.574543650916894,-9.5228861341035653,-19.788490814814573,0,0.46278460853257936,-0.11920656285193283,-0.01365752897600008,0,0,0 +20,-35.563484488409081,-28.633726656316636,-12.438347765451326,0,0.085058357733649184,-0.12555813001410421,-0.01603897532399377,0,0,0 +20,-14.200725792275222,8.4041897977722684,-45.858535484595734,0,0.14510472993832621,0.15471681386543873,0.014018232189548133,0,0,0 +20,32.459113235635698,-9.3693527585883913,-28.147220365362394,0,0.3672775297072905,-0.050474346844647133,-0.0080479410912023021,0,0,0 +20,9.7491037437402213,-20.448522155057933,-55.761079490981629,0,0.14893089599897533,0.093158754421151069,0.019177999999999997,0,0,0 +20,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +20,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +22.5,52.955030493423436,27.395038157243647,-8.8820828632123892,0,0.69534220195786611,-0.050648847371025416,-0.014947657250500129,0,0,0 +22.5,43.868632888551574,11.787804359995498,-45.971185031226426,0,0.29714608221072569,-0.061613233005008948,0.014158580006704379,0,0,0 +22.5,-12.541703804709933,-29.44195004306782,-12.059168022088059,0,0.20078547878443892,0.007062676042584792,-0.016161829560843468,0,0,0 +22.5,3.2739774302568634,1.2193424360429432,-2.0593936832047248,0,0.41240507636159263,0.16527045959459968,-0.003465753629465231,0,0,0 +22.5,-11.230860572498329,-30.278984685702213,-43.423215504819758,0,0.11092588240464683,0.0077779946120326727,0.010984115733144837,0,0,0 +22.5,-32.980103354584053,13.337287228011547,-49.1668254070279,0,0.093320935566570007,0.062092537099614036,0.018139964438107923,0,0,0 +22.5,51.845307354855038,-12.92926670713549,-13.079923721627608,0,0.55310463565082357,-0.21194606682854195,-0.015831104714192655,0,0,0 +22.5,-56.63621197037746,-29.049078574654985,0.66712673497698916,0,-0.026964507546229716,-0.28845645837936457,0,0,0,0 +22.5,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +22.5,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +25,-22.453078275656743,-8.6141682183663271,-36.181294116121833,0,0.13114885304843188,0.054833721354260928,0.0019615507133938703,0,0,0 +25,18.544626904752903,-6.4134851445475576,-3.134056229573595,0,0.47275179045145543,0.078142451802730578,-0.0052743032287494033,0,0,0 +25,-72.795405077268882,-2.6048927911537731,-17.334561876002411,0,0.025211341011110267,-0.2084175711646151,-0.01445260195217522,0,0,0 +25,23.643734869303813,-14.318104711484274,-38.443908132957965,0,0.25915838290515447,0.0037238459683309388,0.0047804962646896708,0,0,0 +25,54.155937200493838,-16.368152599111561,-41.970930547766002,0,0.30941189725718332,-0.22570161039644626,0.0091747429508507068,0,0,0 +25,-63.160755363281091,-31.556726966433271,-53.955593748659936,0,-0.018749999999999999,-0.317998,0.019178000000000001,0,0,0 +25,-10.255299548027182,-11.332684738402683,-37.872136745137716,0,0.16033345976316993,0.084640869659346946,0.0040681377280321783,0,0,0 +25,61.983239135326613,9.271165380687961,-22.298757622753541,0,0.52494678682905449,-0.12314433847724815,-0.012844202530227852,0,0,0 +25,-20,30,-25,0,0.25437500000000002,0.22806000000000001,-0.011969,0,0,0 +25,80,-50,-60,0,0.22875000000000001,-0.28022900000000001,0.019178000000000001,0,0,0 +31.399999999999999,24.450592872595692,32.499513975114724,-24.423911467133188,0,0.5992294034670248,0.10244614775540339,-0.015500010429045025,0,0,0 +31.399999999999999,-33.513074653386902,30.692187109415158,-10.399877719313537,0,0.34053232100961972,0.19256312267705805,-0.015856667458906838,0,0,0 +31.399999999999999,17.1726462947003,-28.057833796119702,-0.71988168272214637,0,0.56234618396335612,-0.080001012488441103,0.0057728617842764673,0,0,0 +31.399999999999999,-16.00977467511688,7.6043089807087583,-38.79594561730211,0,0.22799700621164404,0.19695587144306309,0.0060544409604657594,0,0,0 +31.399999999999999,49.566117556135637,24.295795554898319,-39.238335764043498,0,0.53170491735442826,-0.092171281803160268,-0.0012556821051353043,0,0,0 +31.399999999999999,38.788165897626385,-17.477565914614843,-0.59431619239282441,0,0.78031385205663639,-0.18553906548707136,0.012211819395836678,0,0,0 +31.399999999999999,-60.260634974840968,2.6871793692610311,-39.943859126396738,0,0.032601393396417877,-0.12652248252295595,0.0030782051829547526,0,0,0 +31.399999999999999,9.3243104320719254,13.805370194256845,-52.203358903689526,0,0.25267479112215724,0.13873018576695495,0.019724277295129815,0,0,0 +31.399999999999999,-20,30,-25,0,0.34461360000000008,0.29961619999999994,-0.0025758000000000057,0,0,0 +31.399999999999999,80,-50,-60,0,0.30989780000000006,-0.3123224,0.010046800000000012,0,0,0 +51,-14.136121752396775,-29.809806473708225,-47.363274970617141,0,0.10128512059831829,0.010223366804138486,0.015492908336945157,0,0,0 +51,2.089085739222412,37.690841817195974,-19.510792555907237,0,0.41787615073124462,0.27135266913421452,-0.013704080377416494,0,0,0 +51,41.081155166650007,22.464695846937673,-49.823416984686531,0,0.29614178902973093,-0.0043862680038635714,0.018357585250831317,0,0,0 +51,-53.55266041769373,-8.0931132571621305,-6.8730847808931799,0,0.054691251112104614,-0.1725281134940137,-0.012610915920695147,0,0,0 +51,-58.451775222553053,-29.717639119292897,-10.922401606337985,0,-0.037854428024012475,-0.29723877351781103,-0.016161947960753428,0,0,0 +51,-54.243395302610551,-3.3436013108621481,-53.345232541370628,0,0.026603789726054317,-0.15891772183032768,0.016071804242955474,0,0,0 +51,-22.39801804532383,-1.1037955731224685,-55.27030896441515,0,0.10817431972273717,0.098431940735969184,0.018268020685504247,0,0,0 +51,-41.706278815237233,12.712612818433882,-5.2026717819242521,0,0.19320446379057454,0.0030952642055547333,-0.010167724383337785,0,0,0 +51,-20,30,-25,0,0.27974879999999991,0.24155139999999994,-0.010532200000000005,0,0,0 +51,80,-50,-60,0,0.25156759999999989,-0.28778279999999995,0.018369600000000003,0,0,0 diff --git a/tests/data/currents_mdc/c5uniform/current_profile_4d.txt b/tests/data/currents_mdc/c5uniform/current_profile_4d.txt new file mode 100644 index 00000000..bb068aef --- /dev/null +++ b/tests/data/currents_mdc/c5uniform/current_profile_4d.txt @@ -0,0 +1,105 @@ +2 2 5 5 +-100.0 100.0 +-60.0 60.0 +-50.0 -30.0 -12.5 -5.0 0.0 +0.0 4.0 7.0 15.0 30.0 +-100.0 -60.0 -50.0 0.0 0.000000 0.000000 0.000000 +100.0 60.0 -5.0 30.0 1.448678 0.066697 -0.009380 +-100.0 -60.0 0.0 7.0 1.378881 0.055749 0.000000 +100.0 -60.0 -12.5 30.0 1.293462 0.081697 0.000994 +100.0 60.0 0.0 15.0 1.060725 -0.124508 0.000000 +100.0 60.0 0.0 0.0 1.006387 0.150000 0.000000 +-100.0 60.0 -5.0 0.0 0.939295 0.160000 -0.000000 +-100.0 60.0 -12.5 30.0 1.293462 0.081697 0.000994 +-100.0 60.0 -12.5 7.0 1.149067 0.080749 0.009436 +100.0 -60.0 -30.0 30.0 0.931293 0.116697 -0.008509 +-100.0 -60.0 -50.0 15.0 0.353575 -0.024508 0.001978 +100.0 -60.0 -30.0 0.0 0.603832 0.210000 -0.000000 +100.0 -60.0 -5.0 7.0 1.286955 0.065749 -0.009840 +100.0 60.0 -12.5 4.0 1.082590 0.141636 -0.005985 +-100.0 -60.0 -50.0 4.0 0.433036 0.216636 0.005440 +100.0 60.0 -5.0 4.0 1.212501 0.126636 -0.008415 +100.0 -60.0 -50.0 0.0 0.000000 0.000000 0.000000 +100.0 60.0 -50.0 4.0 0.433036 0.216636 0.005440 +-100.0 60.0 0.0 30.0 1.552155 0.056697 0.000000 +-100.0 60.0 -5.0 7.0 1.286955 0.065749 -0.009840 +-100.0 60.0 -30.0 0.0 0.603832 0.210000 -0.000000 +100.0 -60.0 -30.0 15.0 0.636435 -0.064508 0.004872 +-100.0 60.0 -30.0 7.0 0.827328 0.115749 0.008797 +-100.0 60.0 -30.0 30.0 0.931293 0.116697 -0.008509 +-100.0 60.0 -30.0 4.0 0.779465 0.176636 0.002794 +100.0 -60.0 -5.0 0.0 0.939295 0.160000 -0.000000 +-100.0 -60.0 -12.5 4.0 1.082590 0.141636 -0.005985 +-100.0 -60.0 -5.0 7.0 1.286955 0.065749 -0.009840 +-100.0 60.0 -5.0 30.0 1.448678 0.066697 -0.009380 +-100.0 -60.0 -30.0 15.0 0.636435 -0.064508 0.004872 +100.0 -60.0 -30.0 4.0 0.779465 0.176636 0.002794 +-100.0 -60.0 -5.0 30.0 1.448678 0.066697 -0.009380 +100.0 60.0 -30.0 0.0 0.603832 0.210000 -0.000000 +100.0 60.0 -12.5 30.0 1.293462 0.081697 0.000994 +100.0 -60.0 -5.0 15.0 0.990010 -0.114508 0.005716 +-100.0 60.0 -50.0 4.0 0.433036 0.216636 0.005440 +-100.0 -60.0 -30.0 0.0 0.603832 0.210000 -0.000000 +-100.0 -60.0 -12.5 30.0 1.293462 0.081697 0.000994 +100.0 60.0 -50.0 7.0 0.459627 0.155749 0.009756 +100.0 -60.0 -50.0 30.0 0.517385 0.156697 0.003878 +100.0 60.0 -5.0 0.0 0.939295 0.160000 -0.000000 +-100.0 -60.0 -5.0 15.0 0.990010 -0.114508 0.005716 +100.0 60.0 -12.5 0.0 0.838656 0.175000 -0.000000 +-100.0 -60.0 -5.0 4.0 1.212501 0.126636 -0.008415 +100.0 -60.0 -30.0 7.0 0.827328 0.115749 0.008797 +100.0 -60.0 -5.0 30.0 1.448678 0.066697 -0.009380 +-100.0 60.0 -5.0 4.0 1.212501 0.126636 -0.008415 +-100.0 -60.0 0.0 15.0 1.060725 -0.124508 0.000000 +100.0 60.0 0.0 30.0 1.552155 0.056697 0.000000 +100.0 60.0 -30.0 4.0 0.779465 0.176636 0.002794 +-100.0 -60.0 -30.0 30.0 0.931293 0.116697 -0.008509 +100.0 60.0 -5.0 15.0 0.990010 -0.114508 0.005716 +100.0 -60.0 0.0 4.0 1.299108 0.116636 0.000000 +-100.0 60.0 -12.5 4.0 1.082590 0.141636 -0.005985 +-100.0 -60.0 -5.0 0.0 0.939295 0.160000 -0.000000 +-100.0 -60.0 0.0 30.0 1.552155 0.056697 0.000000 +-100.0 -60.0 -12.5 7.0 1.149067 0.080749 0.009436 +100.0 60.0 -30.0 7.0 0.827328 0.115749 0.008797 +-100.0 60.0 -5.0 15.0 0.990010 -0.114508 0.005716 +100.0 60.0 -50.0 30.0 0.517385 0.156697 0.003878 +-100.0 60.0 -12.5 15.0 0.883938 -0.099508 -0.000498 +100.0 60.0 -12.5 7.0 1.149067 0.080749 0.009436 +-100.0 -60.0 -30.0 7.0 0.827328 0.115749 0.008797 +100.0 -60.0 -50.0 4.0 0.433036 0.216636 0.005440 +100.0 -60.0 -50.0 7.0 0.459627 0.155749 0.009756 +100.0 -60.0 -12.5 7.0 1.149067 0.080749 0.009436 +-100.0 -60.0 0.0 0.0 1.006387 0.150000 0.000000 +-100.0 60.0 -50.0 30.0 0.517385 0.156697 0.003878 +-100.0 60.0 0.0 15.0 1.060725 -0.124508 0.000000 +-100.0 60.0 -50.0 0.0 0.000000 0.000000 0.000000 +-100.0 -60.0 0.0 4.0 1.299108 0.116636 0.000000 +-100.0 60.0 -30.0 15.0 0.636435 -0.064508 0.004872 +-100.0 -60.0 -12.5 15.0 0.883938 -0.099508 -0.000498 +100.0 -60.0 -5.0 4.0 1.212501 0.126636 -0.008415 +100.0 60.0 0.0 4.0 1.299108 0.116636 0.000000 +100.0 -60.0 -12.5 4.0 1.082590 0.141636 -0.005985 +-100.0 -60.0 -30.0 4.0 0.779465 0.176636 0.002794 +100.0 -60.0 -12.5 15.0 0.883938 -0.099508 -0.000498 +-100.0 60.0 -50.0 15.0 0.353575 -0.024508 0.001978 +100.0 60.0 0.0 7.0 1.378881 0.055749 0.000000 +-100.0 60.0 0.0 0.0 1.006387 0.150000 0.000000 +100.0 -60.0 0.0 30.0 1.552155 0.056697 0.000000 +100.0 -60.0 0.0 7.0 1.378881 0.055749 0.000000 +-100.0 -60.0 -12.5 0.0 0.838656 0.175000 -0.000000 +100.0 60.0 -12.5 15.0 0.883938 -0.099508 -0.000498 +100.0 60.0 -30.0 15.0 0.636435 -0.064508 0.004872 +100.0 60.0 -5.0 7.0 1.286955 0.065749 -0.009840 +-100.0 60.0 0.0 7.0 1.378881 0.055749 0.000000 +100.0 -60.0 0.0 0.0 1.006387 0.150000 0.000000 +100.0 -60.0 -12.5 0.0 0.838656 0.175000 -0.000000 +-100.0 -60.0 -50.0 30.0 0.517385 0.156697 0.003878 +-100.0 60.0 -50.0 7.0 0.459627 0.155749 0.009756 +100.0 -60.0 0.0 15.0 1.060725 -0.124508 0.000000 +-100.0 -60.0 -50.0 7.0 0.459627 0.155749 0.009756 +-100.0 60.0 0.0 4.0 1.299108 0.116636 0.000000 +100.0 -60.0 -50.0 15.0 0.353575 -0.024508 0.001978 +100.0 60.0 -50.0 0.0 0.000000 0.000000 0.000000 +-100.0 60.0 -12.5 0.0 0.838656 0.175000 -0.000000 +100.0 60.0 -30.0 30.0 0.931293 0.116697 -0.008509 +100.0 60.0 -50.0 15.0 0.353575 -0.024508 0.001978 diff --git a/tests/data/currents_mdc/c5uniform/currents.dat b/tests/data/currents_mdc/c5uniform/currents.dat new file mode 100644 index 00000000..43203b53 --- /dev/null +++ b/tests/data/currents_mdc/c5uniform/currents.dat @@ -0,0 +1,26 @@ +--------------------- MoorDyn Input File ------------------------------------ +Shared current parity deck (MoorDyn-C WaveKin 0, Currents 5): the c2 profile, uniform in x and y +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed -30.0 0.0 -20.0 0 0 0 0 +2 Vessel 30.0 0.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 chain 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +72.0 TMax simulation length (s) +3.0e6 kBot bottom stiffness (Pa/m) +3.0e5 cBot bottom damping (Pa-s/m) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +0.0 TmaxIC max time for ic gen (s) +0 WaveKin MoorDyn-C water kinematics mode (-) +5 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/c5uniform/points.txt b/tests/data/currents_mdc/c5uniform/points.txt new file mode 100644 index 00000000..8234db01 --- /dev/null +++ b/tests/data/currents_mdc/c5uniform/points.txt @@ -0,0 +1,340 @@ +0.0 -7.02274407112499 5.111191447569773 -70.0 +0.0 -28.09097628449996 -46.00072302812796 -70.0 +0.0 31.485198909702078 -2.714340560540456 -50.0 +0.0 125.94079563880831 24.429065044864103 -50.0 +0.0 -20.809732103447978 -0.11709455529188517 -41.0 +0.0 -83.23892841379191 1.0538509976269665 -41.0 +0.0 39.37280373726867 8.147073783375749 -30.0 +0.0 157.49121494907467 -73.32366405038174 -30.0 +0.0 22.655718499009495 9.007258842943656 -20.0 +0.0 90.62287399603798 -81.06532958649291 -20.0 +0.0 -18.7537186637282 -6.33128609556366 -12.5 +0.0 -75.0148746549128 56.98157486007294 -12.5 +0.0 -12.854524951559121 -9.226121975251093 -7.3 +0.0 -51.418099806236484 83.03509777725984 -7.3 +0.0 -14.582842600996724 9.948139588388933 -1.0 +0.0 -58.331370403986895 -89.5332562955004 -1.0 +0.0 36.632586546811126 8.810295057781655 0.0 +0.0 146.5303461872445 -79.2926555200349 0.0 +0.0 -29.96197077630681 -7.427336525682544 2.0 +0.0 -119.84788310522724 66.8460287311429 2.0 +0.7 -28.02076086210656 -6.523047821498196 -70.0 +0.7 -112.08304344842624 58.70743039348376 -70.0 +0.7 -36.14628172153602 -9.284919940469585 -50.0 +0.7 -144.58512688614408 83.56427946422627 -50.0 +0.7 3.3553280663774103 -4.097783379274052 -41.0 +0.7 13.421312265509641 36.88005041346646 -41.0 +0.7 -31.972033235176774 5.452151169515091 -30.0 +0.7 -127.8881329407071 -49.069360525635815 -30.0 +0.7 34.37959677019529 -8.721812201917752 -20.0 +0.7 137.51838708078117 78.49630981725977 -20.0 +0.7 11.16126785635651 2.5043531721859065 -12.5 +0.7 44.64507142542604 -22.53917854967316 -12.5 +0.7 -29.348708093264236 0.9562592119631503 -7.3 +0.7 -117.39483237305694 -8.606332907668353 -7.3 +0.7 -22.203587385333094 -2.037888397728058 -1.0 +0.7 -88.81434954133238 18.340995579552523 -1.0 +0.7 18.190400780927327 7.693202911420261 0.0 +0.7 72.7616031237093 -69.23882620278235 0.0 +0.7 -24.12915133518095 1.4288192371581143 2.0 +0.7 -96.5166053407238 -12.859373134423029 2.0 +2.9999 -22.69698324330357 4.7645721603939695 -70.0 +2.9999 -90.78793297321428 -42.88114944354572 -70.0 +2.9999 29.60912871286267 -4.595171802377718 -50.0 +2.9999 118.43651485145068 41.35654622139946 -50.0 +2.9999 25.618852234935133 7.654491368813606 -41.0 +2.9999 102.47540893974053 -68.89042231932245 -41.0 +2.9999 10.53684893278772 -6.745087112276895 -30.0 +2.9999 42.14739573115088 60.70578401049205 -30.0 +2.9999 -20.11730365275597 -8.15528754041507 -20.0 +2.9999 -80.46921461102389 73.39758786373564 -20.0 +2.9999 28.877993020518687 3.6868449410257362 -12.5 +2.9999 115.51197208207475 -33.18160446923163 -12.5 +2.9999 34.88947203636303 -8.649918397237435 -7.3 +2.9999 139.55788814545213 77.84926557513691 -7.3 +2.9999 -17.050722524734745 6.410433238769084 -1.0 +2.9999 -68.20289009893898 -57.69389914892176 -1.0 +2.9999 -16.690651040342416 -9.102290200816356 0.0 +2.9999 -66.76260416136967 81.9206118073472 0.0 +2.9999 9.341015495959546 -0.6708157716698366 2.0 +2.9999 37.364061983838184 6.03734194502853 2.0 +3.0 -10.836166288895548 -2.811508683337676 -70.0 +3.0 -43.34466515558219 25.303578150039087 -70.0 +3.0 16.77544370038276 -6.71317237580249 -50.0 +3.0 67.10177480153104 60.418551382222404 -50.0 +3.0 15.42782093757721 9.244832796080779 -41.0 +3.0 61.71128375030884 -83.203495164727 -41.0 +3.0 7.630055290347471 -3.3308172468554282 -30.0 +3.0 30.520221161389884 29.977355221698854 -30.0 +3.0 -27.412426819126992 9.635807381611084 -20.0 +3.0 -109.64970727650797 -86.72226643449976 -20.0 +3.0 17.20368294581285 6.804029695690261 -12.5 +3.0 68.8147317832514 -61.23626726121235 -12.5 +3.0 -38.99039508391235 -8.600796918063523 -7.3 +3.0 -155.9615803356494 77.4071722625717 -7.3 +3.0 -29.23184990330986 7.16677430254904 -1.0 +3.0 -116.92739961323944 -64.50096872294137 -1.0 +3.0 -35.203358965445574 -9.06927555629794 0.0 +3.0 -140.8134358617823 81.62348000668146 0.0 +3.0 -36.116039280277235 -3.882238256345685 2.0 +3.0 -144.46415712110894 34.94014430711117 2.0 +4.4 1.1124388464913793 5.20525876471501 -70.0 +4.4 4.449755385965517 -46.84732888243509 -70.0 +4.4 34.909765359536976 4.649206520776003 -50.0 +4.4 139.6390614381479 -41.84285868698403 -50.0 +4.4 33.38247618905423 6.2852042478643355 -41.0 +4.4 133.52990475621692 -56.56683823077902 -41.0 +4.4 21.11808898951169 7.146451792665914 -30.0 +4.4 84.47235595804676 -64.31806613399323 -30.0 +4.4 -16.79152348675787 1.797590082510812 -20.0 +4.4 -67.16609394703148 -16.178310742597308 -20.0 +4.4 7.904121174278195 -0.05464630281863947 -12.5 +4.4 31.61648469711278 0.4918167253677552 -12.5 +4.4 38.84417503848353 7.184393131716664 -7.3 +4.4 155.3767001539341 -64.65953818544997 -7.3 +4.4 -8.721368622618133 2.939017904926253 -1.0 +4.4 -34.88547449047253 -26.451161144336275 -1.0 +4.4 -31.500770648871857 -4.191686418096204 0.0 +4.4 -126.00308259548743 37.72517776286583 0.0 +4.4 -31.018717744515953 4.28736024868326 2.0 +4.4 -124.07487097806381 -38.58624223814934 2.0 +6.99 25.984579991006967 6.148921133070914 -70.0 +6.99 103.93831996402787 -55.340290197638225 -70.0 +6.99 25.581854432298712 9.711080199082648 -50.0 +6.99 102.32741772919485 -87.39972179174383 -50.0 +6.99 36.400293065186446 -6.478819272190939 -41.0 +6.99 145.60117226074578 58.30937344971845 -41.0 +6.99 -16.131052630013 -9.933801481428981 -30.0 +6.99 -64.524210520052 89.40421333286083 -30.0 +6.99 11.949152372833652 -0.6496388177203514 -20.0 +6.99 47.79660949133461 5.846749359483162 -20.0 +6.99 1.7948777433545473 1.053663708101407 -12.5 +6.99 7.179510973418189 -9.482973372912664 -12.5 +6.99 -5.967658939612022 -1.1771128513667843 -7.3 +6.99 -23.87063575844809 10.594015662301059 -7.3 +6.99 24.096936358151595 3.474822206122692 -1.0 +6.99 96.38774543260638 -31.273399855104227 -1.0 +6.99 34.277818838471035 0.919347914896818 0.0 +6.99 137.11127535388414 -8.274131234071362 0.0 +6.99 29.82452168463881 -6.78566161845475 2.0 +6.99 119.29808673855524 61.07095456609275 2.0 +10.1 -38.71377810637341 -2.6909196691918824 -70.0 +10.1 -154.85511242549364 24.21827702272694 -70.0 +10.1 21.585287827692134 -1.5231418564411054 -50.0 +10.1 86.34115131076854 13.708276707969949 -50.0 +10.1 33.277869171065134 -8.813343938797555 -41.0 +10.1 133.11147668426054 79.320095449178 -41.0 +10.1 33.31326330797876 2.9080081138450176 -30.0 +10.1 133.25305323191503 -26.172073024605158 -30.0 +10.1 -4.615604223592669 5.469048364129481 -20.0 +10.1 -18.462416894370676 -49.22143527716533 -20.0 +10.1 14.431288479807982 -6.086644825390774 -12.5 +10.1 57.72515391923193 54.77980342851697 -12.5 +10.1 -22.287438378876743 -5.993156351656794 -7.3 +10.1 -89.14975351550697 53.93840716491115 -7.3 +10.1 24.79879938034503 -3.9029596822975527 -1.0 +10.1 99.19519752138012 35.12663714067797 -1.0 +10.1 -22.749879023039252 8.395813095968222 0.0 +10.1 -90.99951609215701 -75.562317863714 0.0 +10.1 22.027009649720995 1.515237560299898 2.0 +10.1 88.10803859888398 -13.637138042699082 2.0 +15.0 13.876708886608398 0.7419805953356473 -70.0 +15.0 55.50683554643359 -6.677825358020826 -70.0 +15.0 -2.7469521472092566 -3.5314995308744734 -50.0 +15.0 -10.987808588837026 31.78349577787026 -50.0 +15.0 29.646585258486994 9.962368830173471 -41.0 +15.0 118.58634103394797 -89.66131947156124 -41.0 +15.0 37.053032151947576 9.81812850654958 -30.0 +15.0 148.2121286077903 -88.36315655894623 -30.0 +15.0 21.02986346698144 -5.0995662461400215 -20.0 +15.0 84.11945386792576 45.896096215260194 -20.0 +15.0 32.84519682282985 -2.3039314011475254 -12.5 +15.0 131.3807872913194 20.73538261032773 -12.5 +15.0 36.13609205407985 7.003867378567644 -7.3 +15.0 144.5443682163194 -63.0348064071088 -7.3 +15.0 -11.799015997376479 9.143553865208155 -1.0 +15.0 -47.196063989505916 -82.2919847868734 -1.0 +15.0 -13.440509756587147 3.6347630909713775 0.0 +15.0 -53.76203902634859 -32.712867818742396 0.0 +15.0 0.9221939903324099 -3.9009838610955754 2.0 +15.0 3.6887759613296396 35.10885474986018 2.0 +22.2 36.86710835794585 4.323452802889294 -70.0 +22.2 147.4684334317834 -38.911075226003646 -70.0 +22.2 -32.32894301793878 -1.8016757645856387 -50.0 +22.2 -129.3157720717551 16.21508188127075 -50.0 +22.2 -35.80139720077473 -5.159978650043689 -41.0 +22.2 -143.20558880309892 46.4398078503932 -41.0 +22.2 -26.22368089792042 8.239591500764341 -30.0 +22.2 -104.89472359168168 -74.15632350687906 -30.0 +22.2 23.990432529791548 4.278286793812818 -20.0 +22.2 95.96173011916619 -38.50458114431536 -20.0 +22.2 2.887023810869664 6.482848982697266 -12.5 +22.2 11.548095243478656 -58.345640844275394 -12.5 +22.2 32.434164811981134 -7.850777221993363 -7.3 +22.2 129.73665924792454 70.65699499794027 -7.3 +22.2 27.646650826375748 6.677775432800441 -1.0 +22.2 110.58660330550299 -60.099978895203975 -1.0 +22.2 0.7439691736044267 5.562222983029244 0.0 +22.2 2.975876694417707 -50.060006847263196 0.0 +22.2 25.152845672099858 7.842833299939155 2.0 +22.2 100.61138268839943 -70.5854996994524 2.0 +27.0 34.17743485462587 5.976624160118602 -70.0 +27.0 136.7097394185035 -53.78961744106742 -70.0 +27.0 22.493094807101244 -0.3077505481058491 -50.0 +27.0 89.97237922840498 2.769754932952642 -50.0 +27.0 25.88581939047276 -5.8243899747383665 -41.0 +27.0 103.54327756189105 52.4195097726453 -41.0 +27.0 -28.483027801526923 -9.30702194503688 -30.0 +27.0 -113.93211120610769 83.76319750533192 -30.0 +27.0 9.021346610391355 -3.454486553556011 -20.0 +27.0 36.08538644156542 31.090378982004097 -20.0 +27.0 -7.8579344021051085 4.308805042569695 -12.5 +27.0 -31.431737608420434 -38.779245383127254 -12.5 +27.0 3.846277922265557 2.544877826817034 -7.3 +27.0 15.385111689062228 -22.903900441353308 -7.3 +27.0 18.177235829689387 4.683102526838535 -1.0 +27.0 72.70894331875755 -42.14792274154682 -1.0 +27.0 -0.7580107998057599 -8.798399170974848 0.0 +27.0 -3.0320431992230397 79.18559253877363 0.0 +27.0 21.20569224848559 -8.59787987749832 2.0 +27.0 84.82276899394236 77.38091889748488 2.0 +29.9 1.406890943436487 -8.376998968552357 -70.0 +29.9 5.627563773745948 75.39299071697121 -70.0 +29.9 35.73493492274133 1.1619742971977622 -50.0 +29.9 142.93973969096533 -10.45776867477986 -50.0 +29.9 37.799493650061336 0.41397227450426044 -41.0 +29.9 151.19797460024535 -3.725750470538344 -41.0 +29.9 20.183925874373905 1.0212616773877166 -30.0 +29.9 80.73570349749562 -9.191355096489449 -30.0 +29.9 -17.81588963423217 -1.0721355449493082 -20.0 +29.9 -71.26355853692868 9.649219904543774 -20.0 +29.9 10.672238679317502 -7.289743184122948 -12.5 +29.9 42.68895471727001 65.60768865710654 -12.5 +29.9 -26.973218729797495 0.3614691414785991 -7.3 +29.9 -107.89287491918998 -3.253222273307392 -7.3 +29.9 37.135747505861445 -5.539721977770158 -1.0 +29.9 148.54299002344578 49.85749779993142 -1.0 +29.9 14.740809994223198 9.11256286402461 0.0 +29.9 58.963239976892794 -82.0130657762215 0.0 +29.9 -11.677147320143256 -9.247415795948292 2.0 +29.9 -46.70858928057302 83.22674216353462 2.0 +30.0 -8.650754310000881 9.16934613710388 -70.0 +30.0 -34.603017240003524 -82.52411523393491 -70.0 +30.0 -21.52834483255002 -2.4498442073934967 -50.0 +30.0 -86.11337933020008 22.04859786654147 -50.0 +30.0 -37.91365942204985 1.7869178293190444 -41.0 +30.0 -151.6546376881994 -16.0822604638714 -41.0 +30.0 8.448105983536863 -0.7104286343268011 -30.0 +30.0 33.79242393414745 6.39385770894121 -30.0 +30.0 -10.984575041640863 -1.482566812128896 -20.0 +30.0 -43.93830016656345 13.343101309160064 -20.0 +30.0 17.47171695947599 -3.3085417618235073 -12.5 +30.0 69.88686783790396 29.776875856411564 -12.5 +30.0 -9.969297911143286 6.476991369519826 -7.3 +30.0 -39.877191644573145 -58.29292232567843 -7.3 +30.0 19.28656187456903 -9.71700139622218 -1.0 +30.0 77.14624749827613 87.45301256599961 -1.0 +30.0 26.75939860221601 -2.596169523828566 0.0 +30.0 107.03759440886404 23.365525714457092 0.0 +30.0 -27.572206265855908 -8.028149162705635 2.0 +30.0 -110.28882506342363 72.25334246435071 2.0 +31.5 12.32596528400471 -4.333836550439541 -70.0 +31.5 49.30386113601884 39.00452895395587 -70.0 +31.5 13.765699540806267 -1.3972193507397392 -50.0 +31.5 55.06279816322507 12.574974156657653 -50.0 +31.5 30.07191375299493 -0.2767730234363128 -41.0 +31.5 120.28765501197972 2.4909572109268154 -41.0 +31.5 19.43154862585076 -9.795994592560435 -30.0 +31.5 77.72619450340304 88.16395133304391 -30.0 +31.5 -28.793376785410032 -8.456781239044686 -20.0 +31.5 -115.17350714164013 76.11103115140217 -20.0 +31.5 -36.30974966959437 4.593534942927555 -12.5 +31.5 -145.23899867837747 -41.34181448634799 -12.5 +31.5 -2.239900235497096 0.13376092702809217 -7.3 +31.5 -8.959600941988384 -1.2038483432528295 -7.3 +31.5 -23.449608268622228 2.8363753799615417 -1.0 +31.5 -93.79843307448891 -25.527378419653875 -1.0 +31.5 37.40950389700063 4.018053153001375 0.0 +31.5 149.63801558800253 -36.16247837701238 0.0 +31.5 -29.032706522727636 -0.2497391911787421 2.0 +31.5 -116.13082609091055 2.247652720608679 2.0 +33.0 -39.85412472901931 3.8768432788161906 -70.0 +33.0 -159.41649891607724 -34.891589509345714 -70.0 +33.0 17.684325638275766 3.5714735876826005 -50.0 +33.0 70.73730255310306 -32.14326228914341 -50.0 +33.0 -0.4594188146910767 6.52802352390988 -41.0 +33.0 -1.8376752587643068 -58.75221171518892 -41.0 +33.0 38.256746798218416 -3.2436924925503297 -30.0 +33.0 153.02698719287366 29.193232432952968 -30.0 +33.0 -27.521341499367054 -2.7390553415641 -20.0 +33.0 -110.08536599746822 24.6514980740769 -20.0 +33.0 -12.987076895057115 -7.1632817430584605 -12.5 +33.0 -51.94830758022846 64.46953568752615 -12.5 +33.0 -12.696516486637286 -6.258068783689041 -7.3 +33.0 -50.786065946549144 56.32261905320137 -7.3 +33.0 -15.027932615069012 -1.6160955882136356 -1.0 +33.0 -60.11173046027605 14.54486029392272 -1.0 +33.0 -30.393098056862947 -6.300330717877102 0.0 +33.0 -121.57239222745179 56.70297646089392 0.0 +33.0 17.451886515299904 -7.455914823927974 2.0 +33.0 69.80754606119962 67.10323341535177 2.0 +35.2 -12.175965967280263 6.783113370124319 -70.0 +35.2 -48.70386386912105 -61.04802033111887 -70.0 +35.2 4.618081470479673 0.8154909897060758 -50.0 +35.2 18.472325881918692 -7.339418907354682 -50.0 +35.2 35.55926111218679 4.137211499995836 -41.0 +35.2 142.23704444874716 -37.23490349996252 -41.0 +35.2 -5.401121673640503 9.606615354240503 -30.0 +35.2 -21.604486694562013 -86.45953818816453 -30.0 +35.2 -12.10973856338616 0.03748479100456059 -20.0 +35.2 -48.43895425354464 -0.3373631190410453 -20.0 +35.2 11.75197738317857 -9.52412923600807 -12.5 +35.2 47.00790953271428 85.71716312407263 -12.5 +35.2 21.03837088156746 3.5302548364859625 -7.3 +35.2 84.15348352626984 -31.772293528373662 -7.3 +35.2 -15.973711330369085 3.4445876816223553 -1.0 +35.2 -63.89484532147634 -31.001289134601198 -1.0 +35.2 -20.73709617203651 -6.918272024152479 0.0 +35.2 -82.94838468814604 62.26444821737231 0.0 +35.2 24.68259701174533 2.2417909878109477 2.0 +35.2 98.73038804698132 -20.17611889029853 2.0 +40.0 -28.53669579612899 -4.9250282768244125 -70.0 +40.0 -114.14678318451595 44.32525449141971 -70.0 +40.0 -37.79487475670331 -3.100688797868414 -50.0 +40.0 -151.17949902681323 27.906199180815726 -50.0 +40.0 -34.489431309685216 0.3955085003395453 -41.0 +40.0 -137.95772523874086 -3.559576503055908 -41.0 +40.0 -22.625244513000098 -1.5039685698797065 -30.0 +40.0 -90.50097805200039 13.535717128917359 -30.0 +40.0 -8.384812969166795 -6.875514272293152 -20.0 +40.0 -33.53925187666718 61.87962845063837 -20.0 +40.0 -24.046467454115312 9.193786772436233 -12.5 +40.0 -96.18586981646125 -82.7440809519261 -12.5 +40.0 -7.158361636532753 -9.175947291231326 -7.3 +40.0 -28.63344654613101 82.58352562108193 -7.3 +40.0 -37.56341961594708 -7.950113084987189 -1.0 +40.0 -150.25367846378833 71.5510177648847 -1.0 +40.0 16.627586727950444 -1.701836685221103 0.0 +40.0 66.51034691180178 15.316530166989928 0.0 +40.0 -20.29979488321547 2.246366688187342 2.0 +40.0 -81.19917953286188 -20.21730019368608 2.0 +70.3 -27.25943988546411 1.3303422268762404 -70.0 +70.3 -109.03775954185645 -11.973080041886163 -70.0 +70.3 -18.329419181105777 8.499933068799717 -50.0 +70.3 -73.31767672442311 -76.49939761919745 -50.0 +70.3 -28.279731776551642 0.4043904563369196 -41.0 +70.3 -113.11892710620657 -3.6395141070322765 -41.0 +70.3 7.2620474241576645 1.7805222100826015 -30.0 +70.3 29.048189696630658 -16.024699890743413 -30.0 +70.3 5.56942953748969 7.433773413905932 -20.0 +70.3 22.27771814995876 -66.90396072515338 -20.0 +70.3 -32.08471351381484 5.214401425367065 -12.5 +70.3 -128.33885405525936 -46.92961282830358 -12.5 +70.3 30.99699708402197 -7.629852384347919 -7.3 +70.3 123.98798833608788 68.66867145913128 -7.3 +70.3 16.420688115163323 0.3052507316806885 -1.0 +70.3 65.68275246065329 -2.7472565851261965 -1.0 +70.3 -12.057577684522364 -8.488938632238991 0.0 +70.3 -48.23031073808946 76.40044769015091 0.0 +70.3 -7.35147907642898 0.5750754838162742 2.0 +70.3 -29.40591630571592 -5.175679354346467 2.0 diff --git a/tests/data/currents_mdc/c5uniform/ref_moordyn_c.csv b/tests/data/currents_mdc/c5uniform/ref_moordyn_c.csv new file mode 100644 index 00000000..8b63bf6a --- /dev/null +++ b/tests/data/currents_mdc/c5uniform/ref_moordyn_c.csv @@ -0,0 +1,341 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,-7.0227440711249898,5.1111914475697731,-70,0,0,0,0,0,0,0 +0,-28.090976284499959,-46.000723028127958,-70,0,0,0,0,0,0,0 +0,31.485198909702078,-2.7143405605404558,-50,0,0,0,0,0,0,0 +0,125.94079563880831,24.429065044864103,-50,0,0,0,0,0,0,0 +0,-20.809732103447978,-0.11709455529188517,-41,0,0.27172440000000009,0.094500000000000001,0,0,0,0 +0,-83.238928413791911,1.0538509976269665,-41,0,0.27172440000000003,0.094499999999999987,0,0,0,0 +0,39.372803737268669,8.1470737833757489,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +0,157.49121494907467,-73.323664050381737,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +0,22.655718499009495,9.0072588429436564,-20,0,0.73801714285714293,0.19,0,0,0,0 +0,90.622873996037981,-81.065329586492908,-20,0,0.73801714285714282,0.19,0,0,0,0 +0,-18.753718663728201,-6.3312860955636596,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +0,-75.014874654912802,56.981574860072939,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +0,-12.854524951559121,-9.2261219752510932,-7.2999999999999998,0,0.90843237333333327,0.16460000000000002,0,0,0,0 +0,-51.418099806236484,83.035097777259836,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +0,-14.582842600996724,9.9481395883889334,-1,0,0.99296859999999998,0.15199999999999997,0,0,0,0 +0,-58.331370403986895,-89.533256295500394,-1,0,0.99296859999999998,0.152,0,0,0,0 +0,36.632586546811126,8.810295057781655,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,146.5303461872445,-79.292655520034899,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,-29.96197077630681,-7.4273365256825441,2,0,1.0063869999999997,0.15000000000000002,0,0,0,0 +0,-119.84788310522724,66.846028731142894,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0.69999999999999984,-28.02076086210656,-6.5230478214981957,-70,0,0.075781299999999968,0.037911299999999981,0.00095199999999999983,0,0,0 +0.69999999999999996,-112.08304344842624,58.707430393483762,-70,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,-36.14628172153602,-9.2849199404695852,-50,0,0.075781299999999968,0.037911299999999995,0.00095199999999999983,0,0,0 +0.69999999999999996,-144.58512688614408,83.564279464226274,-50,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,3.3553280663774103,-4.0977833792740519,-41,0,0.32723521375000003,0.11272379999999999,0.00074362750000000002,0,0,0 +0.69999999999999996,13.421312265509641,36.880050413466464,-41,0,0.32723521375000003,0.11272379999999999,0.00074362750000000002,0,0,0 +0.69999999999999996,-31.972033235176774,5.4521511695150906,-30,0,0.63456777500000006,0.20416129999999999,0.00048894999999999993,0,0,0 +0.69999999999999996,-127.8881329407071,-49.069360525635815,-30,0,0.63456777499999995,0.20416129999999996,0.00048894999999999993,0,0,0 +0.69999999999999996,34.379596770195292,-8.7218122019177518,-20,0,0.7755830178571429,0.18416129999999997,-0.0003889500000000001,0,0,0 +0.69999999999999996,137.51838708078117,78.496309817259771,-20,0,0.7755830178571429,0.18416129999999997,-0.00038894999999999999,0,0,0 +0.69999999999999996,11.16126785635651,2.5043531721859065,-12.5,0,0.88134445000000006,0.16916129999999999,-0.0010473749999999999,0,0,0 +0.69999999999999996,44.645071425426039,-22.53917854967316,-12.5,0,0.88134445000000017,0.16916129999999999,-0.0010473749999999999,0,0,0 +0.69999999999999996,-29.348708093264236,0.95625921196315034,-7.2999999999999998,0,0.95467249266666687,0.15876129999999999,-0.0013422149999999999,0,0,0 +0.69999999999999996,-117.39483237305694,-8.606332907668353,-7.2999999999999998,0,0.95467249266666687,0.15876129999999999,-0.0013422149999999999,0,0,0 +0.69999999999999996,-22.203587385333094,-2.0378883977280582,-1,0,1.04351175,0.14616129999999999,-0.00029452499999999991,0,0,0 +0.69999999999999996,-88.814349541332376,18.340995579552523,-1,0,1.04351175,0.14616129999999999,-0.00029452499999999991,0,0,0 +0.69999999999999996,18.190400780927327,7.6932029114202614,0,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,72.761603123709307,-69.238826202782349,0,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,-24.12915133518095,1.4288192371581143,2,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,-96.5166053407238,-12.859373134423029,2,0,1.0576131749999997,0.14416129999999999,0,0,0,0 +2.9998999999998115,-22.696983243303571,4.7645721603939695,-70,0,0.3247661740999796,0.16247158409998977,0.004079863999999744,0,0,0 +2.9998999999999998,-90.787932973214282,-42.881149443545723,-70,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,29.60912871286267,-4.5951718023777177,-50,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,118.43651485145068,41.356546221399462,-50,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,25.618852234935133,7.6544913688136056,-41,0,0.50961995738374999,0.17259939659999998,0.0031868687675,0,0,0 +2.9998999999999998,102.47540893974053,-68.890422319322454,-41,0,0.50961995738374999,0.17259939659999998,0.0031868687675,0,0,0 +2.9998999999999998,10.53684893278772,-6.7450871122768952,-30,0,0.73555235917499995,0.18497783409999999,0.00209543015,0,0,0 +2.9998999999999998,42.14739573115088,60.705784010492053,-30,0,0.73555235917499995,0.18497783409999999,0.00209543015,0,0,0 +2.9998999999999998,-20.117303652755972,-8.1552875404150704,-20,0,0.89900838344642864,0.16497783410000005,-0.0016668730071428565,0,0,0 +2.9998999999999998,-80.469214611023887,73.397587863735637,-20,0,0.89900838344642864,0.1649778341,-0.0016668730071428561,0,0,0 +2.9998999999999998,28.877993020518687,3.6868449410257362,-12.5,0,1.02160040165,0.14997783410000001,-0.0044886003749999995,0,0,0 +2.9998999999999998,115.51197208207475,-33.18160446923163,-12.5,0,1.02160040165,0.14997783410000004,-0.0044886003749999995,0,0,0 +2.9998999999999998,34.889472036363031,-8.6499183972374354,-7.2999999999999998,0,1.1065977076019999,0.13957783410000002,-0.0057521582550000006,0,0,0 +2.9998999999999998,139.55788814545213,77.849265575136911,-7.2999999999999998,0,1.1065977076019999,0.13957783410000002,-0.0057521582550000006,0,0,0 +2.9998999999999998,-17.050722524734745,6.4104332387690839,-1,0,1.2095748795499999,0.12697783409999999,-0.0012622079249999998,0,0,0 +2.9998999999999998,-68.20289009893898,-57.693899148921759,-1,0,1.2095748795499999,0.12697783410000002,-0.0012622079249999998,0,0,0 +2.9998999999999998,-16.690651040342416,-9.1022902008163555,0,0,1.2259204319750001,0.1249778341,0,0,0,0 +2.9998999999999998,-66.762604161369666,81.9206118073472,0,0,1.2259204319750001,0.12497783410000002,0,0,0,0 +2.9998999999999998,9.3410154959595459,-0.67081577166983664,2,0,1.2259204319749999,0.12497783409999999,0,0,0,0 +2.9998999999999998,37.364061983838184,6.0373419450285297,2,0,1.2259204319749999,0.1249778341,0,0,0,0 +3,-10.836166288895548,-2.8115086833376761,-70,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,-43.344665155582192,25.303578150039087,-70,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,16.775443700382759,-6.7131723758024897,-50,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,67.101774801531036,60.418551382222404,-50,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,15.427820937577209,9.2448327960807788,-41,0,0.50962788749999999,0.17260199999999998,0.0031869750000000003,0,0,0 +3,61.711283750308837,-83.203495164727002,-41,0,0.50962788749999999,0.17260199999999998,0.0031869750000000003,0,0,0 +3,7.630055290347471,-3.3308172468554282,-30,0,0.73555674999999998,0.184977,0.0020955000000000001,0,0,0 +3,30.520221161389884,29.977355221698854,-30,0,0.73555674999999998,0.18497699999999997,0.0020955000000000001,0,0,0 +3,-27.412426819126992,9.6358073816110839,-20,0,0.89901374999999994,0.16497699999999998,-0.0016669285714285709,0,0,0 +3,-109.64970727650797,-86.722266434499758,-20,0,0.89901374999999994,0.16497699999999998,-0.0016669285714285709,0,0,0 +3,17.203682945812851,6.8040296956902608,-12.5,0,1.0216065000000001,0.14997700000000003,-0.0044887499999999997,0,0,0 +3,68.814731783251403,-61.236267261212348,-12.5,0,1.0216065000000001,0.14997700000000003,-0.0044887499999999997,0,0,0 +3,-38.990395083912347,-8.6007969180635229,-7.2999999999999998,0,1.1066043133333334,0.13957700000000001,-0.0057523500000000007,0,0,0 +3,-155.96158033564939,77.407172262571706,-7.2999999999999998,0,1.1066043133333334,0.13957700000000001,-0.0057523500000000007,0,0,0 +3,-29.231849903309861,7.1667743025490402,-1,0,1.2095820999999998,0.12697700000000001,-0.0012622499999999999,0,0,0 +3,-116.92739961323944,-64.500968722941366,-1,0,1.2095820999999998,0.12697700000000001,-0.0012622499999999999,0,0,0 +3,-35.203358965445574,-9.0692755562979404,0,0,1.2259277499999999,0.124977,0,0,0,0 +3,-140.8134358617823,81.623480006681461,0,0,1.2259277499999999,0.124977,0,0,0,0 +3,-36.116039280277235,-3.8822382563456852,2,0,1.2259277499999999,0.124977,0,0,0,0 +3,-144.46415712110894,34.940144307111169,2,0,1.2259277499999999,0.124977,0,0,0,0 +4.4000000000000217,1.1124388464913793,5.2052587647150101,-70,0,0.3835706222222231,0.16880857777777786,0.0060574222222222534,0,0,0 +4.4000000000000217,4.449755385965517,-46.847328882435093,-70,0,0.38357062222222305,0.16880857777777783,0.0060574222222222534,0,0,0 +4.4000000000000217,34.909765359536976,4.6492065207760032,-50,0,0.38357062222222316,0.16880857777777786,0.0060574222222222534,0,0,0 +4.4000000000000217,139.63906143814791,-41.84285868698403,-50,0,0.3835706222222231,0.16880857777777786,0.0060574222222222526,0,0,0 +4.4000000000000217,33.382476189054231,6.2852042478643355,-41,0,0.55788593222222294,0.16580857777777769,0.0052616622222222548,0,0,0 +4.4000000000000217,133.52990475621692,-56.56683823077902,-41,0,0.55788593222222294,0.16580857777777769,0.0052616622222222548,0,0,0 +4.4000000000000217,21.118088989511691,7.1464517926659141,-30,0,0.77093797777777828,0.16214191111111076,0.0042890666666667004,0,0,0 +4.4000000000000217,84.472355958046762,-64.318066133993227,-30,0,0.77093797777777828,0.16214191111111076,0.0042890666666667004,0,0,0 +4.4000000000000217,-16.791523486757871,1.797590082510812,-20,0,0.94225753333333406,0.1421419111111108,0.0016156825396825905,0,0,0 +4.4000000000000217,-67.166093947031484,-16.178310742597308,-20,0,0.94225753333333406,0.1421419111111108,0.0016156825396825905,0,0,0 +4.4000000000000217,7.9041211742781954,-0.054646302818639469,-12.5,0,1.0707472000000009,0.12714191111111078,-0.00038935555555549188,0,0,0 +4.4000000000000217,31.616484697112782,0.49181672536775523,-12.5,0,1.0707472000000009,0.12714191111111078,-0.00038935555555549188,0,0,0 +4.4000000000000217,38.844175038483527,7.1843931317166643,-7.2999999999999998,0,1.1598334613333343,0.11674191111111076,-0.005483260148148145,0,0,0 +4.4000000000000217,155.37670015393411,-64.659538185449975,-7.2999999999999998,0,1.1598334613333343,0.11674191111111076,-0.005483260148148145,0,0,0 +4.4000000000000217,-8.7213686226181331,2.9390179049262528,-1,0,1.2677648400000008,0.10414191111111076,-0.0015472666666666711,0,0,0 +4.4000000000000217,-34.885474490472532,-26.451161144336275,-1,0,1.2677648400000008,0.10414191111111076,-0.0015472666666666707,0,0,0 +4.4000000000000217,-31.500770648871857,-4.1916864180962037,0,0,1.2848968000000007,0.10214191111111076,0,0,0,0 +4.4000000000000217,-126.00308259548743,37.725177762865833,0,0,1.2848968000000007,0.10214191111111076,0,0,0,0 +4.4000000000000217,-31.018717744515953,4.2873602486832603,2,0,1.2848968000000007,0.10214191111111076,0,0,0,0 +4.4000000000000217,-124.07487097806381,-38.586242238149339,2,0,1.2848968000000007,0.10214191111111076,0,0,0,0 +6.9900000000009292,25.984579991006967,6.1489211330709139,-70,0,0.44493905333332784,0.15447589416664645,0.0081504083333331784,0,0,0 +6.9900000000009292,103.93831996402787,-55.340290197638225,-70,0,0.44493905333332784,0.15447589416664642,0.0081504083333331784,0,0,0 +6.9900000000009292,25.581854432298712,9.7110801990826481,-50,0,0.44493905333332784,0.15447589416664645,0.0081504083333331784,0,0,0 +6.9900000000009292,102.32741772919485,-87.399721791743829,-50,0,0.44493905333332784,0.15447589416664645,0.0081504083333331784,0,0,0 +6.9900000000009292,36.400293065186446,-6.4788192721909388,-41,0,0.60511694520832582,0.13647589416664643,0.0076923574583333898,0,0,0 +6.9900000000009292,145.60117226074578,58.30937344971845,-41,0,0.60511694520832593,0.13647589416664646,0.0076923574583333907,0,0,0 +6.9900000000009292,-16.131052630012999,-9.933801481428981,-30,0,0.80088992416665683,0.11447589416664644,0.0071325175000003151,0,0,0 +6.9900000000009292,-64.524210520051994,89.404213332860834,-30,0,0.80088992416665683,0.11447589416664644,0.0071325175000003151,0,0,0 +6.9900000000009292,11.949152372833652,-0.64963881772035137,-20,0,0.97886558321427375,0.094475894166646451,0.0060124627380958428,0,0,0 +6.9900000000009292,47.796609491334607,5.8467493594831623,-20,0,0.97886558321427375,0.094475894166646451,0.0060124627380958428,0,0,0 +6.9900000000009292,1.7948777433545473,1.0536637081014071,-12.5,0,1.1123473274999864,0.079475894166646438,0.0051724216666674885,0,0,0 +6.9900000000009292,7.1795109734181892,-9.4829733729126637,-12.5,0,1.1123473274999864,0.079475894166646438,0.0051724216666674885,0,0,0 +6.9900000000009292,-5.9676589396120221,-1.1771128513667843,-7.2999999999999998,0,1.2048946048333187,0.069075894166646432,-0.0041257341555545717,0,0,0 +6.9900000000009292,-23.870635758448088,10.594015662301059,-7.2999999999999998,0,1.2048946048333187,0.069075894166646432,-0.0041257341555545717,0,0,0 +6.9900000000009292,24.096936358151595,3.4748222061226919,-1,0,1.3170195234999837,0.056475894166646431,-0.0016476759999997884,0,0,0 +6.9900000000009292,96.38774543260638,-31.273399855104227,-1,0,1.3170195234999837,0.056475894166646431,-0.0016476759999997884,0,0,0 +6.9900000000009292,34.277818838471035,0.919347914896818,0,0,1.3348171599999836,0.054475894166646444,0,0,0,0 +6.9900000000009292,137.11127535388414,-8.274131234071362,0,0,1.3348171599999836,0.054475894166646437,0,0,0,0 +6.9900000000009292,29.82452168463881,-6.7856616184547498,2,0,1.3348171599999836,0.054475894166646444,0,0,0,0 +6.9900000000009292,119.29808673855524,61.070954566092752,2,0,1.3348171599999836,0.054475894166646437,0,0,0,0 +10.099999999999296,-38.713778106373411,-2.6909196691918824,-70,0,0.41853185000000936,0.085899412500015843,0.0067420250000006857,0,0,0 +10.1,-154.85511242549364,24.218277022726941,-70,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,21.585287827692134,-1.5231418564411054,-50,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,86.341151310768538,13.708276707969949,-50,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,33.277869171065134,-8.813343938797555,-41,0,0.56920315062499993,0.067899412500000006,0.0069823418750000008,0,0,0 +10.1,133.11147668426054,79.320095449177998,-41,0,0.56920315062499993,0.067899412500000006,0.0069823418750000008,0,0,0 +10.1,33.313263307978758,2.9080081138450176,-30,0,0.75335696249999995,0.045899412500000007,0.0072760624999999995,0,0,0 +10.1,133.25305323191503,-26.172073024605158,-30,0,0.75335696250000006,0.045899412500000014,0.0072760624999999995,0,0,0 +10.1,-4.6156042235926691,5.4690483641294811,-20,0,0.92076984821428565,0.0258994125,0.006310641071428571,0,0,0 +10.1,-18.462416894370676,-49.221435277165327,-20,0,0.92076984821428576,0.02589941250000001,0.006310641071428571,0,0,0 +10.1,14.431288479807982,-6.0866448253907741,-12.5,0,1.0463295125000001,0.010899412499999997,0.0055865749999999999,0,0,0 +10.1,57.725153919231929,54.779803428516971,-12.5,0,1.0463295125000003,0.010899412499999999,0.0055865749999999999,0,0,0 +10.1,-22.287438378876743,-5.9931563516567943,-7.2999999999999998,0,1.1333839605,0.00049941249999999743,-0.00092980500000000013,0,0,0 +10.1,-89.149753515506973,53.938407164911148,-7.2999999999999998,0,1.1333839605000002,0.00049941249999999743,-0.00092980500000000013,0,0,0 +10.1,24.798799380345031,-3.9029596822975527,-1,0,1.2388542025,-0.012100587499999999,-0.00076240999999999961,0,0,0 +10.1,99.195197521380123,35.126637140677971,-1,0,1.2388542025,-0.012100587499999999,-0.00076240999999999972,0,0,0 +10.1,-22.749879023039252,8.3958130959682222,0,0,1.2555955499999998,-0.014100587499999996,0,0,0,0 +10.1,-90.999516092157009,-75.562317863714,0,0,1.25559555,-0.014100587499999997,0,0,0,0 +10.1,22.027009649720995,1.515237560299898,2,0,1.25559555,-0.014100587499999997,0,0,0,0 +10.1,88.108038598883979,-13.637138042699082,2,0,1.2555955500000002,-0.014100587499999997,0,0,0,0 +14.999999999997604,13.876708886608398,0.74198059533564731,-70,0,0.35357500000003173,-0.024507999999946024,0.001978000000002329,0,0,0 +15,55.506835546433592,-6.6778253580208258,-70,0,0.35357499999999997,-0.024507999999999999,0.0019780000000000002,0,0,0 +15,-2.7469521472092566,-3.5314995308744734,-50,0,0.35357499999999997,-0.024507999999999999,0.0019780000000000002,0,0,0 +15,-10.987808588837026,31.783495777870261,-50,0,0.35357499999999997,-0.024508000000000002,0.0019780000000000006,0,0,0 +15,29.646585258486994,9.962368830173471,-41,0,0.48086200000000001,-0.042507999999999997,0.0032802999999999999,0,0,0 +15,118.58634103394797,-89.661319471561242,-41,0,0.48086200000000001,-0.042507999999999997,0.0032802999999999999,0,0,0 +15,37.053032151947576,9.8181285065495807,-30,0,0.63643499999999997,-0.064507999999999996,0.0048719999999999996,0,0,0 +15,148.21212860779031,-88.36315655894623,-30,0,0.63643499999999997,-0.064507999999999996,0.0048719999999999996,0,0,0 +15,21.029863466981439,-5.0995662461400215,-20,0,0.7778652857142857,-0.084508,0.0018034285714285715,0,0,0 +15,84.119453867925756,45.896096215260194,-20,0,0.7778652857142857,-0.084508,0.0018034285714285715,0,0,0 +15,32.845196822829848,-2.3039314011475254,-12.5,0,0.88393799999999989,-0.099507999999999999,-0.00049799999999999996,0,0,0 +15,131.38078729131939,20.735382610327729,-12.5,0,0.883938,-0.099507999999999999,-0.00049799999999999996,0,0,0 +15,36.136092054079853,7.0038673785676444,-7.2999999999999998,0,0.95748125333333323,-0.10990799999999999,0.0038103733333333333,0,0,0 +15,144.54436821631941,-63.034806407108803,-7.2999999999999998,0,0.95748125333333334,-0.10990800000000001,0.0038103733333333333,0,0,0 +15,-11.799015997376479,9.1435538652081547,-1,0,1.0465819999999999,-0.12250799999999999,0.0011431999999999996,0,0,0 +15,-47.196063989505916,-82.2919847868734,-1,0,1.0465819999999999,-0.12250799999999999,0.0011431999999999998,0,0,0 +15,-13.440509756587147,3.6347630909713775,0,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,-53.762039026348589,-32.712867818742396,0,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,0.9221939903324099,-3.9009838610955754,2,0,1.0607249999999999,-0.12450800000000001,0,0,0,0 +15,3.6887759613296396,35.108854749860178,2,0,1.0607249999999999,-0.12450799999999998,0,0,0,0 +22.200000000007591,36.867108357945853,4.3234528028892942,-70,0,0.43220380000008285,0.062470400000091728,0.0028900000000009621,0,0,0 +22.200000000007591,147.46843343178341,-38.911075226003646,-70,0,0.43220380000008285,0.062470400000091728,0.0028900000000009617,0,0,0 +22.200000000007591,-32.328943017938776,-1.8016757645856387,-50,0,0.43220380000008285,0.062470400000091728,0.0028900000000009612,0,0,0 +22.200000000007591,-129.31577207175511,16.215081881270748,-50,0,0.43220380000008285,0.062470400000091728,0.0028900000000009617,0,0,0 +22.200000000007591,-35.80139720077473,-5.1599786500436888,-41,0,0.58779716800011284,0.044470400000091725,0.00089160399999748102,0,0,0 +22.200000000007591,-143.20558880309892,46.439807850393201,-41,0,0.58779716800011284,0.044470400000091725,0.00089160399999748123,0,0,0 +22.200000000007591,-26.223680897920421,8.239591500764341,-30,0,0.77796684000014937,0.022470400000091713,-0.0015508800000067729,0,0,0 +22.200000000007591,-104.89472359168168,-74.156323506879062,-30,0,0.77796684000014937,0.022470400000091713,-0.0015508800000067729,0,0,0 +22.200000000007591,23.990432529791548,4.2782867938128177,-20,0,0.95084837142875389,0.0024704000000917194,-0.00054000000000247112,0,0,0 +22.200000000007591,95.961730119166191,-38.50458114431536,-20,0,0.95084837142875389,0.0024704000000917194,-0.00054000000000247112,0,0,0 +22.200000000007591,2.887023810869664,6.4828489826972664,-12.5,0,1.0805095200002073,-0.012529599999908278,0.00021816000000075529,0,0,0 +22.200000000007591,11.548095243478656,-58.345640844275394,-12.5,0,1.0805095200002073,-0.012529599999908278,0.00021816000000075529,0,0,0 +22.200000000007591,32.434164811981134,-7.8507772219933631,-7.2999999999999998,0,1.1704078965335578,-0.022929599999908276,-0.00099395306667173248,0,0,0 +22.200000000007591,129.73665924792454,70.656994997940274,-7.2999999999999998,0,1.1704078965335578,-0.02292959999990828,-0.0009939530666717327,0,0,0 +22.200000000007591,27.646650826375748,6.6777754328004413,-1,0,1.2793232480002454,-0.035529599999908283,-0.00030601600000152812,0,0,0 +22.200000000007591,110.58660330550299,-60.099978895203975,-1,0,1.2793232480002454,-0.035529599999908276,-0.00030601600000152812,0,0,0 +22.200000000007591,0.74396917360442671,5.562222983029244,0,0,1.2966114000002487,-0.037529599999908278,0,0,0,0 +22.200000000007591,2.9758766944177069,-50.060006847263196,0,0,1.2966114000002487,-0.037529599999908278,0,0,0,0 +22.200000000007591,25.152845672099858,7.842833299939155,2,0,1.2966114000002487,-0.037529599999908278,0,0,0,0 +22.200000000007591,100.61138268839943,-70.585499699452399,2,0,1.2966114000002487,-0.037529599999908278,0,0,0,0 +27.000000000006168,34.177434854625872,5.9766241601186021,-70,0,0.48462300000006731,0.1204560000000745,0.0034980000000007809,0,0,0 +27.000000000006168,136.70973941850349,-53.789617441067421,-70,0,0.48462300000006731,0.12045600000007448,0.0034980000000007809,0,0,0 +27.000000000006168,22.493094807101244,-0.30775054810584912,-50,0,0.48462300000006731,0.12045600000007449,0.0034980000000007809,0,0,0 +27.000000000006168,89.972379228404975,2.7697549329526421,-50,0,0.48462300000006731,0.12045600000007448,0.0034980000000007809,0,0,0 +27.000000000006168,25.885819390472761,-5.8243899747383665,-41,0,0.65908728000009165,0.10245600000007449,-0.00070086000000204522,0,0,0 +27.000000000006168,103.54327756189105,52.419509772645299,-41,0,0.65908728000009154,0.10245600000007449,-0.00070086000000204522,0,0,0 +27.000000000006168,-28.483027801526923,-9.3070219450368796,-30,0,0.87232140000012137,0.080456000000074496,-0.0058328000000054999,0,0,0 +27.000000000006168,-113.93211120610769,83.763197505331917,-30,0,0.87232140000012126,0.080456000000074482,-0.0058328000000054999,0,0,0 +27.000000000006168,9.0213466103913547,-3.454486553556011,-20,0,1.0661704285715765,0.060456000000074492,-0.0021022857142877212,0,0,0 +27.000000000006168,36.085386441565419,31.090378982004097,-20,0,1.0661704285715765,0.060456000000074492,-0.0021022857142877212,0,0,0 +27.000000000006168,-7.8579344021051085,4.3088050425696949,-12.5,0,1.2115572000001682,0.045456000000074492,0.00069560000000061354,0,0,0 +27.000000000006168,-31.431737608420434,-38.779245383127254,-12.5,0,1.2115572000001682,0.045456000000074492,0.00069560000000061354,0,0,0 +27.000000000006168,3.846277922265557,2.544877826817034,-7.2999999999999998,0,1.3123589920001824,0.035056000000074493,-0.0041968373333374481,0,0,0 +27.000000000006168,15.385111689062228,-22.903900441353308,-7.2999999999999998,0,1.3123589920001824,0.035056000000074493,-0.0041968373333374481,0,0,0 +27.000000000006168,18.177235829689387,4.6831025268385353,-1,0,1.4344840800001994,0.022456000000074486,-0.0012721600000012408,0,0,0 +27.000000000006168,72.708943318757548,-42.147922741546822,-1,0,1.4344840800001994,0.022456000000074486,-0.0012721600000012408,0,0,0 +27.000000000006168,-0.75801079980575992,-8.7983991709748484,0,0,1.4538690000002021,0.020456000000074484,0,0,0,0 +27.000000000006168,-3.0320431992230397,79.185592538773633,0,0,1.4538690000002021,0.020456000000074491,0,0,0,0 +27.000000000006168,21.20569224848559,-8.5978798774983201,2,0,1.4538690000002021,0.020456000000074488,0,0,0,0 +27.000000000006168,84.822768993942361,77.380918897484875,2,0,1.4538690000002021,0.020456000000074488,0,0,0,0 +29.900000000003637,1.4068909434364869,-8.3769989685523569,-70,0,0.51629293333337301,0.15548896666671058,0.003865333333333794,0,0,0 +29.900000000003637,5.6275637737459476,75.392990716971212,-70,0,0.51629293333337301,0.15548896666671058,0.003865333333333794,0,0,0 +29.900000000003637,35.734934922741331,1.1619742971977622,-50,0,0.51629293333337301,0.15548896666671058,0.003865333333333794,0,0,0 +29.900000000003637,142.93973969096533,-10.45776867477986,-50,0,0.51629293333337301,0.15548896666671058,0.003865333333333794,0,0,0 +29.900000000003637,37.799493650061336,0.41397227450426044,-41,0,0.70215838933338737,0.13748896666671057,-0.0016629736666678723,0,0,0 +29.900000000003637,151.19797460024535,-3.725750470538344,-41,0,0.70215838933338737,0.13748896666671057,-0.0016629736666678723,0,0,0 +29.900000000003637,20.183925874373905,1.0212616773877166,-30,0,0.92932728000007137,0.11548896666671057,-0.0084197933333365754,0,0,0 +29.900000000003637,80.735703497495621,-9.191355096489449,-30,0,0.92932728000007148,0.11548896666671057,-0.0084197933333365754,0,0,0 +29.900000000003637,-17.815889634232171,-1.0721355449493082,-20,0,1.1358441714286587,0.095488966666710584,-0.0030461666666678497,0,0,0 +29.900000000003637,-71.263558536928684,9.6492199045437737,-20,0,1.1358441714286589,0.095488966666710584,-0.0030461666666678497,0,0,0 +29.900000000003637,10.672238679317502,-7.2897431841229476,-12.5,0,1.2907318400000991,0.080488966666710571,0.00098405333333369499,0,0,0 +29.900000000003637,42.688954717270008,65.607688657106536,-12.5,0,1.2907318400000991,0.080488966666710585,0.00098405333333369499,0,0,0 +29.900000000003637,-26.973218729797495,0.3614691414785991,-7.2999999999999998,0,1.3981211121778852,0.070088966666710592,-0.0061319132444468691,0,0,0 +29.900000000003637,-107.89287491918998,-3.2532222733073919,-7.2999999999999998,0,1.3981211121778852,0.070088966666710592,-0.0061319132444468691,0,0,0 +29.900000000003637,37.135747505861445,-5.5397219777701583,-1,0,1.5282270826667843,0.057488966666710578,-0.0018558720000007309,0,0,0 +29.900000000003637,148.54299002344578,49.857497799931423,-1,0,1.5282270826667841,0.057488966666710578,-0.0018558720000007309,0,0,0 +29.900000000003637,14.740809994223198,9.1125628640246106,0,0,1.548878800000119,0.055488966666710576,0,0,0,0 +29.900000000003637,58.963239976892794,-82.013065776221495,0,0,1.5488788000001192,0.055488966666710576,0,0,0,0 +29.900000000003637,-11.677147320143256,-9.2474157959482923,2,0,1.5488788000001192,0.055488966666710576,0,0,0,0 +29.900000000003637,-46.708589280573023,83.226742163534624,2,0,1.548878800000119,0.055488966666710576,0,0,0,0 +30.000000000000121,-8.650754310000881,9.1693461371038794,-70,0,0,0,0,0,0,0 +30.000000000000121,-34.603017240003524,-82.524115233934907,-70,0,0,0,0,0,0,0 +30.000000000000121,-21.528344832550019,-2.4498442073934967,-50,0,0,0,0,0,0,0 +30.000000000000121,-86.113379330200075,22.048597866541471,-50,0,0,0,0,0,0,0 +30.000000000000121,-37.913659422049847,1.7869178293190444,-41,0,0.27172440000000003,0.094499999999999987,0,0,0,0 +30.000000000000121,-151.65463768819939,-16.0822604638714,-41,0,0.27172440000000009,0.094500000000000015,0,0,0,0 +30.000000000000121,8.4481059835368626,-0.71042863432680114,-30,0,0.60383199999999992,0.20999999999999996,0,0,0,0 +30.000000000000121,33.79242393414745,6.3938577089412103,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +30.000000000000121,-10.984575041640863,-1.482566812128896,-20,0,0.73801714285714271,0.19,0,0,0,0 +30.000000000000121,-43.938300166563451,13.343101309160064,-20,0,0.73801714285714293,0.19,0,0,0,0 +30.000000000000121,17.471716959475991,-3.3085417618235073,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +30.000000000000121,69.886867837903964,29.776875856411564,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +30.000000000000121,-9.9692979111432862,6.4769913695198262,-7.2999999999999998,0,0.90843237333333327,0.16460000000000002,0,0,0,0 +30.000000000000121,-39.877191644573145,-58.292922325678433,-7.2999999999999998,0,0.90843237333333327,0.16460000000000002,0,0,0,0 +30.000000000000121,19.286561874569031,-9.7170013962221802,-1,0,0.99296859999999998,0.152,0,0,0,0 +30.000000000000121,77.146247498276125,87.453012565999614,-1,0,0.99296859999999998,0.152,0,0,0,0 +30.000000000000121,26.75939860221601,-2.596169523828566,0,0,1.0063869999999999,0.14999999999999997,0,0,0,0 +30.000000000000121,107.03759440886404,23.365525714457092,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +30.000000000000121,-27.572206265855908,-8.0281491627056347,2,0,1.0063870000000001,0.14999999999999997,0,0,0,0 +30.000000000000121,-110.28882506342363,72.253342464350709,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.500000000001826,12.32596528400471,-4.3338365504395409,-70,0,0,0,0,0,0,0 +31.500000000001826,49.303861136018838,39.004528953955869,-70,0,0,0,0,0,0,0 +31.500000000001826,13.765699540806267,-1.3972193507397392,-50,0,0,0,0,0,0,0 +31.500000000001826,55.062798163225068,12.574974156657653,-50,0,0,0,0,0,0,0 +31.500000000001826,30.071913752994931,-0.27677302343631283,-41,0,0.27172440000000003,0.094499999999999987,0,0,0,0 +31.500000000001826,120.28765501197972,2.4909572109268154,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +31.500000000001826,19.431548625850759,-9.7959945925604348,-30,0,0.60383200000000004,0.21000000000000002,0,0,0,0 +31.500000000001826,77.726194503403036,88.163951333043912,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +31.500000000001826,-28.793376785410032,-8.4567812390446857,-20,0,0.73801714285714271,0.19,0,0,0,0 +31.500000000001826,-115.17350714164013,76.111031151402173,-20,0,0.73801714285714282,0.19,0,0,0,0 +31.500000000001826,-36.309749669594368,4.5935349429275547,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +31.500000000001826,-145.23899867837747,-41.341814486347992,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +31.500000000001826,-2.239900235497096,0.13376092702809217,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +31.500000000001826,-8.9596009419883842,-1.2038483432528295,-7.2999999999999998,0,0.90843237333333327,0.16459999999999997,0,0,0,0 +31.500000000001826,-23.449608268622228,2.8363753799615417,-1,0,0.99296859999999998,0.152,0,0,0,0 +31.500000000001826,-93.798433074488912,-25.527378419653875,-1,0,0.99296859999999998,0.15200000000000002,0,0,0,0 +31.500000000001826,37.409503897000633,4.0180531530013752,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.500000000001826,149.63801558800253,-36.162478377012377,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.500000000001826,-29.032706522727636,-0.2497391911787421,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.500000000001826,-116.13082609091055,2.2476527206086789,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +32.999999999998288,-39.854124729019311,3.8768432788161906,-70,0,0,0,0,0,0,0 +33,-159.41649891607724,-34.891589509345714,-70,0,0,0,0,0,0,0 +33,17.684325638275766,3.5714735876826005,-50,0,0,0,0,0,0,0 +33,70.737302553103063,-32.143262289143408,-50,0,0,0,0,0,0,0 +33,-0.4594188146910767,6.5280235239098801,-41,0,0.27172440000000009,0.094500000000000015,0,0,0,0 +33,-1.8376752587643068,-58.75221171518892,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +33,38.256746798218416,-3.2436924925503297,-30,0,0.60383199999999992,0.20999999999999996,0,0,0,0 +33,153.02698719287366,29.193232432952968,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +33,-27.521341499367054,-2.7390553415641001,-20,0,0.73801714285714271,0.19,0,0,0,0 +33,-110.08536599746822,24.651498074076901,-20,0,0.73801714285714271,0.19,0,0,0,0 +33,-12.987076895057115,-7.1632817430584605,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +33,-51.948307580228459,64.469535687526147,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +33,-12.696516486637286,-6.2580687836890414,-7.2999999999999998,0,0.90843237333333327,0.1646,0,0,0,0 +33,-50.786065946549144,56.322619053201372,-7.2999999999999998,0,0.90843237333333349,0.1646,0,0,0,0 +33,-15.027932615069012,-1.6160955882136356,-1,0,0.9929686000000002,0.15200000000000002,0,0,0,0 +33,-60.11173046027605,14.544860293922721,-1,0,0.99296859999999998,0.152,0,0,0,0 +33,-30.393098056862947,-6.3003307178771024,0,0,1.0063870000000001,0.15000000000000002,0,0,0,0 +33,-121.57239222745179,56.702976460893922,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,17.451886515299904,-7.4559148239279738,2,0,1.0063869999999997,0.14999999999999997,0,0,0,0 +33,69.807546061199616,67.103233415351767,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +35.199999999994901,-12.175965967280263,6.7831133701243189,-70,0,0.23816979999944821,0.11914979999972392,0.0029919999999930683,0,0,0 +35.200000000000003,-48.703863869121051,-61.04802033111887,-70,0,0.23816980000000032,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,4.6180814704796731,0.81549098970607581,-50,0,0.23816980000000029,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,18.472325881918692,-7.3394189073546823,-50,0,0.23816980000000026,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,35.559261112186789,4.1372114999958356,-41,0,0.44618695750000026,0.15177480000000004,0.0023371150000000033,0,0,0 +35.200000000000003,142.23704444874716,-37.23490349996252,-41,0,0.4461869575000002,0.15177480000000004,0.0023371150000000033,0,0,0 +35.200000000000003,-5.4011216736405032,9.6066153542405033,-30,0,0.70043015000000008,0.19164979999999995,0.0015367000000000022,0,0,0 +35.200000000000003,-21.604486694562013,-86.45953818816453,-30,0,0.70043015000000008,0.19164979999999995,0.0015367000000000022,0,0,0 +35.200000000000003,-12.109738563386159,0.037484791004560591,-20,0,0.85608132142857163,0.17164979999999996,-0.0012224142857142869,0,0,0 +35.200000000000003,-48.438954253544637,-0.33736311904104532,-20,0,0.85608132142857163,0.17164980000000002,-0.0012224142857142871,0,0,0 +35.200000000000003,11.75197738317857,-9.5241292360080703,-12.5,0,0.97281970000000029,0.15664980000000001,-0.0032917500000000039,0,0,0 +35.200000000000003,47.00790953271428,85.717163124072627,-12.5,0,0.97281970000000029,0.15664980000000001,-0.0032917500000000039,0,0,0 +35.200000000000003,21.038370881567459,3.5302548364859625,-7.2999999999999998,0,1.053758462666667,0.14624979999999999,-0.0042183900000000059,0,0,0 +35.200000000000003,84.153483526269838,-31.772293528373662,-7.2999999999999998,0,1.053758462666667,0.14624979999999999,-0.0042183900000000059,0,0,0 +35.200000000000003,-15.973711330369085,3.4445876816223553,-1,0,1.1518185000000001,0.13364979999999999,-0.00092565000000000106,0,0,0 +35.200000000000003,-63.894845321476339,-31.001289134601198,-1,0,1.1518185000000001,0.13364979999999999,-0.00092565000000000106,0,0,0 +35.200000000000003,-20.737096172036509,-6.9182720241524791,0,0,1.1673835500000003,0.13164979999999998,0,0,0,0 +35.200000000000003,-82.948384688146035,62.264448217372312,0,0,1.16738355,0.13164979999999998,0,0,0,0 +35.200000000000003,24.682597011745329,2.2417909878109477,2,0,1.16738355,0.13164979999999998,0,0,0,0 +35.200000000000003,98.730388046981318,-20.176118890298529,2,0,1.16738355,0.13164979999999998,0,0,0,0 +39.999999999989114,-28.536695796128988,-4.9250282768244125,-70,0,0.44488022222228624,0.15425802777801495,0.0081487222222240592,0,0,0 +40,-114.14678318451595,44.325254491419713,-70,0,0.44488022222222223,0.15425802777777775,0.0081487222222222239,0,0,0 +40,-37.794874756703308,-3.1006887978684139,-50,0,0.44488022222222223,0.15425802777777775,0.0081487222222222239,0,0,0 +40,-151.17949902681323,27.906199180815726,-50,0,0.44488022222222223,0.15425802777777775,0.0081487222222222239,0,0,0 +40,-34.489431309685216,0.39550850033954532,-41,0,0.6050369347222222,0.13625802777777773,0.0076929597222222239,0,0,0 +40,-137.95772523874086,-3.5595765030559079,-41,0,0.6050369347222222,0.13625802777777773,0.0076929597222222239,0,0,0 +40,-22.625244513000098,-1.5039685698797065,-30,0,0.8007840277777778,0.11425802777777774,0.0071359166666666671,0,0,0 +40,-90.500978052000391,13.535717128917359,-30,0,0.8007840277777778,0.11425802777777774,0.0071359166666666671,0,0,0 +40,-8.384812969166795,-6.8755142722931524,-20,0,0.9787361547619049,0.094258027777777739,0.0060189801587301603,0,0,0 +40,-33.53925187666718,61.879628450638371,-20,0,0.9787361547619049,0.094258027777777739,0.0060189801587301603,0,0,0 +40,-24.046467454115312,9.1937867724362334,-12.5,0,1.1122002500000001,0.07925802777777774,0.0051812777777777794,0,0,0 +40,-96.185869816461249,-82.744080951926094,-12.5,0,1.1122002500000001,0.07925802777777774,0.0051812777777777794,0,0,0 +40,-7.1583616365327529,-9.175947291231326,-7.2999999999999998,0,1.2047352899999999,0.068858027777777747,-0.0041151281481481465,0,0,0 +40,-28.633446546131012,82.583525621081932,-7.2999999999999998,0,1.2047352899999999,0.068858027777777747,-0.0041151281481481465,0,0,0 +40,-37.563419615947083,-7.9501130849871888,-1,0,1.3168453833333331,0.05625802777777774,-0.0016453999999999993,0,0,0 +40,-150.25367846378833,71.551017764884705,-1,0,1.3168453833333331,0.056258027777777747,-0.0016453999999999993,0,0,0 +40,16.627586727950444,-1.7018366852211031,0,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,66.510346911801776,15.316530166989928,0,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,-20.299794883215469,2.2463666881873419,2,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,-81.199179532861876,-20.217300193686079,2,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +70.299999999980059,-27.259439885464111,1.3303422268762404,-70,0,0.37937107777694035,0.16835632222213204,0.0059161777777496137,0,0,0 +70.300000000000011,-109.03775954185645,-11.973080041886163,-70,0,0.37937107777777823,0.16835632222222227,0.0059161777777777943,0,0,0 +70.300000000000011,-18.329419181105777,8.4999330687997166,-50,0,0.37937107777777823,0.16835632222222227,0.0059161777777777943,0,0,0 +70.300000000000011,-73.317676724423109,-76.499397619197453,-50,0,0.37937107777777823,0.16835632222222227,0.0059161777777777943,0,0,0 +70.300000000000011,-28.279731776551642,0.40439045633691961,-41,0,0.55443892902777825,0.16629382222222219,0.0051134702777777949,0,0,0 +70.300000000000011,-113.11892710620657,-3.6395141070322765,-41,0,0.55443892902777825,0.16629382222222217,0.0051134702777777949,0,0,0 +70.300000000000011,7.2620474241576645,1.7805222100826015,-30,0,0.76841074722222258,0.16377298888888869,0.0041323833333333504,0,0,0 +70.300000000000011,29.048189696630658,-16.024699890743413,-30,0,0.76841074722222258,0.16377298888888869,0.0041323833333333504,0,0,0 +70.300000000000011,5.5694295374896896,7.4337734139059322,-20,0,0.93916869166666705,0.1437729888888887,0.0013812103174603439,0,0,0 +70.300000000000011,22.277718149958758,-66.903960725153382,-20,0,0.93916869166666705,0.1437729888888887,0.0013812103174603439,0,0,0 +70.300000000000011,-32.08471351381484,5.2144014253670647,-12.5,0,1.0672371500000004,0.12877298888888872,-0.00068216944444441123,0,0,0 +70.300000000000011,-128.33885405525936,-46.929612828303583,-12.5,0,1.0672371500000004,0.12877298888888872,-0.00068216944444441123,0,0,0 +70.300000000000011,30.99699708402197,-7.6298523843479193,-7.2999999999999998,0,1.1560313793333339,0.11837298888888871,-0.00550248085185185,0,0,0 +70.300000000000011,123.98798833608788,68.668671459131275,-7.2999999999999998,0,1.1560313793333339,0.11837298888888871,-0.00550248085185185,0,0,0 +70.300000000000011,16.420688115163323,0.3052507316806885,-1,0,1.2636089300000006,0.10577298888888871,-0.0015269083333333353,0,0,0 +70.300000000000011,65.68275246065329,-2.7472565851261965,-1,0,1.2636089300000006,0.10577298888888871,-0.0015269083333333353,0,0,0 +70.300000000000011,-12.057577684522364,-8.488938632238991,0,0,1.2806847250000004,0.10377298888888872,0,0,0,0 +70.300000000000011,-48.230310738089457,76.400447690150912,0,0,1.2806847250000004,0.10377298888888871,0,0,0,0 +70.300000000000011,-7.3514790764289799,0.57507548381627416,2,0,1.2806847250000004,0.10377298888888871,0,0,0,0 +70.300000000000011,-29.40591630571592,-5.1756793543464674,2,0,1.2806847250000004,0.1037729888888887,0,0,0,0 diff --git a/tests/data/currents_mdc/c5uniform/ref_python.csv b/tests/data/currents_mdc/c5uniform/ref_python.csv new file mode 100644 index 00000000..947bd68b --- /dev/null +++ b/tests/data/currents_mdc/c5uniform/ref_python.csv @@ -0,0 +1,341 @@ +t,x,y,z,zeta,ux,uy,uz,ax,ay,az +0,-7.0227440711249898,5.1111914475697731,-70,0,0,0,0,0,0,0 +0,-28.090976284499959,-46.000723028127958,-70,0,0,0,0,0,0,0 +0,31.485198909702078,-2.7143405605404558,-50,0,0,0,0,0,0,0 +0,125.94079563880831,24.429065044864103,-50,0,0,0,0,0,0,0 +0,-20.809732103447978,-0.11709455529188517,-41,0,0.27172440000000003,0.094500000000000015,0,0,0,0 +0,-83.238928413791911,1.0538509976269665,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +0,39.372803737268669,8.1470737833757489,-30,0,0.60383200000000004,0.20999999999999996,0,0,0,0 +0,157.49121494907467,-73.323664050381737,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +0,22.655718499009495,9.0072588429436564,-20,0,0.73801714285714282,0.19,0,0,0,0 +0,90.622873996037981,-81.065329586492908,-20,0,0.73801714285714293,0.19,0,0,0,0 +0,-18.753718663728201,-6.3312860955636596,-12.5,0,0.83865599999999985,0.17499999999999999,0,0,0,0 +0,-75.014874654912802,56.981574860072939,-12.5,0,0.83865599999999996,0.17500000000000002,0,0,0,0 +0,-12.854524951559121,-9.2261219752510932,-7.2999999999999998,0,0.90843237333333338,0.1646,0,0,0,0 +0,-51.418099806236484,83.035097777259836,-7.2999999999999998,0,0.90843237333333338,0.16460000000000002,0,0,0,0 +0,-14.582842600996724,9.9481395883889334,-1,0,0.99296859999999965,0.15199999999999997,0,0,0,0 +0,-58.331370403986895,-89.533256295500394,-1,0,0.99296860000000009,0.15200000000000002,0,0,0,0 +0,36.632586546811126,8.810295057781655,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,146.5303461872445,-79.292655520034899,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,-29.96197077630681,-7.4273365256825441,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0,-119.84788310522724,66.846028731142894,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +0.69999999999999996,-28.02076086210656,-6.5230478214981957,-70,0,0.075781299999999968,0.037911299999999988,0.00095199999999999994,0,0,0 +0.69999999999999996,-112.08304344842624,58.707430393483762,-70,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,-36.14628172153602,-9.2849199404695852,-50,0,0.075781299999999968,0.037911299999999995,0.00095199999999999983,0,0,0 +0.69999999999999996,-144.58512688614408,83.564279464226274,-50,0,0.075781299999999982,0.037911299999999995,0.00095199999999999994,0,0,0 +0.69999999999999996,3.3553280663774103,-4.0977833792740519,-41,0,0.32723521375000003,0.1127238,0.00074362750000000002,0,0,0 +0.69999999999999996,13.421312265509641,36.880050413466464,-41,0,0.32723521375000003,0.11272379999999999,0.00074362750000000002,0,0,0 +0.69999999999999996,-31.972033235176774,5.4521511695150906,-30,0,0.63456777500000006,0.20416129999999999,0.00048894999999999993,0,0,0 +0.69999999999999996,-127.8881329407071,-49.069360525635815,-30,0,0.63456777499999995,0.20416129999999996,0.00048894999999999993,0,0,0 +0.69999999999999996,34.379596770195292,-8.7218122019177518,-20,0,0.7755830178571429,0.1841613,-0.00038894999999999999,0,0,0 +0.69999999999999996,137.51838708078117,78.496309817259771,-20,0,0.77558301785714279,0.18416129999999997,-0.00038894999999999999,0,0,0 +0.69999999999999996,11.16126785635651,2.5043531721859065,-12.5,0,0.88134444999999983,0.16916129999999999,-0.0010473749999999999,0,0,0 +0.69999999999999996,44.645071425426039,-22.53917854967316,-12.5,0,0.88134444999999995,0.16916130000000001,-0.0010473750000000001,0,0,0 +0.69999999999999996,-29.348708093264236,0.95625921196315034,-7.2999999999999998,0,0.95467249266666654,0.15876129999999997,-0.0013422149999999999,0,0,0 +0.69999999999999996,-117.39483237305694,-8.606332907668353,-7.2999999999999998,0,0.95467249266666654,0.15876129999999999,-0.0013422150000000001,0,0,0 +0.69999999999999996,-22.203587385333094,-2.0378883977280582,-1,0,1.04351175,0.14616129999999999,-0.00029452499999999991,0,0,0 +0.69999999999999996,-88.814349541332376,18.340995579552523,-1,0,1.04351175,0.14616129999999999,-0.00029452499999999996,0,0,0 +0.69999999999999996,18.190400780927327,7.6932029114202614,0,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,72.761603123709307,-69.238826202782349,0,0,1.057613175,0.14416129999999999,0,0,0,0 +0.69999999999999996,-24.12915133518095,1.4288192371581143,2,0,1.057613175,0.14416129999999996,0,0,0,0 +0.69999999999999996,-96.5166053407238,-12.859373134423029,2,0,1.0576131750000002,0.14416129999999999,0,0,0,0 +2.9998999999999998,-22.696983243303571,4.7645721603939695,-70,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,-90.787932973214282,-42.881149443545723,-70,0,0.32476617409999997,0.16247158409999993,0.0040798640000000008,0,0,0 +2.9998999999999998,29.60912871286267,-4.5951718023777177,-50,0,0.32476617409999997,0.16247158409999995,0.0040798640000000008,0,0,0 +2.9998999999999998,118.43651485145068,41.356546221399462,-50,0,0.32476617409999997,0.16247158409999995,0.0040798639999999999,0,0,0 +2.9998999999999998,25.618852234935133,7.6544913688136056,-41,0,0.50961995738374999,0.17259939659999998,0.0031868687675000004,0,0,0 +2.9998999999999998,102.47540893974053,-68.890422319322454,-41,0,0.50961995738374999,0.17259939660000001,0.0031868687675,0,0,0 +2.9998999999999998,10.53684893278772,-6.7450871122768952,-30,0,0.73555235917499995,0.18497783410000002,0.00209543015,0,0,0 +2.9998999999999998,42.14739573115088,60.705784010492053,-30,0,0.73555235917499995,0.18497783410000002,0.00209543015,0,0,0 +2.9998999999999998,-20.117303652755972,-8.1552875404150704,-20,0,0.89900838344642842,0.16497783410000003,-0.0016668730071428568,0,0,0 +2.9998999999999998,-80.469214611023887,73.397587863735637,-20,0,0.89900838344642831,0.1649778341,-0.0016668730071428565,0,0,0 +2.9998999999999998,28.877993020518687,3.6868449410257362,-12.5,0,1.0216004016499998,0.14997783409999998,-0.0044886003749999986,0,0,0 +2.9998999999999998,115.51197208207475,-33.18160446923163,-12.5,0,1.0216004016499998,0.14997783409999998,-0.0044886003749999995,0,0,0 +2.9998999999999998,34.889472036363031,-8.6499183972374354,-7.2999999999999998,0,1.1065977076019999,0.13957783410000002,-0.0057521582549999997,0,0,0 +2.9998999999999998,139.55788814545213,77.849265575136911,-7.2999999999999998,0,1.1065977076019999,0.13957783410000002,-0.0057521582550000006,0,0,0 +2.9998999999999998,-17.050722524734745,6.4104332387690839,-1,0,1.2095748795500001,0.12697783409999999,-0.0012622079249999998,0,0,0 +2.9998999999999998,-68.20289009893898,-57.693899148921759,-1,0,1.2095748795500001,0.12697783410000002,-0.0012622079249999998,0,0,0 +2.9998999999999998,-16.690651040342416,-9.1022902008163555,0,0,1.2259204319750001,0.1249778341,0,0,0,0 +2.9998999999999998,-66.762604161369666,81.9206118073472,0,0,1.2259204319750001,0.12497783410000002,0,0,0,0 +2.9998999999999998,9.3410154959595459,-0.67081577166983664,2,0,1.2259204319749999,0.1249778341,0,0,0,0 +2.9998999999999998,37.364061983838184,6.0373419450285297,2,0,1.2259204319749999,0.12497783410000002,0,0,0,0 +3,-10.836166288895548,-2.8115086833376761,-70,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,-43.344665155582192,25.303578150039087,-70,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,16.775443700382759,-6.7131723758024897,-50,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,67.101774801531036,60.418551382222404,-50,0,0.32477699999999998,0.16247699999999998,0.0040800000000000003,0,0,0 +3,15.427820937577209,9.2448327960807788,-41,0,0.50962788749999999,0.17260200000000001,0.0031869750000000003,0,0,0 +3,61.711283750308837,-83.203495164727002,-41,0,0.50962788749999999,0.17260200000000001,0.0031869750000000007,0,0,0 +3,7.630055290347471,-3.3308172468554282,-30,0,0.73555675000000009,0.184977,0.0020955000000000006,0,0,0 +3,30.520221161389884,29.977355221698854,-30,0,0.73555674999999998,0.184977,0.0020955000000000001,0,0,0 +3,-27.412426819126992,9.6358073816110839,-20,0,0.89901374999999983,0.16497700000000001,-0.0016669285714285709,0,0,0 +3,-109.64970727650797,-86.722266434499758,-20,0,0.89901374999999994,0.16497699999999998,-0.0016669285714285709,0,0,0 +3,17.203682945812851,6.8040296956902608,-12.5,0,1.0216064999999999,0.149977,-0.0044887499999999997,0,0,0 +3,68.814731783251403,-61.236267261212348,-12.5,0,1.0216064999999999,0.149977,-0.0044887499999999997,0,0,0 +3,-38.990395083912347,-8.6007969180635229,-7.2999999999999998,0,1.1066043133333334,0.13957699999999998,-0.0057523500000000007,0,0,0 +3,-155.96158033564939,77.407172262571706,-7.2999999999999998,0,1.1066043133333334,0.13957700000000001,-0.0057523500000000007,0,0,0 +3,-29.231849903309861,7.1667743025490402,-1,0,1.2095821,0.12697700000000001,-0.0012622499999999999,0,0,0 +3,-116.92739961323944,-64.500968722941366,-1,0,1.2095820999999998,0.12697700000000001,-0.0012622499999999999,0,0,0 +3,-35.203358965445574,-9.0692755562979404,0,0,1.2259277499999999,0.124977,0,0,0,0 +3,-140.8134358617823,81.623480006681461,0,0,1.2259277499999999,0.124977,0,0,0,0 +3,-36.116039280277235,-3.8822382563456852,2,0,1.2259277499999999,0.12497700000000002,0,0,0,0 +3,-144.46415712110894,34.940144307111169,2,0,1.2259277499999999,0.124977,0,0,0,0 +4.4000000000000004,1.1124388464913793,5.2052587647150101,-70,0,0.38357062222222227,0.16880857777777775,0.0060574222222222231,0,0,0 +4.4000000000000004,4.449755385965517,-46.847328882435093,-70,0,0.38357062222222227,0.16880857777777772,0.0060574222222222231,0,0,0 +4.4000000000000004,34.909765359536976,4.6492065207760032,-50,0,0.38357062222222227,0.16880857777777775,0.0060574222222222231,0,0,0 +4.4000000000000004,139.63906143814791,-41.84285868698403,-50,0,0.38357062222222227,0.16880857777777775,0.0060574222222222231,0,0,0 +4.4000000000000004,33.382476189054231,6.2852042478643355,-41,0,0.55788593222222227,0.16580857777777777,0.0052616622222222235,0,0,0 +4.4000000000000004,133.52990475621692,-56.56683823077902,-41,0,0.55788593222222216,0.16580857777777777,0.0052616622222222235,0,0,0 +4.4000000000000004,21.118088989511691,7.1464517926659141,-30,0,0.77093797777777773,0.16214191111111109,0.0042890666666666674,0,0,0 +4.4000000000000004,84.472355958046762,-64.318066133993227,-30,0,0.77093797777777773,0.16214191111111109,0.0042890666666666674,0,0,0 +4.4000000000000004,-16.791523486757871,1.797590082510812,-20,0,0.94225753333333329,0.14214191111111113,0.0016156825396825409,0,0,0 +4.4000000000000004,-67.166093947031484,-16.178310742597308,-20,0,0.94225753333333329,0.1421419111111111,0.0016156825396825406,0,0,0 +4.4000000000000004,7.9041211742781954,-0.054646302818639469,-12.5,0,1.0707471999999998,0.12714191111111112,-0.00038935555555555428,0,0,0 +4.4000000000000004,31.616484697112782,0.49181672536775523,-12.5,0,1.0707472,0.12714191111111112,-0.00038935555555555433,0,0,0 +4.4000000000000004,38.844175038483527,7.1843931317166643,-7.2999999999999998,0,1.1598334613333334,0.11674191111111111,-0.0054832601481481485,0,0,0 +4.4000000000000004,155.37670015393411,-64.659538185449975,-7.2999999999999998,0,1.1598334613333334,0.11674191111111112,-0.0054832601481481485,0,0,0 +4.4000000000000004,-8.7213686226181331,2.9390179049262528,-1,0,1.2677648399999997,0.10414191111111111,-0.0015472666666666668,0,0,0 +4.4000000000000004,-34.885474490472532,-26.451161144336275,-1,0,1.2677648399999997,0.10414191111111112,-0.0015472666666666666,0,0,0 +4.4000000000000004,-31.500770648871857,-4.1916864180962037,0,0,1.2848967999999996,0.10214191111111112,0,0,0,0 +4.4000000000000004,-126.00308259548743,37.725177762865833,0,0,1.2848967999999998,0.10214191111111112,0,0,0,0 +4.4000000000000004,-31.018717744515953,4.2873602486832603,2,0,1.2848967999999998,0.10214191111111111,0,0,0,0 +4.4000000000000004,-124.07487097806381,-38.586242238149339,2,0,1.2848967999999998,0.10214191111111112,0,0,0,0 +6.9900000000000002,25.984579991006967,6.1489211330709139,-70,0,0.44493905333333333,0.15447589416666666,0.0081504083333333345,0,0,0 +6.9900000000000002,103.93831996402787,-55.340290197638225,-70,0,0.44493905333333333,0.15447589416666666,0.0081504083333333345,0,0,0 +6.9900000000000002,25.581854432298712,9.7110801990826481,-50,0,0.44493905333333333,0.15447589416666666,0.0081504083333333345,0,0,0 +6.9900000000000002,102.32741772919485,-87.399721791743829,-50,0,0.44493905333333333,0.15447589416666666,0.0081504083333333345,0,0,0 +6.9900000000000002,36.400293065186446,-6.4788192721909388,-41,0,0.60511694520833337,0.13647589416666667,0.0076923574583333352,0,0,0 +6.9900000000000002,145.60117226074578,58.30937344971845,-41,0,0.60511694520833337,0.13647589416666667,0.0076923574583333352,0,0,0 +6.9900000000000002,-16.131052630012999,-9.933801481428981,-30,0,0.80088992416666671,0.11447589416666668,0.0071325175000000003,0,0,0 +6.9900000000000002,-64.524210520051994,89.404213332860834,-30,0,0.80088992416666671,0.11447589416666666,0.0071325175000000003,0,0,0 +6.9900000000000002,11.949152372833652,-0.64963881772035137,-20,0,0.97886558321428563,0.094475894166666657,0.0060124627380952391,0,0,0 +6.9900000000000002,47.796609491334607,5.8467493594831623,-20,0,0.97886558321428574,0.094475894166666657,0.0060124627380952391,0,0,0 +6.9900000000000002,1.7948777433545473,1.0536637081014071,-12.5,0,1.1123473274999998,0.079475894166666658,0.005172421666666668,0,0,0 +6.9900000000000002,7.1795109734181892,-9.4829733729126637,-12.5,0,1.1123473275,0.079475894166666658,0.0051724216666666671,0,0,0 +6.9900000000000002,-5.9676589396120221,-1.1771128513667843,-7.2999999999999998,0,1.2048946048333333,0.069075894166666665,-0.0041257341555555552,0,0,0 +6.9900000000000002,-23.870635758448088,10.594015662301059,-7.2999999999999998,0,1.2048946048333331,0.069075894166666665,-0.0041257341555555552,0,0,0 +6.9900000000000002,24.096936358151595,3.4748222061226919,-1,0,1.3170195235,0.056475894166666665,-0.0016476759999999998,0,0,0 +6.9900000000000002,96.38774543260638,-31.273399855104227,-1,0,1.3170195235,0.056475894166666665,-0.0016476759999999994,0,0,0 +6.9900000000000002,34.277818838471035,0.919347914896818,0,0,1.3348171600000001,0.054475894166666664,0,0,0,0 +6.9900000000000002,137.11127535388414,-8.274131234071362,0,0,1.3348171600000001,0.054475894166666664,0,0,0,0 +6.9900000000000002,29.82452168463881,-6.7856616184547498,2,0,1.3348171600000001,0.054475894166666664,0,0,0,0 +6.9900000000000002,119.29808673855524,61.070954566092752,2,0,1.3348171600000001,0.054475894166666664,0,0,0,0 +10.1,-38.713778106373411,-2.6909196691918824,-70,0,0.41853184999999998,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,-154.85511242549364,24.218277022726941,-70,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,21.585287827692134,-1.5231418564411054,-50,0,0.41853184999999993,0.085899412500000008,0.0067420250000000004,0,0,0 +10.1,86.341151310768538,13.708276707969949,-50,0,0.41853184999999993,0.085899412499999994,0.0067420250000000004,0,0,0 +10.1,33.277869171065134,-8.813343938797555,-41,0,0.56920315062499993,0.067899412500000006,0.0069823418750000008,0,0,0 +10.1,133.11147668426054,79.320095449177998,-41,0,0.56920315062499993,0.067899412500000006,0.0069823418750000008,0,0,0 +10.1,33.313263307978758,2.9080081138450176,-30,0,0.75335696250000006,0.045899412500000007,0.0072760624999999995,0,0,0 +10.1,133.25305323191503,-26.172073024605158,-30,0,0.75335696250000006,0.045899412500000014,0.0072760624999999995,0,0,0 +10.1,-4.6156042235926691,5.4690483641294811,-20,0,0.92076984821428554,0.0258994125,0.006310641071428571,0,0,0 +10.1,-18.462416894370676,-49.221435277165327,-20,0,0.92076984821428565,0.025899412499999996,0.0063106410714285702,0,0,0 +10.1,14.431288479807982,-6.0866448253907741,-12.5,0,1.0463295125000001,0.010899412499999999,0.0055865749999999999,0,0,0 +10.1,57.725153919231929,54.779803428516971,-12.5,0,1.0463295125000001,0.010899412499999999,0.0055865749999999999,0,0,0 +10.1,-22.287438378876743,-5.9931563516567943,-7.2999999999999998,0,1.1333839605,0.00049941250000000003,-0.00092980499999999991,0,0,0 +10.1,-89.149753515506973,53.938407164911148,-7.2999999999999998,0,1.1333839605,0.00049941249999999981,-0.00092980500000000013,0,0,0 +10.1,24.798799380345031,-3.9029596822975527,-1,0,1.2388542025000002,-0.012100587500000003,-0.00076240999999999982,0,0,0 +10.1,99.195197521380123,35.126637140677971,-1,0,1.2388542024999998,-0.012100587500000001,-0.00076240999999999972,0,0,0 +10.1,-22.749879023039252,8.3958130959682222,0,0,1.25559555,-0.014100587500000001,0,0,0,0 +10.1,-90.999516092157009,-75.562317863714,0,0,1.25559555,-0.014100587500000003,0,0,0,0 +10.1,22.027009649720995,1.515237560299898,2,0,1.25559555,-0.014100587500000003,0,0,0,0 +10.1,88.108038598883979,-13.637138042699082,2,0,1.25559555,-0.014100587500000004,0,0,0,0 +15,13.876708886608398,0.74198059533564731,-70,0,0.35357499999999997,-0.024507999999999995,0.0019780000000000002,0,0,0 +15,55.506835546433592,-6.6778253580208258,-70,0,0.35357499999999997,-0.024508000000000002,0.0019780000000000002,0,0,0 +15,-2.7469521472092566,-3.5314995308744734,-50,0,0.35357499999999997,-0.024507999999999995,0.0019780000000000002,0,0,0 +15,-10.987808588837026,31.783495777870261,-50,0,0.35357500000000003,-0.024508000000000002,0.0019780000000000006,0,0,0 +15,29.646585258486994,9.962368830173471,-41,0,0.48086200000000001,-0.042507999999999997,0.0032802999999999999,0,0,0 +15,118.58634103394797,-89.661319471561242,-41,0,0.48086200000000001,-0.042507999999999997,0.0032802999999999999,0,0,0 +15,37.053032151947576,9.8181285065495807,-30,0,0.63643499999999997,-0.064507999999999996,0.0048719999999999996,0,0,0 +15,148.21212860779031,-88.36315655894623,-30,0,0.63643499999999997,-0.064507999999999996,0.0048719999999999996,0,0,0 +15,21.029863466981439,-5.0995662461400215,-20,0,0.77786528571428559,-0.084507999999999986,0.0018034285714285713,0,0,0 +15,84.119453867925756,45.896096215260194,-20,0,0.7778652857142857,-0.084508,0.0018034285714285713,0,0,0 +15,32.845196822829848,-2.3039314011475254,-12.5,0,0.883938,-0.099507999999999985,-0.00049799999999999996,0,0,0 +15,131.38078729131939,20.735382610327729,-12.5,0,0.883938,-0.099507999999999999,-0.00049799999999999996,0,0,0 +15,36.136092054079853,7.0038673785676444,-7.2999999999999998,0,0.95748125333333345,-0.10990800000000001,0.0038103733333333333,0,0,0 +15,144.54436821631941,-63.034806407108803,-7.2999999999999998,0,0.95748125333333334,-0.10990800000000001,0.0038103733333333333,0,0,0 +15,-11.799015997376479,9.1435538652081547,-1,0,1.0465819999999999,-0.12250800000000001,0.0011431999999999996,0,0,0 +15,-47.196063989505916,-82.2919847868734,-1,0,1.0465820000000001,-0.12250799999999999,0.0011431999999999998,0,0,0 +15,-13.440509756587147,3.6347630909713775,0,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,-53.762039026348589,-32.712867818742396,0,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,0.9221939903324099,-3.9009838610955754,2,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +15,3.6887759613296396,35.108854749860178,2,0,1.0607249999999999,-0.12450799999999999,0,0,0,0 +22.199999999999999,36.867108357945853,4.3234528028892942,-70,0,0.43220379999999992,0.062470399999999981,0.0028900000000000002,0,0,0 +22.199999999999999,147.46843343178341,-38.911075226003646,-70,0,0.43220379999999997,0.062470399999999988,0.0028900000000000002,0,0,0 +22.199999999999999,-32.328943017938776,-1.8016757645856387,-50,0,0.43220379999999992,0.062470399999999981,0.0028900000000000002,0,0,0 +22.199999999999999,-129.31577207175511,16.215081881270748,-50,0,0.43220379999999997,0.062470399999999981,0.0028900000000000002,0,0,0 +22.199999999999999,-35.80139720077473,-5.1599786500436888,-41,0,0.58779716800000004,0.044470399999999979,0.00089160400000000114,0,0,0 +22.199999999999999,-143.20558880309892,46.439807850393201,-41,0,0.58779716800000004,0.044470399999999986,0.00089160400000000092,0,0,0 +22.199999999999999,-26.223680897920421,8.239591500764341,-30,0,0.77796683999999994,0.022470399999999984,-0.001550879999999998,0,0,0 +22.199999999999999,-104.89472359168168,-74.156323506879062,-30,0,0.77796683999999994,0.022470399999999988,-0.001550879999999998,0,0,0 +22.199999999999999,23.990432529791548,4.2782867938128177,-20,0,0.95084837142857137,0.0024703999999999863,-0.00053999999999999936,0,0,0 +22.199999999999999,95.961730119166191,-38.50458114431536,-20,0,0.95084837142857137,0.0024703999999999868,-0.00053999999999999925,0,0,0 +22.199999999999999,2.887023810869664,6.4828489826972664,-12.5,0,1.0805095199999999,-0.012529600000000016,0.00021815999999999985,0,0,0 +22.199999999999999,11.548095243478656,-58.345640844275394,-12.5,0,1.0805095199999999,-0.012529600000000016,0.00021815999999999985,0,0,0 +22.199999999999999,32.434164811981134,-7.8507772219933631,-7.2999999999999998,0,1.1704078965333331,-0.022929600000000015,-0.00099395306666666535,0,0,0 +22.199999999999999,129.73665924792454,70.656994997940274,-7.2999999999999998,0,1.1704078965333333,-0.022929600000000015,-0.00099395306666666535,0,0,0 +22.199999999999999,27.646650826375748,6.6777754328004413,-1,0,1.2793232479999999,-0.035529600000000008,-0.0003060159999999995,0,0,0 +22.199999999999999,110.58660330550299,-60.099978895203975,-1,0,1.2793232479999999,-0.035529600000000015,-0.0003060159999999995,0,0,0 +22.199999999999999,0.74396917360442671,5.562222983029244,0,0,1.2966113999999997,-0.03752960000000001,0,0,0,0 +22.199999999999999,2.9758766944177069,-50.060006847263196,0,0,1.2966113999999997,-0.037529600000000017,0,0,0,0 +22.199999999999999,25.152845672099858,7.842833299939155,2,0,1.2966113999999997,-0.03752960000000001,0,0,0,0 +22.199999999999999,100.61138268839943,-70.585499699452399,2,0,1.2966113999999997,-0.03752960000000001,0,0,0,0 +27,34.177434854625872,5.9766241601186021,-70,0,0.48462299999999991,0.12045600000000001,0.0034980000000000002,0,0,0 +27,136.70973941850349,-53.789617441067421,-70,0,0.48462299999999997,0.12045600000000001,0.0034980000000000002,0,0,0 +27,22.493094807101244,-0.30775054810584912,-50,0,0.48462299999999997,0.12045600000000001,0.0034980000000000002,0,0,0 +27,89.972379228404975,2.7697549329526421,-50,0,0.48462299999999997,0.12045600000000001,0.0034980000000000002,0,0,0 +27,25.885819390472761,-5.8243899747383665,-41,0,0.65908728000000005,0.10245600000000002,-0.00070085999999999933,0,0,0 +27,103.54327756189105,52.419509772645299,-41,0,0.65908728000000005,0.10245600000000001,-0.00070085999999999933,0,0,0 +27,-28.483027801526923,-9.3070219450368796,-30,0,0.87232140000000002,0.080456000000000014,-0.0058328,0,0,0 +27,-113.93211120610769,83.763197505331917,-30,0,0.87232140000000002,0.080456000000000014,-0.0058327999999999991,0,0,0 +27,9.0213466103913547,-3.454486553556011,-20,0,1.0661704285714286,0.06045600000000001,-0.0021022857142857141,0,0,0 +27,36.085386441565419,31.090378982004097,-20,0,1.0661704285714286,0.060456000000000017,-0.0021022857142857141,0,0,0 +27,-7.8579344021051085,4.3088050425696949,-12.5,0,1.2115571999999999,0.04545600000000001,0.00069559999999999999,0,0,0 +27,-31.431737608420434,-38.779245383127254,-12.5,0,1.2115571999999999,0.04545600000000001,0.00069559999999999999,0,0,0 +27,3.846277922265557,2.544877826817034,-7.2999999999999998,0,1.3123589919999998,0.035056000000000011,-0.0041968373333333324,0,0,0 +27,15.385111689062228,-22.903900441353308,-7.2999999999999998,0,1.3123589920000001,0.035056000000000004,-0.0041968373333333324,0,0,0 +27,18.177235829689387,4.6831025268385353,-1,0,1.4344840799999998,0.022456000000000018,-0.0012721599999999996,0,0,0 +27,72.708943318757548,-42.147922741546822,-1,0,1.4344840800000001,0.022456000000000018,-0.0012721599999999996,0,0,0 +27,-0.75801079980575992,-8.7983991709748484,0,0,1.4538689999999996,0.020456000000000012,0,0,0,0 +27,-3.0320431992230397,79.185592538773633,0,0,1.4538689999999999,0.020456000000000016,0,0,0,0 +27,21.20569224848559,-8.5978798774983201,2,0,1.4538689999999999,0.020456000000000016,0,0,0,0 +27,84.822768993942361,77.380918897484875,2,0,1.4538689999999999,0.020456000000000016,0,0,0,0 +29.899999999999999,1.4068909434364869,-8.3769989685523569,-70,0,0.51629293333333337,0.15548896666666667,0.0038653333333333335,0,0,0 +29.899999999999999,5.6275637737459476,75.392990716971212,-70,0,0.51629293333333337,0.15548896666666667,0.0038653333333333335,0,0,0 +29.899999999999999,35.734934922741331,1.1619742971977622,-50,0,0.51629293333333337,0.15548896666666667,0.0038653333333333335,0,0,0 +29.899999999999999,142.93973969096533,-10.45776867477986,-50,0,0.51629293333333337,0.15548896666666667,0.0038653333333333335,0,0,0 +29.899999999999999,37.799493650061336,0.41397227450426044,-41,0,0.70215838933333341,0.13748896666666668,-0.0016629736666666664,0,0,0 +29.899999999999999,151.19797460024535,-3.725750470538344,-41,0,0.70215838933333352,0.13748896666666668,-0.0016629736666666666,0,0,0 +29.899999999999999,20.183925874373905,1.0212616773877166,-30,0,0.92932728000000009,0.11548896666666666,-0.0084197933333333332,0,0,0 +29.899999999999999,80.735703497495621,-9.191355096489449,-30,0,0.9293272800000002,0.11548896666666666,-0.0084197933333333332,0,0,0 +29.899999999999999,-17.815889634232171,-1.0721355449493082,-20,0,1.1358441714285714,0.095488966666666675,-0.0030461666666666666,0,0,0 +29.899999999999999,-71.263558536928684,9.6492199045437737,-20,0,1.1358441714285712,0.095488966666666675,-0.0030461666666666666,0,0,0 +29.899999999999999,10.672238679317502,-7.2897431841229476,-12.5,0,1.2907318399999999,0.080488966666666675,0.00098405333333333352,0,0,0 +29.899999999999999,42.688954717270008,65.607688657106536,-12.5,0,1.2907318399999999,0.080488966666666675,0.00098405333333333352,0,0,0 +29.899999999999999,-26.973218729797495,0.3614691414785991,-7.2999999999999998,0,1.3981211121777777,0.070088966666666669,-0.006131913244444444,0,0,0 +29.899999999999999,-107.89287491918998,-3.2532222733073919,-7.2999999999999998,0,1.3981211121777775,0.070088966666666669,-0.0061319132444444431,0,0,0 +29.899999999999999,37.135747505861445,-5.5397219777701583,-1,0,1.5282270826666662,0.057488966666666662,-0.0018558719999999993,0,0,0 +29.899999999999999,148.54299002344578,49.857497799931423,-1,0,1.5282270826666664,0.057488966666666662,-0.0018558719999999993,0,0,0 +29.899999999999999,14.740809994223198,9.1125628640246106,0,0,1.5488787999999998,0.055488966666666667,0,0,0,0 +29.899999999999999,58.963239976892794,-82.013065776221495,0,0,1.5488787999999998,0.055488966666666667,0,0,0,0 +29.899999999999999,-11.677147320143256,-9.2474157959482923,2,0,1.5488787999999998,0.055488966666666674,0,0,0,0 +29.899999999999999,-46.708589280573023,83.226742163534624,2,0,1.5488787999999998,0.055488966666666667,0,0,0,0 +30,-8.650754310000881,9.1693461371038794,-70,0,0,0,0,0,0,0 +30,-34.603017240003524,-82.524115233934907,-70,0,0,0,0,0,0,0 +30,-21.528344832550019,-2.4498442073934967,-50,0,0,0,0,0,0,0 +30,-86.113379330200075,22.048597866541471,-50,0,0,0,0,0,0,0 +30,-37.913659422049847,1.7869178293190444,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +30,-151.65463768819939,-16.0822604638714,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +30,8.4481059835368626,-0.71042863432680114,-30,0,0.60383199999999992,0.20999999999999996,0,0,0,0 +30,33.79242393414745,6.3938577089412103,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +30,-10.984575041640863,-1.482566812128896,-20,0,0.73801714285714282,0.18999999999999997,0,0,0,0 +30,-43.938300166563451,13.343101309160064,-20,0,0.73801714285714271,0.18999999999999997,0,0,0,0 +30,17.471716959475991,-3.3085417618235073,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +30,69.886867837903964,29.776875856411564,-12.5,0,0.83865600000000007,0.17499999999999999,0,0,0,0 +30,-9.9692979111432862,6.4769913695198262,-7.2999999999999998,0,0.90843237333333338,0.1646,0,0,0,0 +30,-39.877191644573145,-58.292922325678433,-7.2999999999999998,0,0.90843237333333338,0.1646,0,0,0,0 +30,19.286561874569031,-9.7170013962221802,-1,0,0.99296859999999998,0.152,0,0,0,0 +30,77.146247498276125,87.453012565999614,-1,0,0.99296859999999987,0.152,0,0,0,0 +30,26.75939860221601,-2.596169523828566,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +30,107.03759440886404,23.365525714457092,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +30,-27.572206265855908,-8.0281491627056347,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +30,-110.28882506342363,72.253342464350709,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.5,12.32596528400471,-4.3338365504395409,-70,0,0,0,0,0,0,0 +31.5,49.303861136018838,39.004528953955869,-70,0,0,0,0,0,0,0 +31.5,13.765699540806267,-1.3972193507397392,-50,0,0,0,0,0,0,0 +31.5,55.062798163225068,12.574974156657653,-50,0,0,0,0,0,0,0 +31.5,30.071913752994931,-0.27677302343631283,-41,0,0.27172440000000003,0.094500000000000001,0,0,0,0 +31.5,120.28765501197972,2.4909572109268154,-41,0,0.27172439999999998,0.094500000000000001,0,0,0,0 +31.5,19.431548625850759,-9.7959945925604348,-30,0,0.60383199999999992,0.20999999999999996,0,0,0,0 +31.5,77.726194503403036,88.163951333043912,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +31.5,-28.793376785410032,-8.4567812390446857,-20,0,0.73801714285714282,0.19,0,0,0,0 +31.5,-115.17350714164013,76.111031151402173,-20,0,0.73801714285714282,0.19,0,0,0,0 +31.5,-36.309749669594368,4.5935349429275547,-12.5,0,0.83865600000000007,0.17499999999999999,0,0,0,0 +31.5,-145.23899867837747,-41.341814486347992,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +31.5,-2.239900235497096,0.13376092702809217,-7.2999999999999998,0,0.90843237333333338,0.16459999999999997,0,0,0,0 +31.5,-8.9596009419883842,-1.2038483432528295,-7.2999999999999998,0,0.90843237333333315,0.1646,0,0,0,0 +31.5,-23.449608268622228,2.8363753799615417,-1,0,0.99296859999999998,0.15200000000000002,0,0,0,0 +31.5,-93.798433074488912,-25.527378419653875,-1,0,0.99296859999999998,0.152,0,0,0,0 +31.5,37.409503897000633,4.0180531530013752,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.5,149.63801558800253,-36.162478377012377,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +31.5,-29.032706522727636,-0.2497391911787421,2,0,1.0063869999999999,0.15000000000000002,0,0,0,0 +31.5,-116.13082609091055,2.2476527206086789,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,-39.854124729019311,3.8768432788161906,-70,0,0,0,0,0,0,0 +33,-159.41649891607724,-34.891589509345714,-70,0,0,0,0,0,0,0 +33,17.684325638275766,3.5714735876826005,-50,0,0,0,0,0,0,0 +33,70.737302553103063,-32.143262289143408,-50,0,0,0,0,0,0,0 +33,-0.4594188146910767,6.5280235239098801,-41,0,0.27172440000000003,0.094500000000000015,0,0,0,0 +33,-1.8376752587643068,-58.75221171518892,-41,0,0.27172440000000003,0.094499999999999987,0,0,0,0 +33,38.256746798218416,-3.2436924925503297,-30,0,0.60383199999999992,0.20999999999999996,0,0,0,0 +33,153.02698719287366,29.193232432952968,-30,0,0.60383200000000004,0.20999999999999999,0,0,0,0 +33,-27.521341499367054,-2.7390553415641001,-20,0,0.73801714285714271,0.18999999999999997,0,0,0,0 +33,-110.08536599746822,24.651498074076901,-20,0,0.73801714285714282,0.19,0,0,0,0 +33,-12.987076895057115,-7.1632817430584605,-12.5,0,0.83865599999999985,0.17499999999999999,0,0,0,0 +33,-51.948307580228459,64.469535687526147,-12.5,0,0.83865599999999996,0.17499999999999999,0,0,0,0 +33,-12.696516486637286,-6.2580687836890414,-7.2999999999999998,0,0.90843237333333338,0.1646,0,0,0,0 +33,-50.786065946549144,56.322619053201372,-7.2999999999999998,0,0.90843237333333349,0.16459999999999997,0,0,0,0 +33,-15.027932615069012,-1.6160955882136356,-1,0,0.99296859999999998,0.15200000000000002,0,0,0,0 +33,-60.11173046027605,14.544860293922721,-1,0,0.99296859999999976,0.152,0,0,0,0 +33,-30.393098056862947,-6.3003307178771024,0,0,1.0063870000000001,0.15000000000000002,0,0,0,0 +33,-121.57239222745179,56.702976460893922,0,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,17.451886515299904,-7.4559148239279738,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +33,69.807546061199616,67.103233415351767,2,0,1.0063869999999999,0.14999999999999999,0,0,0,0 +35.200000000000003,-12.175965967280263,6.7831133701243189,-70,0,0.23816980000000026,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,-48.703863869121051,-61.04802033111887,-70,0,0.23816980000000032,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,4.6180814704796731,0.81549098970607581,-50,0,0.23816980000000029,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,18.472325881918692,-7.3394189073546823,-50,0,0.23816980000000032,0.11914980000000014,0.0029920000000000042,0,0,0 +35.200000000000003,35.559261112186789,4.1372114999958356,-41,0,0.44618695750000026,0.15177480000000007,0.0023371150000000033,0,0,0 +35.200000000000003,142.23704444874716,-37.23490349996252,-41,0,0.44618695750000015,0.15177480000000004,0.0023371150000000033,0,0,0 +35.200000000000003,-5.4011216736405032,9.6066153542405033,-30,0,0.70043015000000008,0.19164979999999998,0.0015367000000000022,0,0,0 +35.200000000000003,-21.604486694562013,-86.45953818816453,-30,0,0.70043015000000008,0.19164979999999998,0.0015367000000000022,0,0,0 +35.200000000000003,-12.109738563386159,0.037484791004560591,-20,0,0.85608132142857141,0.17164979999999996,-0.0012224142857142867,0,0,0 +35.200000000000003,-48.438954253544637,-0.33736311904104532,-20,0,0.85608132142857163,0.17164979999999996,-0.0012224142857142871,0,0,0 +35.200000000000003,11.75197738317857,-9.5241292360080703,-12.5,0,0.97281970000000006,0.15664979999999995,-0.0032917500000000039,0,0,0 +35.200000000000003,47.00790953271428,85.717163124072627,-12.5,0,0.97281970000000006,0.15664979999999995,-0.0032917500000000039,0,0,0 +35.200000000000003,21.038370881567459,3.5302548364859625,-7.2999999999999998,0,1.053758462666667,0.14624979999999999,-0.004218390000000005,0,0,0 +35.200000000000003,84.153483526269838,-31.772293528373662,-7.2999999999999998,0,1.0537584626666667,0.14624979999999999,-0.0042183900000000059,0,0,0 +35.200000000000003,-15.973711330369085,3.4445876816223553,-1,0,1.1518185000000001,0.13364979999999999,-0.00092565000000000117,0,0,0 +35.200000000000003,-63.894845321476339,-31.001289134601198,-1,0,1.1518185000000001,0.13364979999999996,-0.00092565000000000106,0,0,0 +35.200000000000003,-20.737096172036509,-6.9182720241524791,0,0,1.1673835500000003,0.13164980000000001,0,0,0,0 +35.200000000000003,-82.948384688146035,62.264448217372312,0,0,1.16738355,0.13164979999999998,0,0,0,0 +35.200000000000003,24.682597011745329,2.2417909878109477,2,0,1.16738355,0.13164979999999998,0,0,0,0 +35.200000000000003,98.730388046981318,-20.176118890298529,2,0,1.16738355,0.13164979999999998,0,0,0,0 +40,-28.536695796128988,-4.9250282768244125,-70,0,0.44488022222222223,0.1542580277777777,0.0081487222222222239,0,0,0 +40,-114.14678318451595,44.325254491419713,-70,0,0.44488022222222223,0.15425802777777772,0.0081487222222222239,0,0,0 +40,-37.794874756703308,-3.1006887978684139,-50,0,0.44488022222222223,0.15425802777777772,0.0081487222222222239,0,0,0 +40,-151.17949902681323,27.906199180815726,-50,0,0.44488022222222223,0.15425802777777772,0.0081487222222222239,0,0,0 +40,-34.489431309685216,0.39550850033954532,-41,0,0.6050369347222222,0.13625802777777771,0.0076929597222222239,0,0,0 +40,-137.95772523874086,-3.5595765030559079,-41,0,0.60503693472222231,0.13625802777777773,0.0076929597222222239,0,0,0 +40,-22.625244513000098,-1.5039685698797065,-30,0,0.8007840277777778,0.11425802777777773,0.0071359166666666671,0,0,0 +40,-90.500978052000391,13.535717128917359,-30,0,0.8007840277777778,0.11425802777777774,0.0071359166666666671,0,0,0 +40,-8.384812969166795,-6.8755142722931524,-20,0,0.9787361547619049,0.094258027777777753,0.0060189801587301603,0,0,0 +40,-33.53925187666718,61.879628450638371,-20,0,0.9787361547619049,0.094258027777777753,0.0060189801587301594,0,0,0 +40,-24.046467454115312,9.1937867724362334,-12.5,0,1.1122002499999999,0.07925802777777774,0.0051812777777777794,0,0,0 +40,-96.185869816461249,-82.744080951926094,-12.5,0,1.1122002500000001,0.07925802777777774,0.0051812777777777794,0,0,0 +40,-7.1583616365327529,-9.175947291231326,-7.2999999999999998,0,1.2047352899999999,0.068858027777777733,-0.0041151281481481465,0,0,0 +40,-28.633446546131012,82.583525621081932,-7.2999999999999998,0,1.2047352899999999,0.068858027777777733,-0.0041151281481481474,0,0,0 +40,-37.563419615947083,-7.9501130849871888,-1,0,1.3168453833333331,0.05625802777777774,-0.0016453999999999989,0,0,0 +40,-150.25367846378833,71.551017764884705,-1,0,1.3168453833333331,0.05625802777777774,-0.0016453999999999993,0,0,0 +40,16.627586727950444,-1.7018366852211031,0,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,66.510346911801776,15.316530166989928,0,0,1.3346406666666666,0.054258027777777745,0,0,0,0 +40,-20.299794883215469,2.2463666881873419,2,0,1.3346406666666666,0.054258027777777752,0,0,0,0 +40,-81.199179532861876,-20.217300193686079,2,0,1.3346406666666666,0.054258027777777752,0,0,0,0 +70.299999999999997,-27.259439885464111,1.3303422268762404,-70,0,0.37937107777777779,0.16835632222222222,0.0059161777777777796,0,0,0 +70.299999999999997,-109.03775954185645,-11.973080041886163,-70,0,0.37937107777777779,0.16835632222222222,0.0059161777777777796,0,0,0 +70.299999999999997,-18.329419181105777,8.4999330687997166,-50,0,0.37937107777777779,0.16835632222222222,0.0059161777777777796,0,0,0 +70.299999999999997,-73.317676724423109,-76.499397619197453,-50,0,0.37937107777777779,0.16835632222222222,0.0059161777777777796,0,0,0 +70.299999999999997,-28.279731776551642,0.40439045633691961,-41,0,0.5544389290277778,0.16629382222222222,0.0051134702777777801,0,0,0 +70.299999999999997,-113.11892710620657,-3.6395141070322765,-41,0,0.5544389290277778,0.16629382222222222,0.0051134702777777792,0,0,0 +70.299999999999997,7.2620474241576645,1.7805222100826015,-30,0,0.76841074722222225,0.16377298888888889,0.0041323833333333348,0,0,0 +70.299999999999997,29.048189696630658,-16.024699890743413,-30,0,0.76841074722222213,0.16377298888888886,0.0041323833333333348,0,0,0 +70.299999999999997,5.5694295374896896,7.4337734139059322,-20,0,0.93916869166666661,0.1437729888888889,0.0013812103174603199,0,0,0 +70.299999999999997,22.277718149958758,-66.903960725153382,-20,0,0.93916869166666661,0.14377298888888887,0.0013812103174603197,0,0,0 +70.299999999999997,-32.08471351381484,5.2144014253670647,-12.5,0,1.06723715,0.12877298888888888,-0.00068216944444444169,0,0,0 +70.299999999999997,-128.33885405525936,-46.929612828303583,-12.5,0,1.06723715,0.12877298888888888,-0.0006821694444444418,0,0,0 +70.299999999999997,30.99699708402197,-7.6298523843479193,-7.2999999999999998,0,1.1560313793333337,0.11837298888888888,-0.0055024808518518526,0,0,0 +70.299999999999997,123.98798833608788,68.668671459131275,-7.2999999999999998,0,1.1560313793333334,0.11837298888888888,-0.0055024808518518518,0,0,0 +70.299999999999997,16.420688115163323,0.3052507316806885,-1,0,1.26360893,0.10577298888888889,-0.0015269083333333332,0,0,0 +70.299999999999997,65.68275246065329,-2.7472565851261965,-1,0,1.2636089300000002,0.10577298888888889,-0.0015269083333333332,0,0,0 +70.299999999999997,-12.057577684522364,-8.488938632238991,0,0,1.280684725,0.10377298888888889,0,0,0,0 +70.299999999999997,-48.230310738089457,76.400447690150912,0,0,1.280684725,0.10377298888888889,0,0,0,0 +70.299999999999997,-7.3514790764289799,0.57507548381627416,2,0,1.280684725,0.10377298888888889,0,0,0,0 +70.299999999999997,-29.40591630571592,-5.1756793543464674,2,0,1.280684725,0.10377298888888888,0,0,0,0 diff --git a/tests/data/currents_mdc/offchord/c1.dat b/tests/data/currents_mdc/offchord/c1.dat new file mode 100644 index 00000000..288326a2 --- /dev/null +++ b/tests/data/currents_mdc/offchord/c1.dat @@ -0,0 +1,25 @@ +--------------------- MoorDyn Input File ------------------------------------ +A current below the straight chord (0.8 m/s under z = -32 m, ends at z = -20 m) +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +rope 0.3 80.0 1.0e7 -1.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0.0 -30.0 -20.0 0 0 0 0 +2 Vessel 0.0 30.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 rope 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +4.0 TMax simulation length (s) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +300.0 TmaxIC max time for ic gen (s) +1.0e-12 threshIC convergence threshold for ic gen (-) +0 WaveKin MoorDyn-C water kinematics mode (-) +1 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/offchord/c2.dat b/tests/data/currents_mdc/offchord/c2.dat new file mode 100644 index 00000000..ef65bc2b --- /dev/null +++ b/tests/data/currents_mdc/offchord/c2.dat @@ -0,0 +1,25 @@ +--------------------- MoorDyn Input File ------------------------------------ +A current below the straight chord (0.8 m/s under z = -32 m, ends at z = -20 m) +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +rope 0.3 80.0 1.0e7 -1.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0.0 -30.0 -20.0 0 0 0 0 +2 Vessel 0.0 30.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 rope 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +4.0 TMax simulation length (s) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +300.0 TmaxIC max time for ic gen (s) +1.0e-12 threshIC convergence threshold for ic gen (-) +0 WaveKin MoorDyn-C water kinematics mode (-) +2 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/offchord/current_profile.txt b/tests/data/currents_mdc/offchord/current_profile.txt new file mode 100644 index 00000000..c5b43d56 --- /dev/null +++ b/tests/data/currents_mdc/offchord/current_profile.txt @@ -0,0 +1,7 @@ +h +h +h +-50.0 0.8 0 0 +-32.0 0.8 0 0 +-28.0 0 0 0 +0.0 0 0 0 diff --git a/tests/data/currents_mdc/offchord/current_profile_dynamic.txt b/tests/data/currents_mdc/offchord/current_profile_dynamic.txt new file mode 100644 index 00000000..8f708acf --- /dev/null +++ b/tests/data/currents_mdc/offchord/current_profile_dynamic.txt @@ -0,0 +1,8 @@ +h +h +h +h +-50.0 -32.0 -28.0 0.0 +t ux +0.0 0.8 0.8 0.0 0.0 +10.0 0.8 0.8 0.0 0.0 diff --git a/tests/data/currents_mdc/tension_c0/ref_moordyn_c_tension.csv b/tests/data/currents_mdc/tension_c0/ref_moordyn_c_tension.csv new file mode 100644 index 00000000..85921086 --- /dev/null +++ b/tests/data/currents_mdc/tension_c0/ref_moordyn_c_tension.csv @@ -0,0 +1,222 @@ +t,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20 +0,3347.400371,3253.367737,3073.059491,2904.689961,2750.454325,2612.856668,2494.649244,2398.695686,2327.743491,2284.117533,2269.389762,2284.117594,2327.743605,2398.695849,2494.64943,2612.856879,2750.454526,2904.690164,3073.059662,3253.3679,3347.400507 +0.1,3347.400643,3253.368024,3073.059783,2904.690262,2750.45461,2612.856935,2494.64947,2398.695874,2327.743638,2284.117653,2269.389871,2284.117714,2327.743753,2398.696034,2494.64966,2612.857141,2750.454817,2904.690459,3073.059961,3253.368179,3347.400786 +0.2,3347.40138,3253.368784,3073.060579,2904.691069,2750.455387,2612.857641,2494.650068,2398.696348,2327.743995,2284.117928,2269.390116,2284.117988,2327.74411,2398.696507,2494.650258,2612.857846,2750.455594,2904.691265,3073.060757,3253.36894,3347.401523 +0.3,3347.402573,3253.370016,3073.061871,2904.692376,2750.456647,2612.858782,2494.65103,2398.697103,2327.744556,2284.118351,2269.39049,2284.118412,2327.744671,2398.697262,2494.65122,2612.858987,2750.456854,2904.692572,3073.062048,3253.370171,3347.402716 +0.4,3347.404219,3253.371717,3073.063656,2904.694184,2750.458388,2612.860356,2494.652356,2398.698138,2327.74532,2284.118924,2269.390993,2284.118984,2327.745435,2398.698297,2494.652545,2612.86056,2750.458594,2904.694379,3073.063832,3253.371871,3347.404362 +0.5,3347.406324,3253.373891,3073.065937,2904.696495,2750.460614,2612.862369,2494.654049,2398.69946,2327.746295,2284.119652,2269.391632,2284.119712,2327.746409,2398.699618,2494.654237,2612.862572,2750.460818,2904.696689,3073.066113,3253.374044,3347.406465 +0.6,3347.408893,3253.376545,3073.068722,2904.699316,2750.463332,2612.864828,2494.656119,2398.701078,2327.747489,2284.120545,2269.392417,2284.120605,2327.747603,2398.701235,2494.656306,2612.86503,2750.463534,2904.699509,3073.068897,3253.376697,3347.409034 +0.7,3347.411932,3253.379683,3073.072014,2904.70265,2750.466544,2612.867736,2494.658571,2398.702997,2327.748911,2284.121613,2269.393357,2284.121673,2327.749024,2398.703153,2494.658756,2612.867936,2750.466745,2904.702841,3073.072187,3253.379833,3347.412071 +0.8,3347.415435,3253.3833,3073.075808,2904.706492,2750.470247,2612.871091,2494.661402,2398.705218,2327.75056,2284.122856,2269.394453,2284.122915,2327.750672,2398.705373,2494.661586,2612.87129,2750.470446,2904.706681,3073.075979,3253.383449,3347.415573 +0.9,3347.419391,3253.387384,3073.080089,2904.710829,2750.474428,2612.874881,2494.664603,2398.707732,2327.75243,2284.124268,2269.395699,2284.124327,2327.752541,2398.707886,2494.664785,2612.875077,2750.474625,2904.711015,3073.080258,3253.387531,3347.419527 +1,3347.423777,3253.391911,3073.084836,2904.715637,2750.479064,2612.879084,2494.668154,2398.710522,2327.754505,2284.125834,2269.397081,2284.125893,2327.754615,2398.710674,2494.668335,2612.879279,2750.479258,2904.715821,3073.085003,3253.392057,3347.423911 +1.1,3347.428566,3253.396855,3073.09002,2904.720888,2750.484128,2612.883676,2494.672033,2398.713567,2327.756765,2284.127537,2269.398582,2284.127595,2327.756875,2398.713717,2494.672211,2612.883868,2750.48432,2904.72107,3073.090185,3253.396999,3347.428699 +1.2,3347.433733,3253.402189,3073.095615,2904.726556,2750.489594,2612.888632,2494.676216,2398.716846,2327.759194,2284.129359,2269.400185,2284.129416,2327.759302,2398.716994,2494.676392,2612.888821,2750.489784,2904.726735,3073.095776,3253.40233,3347.433863 +1.3,3347.439255,3253.407891,3073.101596,2904.732618,2750.495441,2612.893931,2494.680687,2398.720344,2327.761776,2284.131289,2269.401877,2284.131345,2327.761883,2398.720491,2494.68086,2612.894118,2750.495627,2904.732794,3073.101755,3253.40803,3347.439383 +1.4,3347.445116,3253.413944,3073.107947,2904.739055,2750.501651,2612.89956,2494.685432,2398.724052,2327.764506,2284.13332,2269.403655,2284.133376,2327.764612,2398.724197,2494.685603,2612.899743,2750.501834,2904.739228,3073.108104,3253.41408,3347.445242 +1.5,3347.451308,3253.420338,3073.114658,2904.745858,2750.508213,2612.905509,2494.690446,2398.727967,2327.767383,2284.135454,2269.405519,2284.135509,2327.767486,2398.72811,2494.690614,2612.905689,2750.508393,2904.746027,3073.114811,3253.420472,3347.451431 +1.6,3347.457821,3253.427065,3073.121717,2904.753015,2750.51512,2612.911771,2494.695725,2398.732087,2327.770406,2284.137693,2269.407473,2284.137746,2327.770508,2398.732227,2494.69589,2612.911947,2750.515296,2904.753181,3073.121866,3253.427195,3347.457942 +1.7,3347.464646,3253.434112,3073.129112,2904.760514,2750.522359,2612.918337,2494.701262,2398.736409,2327.773575,2284.140037,2269.409517,2284.14009,2327.773676,2398.736546,2494.701424,2612.918509,2750.522531,2904.760676,3073.129258,3253.434239,3347.464763 +1.8,3347.471764,3253.441463,3073.136826,2904.768337,2750.529913,2612.925191,2494.707044,2398.740923,2327.776885,2284.142482,2269.411648,2284.142534,2327.776983,2398.741057,2494.707203,2612.92536,2750.530081,2904.768495,3073.136968,3253.441587,3347.471879 +1.9,3347.479152,3253.449091,3073.144831,2904.776457,2750.537756,2612.932311,2494.713053,2398.745613,2327.780321,2284.145017,2269.413855,2284.145069,2327.780418,2398.745745,2494.713207,2612.932475,2750.53792,2904.776611,3073.14497,3253.449212,3347.479264 +2,3347.486779,3253.456966,3073.153096,2904.784842,2750.545857,2612.939667,2494.719261,2398.750457,2327.783865,2284.147626,2269.416123,2284.147676,2327.78396,2398.750586,2494.719412,2612.939827,2750.546016,2904.784991,3073.153231,3253.457084,3347.486888 +2.1,3347.494612,3253.465054,3073.161584,2904.793455,2750.554182,2612.947227,2494.725641,2398.755431,2327.787496,2284.150289,2269.418433,2284.150338,2327.787588,2398.755557,2494.725788,2612.947383,2750.554336,2904.7936,3073.161715,3253.465167,3347.494717 +2.2,3347.502616,3253.47332,3073.170261,2904.802263,2750.562696,2612.954961,2494.732166,2398.76051,2327.791193,2284.152988,2269.420767,2284.153035,2327.791283,2398.760633,2494.732309,2612.955113,2750.562845,2904.802403,3073.170388,3253.473429,3347.502718 +2.3,3347.510765,3253.481735,3073.179097,2904.811233,2750.57137,2612.962842,2494.738811,2398.765676,2327.79494,2284.155709,2269.423114,2284.155756,2327.795028,2398.765796,2494.73895,2612.962988,2750.571515,2904.811369,3073.179219,3253.481841,3347.510863 +2.4,3347.519035,3253.490276,3073.188067,2904.820343,2750.580181,2612.970847,2494.74556,2398.770916,2327.798728,2284.158446,2269.425467,2284.158491,2327.798813,2398.771031,2494.745694,2612.970989,2750.580321,2904.820473,3073.188184,3253.490378,3347.519129 +2.5,3347.527408,3253.498924,3073.197151,2904.829571,2750.58911,2612.978962,2494.752399,2398.776219,2327.802551,2284.161196,2269.427823,2284.16124,2327.802634,2398.776331,2494.752529,2612.979099,2750.589245,2904.829696,3073.197264,3253.499022,3347.527498 +2.6,3347.535869,3253.507664,3073.206332,2904.838899,2750.59814,2612.987171,2494.759318,2398.78158,2327.806407,2284.163957,2269.430184,2284.164,2327.806487,2398.781689,2494.759444,2612.987303,2750.598269,2904.839019,3073.20644,3253.507758,3347.535956 +2.7,3347.544402,3253.516476,3073.21559,2904.848308,2750.607251,2612.995458,2494.766305,2398.78699,2327.810291,2284.16673,2269.432549,2284.166771,2327.810368,2398.787095,2494.766425,2612.995584,2750.607375,2904.848423,3073.215693,3253.516566,3347.544484 +2.8,3347.552982,3253.525339,3073.224901,2904.857773,2750.616421,2613.003802,2494.773341,2398.792437,2327.814193,2284.169506,2269.434912,2284.169546,2327.814268,2398.792537,2494.773456,2613.003923,2750.616539,2904.857883,3073.224998,3253.525423,3347.553061 +2.9,3347.561585,3253.534223,3073.234235,2904.867265,2750.625621,2613.012177,2494.780405,2398.797901,2327.818101,2284.172275,2269.437263,2284.172314,2327.818173,2398.797998,2494.780515,2613.012292,2750.625733,2904.867369,3073.234328,3253.534303,3347.561659 +3,3347.570177,3253.543096,3073.24356,2904.87675,2750.634817,2613.020553,2494.787469,2398.803362,2327.821996,2284.175023,2269.439588,2284.17506,2327.822064,2398.803454,2494.787575,2613.020662,2750.634923,2904.876848,3073.243647,3253.543172,3347.570247 +3.1,3347.578725,3253.551925,3073.252838,2904.886191,2750.643975,2613.028897,2494.794507,2398.808795,2327.825857,2284.177731,2269.441872,2284.177766,2327.825923,2398.808883,2494.794607,2613.029001,2750.644075,2904.886283,3073.252921,3253.551996,3347.578791 +3.2,3347.587198,3253.560677,3073.262038,2904.895555,2750.653063,2613.03718,2494.80149,2398.814178,2327.829669,2284.180386,2269.4441,2284.18042,2327.829731,2398.814261,2494.801585,2613.037277,2750.653157,2904.895642,3073.262115,3253.560744,3347.587259 +3.3,3347.595569,3253.569324,3073.27113,2904.904813,2750.662052,2613.045374,2494.808397,2398.819493,2327.833415,2284.182977,2269.446264,2284.183009,2327.833475,2398.819571,2494.808486,2613.045465,2750.662139,2904.904894,3073.271202,3253.569386,3347.595626 +3.4,3347.603817,3253.577844,3073.280091,2904.913941,2750.670918,2613.053459,2494.815211,2398.824727,2327.837089,2284.185497,2269.448358,2284.185527,2327.837145,2398.824801,2494.815294,2613.053544,2750.670999,2904.914015,3073.280157,3253.577901,3347.60387 +3.5,3347.611924,3253.58622,3073.288902,2904.922919,2750.679643,2613.061419,2494.821918,2398.829872,2327.840685,2284.187947,2269.450383,2284.187975,2327.840738,2398.829941,2494.821995,2613.061498,2750.679719,2904.922988,3073.288963,3253.586273,3347.611973 +3.6,3347.619877,3253.594436,3073.297546,2904.931731,2750.688212,2613.06924,2494.828507,2398.834921,2327.844202,2284.190326,2269.452341,2284.190352,2327.844251,2398.834985,2494.828579,2613.069313,2750.688281,2904.931794,3073.297601,3253.594484,3347.619921 +3.7,3347.62766,3253.602477,3073.306007,2904.940359,2750.696606,2613.076906,2494.834968,2398.839866,2327.847635,2284.192633,2269.454231,2284.192658,2327.84768,2398.839925,2494.835034,2613.076972,2750.696668,2904.940415,3073.306056,3253.602519,3347.627699 +3.8,3347.635254,3253.610322,3073.314263,2904.948781,2750.704805,2613.084398,2494.841283,2398.844696,2327.850978,2284.194866,2269.456052,2284.194889,2327.85102,2398.844751,2494.841344,2613.084458,2750.704861,2904.948831,3073.314307,3253.61036,3347.635289 +3.9,3347.642636,3253.617949,3073.32229,2904.956974,2750.712785,2613.091695,2494.847436,2398.849397,2327.854219,2284.197017,2269.457796,2284.197038,2327.854258,2398.849446,2494.84749,2613.091749,2750.712834,2904.957018,3073.322328,3253.617982,3347.642667 +4,3347.649783,3253.625332,3073.330062,2904.964909,2750.720519,2613.098772,2494.853402,2398.85395,2327.857346,2284.199075,2269.459456,2284.199094,2327.857381,2398.853994,2494.85345,2613.098818,2750.720562,2904.964946,3073.330095,3253.62536,3347.649809 +4.1,3347.656668,3253.632444,3073.337551,2904.972559,2750.72798,2613.105602,2494.859161,2398.858336,2327.860344,2284.201029,2269.46102,2284.201046,2327.860375,2398.858376,2494.859203,2613.105642,2750.728016,2904.97259,3073.337578,3253.632468,3347.656689 +4.2,3347.663267,3253.639263,3073.344732,2904.979898,2750.735143,2613.112163,2494.864692,2398.862541,2327.863201,2284.202869,2269.46248,2284.202884,2327.863228,2398.862575,2494.864727,2613.112197,2750.735173,2904.979924,3073.344754,3253.639282,3347.663284 +4.3,3347.669563,3253.645768,3073.351586,2904.986907,2750.741988,2613.118436,2494.869978,2398.86655,2327.865907,2284.204589,2269.463832,2284.204602,2327.86593,2398.866578,2494.870007,2613.118463,2750.742011,2904.986926,3073.351603,3253.645782,3347.669576 +4.4,3347.675541,3253.651947,3073.358098,2904.993569,2750.7485,2613.124406,2494.875008,2398.870356,2327.868458,2284.206189,2269.465075,2284.2062,2327.868477,2398.870379,2494.875031,2613.124426,2750.748516,2904.993582,3073.358108,3253.651955,3347.67555 +4.5,3347.681193,3253.657787,3073.364255,2904.999873,2750.754666,2613.130064,2494.879774,2398.873954,2327.870855,2284.207671,2269.466213,2284.20768,2327.87087,2398.873972,2494.87979,2613.130077,2750.754676,2904.99988,3073.36426,3253.657791,3347.681197 +4.6,3347.686511,3253.663283,3073.370051,2905.00581,2750.760478,2613.135401,2494.88427,2398.877343,2327.873097,2284.209038,2269.467251,2284.209045,2327.873108,2398.877355,2494.884281,2613.135408,2750.760482,2905.005811,3073.37005,3253.663282,3347.68651 +4.7,3347.691487,3253.668426,3073.375475,2905.01137,2750.765927,2613.14041,2494.888491,2398.880518,2327.875185,2284.210293,2269.468192,2284.210298,2327.875192,2398.880525,2494.888495,2613.14041,2750.765924,2905.011365,3073.375469,3253.66842,3347.691482 +4.8,3347.696111,3253.673205,3073.380517,2905.016543,2750.771001,2613.145078,2494.892426,2398.883474,2327.877116,2284.211437,2269.469038,2284.211439,2327.877119,2398.883475,2494.892424,2613.145072,2750.770992,2905.016531,3073.380506,3253.673195,3347.696102 +4.9,3347.700372,3253.677608,3073.385164,2905.021313,2750.775686,2613.149395,2494.896066,2398.886202,2327.878885,2284.212466,2269.469787,2284.212466,2327.878884,2398.886198,2494.896058,2613.149382,2750.77567,2905.021296,3073.385147,3253.677593,3347.700358 +5,3347.704255,3253.681621,3073.3894,2905.025666,2750.779967,2613.153343,2494.899397,2398.888692,2327.880484,2284.213375,2269.470434,2284.213372,2327.880479,2398.888682,2494.899382,2613.153324,2750.779945,2905.025642,3073.389378,3253.681601,3347.704237 +5.1,3347.707745,3253.685229,3073.393211,2905.029585,2750.783828,2613.15691,2494.902405,2398.890932,2327.881906,2284.214158,2269.470974,2284.214154,2327.881896,2398.890917,2494.902384,2613.156883,2750.783799,2905.029556,3073.393184,3253.685205,3347.707723 +5.2,3347.710832,3253.68842,3073.396584,2905.03306,2750.787256,2613.160081,2494.905079,2398.892914,2327.883143,2284.214811,2269.471405,2284.214805,2327.88313,2398.892893,2494.905052,2613.160048,2750.787221,2905.033025,3073.396552,3253.688391,3347.710806 +5.3,3347.713508,3253.691186,3073.399511,2905.03608,2750.790243,2613.162849,2494.907413,2398.894633,2327.884193,2284.215334,2269.471726,2284.215326,2327.884176,2398.894607,2494.907379,2613.16281,2750.790202,2905.036039,3073.399474,3253.691154,3347.713478 +5.4,3347.71577,3253.693526,3073.401989,2905.038642,2750.792785,2613.16521,2494.909402,2398.896087,2327.885057,2284.215729,2269.47194,2284.215718,2327.885035,2398.896055,2494.909362,2613.165165,2750.792737,2905.038596,3073.401946,3253.693488,3347.715736 +5.5,3347.717619,3253.695438,3073.404017,2905.040746,2750.79488,2613.167164,2494.911048,2398.897277,2327.885739,2284.216002,2269.472055,2284.215989,2327.885713,2398.89724,2494.911002,2613.167112,2750.794827,2905.040694,3073.40397,3253.695397,3347.71758 +5.6,3347.719057,3253.696926,3073.405599,2905.042394,2750.796531,2613.168711,2494.912352,2398.898208,2327.886242,2284.216158,2269.472076,2284.216143,2327.886212,2398.898165,2494.912299,2613.168652,2750.796471,2905.042336,3073.405546,3253.69688,3347.719014 +5.7,3347.720086,3253.697991,3073.406735,2905.043586,2750.797738,2613.169852,2494.913315,2398.898881,2327.886572,2284.216204,2269.472009,2284.216186,2327.886538,2398.898833,2494.913257,2613.169788,2750.797672,2905.043523,3073.406678,3253.697941,3347.72004 +5.8,3347.720707,3253.698635,3073.407427,2905.044324,2750.798502,2613.170589,2494.913938,2398.899298,2327.886731,2284.216141,2269.471859,2284.216121,2327.886692,2398.899244,2494.913874,2613.170518,2750.79843,2905.044256,3073.407365,3253.698581,3347.720658 +5.9,3347.72092,3253.698856,3073.407672,2905.044605,2750.798819,2613.170917,2494.914218,2398.899455,2327.886716,2284.215972,2269.471626,2284.215949,2327.886674,2398.899397,2494.914148,2613.17084,2750.798742,2905.044532,3073.407605,3253.698798,3347.720866 +6,3347.72072,3253.69865,3073.407468,2905.044427,2750.798688,2613.170833,2494.914152,2398.899352,2327.886527,2284.215693,2269.471308,2284.215669,2327.886481,2398.899287,2494.914076,2613.170751,2750.798605,2905.044349,3073.407397,3253.698588,3347.720662 +6.1,3347.720105,3253.698017,3073.406814,2905.043787,2750.798105,2613.170335,2494.913736,2398.898983,2327.886161,2284.215304,2269.470905,2284.215277,2327.886111,2398.898914,2494.913654,2613.170247,2750.798017,2905.043704,3073.406738,3253.697951,3347.720044 +6.2,3347.719077,3253.696955,3073.405708,2905.042686,2750.79707,2613.169422,2494.912969,2398.898348,2327.885616,2284.214803,2269.470415,2284.214774,2327.885562,2398.898274,2494.912881,2613.169328,2750.796976,2905.042597,3073.405628,3253.696886,3347.719012 +6.3,3347.717637,3253.69547,3073.404155,2905.041126,2750.795587,2613.168096,2494.911854,2398.89745,2327.884895,2284.214193,2269.469841,2284.214162,2327.884837,2398.89737,2494.91176,2613.167996,2750.795487,2905.041033,3073.404071,3253.695396,3347.717569 +6.4,3347.715794,3253.693567,3073.402163,2905.039117,2750.793662,2613.166364,2494.910395,2398.896292,2327.884003,2284.213479,2269.469189,2284.213446,2327.883941,2398.896208,2494.910296,2613.166258,2750.793557,2905.039019,3073.402075,3253.69349,3347.715723 +6.5,3347.713559,3253.691259,3073.399743,2905.036669,2750.791307,2613.164236,2494.908603,2398.894884,2327.882947,2284.212668,2269.468465,2284.212633,2327.882881,2398.894794,2494.908498,2613.164125,2750.791197,2905.036566,3073.399651,3253.691179,3347.713484 +6.6,3347.710942,3253.688557,3073.396908,2905.033793,2750.788533,2613.161722,2494.906486,2398.893233,2327.881735,2284.211767,2269.467676,2284.21173,2327.881666,2398.893139,2494.906377,2613.161606,2750.788418,2905.033686,3073.396811,3253.688473,3347.710865 +6.7,3347.707956,3253.685473,3073.393668,2905.030503,2750.785351,2613.158834,2494.904055,2398.891349,2327.880374,2284.210783,2269.466829,2284.210744,2327.880301,2398.89125,2494.90394,2613.158713,2750.785231,2905.030391,3073.393567,3253.685385,3347.707875 +6.8,3347.704609,3253.682016,3073.390034,2905.026808,2750.781772,2613.15558,2494.901316,2398.889236,2327.878868,2284.209719,2269.465926,2284.209679,2327.878792,2398.889133,2494.901196,2613.155454,2750.781648,2905.026692,3073.38993,3253.681925,3347.704526 +6.9,3347.70091,3253.678193,3073.386015,2905.022717,2750.777803,2613.151967,2494.898276,2398.886899,2327.87722,2284.208577,2269.46497,2284.208535,2327.877141,2398.886791,2494.898151,2613.151836,2750.777674,2905.022596,3073.385907,3253.678099,3347.700823 +7,3347.696864,3253.674013,3073.381618,2905.018237,2750.773453,2613.148002,2494.894939,2398.884341,2327.875432,2284.207357,2269.463958,2284.207312,2327.875349,2398.884229,2494.894809,2613.147866,2750.773319,2905.018113,3073.381506,3253.673916,3347.696774 +7.1,3347.692479,3253.669482,3073.37685,2905.013377,2750.768728,2613.143691,2494.89131,2398.881565,2327.873503,2284.206057,2269.462891,2284.206011,2327.873417,2398.881448,2494.891175,2613.14355,2750.76859,2905.013249,3073.376735,3253.669382,3347.692386 +7.2,3347.687763,3253.664611,3073.371723,2905.008147,2750.763639,2613.139044,2494.887396,2398.878575,2327.871437,2284.204679,2269.461767,2284.204631,2327.871347,2398.878455,2494.887257,2613.138899,2750.763496,2905.008015,3073.371604,3253.664508,3347.687668 +7.3,3347.68273,3253.65941,3073.366249,2905.002561,2750.758199,2613.134072,2494.883207,2398.875379,2327.869238,2284.203225,2269.46059,2284.203175,2327.869145,2398.875255,2494.883064,2613.133922,2750.758052,2905.002425,3073.366127,3253.659304,3347.682632 +7.4,3347.677393,3253.653897,3073.360445,2904.996636,2750.752424,2613.128791,2494.878757,2398.871988,2327.866914,2284.201701,2269.459363,2284.20165,2327.866818,2398.871859,2494.87861,2613.128637,2750.752274,2904.996496,3073.36032,3253.653788,3347.677293 +7.5,3347.671771,3253.648088,3073.354329,2904.990389,2750.746334,2613.123218,2494.874061,2398.868412,2327.864473,2284.200113,2269.458093,2284.200061,2327.864375,2398.86828,2494.873909,2613.12306,2750.74618,2904.990246,3073.354201,3253.647977,3347.671668 +7.6,3347.665881,3253.642003,3073.34792,2904.983842,2750.739947,2613.117371,2494.869133,2398.864666,2327.861926,2284.198469,2269.456785,2284.198415,2327.861824,2398.86453,2494.868978,2613.117209,2750.739789,2904.983696,3073.34779,3253.641889,3347.665776 +7.7,3347.659741,3253.635659,3073.341239,2904.977013,2750.733282,2613.111267,2494.86399,2398.86076,2327.859279,2284.196774,2269.455444,2284.196718,2327.859176,2398.860621,2494.863831,2613.111101,2750.733121,2904.976864,3073.341105,3253.635543,3347.659634 +7.8,3347.653367,3253.629072,3073.3343,2904.96992,2750.726358,2613.104923,2494.858644,2398.856705,2327.856541,2284.195031,2269.454073,2284.194974,2327.856435,2398.856563,2494.858482,2613.104754,2750.726193,2904.969768,3073.334164,3253.628954,3347.653258 +7.9,3347.646773,3253.622258,3073.327122,2904.96258,2750.719189,2613.098353,2494.853109,2398.85251,2327.853715,2284.193242,2269.452671,2284.193184,2327.853607,2398.852365,2494.852943,2613.098181,2750.719021,2904.962424,3073.326983,3253.622138,3347.646661 +8,3347.639971,3253.61523,3073.319717,2904.955006,2750.71179,2613.091571,2494.847394,2398.848181,2327.850805,2284.191407,2269.451239,2284.191348,2327.850695,2398.848033,2494.847225,2613.091396,2750.71162,2904.954848,3073.319576,3253.615108,3347.639858 +8.1,3347.632976,3253.608003,3073.312101,2904.947217,2750.704178,2613.084592,2494.841511,2398.843726,2327.847815,2284.189527,2269.449774,2284.189467,2327.847702,2398.843575,2494.841339,2613.084413,2750.704005,2904.947056,3073.311958,3253.607878,3347.632861 +8.2,3347.625803,3253.600591,3073.304291,2904.939227,2750.69637,2613.07743,2494.835474,2398.839154,2327.844748,2284.187603,2269.448278,2284.187542,2327.844633,2398.839001,2494.835299,2613.077248,2750.696194,2904.939064,3073.304146,3253.600464,3347.625686 +8.3,3347.618469,3253.593013,3073.296307,2904.931058,2750.688384,2613.070104,2494.829297,2398.834477,2327.841612,2284.185638,2269.446751,2284.185575,2327.841495,2398.834322,2494.82912,2613.06992,2750.688206,2904.930893,3073.296159,3253.592885,3347.618351 +8.4,3347.610994,3253.585289,3073.288169,2904.922732,2750.680244,2613.062634,2494.822998,2398.829707,2327.838415,2284.183636,2269.445197,2284.183573,2327.838297,2398.82955,2494.822819,2613.062448,2750.680063,2904.922564,3073.288019,3253.58516,3347.610874 +8.5,3347.603399,3253.577442,3073.2799,2904.914272,2750.671971,2613.055043,2494.816596,2398.82486,2327.835167,2284.181605,2269.443622,2284.181541,2327.835048,2398.8247,2494.816414,2613.054854,2750.671788,2904.914102,3073.279749,3253.577311,3347.603278 +8.6,3347.595706,3253.569493,3073.271525,2904.905701,2750.663591,2613.047352,2494.81011,2398.819949,2327.831879,2284.179551,2269.44203,2284.179486,2327.831758,2398.819788,2494.809926,2613.047161,2750.663406,2904.90553,3073.271372,3253.569361,3347.595583 +8.7,3347.587935,3253.561465,3073.263064,2904.897044,2750.655125,2613.039583,2494.803558,2398.814989,2327.828558,2284.177478,2269.440425,2284.177413,2327.828437,2398.814827,2494.803372,2613.03939,2750.654938,2904.896871,3073.26291,3253.561331,3347.587811 +8.8,3347.580107,3253.553376,3073.254541,2904.888322,2750.646596,2613.031755,2494.796957,2398.809993,2327.825214,2284.175391,2269.438809,2284.175325,2327.825092,2398.809829,2494.79677,2613.031561,2750.646408,2904.888148,3073.254385,3253.55324,3347.579982 +8.9,3347.572237,3253.545245,3073.245973,2904.879555,2750.638024,2613.023888,2494.790323,2398.804971,2327.821852,2284.173291,2269.437182,2284.173225,2327.821728,2398.804806,2494.790134,2613.023692,2750.637833,2904.879379,3073.245816,3253.545108,3347.572111 +9,3347.564344,3253.537089,3073.237379,2904.870762,2750.629426,2613.015998,2494.783669,2398.799933,2327.818476,2284.17118,2269.435544,2284.171113,2327.818352,2398.799767,2494.783479,2613.015801,2750.629235,2904.870585,3073.237221,3253.536952,3347.564217 +9.1,3347.556443,3253.528926,3073.228778,2904.861962,2750.620823,2613.008104,2494.777011,2398.794889,2327.815092,2284.169058,2269.433896,2284.168991,2327.814968,2398.794722,2494.77682,2613.007906,2750.62063,2904.861784,3073.228619,3253.528788,3347.556315 +9.2,3347.548553,3253.520774,3073.22019,2904.853177,2750.612234,2613.000223,2494.770363,2398.789849,2327.811707,2284.166928,2269.432237,2284.166861,2327.811582,2398.789682,2494.770171,2613.000024,2750.612041,2904.852998,3073.22003,3253.520636,3347.548425 +9.3,3347.540694,3253.512654,3073.211636,2904.844427,2750.603682,2612.992376,2494.763743,2398.784828,2327.808327,2284.164795,2269.43057,2284.164728,2327.808201,2398.784661,2494.763551,2612.992177,2750.603488,2904.844247,3073.211476,3253.512515,3347.540565 +9.4,3347.532885,3253.504588,3073.203139,2904.835737,2750.59519,2612.984586,2494.757169,2398.779839,2327.804962,2284.162662,2269.428899,2284.162595,2327.804836,2398.779671,2494.756977,2612.984386,2750.594995,2904.835557,3073.202978,3253.504448,3347.532756 +9.5,3347.525151,3253.496597,3073.194723,2904.827131,2750.586782,2612.976873,2494.750662,2398.774896,2327.801622,2284.160538,2269.427229,2284.160471,2327.801497,2398.774728,2494.75047,2612.976673,2750.586587,2904.82695,3073.194561,3253.496457,3347.525021 +9.6,3347.517511,3253.488705,3073.186411,2904.818633,2750.578481,2612.969262,2494.744239,2398.770015,2327.798318,2284.158428,2269.425566,2284.158361,2327.798193,2398.769848,2494.744047,2612.969062,2750.578286,2904.818452,3073.186249,3253.488565,3347.517381 +9.7,3347.509988,3253.480933,3073.178226,2904.810267,2750.570311,2612.961773,2494.73792,2398.76521,2327.795058,2284.156337,2269.423912,2284.156271,2327.794934,2398.765043,2494.737729,2612.961573,2750.570117,2904.810086,3073.178065,3253.480792,3347.509858 +9.8,3347.5026,3253.473301,3073.17019,2904.802054,2750.562294,2612.954425,2494.731721,2398.760492,2327.791851,2284.154271,2269.422272,2284.154205,2327.791727,2398.760326,2494.73153,2612.954225,2750.562099,2904.801873,3073.170028,3253.47316,3347.50247 +9.9,3347.495365,3253.465827,3073.16232,2904.794013,2750.554448,2612.947237,2494.725657,2398.755874,2327.788703,2284.152232,2269.420648,2284.152166,2327.78858,2398.755709,2494.725466,2612.947038,2750.554253,2904.793833,3073.162159,3253.465686,3347.495235 +10,3347.4883,3253.458528,3073.154636,2904.786164,2750.546791,2612.940225,2494.719741,2398.751365,2327.78562,2284.150223,2269.419039,2284.150158,2327.785498,2398.7512,2494.719552,2612.940027,2750.546598,2904.785984,3073.154475,3253.458387,3347.48817 +10.1,3347.48142,3253.45142,3073.147155,2904.778525,2750.539343,2612.933406,2494.713988,2398.746974,2327.782607,2284.148246,2269.417449,2284.148182,2327.782486,2398.746811,2494.7138,2612.933209,2750.53915,2904.778346,3073.146994,3253.451281,3347.48129 +10.2,3347.474742,3253.444523,3073.139896,2904.771116,2750.532122,2612.926798,2494.708412,2398.742712,2327.779672,2284.146306,2269.415878,2284.146242,2327.779552,2398.742551,2494.708225,2612.926602,2750.53193,2904.770937,3073.139736,3253.444384,3347.474613 +10.3,3347.468285,3253.437853,3073.132878,2904.763955,2750.525146,2612.920417,2494.703028,2398.738591,2327.776821,2284.144405,2269.414332,2284.144342,2327.776702,2398.738431,2494.702843,2612.920223,2750.524956,2904.763777,3073.132719,3253.437715,3347.468157 +10.4,3347.462066,3253.43143,3073.126121,2904.757063,2750.518437,2612.914284,2494.697851,2398.734623,2327.774064,2284.142552,2269.412814,2284.14249,2327.773947,2398.734465,2494.697668,2612.914091,2750.518248,2904.756887,3073.125963,3253.431293,3347.461939 +10.5,3347.456106,3253.425274,3073.119646,2904.750462,2750.512015,2612.908415,2494.692899,2398.730822,2327.77141,2284.140752,2269.411332,2284.140691,2327.771294,2398.730665,2494.692718,2612.908224,2750.511827,2904.750287,3073.119489,3253.425137,3347.45598 +10.6,3347.450422,3253.419403,3073.113473,2904.744171,2750.505898,2612.90283,2494.688186,2398.727198,2327.768868,2284.139013,2269.40989,2284.138953,2327.768754,2398.727044,2494.688007,2612.902641,2750.505712,2904.743997,3073.113317,3253.419268,3347.450296 +10.7,3347.445031,3253.413835,3073.107619,2904.738209,2750.500106,2612.897545,2494.683727,2398.723764,2327.766446,2284.13734,2269.408494,2284.137281,2327.766334,2398.723612,2494.68355,2612.897359,2750.499922,2904.738037,3073.107465,3253.413701,3347.444906 +10.8,3347.439948,3253.408586,3073.102101,2904.732592,2750.494654,2612.892575,2494.679534,2398.720529,2327.764152,2284.135739,2269.407148,2284.13568,2327.764042,2398.720379,2494.67936,2612.892391,2750.494472,2904.732422,3073.101948,3253.408453,3347.439825 +10.9,3347.435186,3253.403668,3073.096934,2904.727336,2750.489557,2612.887932,2494.675618,2398.717501,2327.761991,2284.134213,2269.405856,2284.134155,2327.761883,2398.717354,2494.675446,2612.887751,2750.489378,2904.727168,3073.096783,3253.403537,3347.435065 +11,3347.430758,3253.399096,3073.09213,2904.722453,2750.484827,2612.883629,2494.671988,2398.714687,2327.759967,2284.132765,2269.404619,2284.132708,2327.759862,2398.714543,2494.67182,2612.88345,2750.484651,2904.722287,3073.091981,3253.398966,3347.430638 +11.1,3347.426675,3253.394879,3073.087703,2904.717956,2750.480477,2612.879675,2494.668653,2398.712094,2327.758086,2284.131398,2269.40344,2284.131343,2327.757983,2398.711953,2494.668488,2612.8795,2750.480303,2904.717793,3073.087556,3253.394751,3347.426557 +11.2,3347.422948,3253.391031,3073.083664,2904.713859,2750.476519,2612.876083,2494.665623,2398.709729,2327.756352,2284.130117,2269.402324,2284.130063,2327.756251,2398.709591,2494.665461,2612.875911,2750.476348,2904.713698,3073.083519,3253.390905,3347.422832 +11.3,3347.419589,3253.387563,3073.080026,2904.710173,2750.472964,2612.872862,2494.662906,2398.707599,2327.754772,2284.128926,2269.401274,2284.128874,2327.754673,2398.707465,2494.662748,2612.872693,2750.472797,2904.710015,3073.079884,3253.387439,3347.419475 +11.4,3347.41661,3253.384487,3073.076802,2904.706911,2750.469826,2612.870024,2494.660512,2398.705713,2327.753351,2284.127831,2269.400296,2284.12778,2327.753255,2398.705581,2494.660357,2612.869859,2750.469662,2904.706756,3073.076662,3253.384365,3347.416497 +11.5,3347.414022,3253.381815,3073.074004,2904.704085,2750.467115,2612.867579,2494.65845,2398.704077,2327.752097,2284.126838,2269.399396,2284.126789,2327.752004,2398.703949,2494.658299,2612.867418,2750.466954,2904.703934,3073.073867,3253.381696,3347.413912 +11.6,3347.411835,3253.379559,3073.071643,2904.701708,2750.464842,2612.865537,2494.656728,2398.702699,2327.751016,2284.125953,2269.398579,2284.125905,2327.750926,2398.702575,2494.656581,2612.86538,2750.464685,2904.701559,3073.071509,3253.379442,3347.411728 +11.7,3347.41006,3253.377726,3073.069729,2904.699786,2750.463016,2612.863905,2494.655352,2398.701585,2327.750113,2284.125181,2269.397851,2284.125135,2327.750026,2398.701464,2494.65521,2612.863752,2750.462863,2904.699642,3073.069598,3253.377612,3347.409954 +11.8,3347.408701,3253.376324,3073.068268,2904.698329,2750.461644,2612.86269,2494.654329,2398.700738,2327.749391,2284.124525,2269.397215,2284.124481,2327.749307,2398.700622,2494.654191,2612.862541,2750.461495,2904.698188,3073.06814,3253.376213,3347.408598 +11.9,3347.407764,3253.375358,3073.067265,2904.69734,2750.460729,2612.861894,2494.65366,2398.700161,2327.748854,2284.123989,2269.396674,2284.123946,2327.748773,2398.700049,2494.653526,2612.86175,2750.460584,2904.697203,3073.067141,3253.37525,3347.407664 +12,3347.407252,3253.37483,3073.066725,2904.696824,2750.460275,2612.86152,2494.653347,2398.699856,2327.748503,2284.123574,2269.396231,2284.123533,2327.748425,2398.699748,2494.653218,2612.861381,2750.460134,2904.696691,3073.066605,3253.374725,3347.407154 +12.1,3347.407167,3253.374744,3073.06665,2904.696782,2750.460283,2612.861569,2494.65339,2398.699823,2327.748338,2284.123281,2269.395886,2284.123242,2327.748263,2398.69972,2494.653266,2612.861435,2750.460147,2904.696653,3073.066533,3253.374642,3347.407072 +12.2,3347.40751,3253.375101,3073.06704,2904.697215,2750.460754,2612.862042,2494.65379,2398.700063,2327.748361,2284.123114,2269.395642,2284.123076,2327.74829,2398.699963,2494.653671,2612.861912,2750.460623,2904.69709,3073.066927,3253.375002,3347.407419 +12.3,3347.408283,3253.375901,3073.067897,2904.698124,2750.461689,2612.862937,2494.654547,2398.700575,2327.748573,2284.123073,2269.395502,2284.123038,2327.748505,2398.70048,2494.654433,2612.862813,2750.461563,2904.698004,3073.067788,3253.375806,3347.408195 +12.4,3347.409487,3253.377146,3073.069222,2904.699511,2750.463087,2612.864256,2494.65566,2398.701361,2327.748977,2284.123162,2269.39547,2284.123129,2327.748912,2398.70127,2494.655551,2612.864137,2750.462966,2904.699395,3073.069117,3253.377055,3347.409402 +12.5,3347.411121,3253.378836,3073.071015,2904.701374,2750.464948,2612.865997,2494.65713,2398.702421,2327.749573,2284.123384,2269.395548,2284.123353,2327.749512,2398.702335,2494.657026,2612.865883,2750.464832,2904.701263,3073.070914,3253.378748,3347.41104 +12.6,3347.413186,3253.380971,3073.073275,2904.703712,2750.46727,2612.868159,2494.658954,2398.703754,2327.750364,2284.123743,2269.395741,2284.123713,2327.750306,2398.703673,2494.658856,2612.868051,2750.46716,2904.703607,3073.073179,3253.380887,3347.413109 +12.7,3347.415679,3253.383547,3073.075999,2904.706522,2750.470051,2612.870737,2494.66113,2398.70536,2327.751349,2284.124239,2269.396051,2284.124211,2327.751295,2398.705284,2494.661038,2612.870635,2750.469946,2904.706422,3073.075907,3253.383467,3347.415605 +12.8,3347.418595,3253.38656,3073.079182,2904.709799,2750.473284,2612.873728,2494.663654,2398.707236,2327.752529,2284.124874,2269.39648,2284.124848,2327.752478,2398.707165,2494.663567,2612.873631,2750.473185,2904.709704,3073.079095,3253.386484,3347.418525 +12.9,3347.421928,3253.390004,3073.082817,2904.713535,2750.476961,2612.877122,2494.666519,2398.709377,2327.7539,2284.125648,2269.397028,2284.125624,2327.753853,2398.70931,2494.666437,2612.877032,2750.476868,2904.713446,3073.082735,3253.389932,3347.421862 +13,3347.425669,3253.393869,3073.086894,2904.717721,2750.481072,2612.880912,2494.669717,2398.711776,2327.755459,2284.126558,2269.397694,2284.126536,2327.755416,2398.711714,2494.669641,2612.880827,2750.480985,2904.717637,3073.086818,3253.393802,3347.425607 +13.1,3347.429808,3253.398145,3073.091404,2904.722345,2750.485607,2612.885086,2494.673238,2398.714427,2327.757202,2284.127603,2269.398477,2284.127583,2327.757162,2398.714371,2494.673168,2612.885007,2750.485526,2904.722266,3073.091332,3253.398083,3347.42975 +13.2,3347.434335,3253.402822,3073.096333,2904.727395,2750.490554,2612.889632,2494.677074,2398.717323,2327.759124,2284.128781,2269.399375,2284.128763,2327.759088,2398.717272,2494.67701,2612.88956,2750.490479,2904.727322,3073.096267,3253.402764,3347.434282 +13.3,3347.439239,3253.407889,3073.101672,2904.732859,2750.4959,2612.89454,2494.681214,2398.720457,2327.761221,2284.130089,2269.400388,2284.130073,2327.761189,2398.720411,2494.681156,2612.894475,2750.495831,2904.732793,3073.101611,3253.407835,3347.43919 +13.4,3347.444509,3253.413333,3073.107406,2904.738724,2750.501632,2612.899798,2494.685649,2398.723821,2327.763489,2284.131527,2269.401516,2284.131512,2327.763461,2398.72378,2494.685597,2612.899739,2750.50157,2904.738664,3073.107351,3253.413284,3347.444464 +13.5,3347.450132,3253.419142,3073.113523,2904.744977,2750.507737,2612.905393,2494.690367,2398.727409,2327.765924,2284.133092,2269.402756,2284.133079,2327.7659,2398.727373,2494.690321,2612.905341,2750.507681,2904.744923,3073.113473,3253.419098,3347.450092 +13.6,3347.456096,3253.425302,3073.120009,2904.751602,2750.5142,2612.911312,2494.695359,2398.731211,2327.768521,2284.134782,2269.404109,2284.134772,2327.768501,2398.73118,2494.695319,2612.911266,2750.514151,2904.751554,3073.119964,3253.425263,3347.45606 +13.7,3347.462385,3253.431799,3073.126846,2904.758583,2750.521005,2612.917539,2494.700611,2398.73522,2327.771275,2284.136595,2269.405572,2284.136587,2327.771258,2398.735194,2494.700577,2612.9175,2750.520963,2904.758541,3073.126808,3253.431765,3347.462354 +13.8,3347.468983,3253.438614,3073.134019,2904.765902,2750.528133,2612.924058,2494.706109,2398.739424,2327.774178,2284.138526,2269.407142,2284.138519,2327.774165,2398.739403,2494.706082,2612.924026,2750.528098,2904.765866,3073.133986,3253.438586,3347.468957 +13.9,3347.475873,3253.445731,3073.141505,2904.773537,2750.535566,2612.930852,2494.711839,2398.743811,2327.777223,2284.140569,2269.408815,2284.140565,2327.777214,2398.743796,2494.711818,2612.930826,2750.535538,2904.773509,3073.141478,3253.445707,3347.475851 +14,3347.483034,3253.453127,3073.149285,2904.781469,2750.543282,2612.937899,2494.717782,2398.748369,2327.7804,2284.142719,2269.410586,2284.142717,2327.780394,2398.748359,2494.717768,2612.93788,2750.54326,2904.781446,3073.149264,3253.453108,3347.483017 +14.1,3347.490445,3253.460782,3073.157335,2904.789673,2750.551258,2612.945181,2494.723923,2398.753084,2327.783699,2284.144969,2269.412447,2284.144968,2327.783697,2398.753079,2494.723914,2612.945168,2750.551243,2904.789657,3073.15732,3253.460769,3347.490433 +14.2,3347.498086,3253.468674,3073.165633,2904.798126,2750.559471,2612.952675,2494.730243,2398.757942,2327.78711,2284.147311,2269.414395,2284.147312,2327.787112,2398.757943,2494.73024,2612.95267,2750.559464,2904.798117,3073.165624,3253.468666,3347.498078 +14.3,3347.505935,3253.47678,3073.174156,2904.806805,2750.5679,2612.960361,2494.736724,2398.76293,2327.790625,2284.149739,2269.416423,2284.149742,2327.79063,2398.762936,2494.736728,2612.960363,2750.567899,2904.806802,3073.174153,3253.476777,3347.505932 +14.4,3347.51397,3253.485079,3073.18288,2904.815685,2750.57652,2612.968219,2494.743349,2398.768034,2327.794233,2284.152246,2269.418525,2284.152251,2327.794242,2398.768045,2494.743359,2612.968227,2750.576526,2904.81569,3073.182883,3253.485082,3347.513972 +14.5,3347.522169,3253.493548,3073.191782,2904.824744,2750.585308,2612.976227,2494.750101,2398.77324,2327.797925,2284.154826,2269.420696,2284.154833,2327.797938,2398.773256,2494.750117,2612.976242,2750.585321,2904.824755,3073.191791,3253.493556,3347.522177 +14.6,3347.530511,3253.502164,3073.200836,2904.833955,2750.594241,2612.984362,2494.75696,2398.778536,2327.801691,2284.157471,2269.42293,2284.15748,2327.801707,2398.778557,2494.756983,2612.984384,2750.594261,2904.833973,3073.200851,3253.502177,3347.530524 +14.7,3347.538972,3253.510902,3073.210018,2904.843293,2750.603293,2612.992604,2494.763909,2398.783905,2327.80552,2284.160175,2269.425221,2284.160186,2327.80554,2398.783931,2494.763938,2612.992633,2750.60332,2904.843318,3073.210039,3253.510921,3347.538989 +14.8,3347.547527,3253.519738,3073.219301,2904.852731,2750.612439,2613.000927,2494.770927,2398.789332,2327.809402,2284.162928,2269.427561,2284.162941,2327.809426,2398.789364,2494.770962,2613.000963,2750.612473,2904.852762,3073.219328,3253.519762,3347.547549 +14.9,3347.55615,3253.528644,3073.228657,2904.862242,2750.62165,2613.009308,2494.777993,2398.794802,2327.813323,2284.165721,2269.429941,2284.165735,2327.81335,2398.794839,2494.778034,2613.009351,2750.621691,2904.862279,3073.228691,3253.528673,3347.556177 +15,3347.564816,3253.537594,3073.238058,2904.871795,2750.630901,2613.017722,2494.785087,2398.800298,2327.817271,2284.168544,2269.432352,2284.16856,2327.817302,2398.800339,2494.785134,2613.017771,2750.630949,2904.87184,3073.238098,3253.537628,3347.564848 +15.1,3347.573497,3253.54656,3073.247476,2904.881364,2750.640163,2613.026143,2494.792186,2398.805801,2327.821233,2284.171387,2269.434786,2284.171405,2327.821268,2398.805847,2494.79224,2613.026199,2750.640218,2904.881415,3073.247521,3253.546599,3347.573534 +15.2,3347.582168,3253.555515,3073.256881,2904.890917,2750.649408,2613.034546,2494.79927,2398.811296,2327.825196,2284.174239,2269.437234,2284.174259,2327.825234,2398.811347,2494.79933,2613.034608,2750.649469,2904.890975,3073.256933,3253.55556,3347.58221 +15.3,3347.590803,3253.564433,3073.266246,2904.900429,2750.658609,2613.042907,2494.806319,2398.816766,2327.829148,2284.177092,2269.439685,2284.177113,2327.829189,2398.816822,2494.806384,2613.042976,2750.658677,2904.900493,3073.266304,3253.564483,3347.590849 +15.4,3347.599376,3253.573286,3073.275544,2904.90987,2750.667739,2613.051202,2494.813311,2398.822195,2327.833077,2284.179935,2269.442133,2284.179959,2327.833121,2398.822256,2494.813382,2613.051277,2750.667814,2904.90994,3073.275608,3253.573342,3347.599427 +15.5,3347.607862,3253.582051,3073.284747,2904.919213,2750.676773,2613.059407,2494.820227,2398.827568,2327.836971,2284.18276,2269.444569,2284.182785,2327.837018,2398.827634,2494.820304,2613.059489,2750.676855,2904.91929,3073.284816,3253.582111,3347.607918 +15.6,3347.616236,3253.5907,3073.293829,2904.928432,2750.685685,2613.067499,2494.827048,2398.83287,2327.840818,2284.185558,2269.446985,2284.185585,2327.840869,2398.83294,2494.827131,2613.067587,2750.685773,2904.928515,3073.293904,3253.590765,3347.616297 +15.7,3347.624475,3253.599208,3073.302762,2904.937499,2750.694448,2613.075455,2494.833754,2398.838085,2327.844607,2284.188319,2269.449372,2284.188348,2327.844661,2398.83816,2494.833843,2613.075549,2750.694542,2904.937588,3073.302842,3253.599278,3347.62454 +15.8,3347.632552,3253.60755,3073.311519,2904.946387,2750.703036,2613.083251,2494.840326,2398.843197,2327.848326,2284.191034,2269.451722,2284.191065,2327.848383,2398.843276,2494.840419,2613.083352,2750.703137,2904.946482,3073.311606,3253.607625,3347.632621 +15.9,3347.640442,3253.615699,3073.320075,2904.955068,2750.711424,2613.090864,2494.846743,2398.848191,2327.851962,2284.193693,2269.454025,2284.193725,2327.852022,2398.848274,2494.846842,2613.09097,2750.711531,2904.955169,3073.320166,3253.615778,3347.640516 +16,3347.648121,3253.623629,3073.3284,2904.963516,2750.719585,2613.09827,2494.852985,2398.85305,2327.855502,2284.196285,2269.456272,2284.196318,2327.855566,2398.853138,2494.85309,2613.098382,2750.719697,2904.963623,3073.328497,3253.623714,3347.648199 +16.1,3347.655565,3253.631317,3073.336471,2904.971704,2750.727494,2613.105447,2494.859035,2398.85776,2327.858936,2284.1988,2269.458454,2284.198835,2327.859002,2398.857852,2494.859144,2613.105565,2750.727613,2904.971817,3073.336573,3253.631406,3347.655647 +16.2,3347.66275,3253.638738,3073.344261,2904.979607,2750.735128,2613.112373,2494.864872,2398.862305,2327.86225,2284.20123,2269.460562,2284.201267,2327.862319,2398.862401,2494.864986,2613.112496,2750.735252,2904.979726,3073.344368,3253.638831,3347.662836 +16.3,3347.669654,3253.645869,3073.351747,2904.987202,2750.742463,2613.119027,2494.87048,2398.866671,2327.865435,2284.203565,2269.462589,2284.203603,2327.865507,2398.866772,2494.8706,2613.119156,2750.742593,2904.987326,3073.351859,3253.645966,3347.669745 +16.4,3347.676258,3253.652689,3073.358907,2904.994466,2750.749478,2613.125391,2494.875844,2398.870847,2327.86848,2284.205798,2269.464526,2284.205837,2327.868555,2398.870951,2494.875968,2613.125526,2750.749613,2904.994595,3073.359023,3253.65279,3347.676352 +16.5,3347.68254,3253.659177,3073.365719,2905.001377,2750.756152,2613.131447,2494.880946,2398.87482,2327.871377,2284.207921,2269.466368,2284.207962,2327.871455,2398.874928,2494.881075,2613.131586,2750.756293,2905.001511,3073.36584,3253.659283,3347.682638 +16.6,3347.688484,3253.665316,3073.372163,2905.007916,2750.762467,2613.137176,2494.885775,2398.878578,2327.874117,2284.209928,2269.468108,2284.20997,2327.874197,2398.87869,2494.885908,2613.13732,2750.762613,2905.008054,3073.372289,3253.665426,3347.688585 +16.7,3347.69407,3253.671086,3073.378221,2905.014062,2750.768404,2613.142562,2494.890314,2398.882111,2327.87669,2284.211811,2269.46974,2284.211854,2327.876773,2398.882227,2494.890452,2613.142712,2750.768555,2905.014205,3073.378351,3253.671199,3347.694175 +16.8,3347.699283,3253.676469,3073.383873,2905.019798,2750.773945,2613.14759,2494.894551,2398.885408,2327.87909,2284.213564,2269.471258,2284.213609,2327.879175,2398.885527,2494.894693,2613.147744,2750.774101,2905.019946,3073.384007,3253.676586,3347.699391 +16.9,3347.704105,3253.68145,3073.389103,2905.025105,2750.779073,2613.152245,2494.898474,2398.888459,2327.881307,2284.21518,2269.472655,2284.215226,2327.881395,2398.888581,2494.89862,2613.152403,2750.779233,2905.025257,3073.389241,3253.68157,3347.704216 +17,3347.708522,3253.686012,3073.393893,2905.029968,2750.783773,2613.156511,2494.902069,2398.891253,2327.883334,2284.216653,2269.473927,2284.216701,2327.883425,2398.891378,2494.902219,2613.156674,2750.783937,2905.030124,3073.394035,3253.686135,3347.708636 +17.1,3347.712519,3253.690141,3073.398229,2905.03437,2750.78803,2613.160376,2494.905326,2398.893782,2327.885165,2284.217978,2269.475067,2284.218027,2327.885258,2398.893911,2494.90548,2613.160543,2750.788198,2905.034531,3073.398375,3253.690267,3347.712637 +17.2,3347.716085,3253.693824,3073.402098,2905.0383,2750.79183,2613.163829,2494.908235,2398.896039,2327.886793,2284.21915,2269.476072,2284.219199,2327.886888,2398.89617,2494.908392,2613.163999,2750.792003,2905.038464,3073.402247,3253.693953,3347.716205 +17.3,3347.719209,3253.69705,3073.405488,2905.041744,2750.795164,2613.166858,2494.910788,2398.898016,2327.888213,2284.220164,2269.476938,2284.220215,2327.88831,2398.89815,2494.910949,2613.167033,2750.79534,2905.041912,3073.40564,3253.697183,3347.719331 +17.4,3347.721882,3253.699811,3073.40839,2905.044695,2750.798022,2613.169458,2494.912978,2398.899708,2327.889421,2284.221018,2269.477662,2284.22107,2327.88952,2398.899845,2494.913142,2613.169635,2750.798201,2905.044865,3073.408544,3253.699946,3347.722007 +17.5,3347.724097,3253.7021,3073.410795,2905.047143,2750.800396,2613.171619,2494.914799,2398.901111,2327.890414,2284.22171,2269.478243,2284.221762,2327.890515,2398.901251,2494.914966,2613.1718,2750.800579,2905.047316,3073.410953,3253.702237,3347.724224 +17.6,3347.725848,3253.703909,3073.412698,2905.049082,2750.80228,2613.173337,2494.916246,2398.902222,2327.89119,2284.222238,2269.478679,2284.222291,2327.891293,2398.902364,2494.916416,2613.173522,2750.802466,2905.049258,3073.412858,3253.704048,3347.725977 +17.7,3347.727131,3253.705234,3073.414094,2905.050507,2750.803669,2613.174608,2494.917317,2398.903037,2327.891748,2284.2226,2269.47897,2284.222655,2327.891852,2398.903182,2494.91749,2613.174795,2750.803858,2905.050686,3073.414257,3253.705376,3347.727262 +17.8,3347.727943,3253.706073,3073.414979,2905.051415,2750.804561,2613.175428,2494.918008,2398.903555,2327.892084,2284.222798,2269.479115,2284.222853,2327.892191,2398.903702,2494.918183,2613.175618,2750.804751,2905.051597,3073.415144,3253.706216,3347.728075 +17.9,3347.728281,3253.706422,3073.415351,2905.051803,2750.804951,2613.175795,2494.918317,2398.903774,2327.8922,2284.222829,2269.479113,2284.222885,2327.892308,2398.903923,2494.918494,2613.175987,2750.805144,2905.051987,3073.415517,3253.706567,3347.728415 +18,3347.728144,3253.706282,3073.415208,2905.051671,2750.804839,2613.175707,2494.918243,2398.903694,2327.892094,2284.222693,2269.478965,2284.22275,2327.892203,2398.903845,2494.918423,2613.175901,2750.805034,2905.051856,3073.415376,3253.706428,3347.728279 +18.1,3347.727533,3253.705652,3073.414552,2905.051018,2750.804226,2613.175165,2494.917787,2398.903314,2327.891766,2284.222392,2269.478672,2284.22245,2327.891877,2398.903467,2494.917968,2613.175362,2750.804423,2905.051205,3073.414722,3253.705799,3347.72767 +18.2,3347.726451,3253.704535,3073.413385,2905.049847,2750.803114,2613.174172,2494.916949,2398.902636,2327.891219,2284.221927,2269.478234,2284.221986,2327.891331,2398.902791,2494.917133,2613.17437,2750.803312,2905.050036,3073.413556,3253.704683,3347.726589 +18.3,3347.724902,3253.702935,3073.411712,2905.048163,2750.801507,2613.17273,2494.915734,2398.901664,2327.890456,2284.221301,2269.477656,2284.221361,2327.890569,2398.90182,2494.915919,2613.172929,2750.801707,2905.048353,3073.411884,3253.703085,3347.72504 +18.4,3347.722892,3253.70086,3073.40954,2905.045973,2750.799411,2613.170845,2494.914146,2398.9004,2327.889478,2284.220518,2269.476941,2284.220578,2327.889592,2398.900558,2494.914333,2613.171046,2750.799612,2905.046164,3073.409712,3253.701011,3347.723031 +18.5,3347.720429,3253.698317,3073.406876,2905.043285,2750.796835,2613.168524,2494.912191,2398.898851,2327.888292,2284.21958,2269.476092,2284.219641,2327.888407,2398.899009,2494.912379,2613.168726,2750.797037,2905.043476,3073.407049,3253.698468,3347.720568 +18.6,3347.717522,3253.695315,3073.40373,2905.040108,2750.793786,2613.165776,2494.909875,2398.897021,2327.886902,2284.218494,2269.475113,2284.218555,2327.887018,2398.89718,2494.910064,2613.165978,2750.793989,2905.0403,3073.403904,3253.695466,3347.717662 +18.7,3347.714181,3253.691865,3073.400114,2905.036453,2750.790276,2613.162608,2494.907207,2398.894917,2327.885313,2284.217263,2269.47401,2284.217324,2327.88543,2398.895078,2494.907396,2613.162811,2750.790479,2905.036645,3073.400288,3253.692016,3347.71432 +18.8,3347.710416,3253.687977,3073.396038,2905.032331,2750.786315,2613.159031,2494.904194,2398.892546,2327.883531,2284.215893,2269.472788,2284.215954,2327.883648,2398.892707,2494.904384,2613.159235,2750.786518,2905.032523,3073.396212,3253.688128,3347.710556 +18.9,3347.70624,3253.683664,3073.391516,2905.027756,2750.781915,2613.155055,2494.900844,2398.889915,2327.881562,2284.214388,2269.47145,2284.21445,2327.881679,2398.890076,2494.901035,2613.155259,2750.782118,2905.027948,3073.391689,3253.683815,3347.706379 +19,3347.701665,3253.67894,3073.386561,2905.022741,2750.777089,2613.150693,2494.897169,2398.887031,2327.879411,2284.212754,2269.470003,2284.212817,2327.879529,2398.887193,2494.89736,2613.150897,2750.777292,2905.022933,3073.386734,3253.679091,3347.701804 +19.1,3347.696706,3253.673819,3073.381189,2905.017302,2750.771852,2613.145956,2494.893179,2398.883903,2327.877087,2284.210997,2269.468451,2284.21106,2327.877205,2398.884065,2494.893369,2613.14616,2750.772055,2905.017493,3073.381361,3253.673969,3347.696845 +19.2,3347.691379,3253.668317,3073.375417,2905.011456,2750.766221,2613.14086,2494.888885,2398.880542,2327.874596,2284.209125,2269.466801,2284.209187,2327.874715,2398.880704,2494.889075,2613.141063,2750.766423,2905.011646,3073.375588,3253.668466,3347.691516 +19.3,3347.6857,3253.662452,3073.369263,2905.005222,2750.760212,2613.13542,2494.884302,2398.876957,2327.871948,2284.207143,2269.46506,2284.207205,2327.872067,2398.877119,2494.884491,2613.135622,2750.760413,2905.005411,3073.369434,3253.6626,3347.685837 +19.4,3347.679688,3253.656243,3073.362748,2904.998619,2750.753845,2613.129653,2494.879442,2398.873161,2327.869153,2284.20506,2269.463235,2284.205123,2327.869271,2398.873322,2494.879632,2613.129854,2750.754045,2904.998807,3073.362917,3253.65639,3347.679824 +19.5,3347.673362,3253.64971,3073.355892,2904.991668,2750.74714,2613.123576,2494.874323,2398.869166,2327.866219,2284.202884,2269.461335,2284.202947,2327.866337,2398.869327,2494.874511,2613.123776,2750.747338,2904.991854,3073.356059,3253.649856,3347.673497 +19.6,3347.666743,3253.642874,3073.348716,2904.984392,2750.740117,2613.11721,2494.868958,2398.864983,2327.863156,2284.200624,2269.459366,2284.200687,2327.863274,2398.865144,2494.869145,2613.117408,2750.740314,2904.984576,3073.348882,3253.643018,3347.666876 +19.7,3347.65985,3253.635755,3073.341243,2904.976811,2750.732798,2613.110572,2494.863365,2398.860627,2327.859976,2284.198288,2269.457337,2284.198351,2327.860093,2398.860787,2494.863551,2613.110769,2750.732993,2904.976994,3073.341407,3253.635898,3347.659982 +19.8,3347.652706,3253.628376,3073.333496,2904.96895,2750.725204,2613.103682,2494.857559,2398.856111,2327.856688,2284.195885,2269.455256,2284.195947,2327.856805,2398.856269,2494.857744,2613.103877,2750.725397,2904.96913,3073.333658,3253.628517,3347.652836 +19.9,3347.645331,3253.620759,3073.325497,2904.960831,2750.717358,2613.09656,2494.851558,2398.851446,2327.853302,2284.193421,2269.453128,2284.193483,2327.853418,2398.851604,2494.851741,2613.096752,2750.717548,2904.961009,3073.325657,3253.620898,3347.645459 +20,3347.637746,3253.612925,3073.317271,2904.952479,2750.709282,2613.089226,2494.845378,2398.846648,2327.849829,2284.190906,2269.450962,2284.190967,2327.849944,2398.846804,2494.845559,2613.089416,2750.70947,2904.952654,3073.317428,3253.613062,3347.637873 +20.1,3347.629975,3253.604899,3073.308841,2904.943917,2750.701,2613.081702,2494.839037,2398.841729,2327.846278,2284.188347,2269.448765,2284.188407,2327.846392,2398.841883,2494.839216,2613.08189,2750.701185,2904.944089,3073.308996,3253.605033,3347.630099 +20.2,3347.62204,3253.596703,3073.300232,2904.935171,2750.692537,2613.074009,2494.832554,2398.836705,2327.842662,2284.185753,2269.446546,2284.185813,2327.842775,2398.836857,2494.83273,2613.074194,2750.692719,2904.935341,3073.300384,3253.596836,3347.622162 +20.3,3347.613966,3253.588363,3073.291471,2904.926267,2750.683916,2613.066169,2494.825946,2398.83159,2327.838991,2284.183133,2269.444311,2284.183193,2327.839103,2398.83174,2494.82612,2613.066352,2750.684095,2904.926434,3073.29162,3253.588493,3347.614086 +20.4,3347.605775,3253.579904,3073.282583,2904.917232,2750.675163,2613.058207,2494.819235,2398.826399,2327.835277,2284.180496,2269.442068,2284.180555,2327.835387,2398.826547,2494.819406,2613.058386,2750.675339,2904.917395,3073.282729,3253.580031,3347.605893 +20.5,3347.597494,3253.57135,3073.273594,2904.908091,2750.666305,2613.050145,2494.812439,2398.821148,2327.831532,2284.177851,2269.439827,2284.177909,2327.83164,2398.821295,2494.812608,2613.050321,2750.666477,2904.908251,3073.273737,3253.571475,3347.597609 +20.6,3347.589146,3253.562727,3073.264532,2904.898872,2750.657367,2613.042006,2494.805579,2398.815853,2327.827766,2284.175206,2269.437594,2284.175264,2327.827873,2398.815997,2494.805744,2613.042178,2750.657535,2904.899029,3073.264672,3253.562849,3347.589258 +20.7,3347.580754,3253.55406,3073.255421,2904.889602,2750.648374,2613.033813,2494.798673,2398.810529,2327.823992,2284.17257,2269.435377,2284.172627,2327.824097,2398.81067,2494.798835,2613.033982,2750.648538,2904.889755,3073.255558,3253.554179,3347.580864 +20.8,3347.572344,3253.545373,3073.246289,2904.880305,2750.639351,2613.02559,2494.791741,2398.80519,2327.82022,2284.169951,2269.433182,2284.170006,2327.820323,2398.805329,2494.791899,2613.025755,2750.639512,2904.880454,3073.246422,3253.545488,3347.572451 +20.9,3347.563938,3253.53669,3073.237159,2904.871009,2750.630324,2613.017359,2494.784802,2398.799852,2327.81646,2284.167355,2269.431015,2284.16741,2327.816561,2398.799988,2494.784957,2613.01752,2750.630481,2904.871154,3073.237289,3253.536802,3347.564042 +21,3347.555559,3253.528035,3073.228059,2904.861739,2750.621318,2613.009143,2494.777875,2398.794529,2327.812723,2284.164791,2269.428884,2284.164844,2327.812822,2398.794661,2494.778026,2613.0093,2750.62147,2904.86188,3073.228184,3253.528145,3347.55566 +21.1,3347.547231,3253.519433,3073.219012,2904.852521,2750.612357,2613.000964,2494.770979,2398.789235,2327.809019,2284.162265,2269.426793,2284.162317,2327.809116,2398.789364,2494.771126,2613.001117,2750.612505,2904.852657,3073.219134,3253.519539,3347.547329 +21.2,3347.538977,3253.510907,3073.210043,2904.843379,2750.603466,2612.992845,2494.764133,2398.783985,2327.805359,2284.159784,2269.424748,2284.159835,2327.805453,2398.784111,2494.764276,2612.992993,2750.60361,2904.843511,3073.210161,3253.511009,3347.539072 +21.3,3347.530819,3253.50248,3073.201178,2904.834339,2750.59467,2612.984808,2494.757356,2398.778794,2327.801751,2284.157355,2269.422756,2284.157405,2327.801843,2398.778916,2494.757495,2612.984952,2750.594809,2904.834467,3073.201292,3253.502579,3347.530911 +21.4,3347.52278,3253.494176,3073.192441,2904.825426,2750.585992,2612.976876,2494.750667,2398.773676,2327.798207,2284.154985,2269.420821,2284.155033,2327.798296,2398.773795,2494.750801,2612.977015,2750.586126,2904.825549,3073.19255,3253.494271,3347.522868 +21.5,3347.514882,3253.486017,3073.183855,2904.816664,2750.577457,2612.96907,2494.744084,2398.768645,2327.794736,2284.152681,2269.418948,2284.152727,2327.794823,2398.76876,2494.744214,2612.969204,2750.577586,2904.816783,3073.18396,3253.486108,3347.514966 +21.6,3347.507146,3253.478025,3073.175444,2904.808078,2750.569088,2612.961412,2494.737625,2398.763715,2327.791348,2284.150447,2269.417144,2284.150492,2327.791431,2398.763826,2494.737751,2612.961541,2750.569212,2904.808192,3073.175545,3253.478113,3347.507227 +21.7,3347.499592,3253.470222,3073.16723,2904.799689,2750.560908,2612.953923,2494.731309,2398.758899,2327.78805,2284.14829,2269.415411,2284.148333,2327.788131,2398.759006,2494.731429,2612.954046,2750.561027,2904.799798,3073.167326,3253.470306,3347.49967 +21.8,3347.49224,3253.462628,3073.159234,2904.79152,2750.552937,2612.946621,2494.72515,2398.75421,2327.784852,2284.146214,2269.413753,2284.146256,2327.784929,2398.754312,2494.725266,2612.94674,2750.55305,2904.791624,3073.159326,3253.462708,3347.492315 +21.9,3347.48511,3253.455262,3073.151477,2904.783591,2750.545196,2612.939527,2494.719166,2398.749659,2327.781761,2284.144223,2269.412173,2284.144264,2327.781835,2398.749757,2494.719276,2612.93964,2750.545304,2904.78369,3073.151564,3253.455338,3347.48518 +22,3347.478218,3253.448141,3073.143978,2904.775924,2750.537705,2612.932658,2494.713371,2398.745258,2327.778783,2284.142323,2269.410674,2284.142361,2327.778854,2398.745351,2494.713477,2612.932765,2750.537808,2904.776018,3073.144061,3253.448214,3347.478284 diff --git a/tests/data/currents_mdc/tension_c0/tension.dat b/tests/data/currents_mdc/tension_c0/tension.dat new file mode 100644 index 00000000..21f86d32 --- /dev/null +++ b/tests/data/currents_mdc/tension_c0/tension.dat @@ -0,0 +1,25 @@ +--------------------- MoorDyn Input File ------------------------------------ +Current tension parity deck (MoorDyn-C Currents 0): still water +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +rope 0.3 80.0 1.0e7 -1.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0.0 -30.0 -20.0 0 0 0 0 +2 Vessel 0.0 30.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 rope 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +22.0 TMax simulation length (s) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +300.0 TmaxIC max time for ic gen (s) +1.0e-12 threshIC convergence threshold for ic gen (-) +0 WaveKin MoorDyn-C water kinematics mode (-) +0 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/tension_c2/current_profile_dynamic.txt b/tests/data/currents_mdc/tension_c2/current_profile_dynamic.txt new file mode 100644 index 00000000..6801c669 --- /dev/null +++ b/tests/data/currents_mdc/tension_c2/current_profile_dynamic.txt @@ -0,0 +1,10 @@ +--------------------- MoorDyn dynamic currents File ---------------------------------- +still water at t = 0, then a sheared cross-flow + + +-50.0 -30.0 -10.0 0.0 +time ux... uy... uz... +0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +5.0 0.300000 0.380000 0.460000 0.500000 0.105184 0.105184 0.105184 0.105184 0.000000 0.000000 0.000000 0.000000 +12.0 0.600000 0.760000 0.920000 1.000000 0.168866 0.168866 0.168866 0.168866 0.000000 0.000000 0.000000 0.000000 +25.0 0.360000 0.456000 0.552000 0.600000 -0.143839 -0.143839 -0.143839 -0.143839 0.000000 0.000000 0.000000 0.000000 diff --git a/tests/data/currents_mdc/tension_c2/ref_moordyn_c_tension.csv b/tests/data/currents_mdc/tension_c2/ref_moordyn_c_tension.csv new file mode 100644 index 00000000..a78ccb8d --- /dev/null +++ b/tests/data/currents_mdc/tension_c2/ref_moordyn_c_tension.csv @@ -0,0 +1,222 @@ +t,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20 +0,3347.400371,3253.367737,3073.059491,2904.689961,2750.454325,2612.856668,2494.649244,2398.695686,2327.743491,2284.117533,2269.389762,2284.117594,2327.743605,2398.695849,2494.64943,2612.856879,2750.454526,2904.690164,3073.059662,3253.3679,3347.400507 +0.1,3347.399715,3253.367387,3073.059649,2904.690483,2750.455052,2612.857481,2494.650022,2398.696352,2327.743984,2284.11783,2269.389861,2284.117518,2327.743393,2398.695548,2494.649108,2612.856602,2750.454388,2904.690254,3073.060112,3253.368834,3347.401731 +0.2,3347.397819,3253.366422,3073.06032,2904.692321,2750.457594,2612.860296,2494.65273,2398.698652,2327.745668,2284.118787,2269.390075,2284.117055,2327.742386,2398.694184,2494.647616,2612.855248,2750.453477,2904.690125,3073.061141,3253.371431,3347.405214 +0.3,3347.394812,3253.364958,3073.061591,2904.695541,2750.461987,2612.865132,2494.657371,2398.702591,2327.748551,2284.120428,2269.390445,2284.116262,2327.740653,2398.691824,2494.645017,2612.85286,2750.451811,2904.689756,3073.062706,3253.375619,3347.410869 +0.4,3347.389871,3253.362161,3073.062664,2904.699404,2750.467562,2612.871411,2494.663471,2398.707809,2327.752401,2284.122654,2269.391009,2284.115317,2327.738508,2398.688913,2494.641874,2612.850108,2750.450157,2904.689994,3073.065717,3253.382347,3347.419639 +0.5,3347.38227,3253.357293,3073.062838,2904.703271,2750.47376,2612.878664,2494.670661,2398.714044,2327.757065,2284.125424,2269.391839,2284.114403,2327.736244,2398.685851,2494.638692,2612.847596,2750.449209,2904.691615,3073.071022,3253.39251,3347.432407 +0.6,3347.371749,3253.350059,3073.061835,2904.706901,2750.48038,2612.886733,2494.678829,2398.721235,2327.762537,2284.128787,2269.39304,2284.113682,2327.73408,2398.682913,2494.635804,2612.845712,2750.449412,2904.695119,3073.079171,3253.406694,3347.449739 +0.7,3347.35775,3253.339872,3073.059092,2904.709786,2750.486987,2612.89527,2494.687725,2398.729239,2327.768784,2284.132828,2269.394817,2284.11348,2327.732463,2398.680667,2494.633891,2612.845248,2750.45166,2904.701494,3073.091238,3253.426026,3347.472744 +0.8,3347.339465,3253.325884,3073.053794,2904.711195,2750.492957,2612.90378,2494.697004,2398.737875,2327.775807,2284.137734,2269.397551,2284.114373,2327.732163,2398.680072,2494.634096,2612.847519,2750.457429,2904.712363,3073.108972,3253.452331,3347.503235 +0.9,3347.316588,3253.307744,3073.0456,2904.710847,2750.498096,2612.912176,2494.706702,2398.747319,2327.783929,2284.143988,2269.401888,2284.117177,2327.734168,2398.682285,2494.637742,2612.854009,2750.468354,2904.7295,3073.134268,3253.487577,3347.543166 +1,3347.289386,3253.285658,3073.034705,2904.708978,2750.502704,2612.92084,2494.717299,2398.758162,2327.793866,2284.15244,2269.408821,2284.123031,2327.739767,2398.688748,2494.646422,2612.86646,2750.486321,2904.754928,3073.169272,3253.533977,3347.594735 +1.1,3347.258287,3253.259992,3073.021454,2904.705982,2750.507255,2612.93035,2494.729499,2398.771254,2327.806631,2284.164279,2269.419726,2284.133508,2327.750731,2398.701433,2494.662307,2612.887233,2750.513875,2904.791363,3073.21685,3253.594475,3347.660877 +1.2,3347.223995,3253.231379,3073.006452,2904.702509,2750.512483,2612.941554,2494.744292,2398.787749,2327.823562,2284.181043,2269.436355,2284.15058,2327.769264,2398.722774,2494.688059,2612.919214,2750.554111,2904.842095,3073.280456,3253.672607,3347.745129 +1.3,3347.187786,3253.201019,3072.990841,2904.699722,2750.519612,2612.955764,2494.7631,2398.809204,2327.846369,2284.204614,2269.460775,2284.176514,2327.797835,2398.75545,2494.726566,2612.965495,2750.61032,2904.910602,3073.363725,3253.772076,3347.851194 +1.4,3347.1513,3253.170468,3072.976101,2904.699106,2750.530171,2612.97458,2494.787623,2398.83744,2327.877014,2284.237113,2269.495282,2284.213793,2327.839126,2398.802343,2494.780914,2613.029364,2750.685987,2905.000553,3073.470478,3253.896763,3347.982952 +1.5,3347.116206,3253.141311,3072.963733,2904.702162,2750.545713,2612.999641,2494.819608,2398.874341,2327.917546,2284.28077,2269.542305,2284.265057,2327.895997,2398.866542,2494.854419,2613.114361,2750.784865,2905.1159,3073.604826,3254.050832,3348.144578 +1.6,3347.084269,3253.115227,3072.955318,2904.710461,2750.567855,2613.03264,2494.860862,2398.921849,2327.970064,2284.337868,2269.604327,2284.333004,2327.97137,2398.951197,2494.950459,2613.224089,2750.910774,2905.260663,3073.770944,3254.238501,3348.340302 +1.7,3347.057476,3253.094113,3072.952637,2904.725755,2750.59837,2613.075411,2494.913302,2398.981997,2328.036738,2284.410732,2269.683848,2284.420322,2328.068132,2399.059402,2495.072338,2613.362056,2751.067423,2905.438735,3073.97286,3254.463823,3348.574189 +1.8,3347.037912,3253.079967,3072.957562,2904.74987,2750.639101,2613.129845,2494.978899,2399.056857,2328.119769,2284.501713,2269.783385,2284.52971,2328.189178,2399.194249,2495.223348,2613.531757,2751.258499,2905.653981,3074.21456,3254.730801,3348.850256 +1.9,3347.027698,3253.074824,3072.971998,2904.784656,2750.69191,2613.197855,2495.059646,2399.148533,2328.221394,2284.613204,2269.905507,2284.663927,2328.337463,2399.3589,2495.406861,2613.736767,2751.487775,2905.910351,3074.500113,3255.043507,3349.172593 +2,3347.029149,3253.080917,3072.998037,2904.832138,2750.758822,2613.281506,2495.157677,2399.259255,2328.343965,2284.747702,2270.052872,2284.82581,2328.516015,2399.55658,2495.626299,2613.980705,2751.759062,2906.211823,3074.833593,3255.406015,3349.545295 +2.1,3347.044867,3253.100763,3073.038048,2904.894598,2750.842101,2613.383083,2495.27533,2399.391437,2328.489999,2284.907844,2270.228261,2285.018297,2328.727943,2399.790576,2495.885131,2614.267223,2752.076184,2906.562372,3075.219058,3255.822373,3349.97243 +2.2,3347.077648,3253.13708,3073.094599,2904.974503,2750.944185,2613.505038,2495.415097,2399.547642,2328.66215,2285.096405,2270.434584,2285.24445,2328.976471,2400.064282,2496.186928,2614.600065,2752.443055,2906.966055,3075.660632,3256.29669,3350.458133 +2.3,3347.130423,3253.192722,3073.17039,2905.074445,2751.06763,2613.649937,2495.579584,2399.730541,2328.863181,2285.316256,2270.674846,2285.507423,2329.264916,2400.381187,2496.53535,2614.983067,2752.863677,2907.427008,3076.162506,3256.833148,3351.00661 +2.4,3347.206271,3253.270694,3073.268275,2905.197156,2751.215119,2613.820457,2495.771496,2399.942891,2329.095925,2285.570333,2270.9521,2285.810405,2329.596615,2400.744784,2496.934053,2615.420045,2753.34202,2907.949322,3076.728813,3257.435869,3351.622013 +2.5,3347.308368,3253.3741,3073.391203,2905.345453,2751.389406,2614.019339,2495.993586,2400.187485,2329.363238,2285.861574,2271.269389,2286.156558,2329.974862,2401.15851,2497.386622,2615.914734,2753.881959,2908.536976,3077.363556,3258.108848,3352.308368 +2.6,3347.439867,3253.506022,3073.542109,2905.522132,2751.593217,2614.249287,2496.24857,2400.46707,2329.667925,2286.192863,2271.629694,2286.548977,2330.40288,2401.625722,2497.896555,2616.470773,2754.487267,2909.193834,3078.070613,3258.855963,3353.069588 +2.7,3347.603865,3253.66949,3073.723883,2905.72994,2751.829218,2614.512944,2496.539093,2400.784325,2330.012714,2286.567001,2272.035908,2286.990663,2330.883789,2402.14967,2498.467236,2617.091681,2755.161585,2909.923621,3078.853713,3259.68095,3353.909445 +2.8,3347.80344,3253.867516,3073.939399,2905.971603,2752.10005,2614.812913,2496.867758,2401.14187,2330.400269,2286.986713,2272.490836,2287.484516,2331.420596,2402.733477,2499.10191,2617.780828,2755.908396,2910.72988,3079.716396,3260.587361,3354.831534 +2.9,3348.041655,3254.103098,3074.191528,2906.249841,2752.408332,2615.151774,2497.237132,2401.542284,2330.833201,2287.454663,2272.997209,2288.033351,2332.016214,2403.380162,2499.803708,2618.541457,2756.731042,2911.616005,3080.662043,3261.578601,3355.839303 +3,3348.321549,3254.37921,3074.483123,2906.567358,2752.756666,2615.532079,2497.649754,2401.988114,2331.314084,2287.973471,2273.557715,2288.639936,2332.6735,2404.092681,2500.575693,2619.376738,2757.632783,2912.585294,3081.693937,3262.657983,3356.936112 +3.1,3348.646156,3254.698823,3074.817049,2906.926868,2753.147653,2615.956378,2498.108154,2402.481894,2331.845476,2288.545737,2274.175008,2289.306996,2333.395265,2404.873942,2501.420871,2620.289776,2758.616806,2913.640961,3082.815277,3263.828745,3358.125253 +3.2,3349.018527,3255.064924,3075.196192,2907.331109,2753.583915,2616.427228,2498.614865,2403.026153,2332.42992,2289.174036,2274.851715,2290.037223,2334.184276,2405.726792,2502.342183,2621.283604,2759.686212,2914.786123,3084.029165,3265.094033,3359.409929 +3.3,3349.441693,3255.480483,3075.623431,2907.782814,2754.068059,2616.947172,2499.172396,2403.623391,2333.069926,2289.860905,2275.590415,2290.83325,2335.043234,2406.654013,2503.342492,2622.361168,2760.844008,2916.023791,3085.338599,3266.4569,3360.79325 +3.4,3349.918617,3255.948399,3076.101583,2908.284662,2754.602636,2617.518686,2499.783192,2404.276041,2333.767932,2290.608804,2276.393606,2291.69763,2335.974755,2407.658292,2504.424567,2623.525312,2762.093088,2917.356856,3086.746462,3267.920288,3362.278222 +3.5,3350.452162,3256.471475,3076.633382,2908.839248,2755.190113,2618.144157,2500.449602,2404.986437,2334.526275,2291.42009,2277.263677,2292.632797,2336.981331,2408.74219,2505.591039,2624.778739,2763.436196,2918.78805,3088.255486,3269.486992,3363.867707 +3.6,3351.04508,3257.052404,3077.221453,2909.449073,2755.832853,2618.825866,2501.173862,2405.756796,2335.34717,2292.296989,2278.202883,2293.641046,2338.065309,2409.908113,2506.844382,2626.123984,2764.875897,2920.319919,3089.868223,3271.159634,3365.564397 +3.7,3351.699998,3257.693751,3077.868306,2910.116525,2756.533111,2619.565975,2501.958087,2406.589211,2336.232704,2293.241599,2279.213344,2294.724532,2339.22889,2411.158318,2508.186914,2627.563418,2766.414582,2921.954835,3091.587055,3272.940668,3367.370819 +3.8,3352.419424,3258.397968,3078.576339,2910.843888,2757.293035,2620.366537,2502.804283,2407.485662,2337.184849,2294.255897,2280.297058,2295.885287,2340.474148,2412.49493,2509.620818,2629.099273,2768.054496,2923.695017,3093.414223,3274.832413,3369.289369 +3.9,3353.205787,3259.167428,3079.347878,2911.633385,2758.11471,2621.229535,2503.714376,2408.448049,2338.205494,2295.341775,2281.455933,2297.125247,2341.80306,2413.919975,2511.14817,2630.733668,2769.797763,2925.542565,3095.351857,3276.837081,3371.322338 +4,3354.061477,3260.004464,3080.185211,2912.487205,2759.000191,2622.156918,2504.690255,2409.478228,2339.296479,2296.501075,2282.691823,2298.44629,2343.217538,2415.43541,2512.770977,2632.468646,2771.646426,2927.499495,3097.402013,3278.956813,3373.471949 +4.1,3354.988865,3260.911394,3081.090614,2913.407535,2759.95153,2623.150623,2505.733789,2410.578033,2340.459623,2297.73561,2284.006554,2299.850263,2344.719463,2417.043157,2514.491208,2634.306208,2773.602476,2929.567782,3099.566713,3281.193723,3375.740403 +4.2,3355.99032,3261.890533,3082.066359,2914.396566,2760.970784,2624.212591,2506.846849,2411.749297,2341.696736,2299.047187,2285.401937,2301.339,2346.310701,2418.745125,2516.310814,2636.248333,2775.667885,2931.749382,3101.847968,3283.549918,3378.129897 +4.3,3357.06821,3262.9442,3083.114724,2915.4565,2762.060025,2625.344769,2508.031306,2412.993846,2343.009624,2300.437602,2286.879776,2302.914323,2347.993103,2420.543204,2518.231728,2638.296979,2777.844595,2934.046231,3104.24778,3286.027504,3380.642631 +4.4,3358.224898,3264.074706,3084.23798,2916.589539,2763.221328,2626.549105,2509.289021,2414.313497,2344.400077,2301.908637,2288.441855,2304.578031,2349.7685,2422.439264,2520.25586,2640.454073,2780.13452,2936.460246,3106.768135,3288.628577,3383.280798 +4.5,3359.462718,3265.284339,3085.438373,2917.797866,2764.456754,2627.827529,2510.621838,2415.71004,2345.869859,2303.462041,2290.089928,2306.331896,2351.638689,2424.43514,2522.385084,2642.72151,2782.539538,2938.993313,3109.411001,3291.35522,3386.046584 +4.6,3360.783976,3266.575355,3086.718122,2919.08364,2765.768344,2629.181949,2512.031568,2417.185236,2347.420698,2305.099531,2291.825712,2308.177651,2353.605433,2426.532635,2524.62124,2645.101142,2785.061487,2941.647293,3112.17832,3294.209503,3388.942165 +4.7,3362.190946,3267.949984,3088.079415,2920.448997,2767.158122,2630.614256,2513.520003,2418.740815,2349.054294,2306.822793,2293.650893,2310.116996,2355.670461,2428.733515,2526.966132,2647.594784,2787.702169,2944.424019,3115.072019,3297.193484,3391.969711 +4.8,3363.685885,3269.41044,3089.52443,2921.896063,2768.628109,2632.126333,2515.088919,2420.378494,2350.772329,2308.633492,2295.567139,2312.151613,2357.835484,2431.03953,2529.421544,2650.204231,2790.463371,2947.325318,3118.094021,3300.309229,3395.131403 +4.9,3365.271052,3270.958937,3091.055347,2923.426969,2770.180337,2633.720077,2516.740106,2422.099994,2352.57649,2310.533298,2297.576117,2314.283186,2360.102216,2433.452435,2531.989266,2652.93128,2793.346884,2950.353036,3121.246273,3303.558835,3398.429461 +5,3366.948721,3272.597708,3092.674365,2925.043869,2771.816867,2635.397417,2518.475375,2423.907058,2354.468479,2312.523898,2299.679514,2316.513419,2362.472392,2435.974004,2534.671106,2655.777749,2796.354528,2953.509054,3124.530765,3306.944454,3401.866164 +5.1,3368.76503,3274.363076,3094.402061,2926.757734,2773.542625,2637.159419,2520.293327,2425.796571,2356.443545,2314.598253,2301.866589,2318.825658,2364.920432,2438.565906,2537.411371,2658.665256,2799.379368,2956.651659,3127.764588,3310.235903,3405.186195 +5.2,3370.659297,3276.203345,3096.197638,2928.527602,2775.308037,2638.940817,2522.106912,2427.654539,2358.356691,2316.577698,2303.92405,2320.972955,2367.168768,2440.92506,2539.888481,2661.262365,2802.090058,2959.460487,3130.649667,3313.168566,3408.144301 +5.3,3372.217414,3277.707905,3097.659165,2929.965873,2776.745479,2640.399513,2523.604901,2429.205485,2359.972249,2318.269282,2305.703146,2322.850691,2369.155283,2443.028803,2542.115042,2663.611991,2804.554492,2962.022989,3133.287559,3315.852846,3410.85403 +5.4,3373.298188,3278.737497,3098.652091,2930.945796,2777.738683,2641.431875,2524.697969,2430.375572,2361.232596,2319.631946,2307.179483,2324.451053,2370.888502,2444.901558,2544.130628,2665.767718,2806.838699,2964.415603,3135.762587,3318.37818,3413.406658 +5.5,3374.228388,3279.615849,3099.491141,2931.767851,2778.569026,2642.295828,2525.616931,2431.365642,2362.306533,2320.801177,2308.454736,2325.842169,2372.404001,2446.548036,2545.911451,2667.680275,2808.871603,2966.549703,3137.973257,3320.635408,3415.690462 +5.6,3375.254351,3280.588215,3100.418412,2932.669348,2779.467621,2643.215116,2526.577336,2432.382618,2363.392259,2321.966638,2309.710466,2327.198101,2373.869055,2448.129489,2547.613504,2669.501172,2810.80107,2968.570381,3140.062757,3322.766864,3417.847638 +5.7,3376.407153,3281.687672,3101.472687,2933.698518,2780.495676,2644.267078,2527.675459,2433.544134,2364.630772,2323.294232,2311.138526,2328.737185,2375.528429,2449.916405,2549.531575,2671.547361,2812.963431,2970.829925,3142.395359,3325.144574,3420.253094 +5.8,3377.813008,3283.040328,3102.779855,2934.981017,2781.778704,2645.577205,2529.036963,2434.976356,2366.149153,2324.912407,2312.869212,2330.592012,2377.517394,2452.046987,2551.806886,2673.963006,2815.505603,2973.477658,3145.122322,3327.921315,3423.060277 +5.9,3379.62882,3284.801318,3104.490051,2936.658824,2783.447719,2647.263022,2530.763753,2436.763912,2368.013555,2326.868076,2314.929835,2332.770345,2379.824611,2454.491639,2554.392825,2676.686149,2818.352412,2976.4277,3148.14992,3330.998772,3426.169354 +6,3381.761059,3286.877429,3106.51083,2938.640499,2785.412596,2649.235943,2532.768929,2438.821693,2370.140702,2329.079739,2317.240539,2335.193788,2382.372934,2457.174238,2557.21406,2679.642056,2821.429605,2979.606166,3151.404598,3334.303811,3429.50736 +6.1,3383.961342,3289.021879,3108.599748,2940.690261,2787.446456,2651.279893,2534.848735,2440.959404,2372.354497,2331.38581,2319.654169,2337.729206,2385.04256,2459.98737,2560.174393,2682.744403,2824.659256,2982.941882,3154.820208,3337.773555,3433.012553 +6.2,3386.092065,3291.097053,3110.61907,2942.66979,2789.410073,2653.254395,2536.861041,2443.032876,2374.508333,2333.636812,2322.017938,2340.220096,2387.672944,2462.766251,2563.104767,2685.820041,2827.864553,2986.254972,3158.214647,3341.224673,3436.501152 +6.3,3388.115686,3293.0647,3112.528625,2944.535407,2791.254912,2655.104815,2538.743987,2444.972064,2376.523208,2335.744161,2324.23321,2342.557484,2390.144708,2465.381279,2565.865804,2688.720615,2830.889308,2989.382829,3161.420633,3344.48714,3439.80218 +6.4,3389.994247,3294.887225,3114.292162,2946.252657,2792.948854,2656.80187,2540.471507,2446.754451,2378.380433,2337.693184,2326.289406,2344.734871,2392.455327,2467.833683,2568.462188,2691.453909,2833.74401,2992.338173,3164.452683,3347.576738,3442.931916 +6.5,3391.762837,3296.600145,3115.946942,2947.861298,2794.534978,2658.392748,2542.095584,2448.437447,2380.143425,2339.553798,2328.263315,2346.836145,2394.695842,2470.221512,2570.998607,2694.130719,2836.544852,2995.241683,3167.434987,3350.619991,3446.0178 +6.6,3393.583578,3298.36492,3117.653232,2949.519396,2796.168322,2660.028824,2543.763432,2450.163822,2381.950465,2341.459933,2330.284796,2348.987468,2396.989139,2472.664795,2573.592648,2696.866631,2839.40586,2998.206255,3170.479831,3353.728958,3449.171936 +6.7,3395.620563,3300.344969,3119.573213,2951.386858,2798.005636,2661.863007,2545.623584,2452.077403,2383.940595,2343.545968,2332.483827,2351.314786,2399.457549,2475.282676,2576.3607,2699.77575,2842.439335,3001.342867,3173.69743,3357.013515,3452.504197 +6.8,3397.932345,3302.599024,3121.766607,2953.524738,2800.109636,2663.960062,2547.743199,2454.248091,2386.186826,2345.888387,2334.940682,2353.902393,2402.189513,2478.167725,2579.399308,2702.958339,2845.748867,3004.757929,3177.196483,3360.583853,3456.125384 +6.9,3400.503983,3305.112398,3124.219713,2955.920659,2802.46954,2666.31111,2550.115547,2456.671497,2388.6873,2348.488017,2337.65896,2356.756685,2405.194165,2481.331672,2582.722597,2706.430709,2849.352685,3008.471299,3180.998205,3364.462067,3460.057932 +7,3403.283244,3307.832744,3126.879915,2958.52132,2805.030867,2668.8601,2552.682614,2459.287271,2391.379023,2351.278962,2340.569637,2359.805318,2408.395708,2484.695211,2586.247834,2710.10695,2853.162091,3012.39204,3185.010117,3368.554726,3464.208058 +7.1,3406.163808,3310.653878,3129.641292,2961.221008,2807.687913,2671.501174,2555.338183,2461.988575,2394.154261,2354.152313,2343.562327,2362.936124,2411.679913,2488.141839,2589.856155,2713.865936,2857.053918,3016.395336,3189.10627,3372.735157,3468.448794 +7.2,3409.016886,3313.447504,3132.376767,2963.894482,2810.317649,2674.113871,2557.964595,2464.660642,2396.901143,2356.998997,2346.530553,2366.044931,2414.944563,2491.570918,2593.448172,2717.609276,2860.930563,3020.384253,3193.190306,3376.90734,3472.684189 +7.3,3411.773335,3316.144708,3135.017956,2966.474178,2812.853393,2676.632469,2560.497128,2467.239713,2399.556803,2359.756965,2349.412959,2369.070912,2418.12916,2494.922081,2596.96351,2721.276531,2864.731507,3024.29828,3197.201809,3381.01091,3476.853878 +7.4,3414.450983,3318.763169,3137.582118,2968.976728,2815.310763,2679.071255,2562.94848,2469.736667,2402.130158,2362.433106,2352.214402,2372.016905,2421.234553,2498.194239,2600.399275,2724.863222,2868.450947,3028.130666,3201.133429,3385.038168,3480.95006 +7.5,3417.118486,3321.371436,3140.137618,2971.470318,2817.757582,2681.49756,2565.385435,2472.217714,2404.6869,2365.092745,2355.000024,2374.948051,2424.326028,2501.452933,2603.821367,2728.435697,2872.155742,3031.948851,3205.053152,3389.057476,3485.041289 +7.6,3419.866213,3324.059871,3142.774942,2974.045792,2820.285096,2684.003099,2567.900311,2474.775928,2407.321072,2367.83118,2357.86669,2377.963058,2427.504328,2504.801043,2607.334847,2732.101167,2875.955102,3035.863874,3209.073473,3393.182282,3489.241428 +7.7,3422.787845,3326.922023,3145.587377,2976.796159,2822.985879,2686.679871,2570.584492,2477.502086,2410.122936,2370.738359,2360.904292,2381.152014,2430.859945,2508.329627,2611.031482,2735.9522,2879.942448,3039.970033,3213.289424,3397.508122,3493.646274 +7.8,3425.941444,3330.015829,3148.632488,2979.77848,2825.916257,2689.583219,2573.492185,2480.44915,2413.144175,2373.864749,2364.162207,2384.563347,2434.44048,2512.085579,2614.957617,2740.034761,2884.163527,3044.313062,3217.746783,3402.080838,3498.301749 +7.9,3429.317639,3333.332043,3151.901185,2982.983972,2829.067794,2692.705019,2576.615571,2483.609575,2416.377482,2377.203279,2367.633611,2388.190461,2438.239517,2516.062613,2619.107097,2744.342845,2888.612536,3048.887444,3222.440249,3406.895295,3503.202804 +8,3432.852786,3336.807295,3155.330546,2986.35043,2832.379207,2695.984969,2579.895379,2486.925101,2419.765529,2380.697466,2371.262756,2391.978193,2442.202287,2520.20619,2623.425522,2748.822143,2893.235279,3053.639154,3227.315908,3411.897669,3508.295642 +8.1,3436.466505,3340.361433,3158.84066,2989.798301,2835.771389,2699.344348,2583.253201,2490.317504,2423.230092,2384.268888,2374.970825,2395.847113,2446.248524,2524.435041,2627.830571,2753.389329,2897.947578,3058.483388,3232.288451,3417.002365,3513.494557 +8.2,3440.090208,3343.926051,3162.363278,2993.259535,2839.176558,2702.715557,2586.621523,2493.719214,2426.703351,2387.849291,2378.688945,2399.72753,2450.307522,2528.677317,2632.249239,2757.970308,2902.674435,3063.344468,3237.281657,3422.132876,3518.722936 +8.3,3443.688112,3347.465548,3165.863054,2996.699138,2842.560237,2706.064646,2589.966911,2497.097275,2430.152749,2391.406432,2382.385117,2403.587588,2454.347447,2532.90112,2636.649547,2762.533041,2907.383836,3068.190469,3242.263632,3427.257394,3523.949027 +8.4,3447.27384,3350.993626,3169.35382,3000.131073,2845.936646,2709.406086,2593.304082,2500.466655,2433.593492,2394.955774,2386.075101,2407.443376,2458.384716,2537.123215,2641.048653,2767.095118,2912.093868,3073.039963,3247.25329,3432.395139,3529.192217 +8.5,3450.905793,3354.568625,3172.893792,3003.613257,2849.363402,2712.7971,2596.689791,2503.883618,2437.081363,2398.552686,2389.81398,2411.349822,2462.474217,2541.398575,2645.501755,2771.712073,2916.860522,3077.949397,3252.307408,3437.603206,3534.509808 +8.6,3454.658326,3358.264825,3176.557132,3007.219521,2852.913999,2716.310763,2600.196627,2507.420273,2440.688026,2402.268492,2393.672901,2415.378066,2466.687239,2545.798802,2650.080922,2776.456556,2921.757125,3082.992726,3257.500405,3442.956426,3539.976879 +8.7,3458.590469,3362.141251,3180.402925,3011.008863,2856.647402,2720.006004,2603.883466,2511.135477,2444.472371,2406.162204,2397.711139,2419.587787,2471.083982,2550.384744,2654.847762,2781.39101,2926.847004,3088.234047,3262.896948,3448.51994,3545.658837 +8.8,3462.727715,3366.223454,3184.456876,3015.006984,2860.589374,2723.908663,2607.776191,2515.055149,2448.46035,2410.259821,2401.95478,2424.005205,2475.690846,2555.183053,2659.829264,2786.542835,2932.158046,3093.701662,3268.525637,3454.322651,3551.584769 +8.9,3467.056074,3370.497567,3188.705323,3019.200272,2864.726402,2728.005332,2611.861431,2519.165899,2452.638466,2414.547646,2406.389857,2428.616017,2480.493142,2560.178672,2665.010058,2791.896445,2937.674571,3099.379795,3274.370611,3460.34876,3557.738945 +9,3471.528762,3374.917009,3193.102027,3023.542729,2869.01281,2732.250721,2616.094233,2523.423035,2456.962173,2418.981122,2410.971644,2433.375176,2485.445379,2565.32562,2670.343688,2797.404988,2943.349436,3105.221023,3280.384233,3466.550606,3564.073717 +9.1,3476.087391,3379.423634,3197.589263,3027.976988,2873.391704,2736.588506,2620.418824,2527.771273,2461.376552,2423.505521,2415.64542,2438.22778,2490.492331,2570.568277,2675.774134,2803.012101,2949.126029,3111.168471,3286.509429,3472.871109,3570.532019 +9.2,3480.688288,3383.973973,3202.123899,3032.460173,2877.82051,2740.976512,2624.793391,2532.1691,2465.84028,2428.079553,2420.369761,2443.132118,2495.59189,2575.864112,2681.25846,2808.674533,2954.960863,3117.178397,3292.702288,3479.266379,3577.069992 +9.3,3485.319271,3388.55597,3206.694109,3036.980546,2882.287577,2745.403229,2629.206536,2536.605174,2470.341999,2432.691743,2425.132973,2448.0762,2500.731739,2581.200515,2686.783833,2814.379332,2960.840933,3123.237705,3298.949686,3485.723414,3583.674719 +9.4,3490.001643,3393.191001,3211.321441,3041.559686,2886.814462,2749.890262,2633.679901,2541.101157,2474.903379,2437.363738,2429.956662,2453.081595,2505.933465,2586.599193,2692.372175,2820.148737,2966.788823,3129.369214,3305.274682,3492.265568,3590.369731 +9.5,3494.780449,3397.924145,3216.05111,3046.242787,2891.446265,2754.482669,2638.258513,2545.702055,2479.569436,2442.140589,2434.885943,2458.193551,2511.242568,2592.106039,2698.069892,2826.02978,2972.852161,3135.621017,3311.725789,3498.94177,3597.20419 +9.6,3499.706684,3402.80642,3220.934237,3051.080909,2896.233866,2759.231189,2642.992979,2550.458344,2484.390548,2447.072603,2439.971099,2463.462406,2516.709573,2597.771929,2703.928352,2832.074424,2979.083488,3142.046094,3318.356407,3505.805834,3604.232147 +9.7,3504.817205,3407.874741,3226.007881,3056.111103,2901.214186,2764.172645,2647.920034,2555.406668,2489.403276,2452.196259,2445.248526,2468.924514,2522.370904,2603.633499,2709.984528,2838.320094,2985.520641,3148.682596,3325.205016,3512.896589,3611.492634 +9.8,3510.121524,3413.138746,3231.281917,3061.343376,2906.397266,2769.317163,2653.049915,2560.557354,2494.618017,2457.521971,2450.728588,2474.590162,2528.236827,2609.701086,2716.248928,2844.777552,2992.174602,3155.541657,3332.282955,3520.225645,3618.997414 +9.9,3515.601449,3418.580414,3236.738612,3066.760245,2911.765788,2774.647638,2658.365766,2565.893758,2500.018278,2463.033288,2456.394737,2480.442611,2534.290401,2615.957598,2722.704382,2851.429632,2999.028167,3162.60601,3339.573011,3527.775955,3626.729533 +10,3521.225837,3424.166445,3242.34263,3072.326708,2917.285027,2780.129665,2663.833536,2571.382126,2505.570506,2468.696699,2462.213309,2486.447894,2540.497305,2622.368376,2729.315951,2858.241179,3006.045932,3169.840028,3347.039489,3535.511911,3634.653438 +10.1,3525.904213,3428.830359,3247.10869,3077.186019,2922.237181,2785.177813,2668.984178,2576.64819,2510.970153,2474.250098,2467.93585,2492.341291,2546.545596,2628.542064,2735.57927,2864.559779,3012.391168,3176.18609,3353.368162,3541.828734,3641.009457 +10.2,3527.903592,3430.819775,3249.199012,3079.363014,2924.493425,2787.510851,2671.393674,2579.138566,2513.549651,2476.92807,2470.717101,2495.218655,2549.497563,2631.538042,2738.587019,2867.552498,3015.349849,3179.095259,3356.220421,3544.639499,3643.84362 +10.3,3525.496966,3428.414798,3246.904852,3077.17057,2922.397586,2785.512358,2669.493327,2577.338912,2511.853913,2475.337432,2469.225721,2493.807536,2548.133975,2630.182422,2737.201585,2866.10893,3013.830812,3177.489695,3354.528005,3542.883883,3642.097487 +10.4,3519.127058,3422.058193,3240.669197,3071.056184,2916.404696,2779.647728,2663.761734,2571.743833,2506.39637,2470.01331,2464.02145,2488.695235,2543.072457,2625.125308,2732.1066,2860.945667,3008.581124,3172.142744,3349.084852,3537.370232,3636.584841 +10.5,3511.251619,3414.199799,3232.927305,3063.434645,2908.902093,2772.270379,2656.513264,2564.625167,2499.404722,2463.139551,2457.246199,2481.984927,2536.381437,2618.404651,2725.31381,2854.052339,3001.572264,3165.011866,3341.838812,3530.042089,3629.249552 +10.6,3504.71297,3407.674,3226.5015,3057.111571,2902.674098,2766.140251,2650.482798,2558.694654,2493.572032,2457.397127,2451.576824,2476.357728,2530.754015,2612.73166,2719.556465,2848.185659,2995.58347,3158.896018,3335.604363,3523.724953,3622.923501 +10.7,3501.450425,3404.419522,3223.336831,3054.043442,2899.692856,2763.249081,2647.685791,2555.995912,2490.974859,2454.900547,2449.170628,2474.017917,2528.444324,2610.411328,2717.189223,2845.746432,2993.056086,3156.269886,3332.881178,3520.934796,3620.130576 +10.8,3502.264031,3405.234323,3224.228565,3055.021386,2900.744287,2764.376964,2648.896754,2557.298967,2492.380655,2456.417277,2450.798106,2475.742129,2530.237978,2612.240453,2719.021385,2847.556684,2994.824083,3157.977816,3334.521747,3522.529625,3621.731616 +10.9,3506.515184,3409.479501,3228.534322,3059.396304,2905.169719,2768.852653,2653.428792,2561.898049,2497.061394,2461.193658,2455.676818,2480.716563,2535.28814,2617.338653,2724.139837,2852.672675,2999.916563,3163.026534,3339.516221,3527.489282,3626.702223 +11,3512.217981,3415.173442,3234.277214,3065.197368,2911.006185,2774.722173,2659.337146,2567.856605,2503.086388,2467.301391,2461.876675,2487.005079,2541.648889,2623.747493,2730.572138,2859.107675,3006.333461,3169.404729,3345.844879,3533.788496,3633.013564 +11.1,3517.002454,3419.9527,3239.103935,3070.085928,2915.934355,2779.688948,2664.349814,2572.92704,2508.230198,2472.533144,2467.203162,2492.420256,2547.134513,2629.278524,2736.123916,2864.659508,3011.864328,3174.894479,3351.284014,3539.199507,3638.434656 +11.2,3519.312887,3422.264002,3241.463288,3072.512724,2918.407234,2782.208008,2666.922945,2575.564863,2510.944951,2475.334135,2470.090682,2495.381911,2550.147135,2632.314128,2739.157013,2867.669925,3014.832637,3177.803999,3354.130497,3542.011856,3641.251262 +11.3,3518.858599,3421.816066,3241.062981,3072.182881,2918.126095,2781.975274,2666.745564,2575.450625,2510.901056,2475.362942,2470.184418,2495.520573,2550.30179,2632.453555,2739.25517,2867.707983,3014.794338,3177.678403,3353.921449,3541.757601,3640.993626 +11.4,3516.490961,3419.458697,3238.752135,3069.945216,2915.94197,2779.844385,2664.674636,2573.445812,2508.966115,2473.495207,2468.37016,2493.73418,2548.510155,2630.62314,2737.35942,2865.72854,3012.716572,3175.494995,3351.641879,3539.42659,3638.654506 +11.5,3513.846287,3416.825048,3236.161689,3067.428369,2913.483408,2777.444101,2662.340099,2571.18348,2506.779153,2471.37954,2466.310126,2491.702465,2546.472665,2628.546052,2735.216219,2863.500348,3010.388144,3173.059284,3349.109949,3536.845006,3636.06481 +11.6,3512.687496,3415.673624,3235.046411,3066.380908,2912.490641,2776.504688,2661.461604,2570.373334,2506.041887,2470.712741,2465.70004,2491.124105,2545.894581,2627.936919,2734.551168,2862.760367,3009.55676,3172.128233,3348.089824,3535.781635,3634.996774 +11.7,3514.091794,3417.078925,3236.478525,3067.870937,2914.026196,2778.082035,2663.08794,2572.057441,2507.790852,2472.527706,2467.571544,2493.032024,2547.812408,2629.837624,2736.412578,2864.563641,3011.283932,3173.769005,3349.653133,3537.31085,3636.526822 +11.8,3518.023593,3421.005895,3240.424929,3071.867612,2918.062111,2782.151723,2667.198778,2576.220059,2512.015278,2476.818904,2471.924559,2497.431724,2552.237249,2634.264761,2740.82221,2868.936613,3015.600266,3178.015745,3353.836776,3541.470978,3640.693811 +11.9,3523.507971,3426.481901,3245.91572,3077.404203,2923.635536,2787.755365,2672.840229,2581.911234,2517.767905,2482.639963,2477.811502,2503.372306,2558.213061,2640.255816,2746.810308,2874.902199,3021.522009,3183.879218,3359.64747,3547.265769,3646.499496 +12,3529.119904,3432.084637,3251.53055,3083.062294,2929.330046,2793.478408,2678.598809,2587.716954,2523.631736,2488.567744,2483.799628,2509.408102,2564.278507,2646.331979,2752.879862,2880.945709,3027.518591,3189.815757,3365.531772,3553.135196,3652.380088 +12.1,3533.543181,3436.500639,3255.958622,3087.534551,2933.842333,2798.021895,2683.179516,2592.344971,2528.315226,2493.308636,2488.590147,2514.232069,2569.115673,2651.162587,2757.686483,2885.70917,3032.219705,3194.444828,3370.101446,3557.685807,3656.939013 +12.2,3536.087993,3439.041795,3258.514311,3090.139191,2936.495289,2800.714056,2685.916085,2595.134197,2531.161627,2496.208956,2491.530916,2517.192023,2572.070849,2654.091192,2760.570105,2888.52856,3034.957605,3197.095567,3372.683223,3560.242604,3659.50005 +12.3,3536.952553,3439.905804,3259.395251,3091.074266,2937.48725,2801.753454,2687.007234,2596.28355,2532.370244,2497.468692,2492.823006,2518.490492,2573.348296,2655.323881,2761.738534,2889.613307,3035.943227,3197.980255,3373.490371,3561.019467,3660.27753 +12.4,3537.056078,3440.009643,3259.516309,3091.252262,2937.727447,2802.045498,2687.354359,2596.69081,2532.836313,2497.982164,2493.361788,2519.025901,2573.851194,2655.769756,2762.107339,2889.885512,3036.104803,3198.032401,3373.460379,3560.956527,3660.213432 +12.5,3537.570591,3440.522821,3260.044957,3091.838496,2938.378442,2802.749733,2688.114223,2597.510884,2533.714594,2498.906333,2494.309142,2519.967708,2574.758802,2656.619341,2762.878891,2890.559233,3036.667135,3198.485936,3373.834036,3561.299044,3660.555749 +12.6,3539.429035,3442.376424,3261.910796,3093.761056,2940.366451,2804.790453,2690.209547,2599.665803,2535.927925,2501.166838,2496.595766,2522.253875,2577.018166,2658.829942,2765.021199,2892.613018,3038.618483,3200.337391,3375.614078,3563.053725,3662.313489 +12.7,3542.985836,3445.924146,3265.466536,3097.370293,2944.039045,2808.513364,2693.984129,2603.497627,2539.817084,2505.103882,2500.562146,2526.226044,2580.972849,2662.747561,2768.883003,2896.398532,3042.313418,3203.943975,3379.159662,3566.580885,3665.847657 +12.8,3547.916034,3450.841673,3270.387816,3102.339742,2949.067463,2813.589207,2699.108023,2608.675345,2545.049502,2510.382734,2505.870755,2531.543296,2586.278059,2668.023199,2774.11103,2901.558585,3047.391446,3208.942631,3384.10571,3571.513956,3670.790756 +12.9,3553.390757,3456.302092,3275.849357,3107.846285,2954.631153,2819.200202,2704.766027,2614.385599,2550.812446,2516.189692,2511.705107,2537.384573,2592.106632,2673.822445,2779.863108,2907.243496,3052.99622,3214.471554,3389.586138,3576.983848,3676.27177 +13,3558.471026,3461.36856,3280.916172,3112.95747,2959.800713,2824.420239,2710.035142,2619.707723,2556.186272,2521.604397,2517.142141,2542.822131,2597.524406,2679.203416,2785.18902,2912.494939,3058.162164,3219.559171,3394.624636,3582.010973,3681.309012 +13.1,3562.506019,3465.39165,3284.939992,3117.026685,2963.931497,2828.606657,2714.274409,2624.00176,2560.530976,2525.985492,2521.537683,2547.207514,2601.877358,2683.505528,2789.421192,2916.638592,3062.20894,3223.520125,3398.531835,3585.903252,3685.208815 +13.2,3565.363112,3468.238977,3287.788649,3119.9223,2966.892558,2831.62911,2717.35395,2627.138042,2563.716832,2529.202925,2524.761059,2550.409109,2605.032588,2686.59425,2792.423329,2919.536528,3064.997225,3226.213906,3401.166101,3588.518311,3687.828456 +13.3,3567.427281,3470.294705,3289.845819,3122.027708,2969.067103,2833.870594,2719.656678,2629.499702,2566.127751,2531.64219,2527.200224,2552.818133,2607.38516,2688.868765,2794.598838,2921.596317,3066.938416,3228.055035,3402.9441,3590.274273,3689.587017 +13.4,3569.402106,3472.260885,3291.812321,3124.042385,2971.153161,2836.027569,2721.87769,2631.781057,2568.458306,2533.999552,2529.554735,2555.138953,2609.645452,2691.046199,2796.671964,2923.549263,3068.770296,3229.78665,3404.612834,3591.920757,3691.235795 +13.5,3571.995177,3474.843532,3294.392693,3126.669001,2973.851291,2838.798264,2724.713022,2634.676484,2571.40222,2536.969489,2532.521415,2558.072276,2612.519306,2693.838353,2799.360948,2926.120094,3071.223612,3232.144481,3406.911655,3594.199577,3693.518204 +13.6,3575.623928,3478.459173,3298.002545,3130.321884,2977.574402,2842.59402,2728.572527,2638.594682,2575.367649,2540.960496,2536.510082,2562.030186,2616.421826,2697.663873,2803.088344,2929.73539,3074.728741,3235.562024,3410.276282,3597.547956,3696.872416 +13.7,3580.271511,3483.091044,3302.625125,3134.984109,2982.305459,2847.397662,2733.438872,2643.518155,2580.336953,2545.95485,2541.502988,2566.994944,2621.33527,2702.505001,2807.836532,2934.377843,3079.268783,3240.022643,3414.690132,3601.949344,3701.281861 +13.8,3585.537879,3488.339996,3307.861996,3140.25789,2987.647502,2852.813034,2738.916512,2649.051586,2585.914472,2551.555852,2547.101603,2572.565395,2626.855152,2707.953464,2813.193407,2939.631794,3084.424966,3245.104842,3419.729505,3606.978572,3706.320427 +13.9,3590.837808,3493.622083,3313.130311,3145.561562,2993.020193,2858.261104,2744.427516,2654.617555,2591.52241,2557.184245,2552.723997,2578.155718,2632.390694,2713.412818,2818.556723,2944.889485,3089.584599,3250.191643,3424.774031,3612.013022,3711.364104 +14,3595.654744,3498.421896,3317.915799,3150.382195,2997.910505,2863.228809,2749.460311,2659.70551,2596.650492,2562.329087,2557.857472,2583.250352,2637.422455,2718.359074,2823.39776,2949.617641,3094.210261,3254.741931,3429.279664,3616.506733,3715.865738 +14.1,3599.743521,3502.494782,3321.974394,3154.476462,3002.07546,2867.47354,2753.773087,2664.074186,2601.057647,2566.749084,2562.260042,2587.606095,2641.705507,2722.545254,2827.467461,2953.565231,3098.04908,3258.501044,3432.990293,3620.202698,3719.56778 +14.2,3603.202852,3505.939227,3325.404568,3157.942892,3005.613729,2871.094133,2757.46484,2667.822801,2604.843452,2570.544374,2566.032599,2591.324722,2645.342535,2726.075002,2830.870524,2956.837983,3101.2076,3261.575944,3436.013143,3623.208416,3722.577955 +14.3,3606.401866,3509.123531,3328.574006,3161.148467,3008.891555,2874.456102,2760.900456,2671.315962,2608.372805,2574.080898,2569.542954,2594.776648,2648.707116,2729.325504,2833.988014,2959.820768,3104.074033,3264.357397,3438.740929,3625.917992,3725.291261 +14.4,3609.803408,3512.50952,3331.943687,3164.553141,3012.367756,2878.017135,2764.536628,2675.009801,2612.10198,2577.815985,2573.250488,2598.424224,2652.2653,2732.767095,2837.294888,2962.993081,3107.131871,3267.332026,3441.662702,3628.822176,3728.199535 +14.5,3613.766943,3516.455859,3335.871521,3168.513821,3016.398091,2882.131828,2768.726876,2679.257093,2616.383571,2582.102766,2577.509664,2602.623982,2656.376289,2736.762179,2841.157089,2966.724382,3110.753656,3270.874785,3445.15533,3632.29916,3731.681796 +14.6,3618.411322,3521.081144,3340.475804,3173.148312,3021.099778,2886.916812,2773.587237,2684.173391,2621.332847,2587.056491,2582.435997,2607.491944,2661.156821,2741.428503,2845.693607,2971.134934,3115.0607,3275.107717,3449.341502,3636.472073,3735.861435 +14.7,3623.589758,3526.238919,3345.61031,3178.310536,3026.326866,2892.226286,2778.971948,2689.612828,2626.803665,2592.530498,2587.882039,2612.879584,2666.457072,2746.614943,2850.752125,2976.071307,3119.898424,3279.875151,3454.06481,3641.183987,3740.581173 +14.8,3628.975624,3531.603283,3350.949755,3183.675859,3031.755412,2897.737023,2784.558325,2695.252941,2632.473333,2598.201283,2593.522819,2618.459795,2671.94727,2751.988852,2855.997123,2981.195179,3124.925797,3284.833662,3458.980086,3646.088532,3745.493865 +14.9,3634.212404,3536.818504,3356.139124,3188.890096,3037.032129,2903.096681,2789.99478,2700.742551,2637.990585,2603.716847,2599.004875,2623.876913,2677.268959,2757.188729,2861.063989,2986.138864,3129.772127,3289.60992,3463.71207,3650.809115,3750.222081 +15,3639.060496,3541.645504,3360.939874,3193.715387,3041.919904,2908.068954,2795.045702,2705.846504,2643.120407,2608.841884,2604.092112,2628.893531,2682.183029,2761.973611,2865.709856,2990.65753,3134.190543,3293.955245,3468.010771,3655.094846,3754.51438 +15.1,3642.247719,3544.82715,3364.144635,3197.036679,3045.429986,2911.816113,2799.027587,2710.017897,2647.428209,2613.224884,2608.483239,2633.223285,2686.381486,2765.976821,2869.471912,2994.154405,3137.41222,3296.890664,3470.648065,3657.425967,3756.692557 +15.2,3641.812007,3544.39765,3363.747038,3196.760699,3045.346116,2911.973557,2799.425635,2710.609433,2648.155038,2614.019731,2609.272936,2633.93309,2686.93835,2766.317406,2869.554275,2993.959698,3136.934215,3296.119901,3469.572952,3656.03583,3755.140168 +15.3,3636.963042,3539.565149,3358.946277,3192.074712,3040.840917,2907.694849,2795.372906,2706.73537,2644.396124,2610.301975,2605.515254,2630.05205,2682.852911,2761.95932,2864.880538,2988.953622,3131.593783,3290.442178,3463.555672,3649.678063,3748.604503 +15.4,3628.816952,3531.442985,3350.851854,3184.084791,3033.016479,2900.077517,2787.962126,2699.48435,2637.238015,2603.159035,2598.302245,2622.681123,2675.239445,2754.034089,2856.602166,2980.308557,3122.583351,3281.067665,3453.820497,3639.58694,3738.324616 +15.5,3619.733322,3522.388805,3341.826018,3175.164084,3024.26177,2891.530359,2779.62504,2691.313776,2629.166701,2595.108399,2590.185611,2614.408423,2666.723813,2745.205326,2847.418892,2970.757122,3112.663978,3270.780806,3443.169714,3628.577274,3727.122619 +15.6,3612.548302,3515.231115,3334.686952,3168.117538,3017.36612,2884.82603,2773.118336,2684.967278,2622.917956,2588.884721,2583.906395,2607.988799,2660.081156,2738.273174,2840.158262,2963.154269,3104.715978,3262.483771,3434.522615,3619.58041,3717.937106 +15.7,3609.213205,3511.916546,3331.375606,3164.87877,3014.254325,2881.879287,2770.345792,2682.337269,2620.373375,2586.360033,2581.328807,2605.280632,2657.166016,2735.089974,2836.671474,2959.350586,3100.58964,3258.02695,3429.730077,3614.448396,3712.622536 +15.8,3609.975415,3512.691903,3332.137879,3165.692307,3015.169688,2882.932718,2771.549986,2683.66722,2621.778655,2587.783819,2582.707793,2606.546037,2658.249318,2735.936721,2837.250229,2959.64837,3100.597147,3257.731231,3429.119824,3613.513484,3711.513115 +15.9,3613.491037,3516.21735,3335.640112,3169.232651,3018.796935,2886.682678,2775.439201,2687.676415,2625.862211,2591.890966,2586.78159,2610.523499,2662.067169,2739.54515,2840.620536,2962.767224,3103.45186,3260.30463,3431.395678,3615.476492,3713.307392 +16,3617.646983,3520.383589,3339.775613,3173.394645,3023.031717,2891.024507,2779.906601,2692.253067,2630.503847,2596.548927,2591.401248,2615.044085,2666.428102,2743.699901,2844.543037,2966.444925,3106.871157,3263.447696,3434.245402,3618.016571,3715.679375 +16.1,3620.376464,3523.127987,3342.486314,3176.124891,3025.825391,2893.913705,2782.91018,2695.354801,2633.656968,2599.702328,2594.497798,2618.020794,2669.22361,2746.268696,2846.860734,2968.500237,3108.651698,3264.938462,3435.432691,3618.887807,3716.377811 +16.2,3620.431914,3523.205994,3342.532955,3176.190843,3025.953515,2894.134761,2783.242356,2695.781298,2634.128302,2600.163025,2594.885972,2618.269026,2669.267853,2746.062837,2846.380805,2967.735429,3107.590809,3263.569827,3433.74683,3616.876893,3714.18753 +16.3,3617.861841,3520.666196,3339.9664,3173.6465,3023.474048,2891.750166,2780.969012,2693.602089,2631.992752,2598.011382,2592.651564,2615.879916,2666.657135,2743.183329,2843.20818,2964.258465,3103.798805,3259.453848,3429.301106,3612.098001,3709.223393 +16.4,3613.877653,3516.716807,3335.992156,3169.693663,3019.584375,2887.952459,2777.277971,2690.000964,2628.431336,2594.427441,2588.975719,2612.037854,2662.580944,2738.825932,2838.545307,2959.27828,3098.490631,3253.810594,3423.319678,3605.778386,3702.715192 +16.5,3610.17462,3513.049181,3332.298299,3166.016368,3015.964147,2884.417021,2773.84119,2686.648018,2625.114538,2591.084955,2585.538601,2608.432507,2658.741019,2734.706046,2834.121746,2954.538152,3093.422144,3248.406612,3417.577506,3599.698952,3696.447816 +16.6,3608.18658,3511.094183,3330.313581,3164.041007,3014.037583,2882.566552,2772.081094,2684.967188,2623.470104,2589.418212,2583.783959,2606.519887,2656.607911,2732.310111,2831.440141,2951.556329,3090.125896,3244.786599,3413.628818,3595.420457,3691.985889 +16.7,3608.574574,3511.511268,3330.695882,3164.423135,3014.457561,2883.051273,2772.645603,2685.604704,2624.143397,2590.072803,2584.358867,2606.949902,2656.835564,2732.296917,2831.1645,2951.002107,3089.276316,3243.62954,3412.156357,3593.628253,3690.016351 +16.8,3611.030312,3513.992456,3333.137137,3166.853774,3016.913559,2885.558652,2775.21971,2688.242459,2626.8124,2592.721964,2586.931095,2609.384393,2659.079673,2734.315958,2832.938276,2952.513415,3090.50672,3244.565101,3412.787214,3593.947676,3690.163556 +16.9,3614.460958,3517.44723,3336.549673,3170.248287,3020.324032,2889.010172,2778.727451,2691.805993,2630.402479,2596.288829,2590.419405,2612.73586,2662.244958,2737.263092,2835.647934,2954.967571,3092.686249,3246.455579,3414.378478,3595.232101,3691.278458 +17,3617.513135,3520.525248,3339.587283,3173.265423,3023.353095,2892.07543,2781.843462,2694.973831,2633.594148,2599.453481,2593.50088,2615.676013,2664.995755,2739.793733,2837.939083,2957.000387,3094.441765,3247.920206,3415.543466,3596.090581,3691.967292 +17.1,3619.159831,3522.201618,3341.228,3174.886727,3024.985857,2893.742935,2783.559069,2696.739049,2635.380625,2601.207308,2595.163035,2617.186649,2666.306543,2740.873798,2838.768368,2957.559343,3094.712391,3247.89098,3415.208668,3595.44573,3691.150335 +17.2,3619.062595,3522.138478,3341.135093,3174.777015,3024.888612,2893.68034,2783.543024,2696.77111,2635.431481,2601.219249,2595.073464,2616.933391,2665.840355,2740.163108,2837.791974,2956.296995,3093.147374,3246.014306,3413.018318,3592.940269,3688.469512 +17.3,3617.618169,3520.731746,3339.704136,3173.332009,3023.457362,2892.284198,2782.19284,2695.468357,2634.146566,2599.892094,2593.638677,2615.327198,2664.013011,2738.082389,2835.435322,2953.64322,3090.180599,3242.727434,3409.412307,3589.015874,3684.367615 +17.4,3615.734298,3518.887198,3337.838859,3171.453485,3021.591848,2890.452458,2780.405294,2693.725837,2632.420629,2598.123621,2591.761347,2613.277387,2661.741752,2735.557502,2832.633094,2950.541357,3086.763374,3238.988489,3405.354144,3584.639759,3679.814117 +17.5,3614.418117,3517.609653,3336.541059,3170.139823,3020.286623,2889.175855,2779.16777,2692.52852,2631.237621,2596.898513,2590.428803,2611.775786,2660.024347,2733.59308,2830.397266,2948.01085,3083.922172,3235.830109,3401.881403,3580.852945,3675.852257 +17.6,3614.351071,3517.578975,3336.488323,3170.06599,3020.21367,2889.123388,2779.146635,2692.540847,2631.261052,2596.880559,2590.306492,2611.490856,2659.533325,2732.866418,2829.410327,2946.739604,3082.350078,3233.949998,3399.695493,3578.359363,3673.187511 +17.7,3615.646852,3518.908614,3337.793591,3171.344448,3021.484859,2890.406355,2780.452748,2693.873445,2632.60153,2598.180559,2591.505715,2612.53471,2660.38179,2733.491702,2829.787673,2946.844436,3082.16538,3233.467865,3398.91725,3577.280511,3671.941706 +17.8,3617.873109,3521.167095,3340.026268,3173.545684,3023.671649,2892.597025,2782.658912,2696.099211,2634.831407,2600.369539,2593.595416,2614.473532,2662.13253,2735.027864,2831.084293,2947.876706,3082.916259,3233.929337,3399.090257,3577.158413,3671.655888 +17.9,3620.277349,3523.603472,3342.437244,3175.92284,3026.029401,2894.952705,2785.023859,2698.477472,2637.209464,2602.704349,2595.829108,2616.556186,2664.028571,2736.711242,2832.529557,2949.059126,3083.819413,3234.546075,3399.422125,3577.197741,3671.532974 +18,3622.110884,3525.470653,3344.28162,3177.733866,3027.819083,2896.737234,2786.813867,2700.276198,2639.004318,2604.452956,2597.47275,2618.045281,2665.327924,2737.794295,2833.369982,2949.632425,3084.110246,3234.548957,3399.139999,3576.622927,3670.795762 +18.1,3622.925958,3526.321869,3345.114168,3178.535732,3028.600106,2897.512431,2787.592955,2701.061203,2639.783022,2605.182949,2598.093698,2618.507116,2665.594964,2737.838784,2833.164403,2949.152541,3083.341974,3233.488845,3397.792687,3574.981284,3668.99067 +18.2,3622.725807,3526.160322,3344.938197,3178.332173,3028.376744,2897.283082,2787.366403,2700.838271,2639.551951,2604.901394,2597.699788,2617.950262,2664.838801,2736.854158,2831.922588,2947.629582,3081.524994,3231.376378,3395.390838,3572.283489,3666.128455 +18.3,3621.913542,3525.388208,3344.154704,3177.522978,3027.547576,2896.446563,2786.530577,2700.003169,2638.70694,2604.005013,2596.689465,2616.775561,2663.463102,2735.247193,2830.054656,2945.47705,3079.07595,3228.63091,3392.355794,3568.952355,3662.632881 +18.4,3621.087388,3524.602439,3343.358786,3176.701242,3026.703672,2895.591998,2785.673022,2699.142527,2637.834332,2603.081057,2595.652463,2615.576247,2662.065341,2733.620133,2828.168013,2943.307544,3076.612284,3225.874061,3389.312353,3565.614995,3659.13248 +18.5,3620.786862,3524.341351,3343.087043,3176.401565,3026.37757,2895.249885,2785.322474,2698.783861,2637.459426,2602.653698,2595.114813,2614.881182,2661.177955,2732.509579,2826.803864,2941.666966,3074.684333,3223.660014,3386.817623,3562.830662,3656.187779 +18.6,3621.287142,3524.879426,3343.612732,3176.895677,3026.839326,2895.68849,2785.74547,2699.192213,2637.845953,2602.985913,2595.339542,2614.953871,2661.065256,2732.180987,2826.229193,2940.82402,3073.562543,3222.260754,3385.14473,3560.873393,3654.073386 +18.7,3622.511736,3526.140283,3344.859494,3178.107235,3028.012631,2896.831418,2786.865407,2700.290644,2638.916548,2603.99988,2596.248298,2615.715242,2661.647277,2732.553474,2826.362377,2940.696498,3073.164278,3221.593261,3384.210238,3559.659535,3652.70549 +18.8,3624.099083,3527.763117,3346.467605,3179.677897,3029.540699,2898.323344,2788.328171,2701.725862,2640.318264,2605.342487,2597.487194,2616.809913,2662.566496,2733.267024,2826.840861,2940.919391,3073.122309,3221.288299,3383.643186,3558.81697,3651.711225 +18.9,3625.578011,3529.277719,3347.968288,3181.140691,3030.958569,2899.701171,2789.672171,2703.037234,2641.590764,2606.552982,2598.594229,2617.773683,2663.355685,2733.850892,2827.190268,2941.014752,3072.955404,3220.861672,3382.956906,3557.85736,3650.601232 +19,3626.562289,3530.298634,3348.977308,3182.112961,3031.885368,2900.585698,2790.519562,2703.847804,2642.357447,2607.254571,2599.191732,2618.227173,2663.633044,2733.920445,2827.023018,2940.592074,3072.270335,3219.917633,3381.753554,3556.381476,3648.975447 +19.1,3626.890272,3530.66455,3349.333979,3182.434927,3032.162448,2900.8194,2790.713813,2704.001856,2642.463247,2607.292725,2599.125464,2618.016018,2663.243697,2733.320118,2826.182822,2939.494293,3070.909268,3218.297485,3379.873687,3554.229441,3646.673715 +19.2,3626.666433,3530.479701,3349.142297,3182.21041,3031.893599,2900.506088,2790.358793,2703.603424,2642.012594,2606.772633,2598.501635,2617.247504,2662.29606,2732.159593,2824.780733,2937.833781,3068.985748,3216.115604,3377.432329,3551.516842,3643.811939 +19.3,3626.194523,3530.047151,3348.704291,3181.740214,3031.378406,2899.94416,2789.751832,2702.949057,2641.301755,2605.990969,2597.617939,2616.220776,2661.091125,2730.742119,2823.122515,2935.918814,3066.810375,3213.684453,3374.743484,3548.558884,3640.70604 +19.4,3625.836183,3529.727722,3348.379477,3181.382249,3030.97311,2899.488218,2789.246035,2702.390716,2640.682126,2605.299298,2596.826821,2615.289744,2659.984782,2729.426077,2821.569353,2934.113419,3064.749819,3211.372876,3372.177826,3545.727634,3637.728907 +19.5,3625.862461,3529.791865,3348.437355,3181.404854,3030.944886,2899.404339,2789.106512,2702.192828,2640.417904,2604.960369,2596.390113,2614.71754,2659.241868,2728.478424,2820.390569,2932.689299,3063.077969,3209.456544,3370.012553,3543.301425,3635.159518 +19.6,3626.360584,3530.326551,3348.964382,3181.893809,3031.378781,2899.776788,2789.41669,2702.438009,2640.591035,2605.054815,2596.387301,2614.583463,2658.941653,2727.978675,2819.666116,2931.726928,3061.875788,3208.016757,3368.329359,3541.362277,3633.080078 +19.7,3627.215034,3531.216457,3349.84549,3182.734359,3032.160401,2900.491494,2790.062658,2703.012322,2641.087388,2605.468139,2596.703272,2614.771492,2658.967032,2727.808643,2819.276748,2931.106045,3061.022013,3206.931293,3367.005368,3539.786867,3631.366999 +19.8,3628.172031,3532.208323,3350.82828,3183.675246,3033.0398,2901.299855,2790.796978,2703.669228,2641.661006,2605.954587,2597.092002,2615.034825,2659.070038,2727.719029,2818.971713,2930.574406,3060.26289,3205.944962,3365.784321,3538.318159,3629.762746 +19.9,3628.95595,3533.027087,3351.638651,3184.443647,3033.745618,2901.931994,2791.351052,2704.141096,2642.044847,2606.247255,2597.286184,2615.10519,2658.981019,2727.438573,2818.477988,2929.857171,3059.321728,3204.779363,3364.386531,3536.675535,3627.986139 +20,3629.37942,3533.485735,3352.090191,3184.853965,3034.093184,2902.204178,2791.54192,2704.245498,2642.056752,2606.163943,2597.103198,2614.799171,2658.515488,2726.7816,2817.6086,2928.766015,3058.008791,3203.243465,3362.620021,3534.666342,3625.844136 +20.1,3629.40412,3533.546004,3352.144786,3184.868352,3034.044999,2902.079327,2791.332876,2703.946061,2641.660655,2605.668837,2596.507405,2614.081206,2657.637938,2725.712686,2816.328151,2927.265495,3056.288427,3201.301395,3360.448833,3532.254555,3623.300676 +20.2,3629.14065,3533.318253,3351.912437,3184.596429,3033.710326,2901.666451,2790.832755,2703.351576,2640.965506,2604.871258,2595.608697,2613.061976,2656.460065,2724.344738,2814.750793,2925.470932,3054.276892,3199.070229,3357.990791,3529.558527,3620.474418 +20.3,3628.792372,3533.005388,3351.595267,3184.239365,3033.289307,2901.164728,2790.239881,2702.659725,2640.168658,2603.968572,2594.604809,2611.93998,2655.181548,2722.878925,2813.079299,2923.586673,3052.179888,3196.756911,3355.453934,3526.787087,3617.574667 +20.4,3628.566671,3532.814331,3351.39939,3184.002275,3032.985967,2900.77717,2789.756388,2702.071994,2639.471281,2603.161973,2593.695452,2610.913864,2654.00227,2721.516672,2811.516746,2921.817404,3050.203497,3194.568827,3353.046777,3524.149558,3614.811224 +20.5,3628.595251,3532.876461,3351.455555,3184.015107,3032.929339,2900.631904,2789.509534,2701.714871,2638.999242,2602.576855,2593.004599,2610.106474,2653.045413,2720.381749,2810.187606,2920.288307,3048.473508,3192.632415,3350.896354,3521.773415,3612.31184 +20.6,3628.88785,3533.201456,3351.773287,3184.287213,3033.128563,2900.737884,2789.508092,2701.596947,2638.760949,2602.221392,2592.540151,2609.525511,2652.318628,2719.48182,2809.099558,2919.007027,3046.997451,3190.95522,3349.010262,3519.6663,3610.084182 +20.7,3629.340517,3533.685579,3352.249223,3184.715784,3033.481473,2900.99366,2789.651334,2701.618134,2638.656807,2601.996237,2592.202763,2609.071511,2651.722292,2718.717008,2808.152352,2917.872819,3045.674008,3189.435506,3347.286423,3517.725877,3608.025743 +20.8,3629.791284,3534.167176,3352.722252,3185.140466,3033.828554,2901.240596,2789.781441,2701.621258,2638.530021,2601.744594,2591.835262,2608.586707,2651.097914,2717.927923,2807.185549,2916.724077,3044.340391,3187.909543,3345.560331,3515.787097,3605.971146 +20.9,3630.088104,3534.494482,3353.041087,3185.410632,3034.01991,2901.329539,2789.749944,2701.458362,2638.232869,2601.318599,2591.289294,2607.92206,2650.295654,2716.963751,2806.047211,2915.407617,3042.842184,3186.221929,3343.67577,3513.693187,3603.763295 +21,3630.143854,3534.580543,3353.119093,3185.440136,3033.969961,2901.175535,2789.472541,2701.045725,2637.682056,2600.635132,2590.481706,2606.994337,2649.232184,2715.740943,2804.653432,2913.839023,3041.094436,3184.287324,3341.547054,3511.358238,3601.316137 +21.1,3629.964433,3534.431247,3352.962155,3185.234929,3033.684764,2900.784816,2788.955734,2700.390162,2636.88469,2599.701518,2589.420027,2605.811388,2647.915812,2714.268257,2803.013337,2912.027642,3039.106677,3182.115502,3339.184116,3508.792333,3598.639823 +21.2,3629.639288,3534.135843,3352.659178,3184.883513,3033.252405,2900.245102,2788.287026,2699.579098,2635.928229,2598.605329,2588.192104,2604.459583,2646.431698,2712.631785,2801.21392,2910.061249,3036.967422,3179.795704,3336.676765,3506.08572,3595.82484 +21.3,3629.300295,3533.825892,3352.341096,3184.51601,3032.802071,2899.684612,2787.593756,2698.739095,2634.938542,2597.471808,2586.92274,2603.062418,2644.902357,2710.954417,2799.37852,2908.063596,3034.800916,3177.452721,3334.150238,3503.364032,3592.99707 +21.4,3629.062301,3533.615964,3352.121917,3184.245704,3032.446223,2899.214973,2786.98684,2697.980494,2634.0255,2596.410477,2585.721328,2601.729493,2643.437917,2709.346979,2797.618684,2906.146911,3032.720116,3175.200233,3331.718804,3500.742002,3590.271515 +21.5,3628.979767,3533.560424,3352.055853,3184.126656,3032.238819,2898.890109,2786.520317,2697.357564,2633.243646,2595.476159,2584.643071,2600.516578,2642.094889,2707.866766,2795.992435,2904.369828,3030.784297,3173.098107,3329.442785,3498.280307,3587.709022 +21.6,3629.038112,3533.644696,3352.128299,3184.14425,3032.165236,2898.695389,2786.179605,2696.855771,2632.578392,2594.654081,2583.67297,2599.408517,2640.85803,2706.498435,2794.484257,2902.7166,3028.977592,3171.130404,3327.306179,3495.96293,3585.293557 +21.7,3629.165285,3533.796831,3352.267456,3184.226884,3032.154097,2898.55963,2785.893708,2696.404212,2631.958712,2593.872845,2582.73909,2598.332776,2639.654165,2705.168082,2793.0194,2901.111583,3027.223622,3169.220115,3325.231472,3493.712037,3582.947109 +21.8,3629.261511,3533.917255,3352.374115,3184.275879,3032.10736,2898.385466,2785.565965,2695.906861,2631.289,2593.036998,2581.745944,2597.193729,2638.387433,2703.779466,2791.501068,2899.457339,3025.424413,3167.26877,3323.119785,3491.428469,3580.570337 +21.9,3629.241877,3533.921241,3352.363935,3184.207457,3031.941964,2898.090634,2785.11499,2695.283196,2630.48944,2592.06724,2580.614638,2595.912841,2636.978219,2702.251747,2789.848371,2897.672799,3023.498761,3165.194984,3320.889566,3489.030551,3578.081454 +22,3629.072234,3533.77471,3352.202976,3183.987898,3031.624474,2897.641997,2784.507959,2694.500656,2629.527556,2590.930993,2579.312364,2594.457016,2635.390976,2700.54685,2788.022697,2895.718822,3021.407132,3162.958862,3318.500662,3486.477971,3575.440066 diff --git a/tests/data/currents_mdc/tension_c2/tension.dat b/tests/data/currents_mdc/tension_c2/tension.dat new file mode 100644 index 00000000..8b4c0d64 --- /dev/null +++ b/tests/data/currents_mdc/tension_c2/tension.dat @@ -0,0 +1,25 @@ +--------------------- MoorDyn Input File ------------------------------------ +Current tension parity deck (MoorDyn-C Currents 2): a time-varying cross-flow profile +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +rope 0.3 80.0 1.0e7 -1.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0.0 -30.0 -20.0 0 0 0 0 +2 Vessel 0.0 30.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 rope 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +22.0 TMax simulation length (s) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +300.0 TmaxIC max time for ic gen (s) +1.0e-12 threshIC convergence threshold for ic gen (-) +0 WaveKin MoorDyn-C water kinematics mode (-) +2 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/data/currents_mdc/tension_c5/current_profile_4d.txt b/tests/data/currents_mdc/tension_c5/current_profile_4d.txt new file mode 100644 index 00000000..14e70669 --- /dev/null +++ b/tests/data/currents_mdc/tension_c5/current_profile_4d.txt @@ -0,0 +1,78 @@ +2 3 3 4 +-20.0 20.0 +-40.0 0.0 40.0 +-50.0 -25.0 0.0 +0.0 6.0 15.0 25.0 +x y z t ux uy uz +-20.0 -40.0 -50.0 0.0 0.000000 0.000000 0.0 +-20.0 -40.0 -25.0 0.0 0.000000 0.000000 0.0 +-20.0 -40.0 0.0 0.0 0.000000 0.000000 0.0 +-20.0 0.0 -50.0 0.0 0.000000 0.000000 0.0 +-20.0 0.0 -25.0 0.0 0.000000 0.000000 0.0 +-20.0 0.0 0.0 0.0 0.000000 0.000000 0.0 +-20.0 40.0 -50.0 0.0 0.000000 0.000000 0.0 +-20.0 40.0 -25.0 0.0 0.000000 0.000000 0.0 +-20.0 40.0 0.0 0.0 0.000000 0.000000 0.0 +20.0 -40.0 -50.0 0.0 0.000000 0.000000 0.0 +20.0 -40.0 -25.0 0.0 0.000000 0.000000 0.0 +20.0 -40.0 0.0 0.0 0.000000 0.000000 0.0 +20.0 0.0 -50.0 0.0 0.000000 0.000000 0.0 +20.0 0.0 -25.0 0.0 0.000000 0.000000 0.0 +20.0 0.0 0.0 0.0 0.000000 0.000000 0.0 +20.0 40.0 -50.0 0.0 0.000000 0.000000 0.0 +20.0 40.0 -25.0 0.0 0.000000 0.000000 0.0 +20.0 40.0 0.0 0.0 0.000000 0.000000 0.0 +-20.0 -40.0 -50.0 6.0 0.235200 0.000000 0.0 +-20.0 -40.0 -25.0 6.0 0.285600 0.035000 0.0 +-20.0 -40.0 0.0 6.0 0.336000 0.070000 0.0 +-20.0 0.0 -50.0 6.0 0.352800 0.000000 0.0 +-20.0 0.0 -25.0 6.0 0.428400 0.035000 0.0 +-20.0 0.0 0.0 6.0 0.504000 0.070000 0.0 +-20.0 40.0 -50.0 6.0 0.470400 0.000000 0.0 +-20.0 40.0 -25.0 6.0 0.571200 0.035000 0.0 +-20.0 40.0 0.0 6.0 0.672000 0.070000 0.0 +20.0 -40.0 -50.0 6.0 0.254800 0.000000 0.0 +20.0 -40.0 -25.0 6.0 0.309400 0.035000 0.0 +20.0 -40.0 0.0 6.0 0.364000 0.070000 0.0 +20.0 0.0 -50.0 6.0 0.382200 0.000000 0.0 +20.0 0.0 -25.0 6.0 0.464100 0.035000 0.0 +20.0 0.0 0.0 6.0 0.546000 0.070000 0.0 +20.0 40.0 -50.0 6.0 0.509600 0.000000 0.0 +20.0 40.0 -25.0 6.0 0.618800 0.035000 0.0 +20.0 40.0 0.0 6.0 0.728000 0.070000 0.0 +-20.0 -40.0 -50.0 15.0 0.369600 0.000000 0.0 +-20.0 -40.0 -25.0 15.0 0.448800 0.055000 0.0 +-20.0 -40.0 0.0 15.0 0.528000 0.110000 0.0 +-20.0 0.0 -50.0 15.0 0.554400 0.000000 0.0 +-20.0 0.0 -25.0 15.0 0.673200 0.055000 0.0 +-20.0 0.0 0.0 15.0 0.792000 0.110000 0.0 +-20.0 40.0 -50.0 15.0 0.739200 0.000000 0.0 +-20.0 40.0 -25.0 15.0 0.897600 0.055000 0.0 +-20.0 40.0 0.0 15.0 1.056000 0.110000 0.0 +20.0 -40.0 -50.0 15.0 0.400400 0.000000 0.0 +20.0 -40.0 -25.0 15.0 0.486200 0.055000 0.0 +20.0 -40.0 0.0 15.0 0.572000 0.110000 0.0 +20.0 0.0 -50.0 15.0 0.600600 0.000000 0.0 +20.0 0.0 -25.0 15.0 0.729300 0.055000 0.0 +20.0 0.0 0.0 15.0 0.858000 0.110000 0.0 +20.0 40.0 -50.0 15.0 0.800800 0.000000 0.0 +20.0 40.0 -25.0 15.0 0.972400 0.055000 0.0 +20.0 40.0 0.0 15.0 1.144000 0.110000 0.0 +-20.0 -40.0 -50.0 25.0 0.168000 0.000000 0.0 +-20.0 -40.0 -25.0 25.0 0.204000 0.025000 0.0 +-20.0 -40.0 0.0 25.0 0.240000 0.050000 0.0 +-20.0 0.0 -50.0 25.0 0.252000 0.000000 0.0 +-20.0 0.0 -25.0 25.0 0.306000 0.025000 0.0 +-20.0 0.0 0.0 25.0 0.360000 0.050000 0.0 +-20.0 40.0 -50.0 25.0 0.336000 0.000000 0.0 +-20.0 40.0 -25.0 25.0 0.408000 0.025000 0.0 +-20.0 40.0 0.0 25.0 0.480000 0.050000 0.0 +20.0 -40.0 -50.0 25.0 0.182000 0.000000 0.0 +20.0 -40.0 -25.0 25.0 0.221000 0.025000 0.0 +20.0 -40.0 0.0 25.0 0.260000 0.050000 0.0 +20.0 0.0 -50.0 25.0 0.273000 0.000000 0.0 +20.0 0.0 -25.0 25.0 0.331500 0.025000 0.0 +20.0 0.0 0.0 25.0 0.390000 0.050000 0.0 +20.0 40.0 -50.0 25.0 0.364000 0.000000 0.0 +20.0 40.0 -25.0 25.0 0.442000 0.025000 0.0 +20.0 40.0 0.0 25.0 0.520000 0.050000 0.0 diff --git a/tests/data/currents_mdc/tension_c5/ref_moordyn_c_tension.csv b/tests/data/currents_mdc/tension_c5/ref_moordyn_c_tension.csv new file mode 100644 index 00000000..2d4d68e9 --- /dev/null +++ b/tests/data/currents_mdc/tension_c5/ref_moordyn_c_tension.csv @@ -0,0 +1,222 @@ +t,T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19,T20 +0,3347.400371,3253.367737,3073.059491,2904.689961,2750.454325,2612.856668,2494.649244,2398.695686,2327.743491,2284.117533,2269.389762,2284.117594,2327.743605,2398.695849,2494.64943,2612.856879,2750.454526,2904.690164,3073.059662,3253.3679,3347.400507 +0.1,3347.401104,3253.368518,3073.060324,2904.690813,2750.455137,2612.85741,2494.649871,2398.696185,2327.74385,2284.117762,2269.389881,2284.11763,2327.743588,2398.6958,2494.649372,2612.856815,2750.454474,2904.690118,3073.059646,3253.367917,3347.400557 +0.2,3347.406887,3253.374384,3073.066253,2904.696589,2750.46055,2612.862269,2494.654019,2398.699517,2327.746317,2284.119375,2269.390698,2284.117744,2327.743104,2398.694823,2494.647995,2612.85512,2750.452534,2904.688012,3073.057465,3253.365772,3347.398458 +0.3,3347.421066,3253.388658,3073.080526,2904.710434,2750.473555,2612.87406,2494.66429,2398.708052,2327.75301,2284.124225,2269.393797,2284.119245,2327.743194,2398.693694,2494.645833,2612.852096,2750.448819,2904.683789,3073.052949,3253.361214,3347.393939 +0.4,3347.442691,3253.410416,3073.102317,2904.731683,2750.493703,2612.892605,2494.680819,2398.72228,2327.764802,2284.133595,2269.400882,2284.12427,2327.746424,2398.695402,2494.646269,2612.851491,2750.447393,2904.681778,3073.050624,3253.358893,3347.39169 +0.5,3347.471928,3253.439828,3073.131839,2904.760622,2750.521381,2612.918408,2494.704248,2398.742997,2327.782651,2284.148611,2269.413253,2284.13429,2327.754438,2398.70175,2494.651263,2612.855403,2750.450478,2904.684303,3073.052894,3253.361265,3347.394179 +0.6,3347.511208,3253.479283,3073.171394,2904.79942,2750.558579,2612.953244,2494.736102,2398.771446,2327.807505,2284.16991,2269.431231,2284.149313,2327.766933,2398.712145,2494.659949,2612.862728,2750.456765,2904.68989,3073.058168,3253.366667,3347.399713 +0.7,3347.560126,3253.528349,3073.220533,2904.847613,2750.604817,2612.996613,2494.775859,2398.807081,2327.838785,2284.196876,2269.454158,2284.168635,2327.783159,2398.72579,2494.671486,2612.872582,2750.465337,2904.697597,3073.065489,3253.374135,3347.407315 +0.8,3347.615493,3253.583843,3073.276131,2904.902192,2750.657245,2613.045869,2494.821107,2398.847752,2327.874619,2284.227926,2269.48074,2284.191246,2327.802384,2398.742213,2494.685645,2612.884956,2750.476376,2904.707769,3073.075326,3253.384213,3347.417547 +0.9,3347.675909,3253.644334,3073.33674,2904.961706,2750.71443,2613.0996,2494.870467,2398.892112,2327.913695,2284.26178,2269.509727,2284.215925,2327.823405,2398.760232,2494.701261,2612.898703,2750.488751,2904.719291,3073.08658,3253.395815,3347.429318 +1,3347.742221,3253.710615,3073.403064,2905.026758,2750.77685,2613.158148,2494.924128,2398.940186,2327.955864,2284.298107,2269.540603,2284.241965,2327.845335,2398.778784,2494.717109,2612.912452,2750.500973,2904.730582,3073.097611,3253.407261,3347.440925 +1.1,3347.81513,3253.78334,3073.475711,2905.097925,2750.84507,2613.222079,2494.982664,2398.992571,2328.001749,2284.337562,2269.574056,2284.270095,2327.868943,2398.79868,2494.734045,2612.927107,2750.513991,2904.742636,3073.109451,3253.419608,3347.453427 +1.2,3347.89593,3253.863761,3073.555901,2905.176434,2750.920352,2613.292718,2495.047497,2399.050798,2328.053012,2284.381952,2269.612052,2284.302445,2327.896527,2398.822388,2494.7547,2612.945454,2750.530734,2904.758509,3073.125261,3253.436078,3347.470059 +1.3,3347.988239,3253.955428,3073.647094,2905.265649,2751.005978,2613.373267,2495.121751,2399.117927,2328.112655,2284.43423,2269.657502,2284.341895,2327.930947,2398.852759,2494.78193,2612.970362,2750.554094,2904.781118,3073.147987,3253.45963,3347.493783 +1.4,3348.096524,3254.062732,3073.753561,2905.369718,2751.10596,2613.467605,2495.209172,2399.19757,2328.184161,2284.497757,2269.713656,2284.391598,2327.975275,2398.892796,2494.818682,2613.00474,2750.586956,2904.813346,3073.180514,3253.493149,3347.527479 +1.5,3348.223957,3254.188778,3073.87833,2905.491601,2751.223211,2613.578614,2495.312627,2399.292596,2328.270418,2284.575452,2269.783479,2284.454573,2328.032591,2398.945652,2494.868191,2613.051904,2750.632719,2904.858668,3073.226385,3253.54021,3347.574732 +1.6,3348.372796,3254.335762,3074.02353,2905.633367,2751.359769,2613.708323,2495.434157,2399.405077,2328.373539,2284.669487,2269.869208,2284.533137,2328.105301,2399.013826,2494.933048,2613.114543,2750.694167,2904.919956,3073.288541,3253.603787,3347.638528 +1.7,3348.545259,3254.505834,3074.191213,2905.796971,2751.517491,2613.8585,2495.575449,2399.536624,2328.495071,2284.781348,2269.972279,2284.628678,2328.194756,2399.098639,2495.014557,2613.193952,2750.772597,2904.99852,3073.368307,3253.685204,3347.720188 +1.8,3348.743014,3254.700595,3074.382892,2905.98382,2751.697693,2614.030374,2495.737654,2399.688318,2328.636029,2284.911988,2270.093589,2284.742045,2328.30176,2399.200863,2495.113464,2613.290864,2750.86874,2905.095099,3073.466431,3253.785197,3347.820447 +1.9,3348.967073,3254.921002,3074.599462,2906.194749,2751.901164,2614.224714,2495.921535,2399.86093,2328.797203,2285.062228,2270.233996,2284.874139,2328.427263,2399.321498,2495.230828,2613.406396,2750.983774,2905.21093,3073.584192,3253.905059,3347.940603 +2,3349.219035,3255.168601,3074.842406,2906.431171,2752.129266,2614.442843,2496.128394,2400.055757,2328.979895,2285.233386,2270.394839,2285.026329,2328.572671,2399.461994,2495.368144,2613.542097,2751.119304,2905.347672,3073.723288,3254.046495,3348.082369 +2.1,3349.5018,3255.446237,3075.114493,2906.695752,2752.384566,2614.687239,2496.360629,2400.275121,2329.186364,2285.427663,2270.578274,2285.200733,2328.740074,2399.624423,2495.52748,2613.700039,2751.277419,2905.507434,3073.885843,3254.211622,3348.247862 +2.2,3349.81902,3255.757511,3075.419249,2906.991925,2752.670406,2614.961162,2496.621425,2400.522148,2329.419684,2285.648093,2270.787305,2285.400339,2328.932456,2399.811776,2495.711845,2613.883261,2751.461193,2905.693333,3074.074994,3254.403579,3348.440226 +2.3,3350.174619,3256.106304,3075.760501,2907.32344,2752.990468,2615.268241,2496.914376,2400.800405,2329.683415,2285.898241,2271.025518,2285.628764,2329.153478,2400.027771,2495.925022,2614.095618,2751.674557,2905.909365,3074.294785,3254.626421,3348.663526 +2.4,3350.572779,3256.496755,3076.14233,2907.694298,2753.348675,2615.61233,2497.243278,2401.11365,2329.981281,2286.181817,2271.296618,2285.889725,2329.40688,2400.276183,2496.170831,2614.340983,2751.921444,2906.159519,3074.549235,3254.884175,3348.921799 +2.5,3351.017507,3256.932835,3076.568647,2908.108322,2753.748759,2615.997077,2497.611703,2401.465382,2330.316726,2286.502215,2271.603964,2286.186555,2329.695985,2400.560335,2496.452609,2614.622718,2752.205248,2906.447219,3074.84178,3255.180278,3349.218485 +2.6,3351.511951,3257.417656,3077.042522,2908.568514,2754.193652,2616.425352,2498.022468,2401.85838,2330.692496,2286.86216,2271.950268,2286.521965,2330.023509,2400.882961,2496.773118,2614.943622,2752.528809,2906.775341,3075.175311,3255.517617,3349.556478 +2.7,3352.058357,3257.953439,3077.566147,2909.077018,2754.685448,2616.899212,2498.477605,2402.29466,2331.110603,2287.263666,2272.337557,2286.898001,2330.391527,2401.246171,2497.134507,2615.30589,2752.894372,2907.14617,3075.552126,3255.898497,3349.938086 +2.8,3352.658584,3258.542019,3078.141331,2909.635595,2755.225856,2617.420323,2498.978747,2402.775826,2331.572632,2287.708309,2272.767399,2287.316229,2330.80161,2401.651546,2497.538379,2615.711153,2753.303597,2907.561387,3075.973911,3256.324598,3350.364993 +2.9,3353.314453,3259.185193,3078.769855,2910.245979,2755.816559,2617.990317,2499.527482,2403.303436,2332.08011,2288.19759,2273.241277,2287.77812,2331.25522,2402.10055,2497.986204,2616.160895,2753.757989,2908.022509,3076.442172,3256.797421,3350.838703 +3,3354.027948,3259.884923,3079.453673,2910.910091,2756.459433,2618.611038,2500.125629,2403.879286,2332.634823,2288.733289,2273.760971,2288.28546,2331.754156,2402.594998,2498.479822,2616.656989,2754.259452,2908.531458,3076.958833,3257.318889,3351.361141 +3.1,3354.801514,3260.643636,3080.195215,2911.630332,2757.156844,2619.284822,2500.7755,2404.505676,2333.239065,2289.317702,2274.328785,2288.840567,2332.300757,2403.137261,2499.021641,2617.201883,2754.810475,2909.09075,3077.526412,3257.891524,3351.934838 +3.2,3355.638208,3261.464367,3080.997524,2912.409713,2757.911762,2620.014596,2501.47999,2405.185474,2333.895683,2289.953663,2274.947548,2289.446272,2332.897866,2403.730199,2499.61455,2617.798503,2755.414018,2909.703359,3078.147886,3258.518306,3352.562776 +3.3,3356.541391,3262.350457,3081.863958,2913.251566,2758.727473,2620.803608,2502.242311,2405.92186,2334.607835,2290.644315,2275.620395,2290.105713,2333.54863,2404.376978,2500.261742,2618.450074,2756.073335,2910.372556,3078.826523,3259.202509,3353.248237 +3.4,3357.514269,3263.305097,3082.797738,2914.159091,2759.607151,2621.655,2503.065581,2406.717939,2335.378616,2291.392752,2276.350425,2290.822,2334.256179,2405.080759,2500.966414,2619.159835,2756.791703,2911.101633,3079.565621,3259.947434,3353.99453 +3.5,3358.559614,3264.331045,3083.801663,2915.135081,2760.553566,2622.571522,2503.952536,2407.576435,2336.210746,2292.201694,2277.140367,2291.597877,2335.02328,2405.844335,2501.731393,2619.930652,2757.572018,2911.893497,3080.368087,3260.755994,3354.804574 +3.6,3359.679618,3265.430482,3084.877969,2916.181769,2761.568933,2623.55537,2504.905355,2408.499518,2337.10639,2293.073304,2277.992386,2292.435514,2335.852112,2406.669902,2502.558899,2620.764766,2758.416539,2912.750405,3081.236171,3261.630438,3355.680624 +3.7,3360.875844,3266.604963,3086.028276,2917.300781,2762.654872,2624.608152,2505.925641,2409.488786,2338.067145,2294.009182,2278.908084,2293.33652,2336.744293,2407.559091,2503.450579,2621.663847,2759.326941,2913.674024,3082.171533,3262.572421,3356.624336 +3.8,3362.149392,3267.855588,3087.253758,2918.49331,2763.812576,2625.731061,2507.014591,2410.545445,2339.094226,2295.010553,2279.888699,2294.302144,2337.701088,2408.513183,2504.407735,2622.629212,2760.304553,2914.665671,3083.17548,3263.583246,3357.637017 +3.9,3363.501274,3269.183369,3088.555512,2919.760476,2765.043171,2626.925224,2508.173335,2411.670632,2340.18878,2296.078575,2280.935401,2295.333569,2338.723689,2409.533387,2505.431593,2623.662105,2761.350619,2915.726576,3084.249232,3264.664126,3358.719884 +4,3364.932738,3270.589557,3089.934879,2921.103647,2766.34803,2628.19201,2509.403243,2412.86572,2341.352185,2297.214633,2282.049579,2296.43219,2339.813503,2410.621119,2506.523584,2624.763968,2762.466578,2916.858163,3085.394203,3265.816469,3359.874348 +4.1,3366.445411,3272.075787,3091.393583,2922.52458,2767.728911,2629.533177,2510.706071,2414.132467,2342.586204,2298.420495,2283.23301,2297.599794,2340.972327,2411.778194,2507.68554,2625.936648,2763.654277,2918.062263,3086.612219,3267.042095,3361.102231 +4.2,3368.041285,3273.644059,3092.933725,2924.025409,2769.187959,2630.950862,2512.083957,2415.473015,2343.892984,2299.698315,2284.487859,2298.838559,2342.202356,2413.006826,2508.919699,2627.1824,2764.915972,2919.341122,3087.905524,3268.343243,3362.40578 +4.3,3369.722586,3275.296614,3094.557642,2925.608516,2770.727557,2632.447447,2513.539275,2416.889736,2345.2749,2301.050475,2285.816515,2300.150885,2343.506006,2414.309452,2510.228518,2628.503696,2766.254135,2920.697201,3089.276577,3269.722371,3363.787455 +4.4,3371.491519,3277.035674,3096.267661,2927.276273,2772.350085,2634.025303,2515.074393,2418.384996,2346.734316,2302.479342,2287.22135,2301.539152,2344.885669,2415.688478,2511.614422,2629.902974,2767.671196,2922.132919,3090.727795,3271.181889,3365.249674 +4.5,3373.35,3278.863177,3098.065832,2929.030783,2774.057657,2635.686545,2516.691421,2419.960904,2348.273347,2303.987034,2288.704489,2303.005496,2346.343491,2417.146067,2513.079591,2631.382418,2769.169329,2923.650437,3092.261334,3272.723949,3366.794592 +4.6,3375.299532,3280.780652,3099.953798,2930.873754,2775.852,2637.432901,2518.392088,2421.619194,2349.893731,2305.575297,2290.267688,2304.551679,2347.881247,2418.684007,2514.625823,2632.943829,2770.750321,2925.251525,3093.878959,3274.35031,3368.423973 +4.7,3377.34124,3282.789258,3101.932841,2932.806537,2777.734487,2639.265751,2520.177775,2423.361251,2351.59686,2307.24553,2291.912349,2306.179112,2349.500355,2420.303724,2516.254551,2634.588636,2772.415578,2926.937572,3095.58205,3276.062343,3370.139192 +4.8,3379.476034,3284.88994,3104.004035,2934.83028,2779.706295,2641.186279,2522.049669,2425.188267,2353.38393,2308.998936,2293.639682,2307.889008,2351.202033,2422.006441,2517.967,2636.318051,2774.166288,2928.709746,3097.371764,3277.861196,3371.941402 +4.9,3381.704817,3287.083643,3106.16846,2936.946144,2781.768617,2643.195687,2524.008976,2427.101452,2355.256161,2310.836737,2295.450915,2309.682601,2352.98752,2423.793405,2519.76442,2638.133313,2776.003663,2930.569241,3099.249284,3279.748045,3373.831782 +5,3384.028702,3289.371524,3108.427417,2939.155512,2783.922872,2645.295405,2526.057126,2429.10224,2357.214989,2312.760379,2297.347499,2311.561346,2354.85828,2425.666085,2521.648281,2640.035878,2777.929136,2932.517475,3101.216018,3281.724292,3375.811743 +5.1,3386.449126,3291.755069,3110.782541,2941.460107,2786.170821,2647.487202,2528.195887,2431.192398,2359.262183,2314.771632,2299.331208,2313.527026,2356.816099,2427.626277,2523.620381,2642.027532,2779.944468,2934.556197,3103.273708,3283.791676,3377.883029 +5.2,3388.96782,3294.236063,3113.235774,2943.861958,2788.514533,2649.773158,2530.427338,2433.374001,2361.399819,2316.872573,2301.404121,2315.581722,2358.86307,2429.67608,2525.682821,2644.110362,2782.051729,2936.687467,3105.424407,3285.952249,3380.047702 +5.3,3391.586656,3296.816435,3115.789217,2946.363254,2790.956248,2652.155526,2532.753726,2435.649293,2363.630139,2319.065449,2303.568489,2317.727693,2361.001458,2431.81777,2527.837879,2646.286635,2784.253163,2938.913523,3107.670348,3288.208246,3382.308006 +5.4,3394.307454,3299.498069,3118.444933,2948.96616,2793.498183,2654.636537,2535.177286,2438.020506,2365.955376,2321.352489,2305.826548,2319.967179,2363.233512,2434.053605,2530.087814,2648.558592,2786.550996,2941.236584,3110.013746,3290.561881,3384.666169 +5.5,3397.131813,3302.282634,3121.204787,2951.672637,2796.142364,2657.21824,2537.700068,2440.489689,2368.377578,2323.735749,2308.180353,2322.302241,2365.561302,2436.385659,2532.434696,2650.928284,2788.947259,2943.658673,3112.456617,3293.015175,3387.12422 +5.6,3400.06108,3305.171505,3124.070319,2954.484349,2798.89053,2659.902409,2540.323856,2443.058628,2370.898536,2326.217019,2310.6317,2324.734682,2367.986634,2438.815743,2534.880327,2653.397491,2791.443708,2946.181537,3115.000699,3295.569867,3389.683915 +5.7,3403.097656,3308.16639,3127.042678,2957.402549,2801.744016,2662.690426,2543.050063,2445.728759,2373.519705,2328.79778,2313.18209,2327.266019,2370.511045,2441.345403,2537.426249,2655.967733,2794.041849,2948.806672,3117.647483,3298.227452,3392.346759 +5.8,3406.243279,3311.268741,3130.123176,2960.428665,2804.70432,2665.583807,2545.880191,2448.501558,2376.242539,2331.479459,2315.832929,2329.897641,2373.135906,2443.975996,2540.073794,2658.640308,2796.742951,2951.535335,3120.398216,3300.989179,3395.114017 +5.9,3409.4992,3314.479709,3133.313021,2963.564037,2807.772879,2668.584049,2548.815767,2451.378569,2379.068592,2334.26362,2318.585788,2332.631121,2375.862788,2446.709081,2542.824493,2661.416703,2799.548467,2954.368951,3123.254306,3303.856457,3397.987109 +6,3412.866756,3317.800523,3136.613495,2966.810086,2810.951218,2671.69274,2551.858415,2454.361437,2381.99953,2337.151953,2321.44238,2335.4682,2378.693464,2449.546452,2545.680146,2664.298716,2802.4602,2957.309333,3126.217574,3306.831121,3400.967891 +6.1,3415.831083,3320.72816,3139.56103,2969.764473,2813.903143,2674.636865,2554.79158,2457.28183,2384.906806,2340.047752,2324.330636,2338.354992,2381.586417,2452.453673,2548.608519,2667.251876,2805.437569,2960.306625,3129.226701,3309.839726,3403.976885 +6.2,3417.566982,3322.438149,3141.318523,2971.566916,2815.750982,2676.53391,2556.742538,2459.29092,2386.977516,2342.18325,2326.534209,2340.630155,2383.936625,2454.881491,2551.114092,2669.831077,2808.08134,2963.001619,3131.955222,3312.579462,3406.720388 +6.3,3418.207866,3323.057009,3141.990404,2972.287562,2816.518524,2677.350032,2557.609613,2460.210397,2387.949602,2343.207445,2327.610061,2341.757771,2385.116758,2456.114995,2552.400499,2671.166823,2809.459182,2964.411122,3133.382403,3314.006481,3408.146249 +6.4,3418.000288,3322.827612,3141.807908,2972.140862,2816.39833,2677.251548,2557.529379,2460.144497,2387.893218,2343.155426,2327.55789,2341.702409,2385.057104,2456.05164,2552.334488,2671.098026,2809.385818,2964.330046,3133.288418,3313.891954,3408.022491 +6.5,3416.915414,3321.726523,3140.762752,2971.145142,2815.445504,2676.339495,2556.656785,2459.308795,2387.089953,2342.378804,2326.801909,2340.961953,2384.328657,2455.333196,2551.624405,2670.39353,2808.682717,2963.622949,3132.569987,3313.152859,3407.273432 +6.6,3415.56397,3320.36389,3139.464196,2969.910323,2814.272091,2675.229408,2555.612447,2458.330875,2386.176536,2341.525839,2326.004345,2340.214865,2383.627939,2454.6754,2551.005499,2669.807454,2808.121253,2963.07593,3132.02462,3312.594285,3406.707216 +6.7,3415.005112,3319.792111,3138.946559,2969.443287,2813.8492,2674.848903,2555.274237,2458.034265,2385.91927,2341.304393,2325.81491,2340.054298,2383.494246,2454.567337,2550.921152,2669.742822,2808.070218,2963.030377,3131.973774,3312.525814,3406.629663 +6.8,3415.662197,3320.433146,3139.628951,2970.159543,2814.587954,2675.604107,2556.043008,2458.814663,2386.709219,2342.10176,2326.618233,2340.863443,2384.310526,2455.392749,2551.756695,2670.587068,2808.91936,2963.878274,3132.811371,3313.342913,3407.437042 +6.9,3417.247133,3322.002606,3141.237705,2971.803277,2816.256886,2677.293547,2557.752014,2460.543806,2388.459355,2343.873914,2328.414097,2342.685762,2386.162884,2457.278429,2553.676735,2672.53883,2810.896677,2965.871485,3134.806993,3315.326279,3409.413989 +7,3419.42101,3324.16153,3143.433439,2974.03446,2818.515132,2679.575118,2560.057361,2462.875317,2390.819996,2346.266924,2330.843334,2345.155916,2388.679031,2459.844629,2556.293914,2675.203397,2813.600749,2968.602876,3137.549139,3318.061699,3412.145193 +7.1,3421.814245,3326.538374,3145.838562,2976.465397,2820.961179,2682.029852,2562.519182,2465.345215,2393.300092,2348.760048,2333.353294,2347.687692,2391.238299,2462.436286,2558.919941,2677.86162,2816.285099,2971.303264,3140.251532,3320.752185,3414.829665 +7.2,3423.817772,3328.5257,3147.849785,2978.499062,2823.006388,2684.079065,2564.569776,2467.397219,2395.354633,2350.818857,2335.418995,2349.764136,2393.330213,2464.547886,2561.052907,2680.014059,2818.451841,2973.475617,3142.41755,3322.90125,3416.970722 +7.3,3424.972576,3329.666888,3149.017436,2979.696559,2824.226436,2685.316146,2565.822723,2468.666855,2396.642133,2352.125198,2336.745347,2351.112405,2394.702927,2465.946957,2562.4778,2681.460996,2819.914135,2974.943345,3143.878113,3324.344424,3418.405397 +7.4,3425.381758,3330.06375,3149.440925,2980.152858,2824.710399,2685.823004,2566.351581,2469.218398,2397.216928,2352.723111,2337.365987,2351.755858,2395.369835,2466.637445,2563.189834,2682.189833,2820.652666,2975.681715,3144.60458,3325.050739,3419.101973 +7.5,3425.486171,3330.154838,3149.554344,2980.294086,2824.873918,2686.002962,2566.54562,2469.425894,2397.437277,2352.955069,2337.608109,2352.007291,2395.630477,2466.906931,2563.466046,2682.468571,2820.927964,2975.94543,3144.847607,3325.268537,3419.3082 +7.6,3425.709162,3330.363266,3149.782394,2980.547161,2825.147122,2686.29038,2566.844473,2469.735413,2397.756991,2353.284055,2337.945304,2352.352207,2395.983262,2467.267271,2563.831739,2682.835338,2821.289749,2976.29403,3145.174366,3325.569952,3419.59824 +7.7,3426.429251,3331.067423,3150.505086,2981.294378,2825.915555,2687.075028,2567.643145,2470.548292,2398.584952,2354.127784,2338.805415,2353.229733,2396.879477,2468.182372,2564.763391,2683.778587,2822.237275,2977.235924,3146.100381,3326.475106,3420.494081 +7.8,3427.935085,3332.554562,3152.00708,2982.815815,2827.453127,2688.623318,2569.199465,2472.113043,2400.159984,2355.715392,2340.408206,2354.850818,2398.521966,2469.847789,2566.450165,2685.48203,2823.949773,2978.946893,3147.799088,3328.156072,3422.167444 +7.9,3430.199529,3334.797096,3154.259892,2985.081117,2829.726864,2690.899,2571.473254,2474.384941,2402.432284,2357.991555,2342.692488,2357.148178,2400.837252,2472.183915,2568.806589,2687.854787,2826.331604,2981.327411,3150.168133,3330.508691,3424.513496 +8,3432.853768,3337.427544,3156.899281,2987.730883,2832.383749,2693.556774,2574.127832,2477.036413,2405.083442,2360.646701,2345.356893,2359.827785,2403.53765,2474.908389,2571.554659,2690.622318,2829.110882,2984.107564,3152.93898,3333.265117,3427.264451 +8.1,3435.449786,3339.999016,3159.480585,2990.323747,2834.986521,2696.164274,2576.736238,2479.645886,2407.696864,2363.268463,2347.992276,2362.482565,2406.217001,2477.614935,2574.287186,2693.375991,2831.877283,2986.875394,3155.698313,3336.010983,3430.005326 +8.2,3437.664186,3342.188225,3161.679989,2992.534912,2837.208581,2698.392578,2578.966815,2481.878156,2409.932848,2365.511604,2350.24681,2364.753117,2408.50753,2479.926911,2576.618576,2695.721602,2834.228785,2989.222313,3158.032555,3338.329437,3432.317903 +8.3,3439.335279,3343.833677,3163.336152,2994.203378,2838.889208,2700.081273,2580.659373,2483.573019,2411.630834,2367.214786,2351.957912,2366.475152,2410.242812,2481.675446,2578.37735,2697.485067,2835.988882,2990.969787,3159.761639,3340.03936,3434.020581 +8.4,3440.507934,3344.980519,3164.495191,2995.377141,2840.078862,2701.283954,2581.87125,2484.792061,2412.857086,2368.449325,2353.202264,2367.730922,2411.510754,2482.954027,2579.662349,2698.770164,2837.265721,2992.229664,3161.000247,3341.257184,3435.230425 +8.5,3441.462338,3345.90836,3165.435826,2996.333909,2841.05388,2702.275457,2582.875813,2485.807357,2413.882753,2369.485991,2354.25093,2368.792515,2412.585135,2484.038678,2580.752208,2699.85828,2838.343388,2993.288516,3162.036978,3342.272844,3436.237968 +8.6,3442.584797,3347.002417,3166.541129,2997.453762,2842.190316,2703.4271,2584.039222,2486.979779,2415.063618,2370.675992,2355.451319,2370.004453,2413.808538,2485.270921,2581.988122,2701.090826,2839.563888,2994.489181,3163.215498,3343.430621,3437.387883 +8.7,3444.166074,3348.552919,3168.100515,2999.025199,2843.775471,2705.024769,2585.646028,2488.592896,2416.682667,2372.3023,2357.08708,2371.6518,2415.468117,2486.940549,2583.662882,2702.763706,2841.226159,2996.133368,3164.839725,3345.035872,3438.986168 +8.8,3446.306394,3350.660134,3170.21449,3001.14941,2845.911447,2707.171655,2587.800869,2490.753264,2418.848704,2374.476293,2359.272486,2373.851999,2417.684694,2489.171876,2585.904274,2705.00801,2843.464318,2998.35783,3167.048417,3347.228592,3441.173295 +8.9,3448.921186,3353.23963,3172.798526,3003.741873,2848.513671,2709.783091,2590.418953,2493.375851,2421.476245,2377.111778,2361.920339,2376.516565,2420.368254,2491.873197,2588.618841,2707.728576,2846.181692,3001.064676,3169.742711,3349.909219,3443.849394 +9,3451.77363,3356.054937,3175.616198,3006.566323,2851.346009,2712.622991,2593.264105,2496.224107,2424.327889,2379.969878,2364.789599,2379.401598,2423.27143,2494.793258,2591.551247,2710.66604,2849.115242,3003.987765,3172.654004,3352.807471,3446.743445 +9.1,3454.556183,3358.79923,3178.361611,3009.318425,2854.106168,2715.391435,2596.038986,2499.003218,2427.111003,2382.759568,2367.590091,2382.21695,2426.103314,2497.639738,2594.407294,2713.524101,2851.966608,3006.82691,3175.480549,3355.620468,3449.551999 +9.2,3457.029645,3361.233889,3180.796952,3011.761757,2856.559589,2717.856042,2598.513612,2501.485627,2429.600245,2385.257297,2370.099496,2384.740897,2428.642164,2500.190364,2596.963797,2716.078445,2854.510341,3009.355624,3177.994925,3358.120079,3452.046545 +9.3,3459.125966,3363.290905,3182.854047,3013.828016,2858.637833,2719.948149,2600.618922,2503.601792,2431.72556,2387.392288,2372.246072,2386.900502,2430.813663,2502.369331,2599.143425,2718.250286,2856.666401,3011.492839,3180.115201,3360.223786,3454.144324 +9.4,3460.950821,3365.075634,3184.637674,3015.621219,2860.443996,2721.769744,2602.455684,2505.451293,2433.585483,2389.262168,2374.126732,2388.792187,2432.713983,2504.272796,2601.042509,2720.136287,2858.531921,3013.336175,3181.939345,3362.029804,3455.943694 +9.5,3462.722199,3366.805649,3186.364976,3017.357988,2862.194148,2723.536299,2604.238877,2507.248879,2435.394897,2391.082411,2375.958051,2390.634165,2434.563483,2506.123664,2602.88674,2721.965,2860.338234,3015.119407,3183.70299,3363.774994,3457.68208 +9.6,3464.688858,3368.729199,3188.283636,3019.285218,2864.13427,2725.492765,2606.212483,2509.237796,2437.396699,2393.096053,2377.983784,2392.671516,2436.609149,2508.17131,2604.928185,2723.991316,2862.343013,3017.102658,3185.668135,3365.722618,3459.623332 +9.7,3467.035838,3371.030857,3190.57757,3021.585803,2866.445999,2727.819296,2608.555093,2511.595168,2439.766741,2395.477965,2380.378184,2395.07829,2439.025255,2510.590618,2607.342628,2726.392137,2864.724385,3019.465175,3188.014875,3368.053368,3461.948456 +9.8,3469.808011,3373.755358,3193.291338,3024.303971,2869.173193,2730.559305,2611.309666,2514.363545,2442.547226,2398.270046,2383.182892,2397.895925,2441.853125,2513.422893,2610.171446,2729.209021,2867.524185,3022.249021,3190.785397,3370.809521,3464.699795 +9.9,3472.900855,3376.798415,3196.321049,3027.336354,2872.213231,2733.611046,2614.375417,2517.443148,2445.63931,2401.374191,2386.300258,2401.026915,2444.995115,2516.570137,2613.316142,2732.342946,2870.642904,3025.354185,3193.879197,3373.890228,3467.776329 +10,3476.119409,3379.965443,3199.472613,3030.489519,2875.373578,2736.783006,2617.561887,2520.644481,2448.854242,2404.602031,2389.541778,2404.282065,2448.260854,2519.840421,2616.583002,2735.59839,2873.883321,3028.581874,3197.096157,3377.09448,3470.976632 +10.1,3479.261775,3383.054888,3202.544843,3033.56276,2878.454175,2739.875842,2620.670418,2523.769365,2451.994059,2407.755474,2392.708683,2407.46136,2451.448574,2523.029855,2619.765811,2738.766831,2877.03477,3031.71947,3200.222055,3380.206989,3474.084939 +10.2,3482.193625,3385.932653,3205.403945,3036.422722,2881.322281,2742.757506,2623.56967,2526.687129,2454.928616,2410.704641,2395.670996,2410.434331,2454.426977,2526.006049,2622.730949,2741.713435,2879.961268,3034.629889,3203.118882,3383.089135,3476.962345 +10.3,3484.896922,3388.580713,3208.031992,3039.051666,2883.96044,2745.410893,2626.242924,2529.381498,2457.642128,2413.434223,2398.413813,2413.186401,2457.181756,2528.754927,2625.464561,2744.424603,2882.649452,3037.29987,3205.773417,3385.72774,3479.595683 +10.4,3487.472778,3391.099917,3210.529549,3041.549797,2886.468425,2747.935276,2628.788936,2531.950794,2460.23265,2416.042198,2401.035239,2415.81602,2459.811931,2531.37628,2628.067378,2747.002134,2885.202155,3039.833081,3208.28998,3388.22759,3482.089963 +10.5,3490.092201,3393.660849,3213.066712,3044.086541,2889.014814,2750.498257,2631.374282,2534.560675,2462.865156,2418.693173,2403.699876,2418.488179,2462.483278,2534.03701,2630.7077,2749.615896,2887.790773,3042.402196,3210.842276,3390.763116,3484.61997 +10.6,3492.921179,3396.429115,3215.808686,3046.826577,2891.76362,2753.263102,2634.161464,2537.373005,2465.701132,2421.548582,2406.569467,2421.365315,2465.359308,2536.902024,2633.552081,2752.434236,2890.585354,3045.178684,3213.602911,3393.507717,3487.359469 +10.7,3496.05737,3399.502152,3218.852674,3049.86682,2894.811401,2756.325974,2637.246249,2540.483248,2468.835909,2424.703822,2409.739677,2424.543579,2468.536878,2540.069073,2636.699341,2755.557143,2893.68697,3048.264489,3216.674537,3396.564533,3490.411829 +10.8,3499.498916,3402.878063,3222.196698,3053.205211,2898.155994,2759.684594,2640.62621,2543.888832,2472.266795,2428.156072,2413.207518,2428.019776,2472.012567,2543.534529,2640.145711,2758.98079,2897.0917,3051.655536,3220.052985,3399.929339,3493.772797 +10.9,3503.15159,3406.462779,3225.746795,3056.747983,2901.703886,2763.245748,2644.208404,2547.497027,2475.901175,2431.812652,2416.879989,2431.700318,2475.691969,2547.203004,2643.794792,2762.607793,2900.701166,3055.252502,3223.638201,3403.501597,3497.341609 +11,3506.871974,3410.113157,3229.360069,3060.352676,2905.313188,2766.868217,2647.852278,2551.167872,2479.599539,2435.534244,2420.617608,2435.44518,2479.434165,2550.932437,2647.503275,2766.293574,2904.369489,3058.908287,3227.282137,3407.132613,3500.969259 +11.1,3510.5292,3413.698572,3232.906103,3063.889274,2908.854414,2770.423138,2651.429583,2554.77366,2483.234592,2439.193733,2424.293124,2439.126628,2483.110629,2554.593283,2651.140508,2769.906346,2907.963696,3062.488811,3230.849856,3410.686868,3504.519951 +11.2,3514.05659,3417.152436,3236.318349,3067.291389,2912.261404,2773.844617,2654.87466,2558.248918,2486.740979,2442.725772,2427.841029,2442.67882,2486.655023,2558.118607,2654.638958,2773.377972,2911.414977,3065.924629,3234.271441,3414.094131,3507.923298 +11.3,3517.472344,3420.492867,3239.614793,3070.576949,2915.552025,2777.150461,2658.20523,2561.611271,2490.136277,2446.14794,2431.278948,2446.119465,2490.085178,2561.526428,2658.016921,2776.727029,2914.742083,3069.234621,3237.565911,3417.37351,3511.198456 +11.4,3520.865784,3423.808962,3242.884289,3073.834581,2918.81464,2780.428742,2661.509055,2564.948212,2493.507807,2449.54758,2434.694497,2449.53668,2493.489917,2564.906464,2661.365177,2780.045374,2918.037795,3072.512371,3240.827518,3420.619713,3514.44034 +11.5,3524.357721,3427.221236,3246.247033,3077.184128,2922.168662,2783.798397,2664.904562,2568.377707,2496.973208,2453.04225,2438.205479,2453.048813,2496.988416,2568.37898,2664.805282,2783.455869,2921.426133,3075.882926,3244.182161,3423.959214,3517.775695 +11.6,3528.050527,3430.831801,3249.804845,3080.727066,2925.715154,2787.360024,2668.491853,2571.999384,2500.631761,2456.731094,2441.911143,2456.755479,2500.680894,2572.045026,2668.4393,2787.061597,2925.011069,3079.451067,3247.735296,3427.497921,3521.310646 +11.7,3531.98874,3434.685063,3253.60196,3084.50745,2929.49797,2791.157269,2672.314339,2575.856412,2504.526449,2460.657007,2445.854416,2460.699757,2504.610693,2575.948334,2672.311458,2790.907246,2928.837652,3083.262189,3251.53261,3431.281716,3525.091172 +11.8,3536.146406,3438.755089,3257.612419,3088.499333,2933.491223,2795.164333,2676.346301,2579.923094,2508.631557,2464.79423,2450.009456,2464.855672,2508.751658,2580.062572,2676.39526,2794.966079,2932.878834,3087.289,3255.546633,3435.283002,3529.089614 +11.9,3540.443755,3442.962236,3261.756639,3092.623267,2937.615677,2799.302255,2680.509031,2584.120884,2512.868589,2469.064181,2454.297435,2469.143978,2513.023964,2584.307242,2680.60948,2799.156038,2937.051688,3091.44785,3259.693141,3439.417162,3533.221176 +12,3544.783246,3447.209125,3265.937333,3096.782145,2941.774508,2803.474558,2684.70639,2588.353872,2517.141712,2473.370945,2458.622163,2473.467998,2517.330252,2588.584181,2684.855062,2803.377045,2941.2551,3095.636752,3263.869451,3443.581042,3537.382482 +12.1,3547.776904,3450.154984,3268.919463,3099.869801,2944.998981,2806.846991,2688.228087,2592.021134,2520.943452,2477.284229,2462.614294,2477.504122,2521.378976,2592.621692,2688.869067,2807.364668,2945.213826,3099.561433,3267.755242,3447.422823,3541.204637 +12.2,3547.405401,3449.758008,3268.599484,3099.715438,2945.0636,2807.163993,2688.818751,2592.898065,2522.107208,2478.718179,2464.286518,2479.37549,2523.409898,2594.777468,2691.124392,2809.700959,2947.610357,3101.993664,3270.197845,3449.849237,3543.619099 +12.3,3544.271272,3446.603047,3265.509991,3096.769396,2942.30601,2804.621214,2686.504923,2590.81811,2520.253423,2477.065273,2462.79402,2477.996678,2522.099815,2593.499621,2689.855661,2808.428076,2946.320941,3100.675153,3268.839617,3448.441496,3542.185267 +12.4,3539.351419,3441.658978,3260.599369,3091.950099,2937.605248,2800.050195,2682.064449,2586.501304,2516.042343,2472.925771,2458.678214,2473.852444,2517.879867,2589.169396,2685.398528,2803.841049,2941.605853,3095.83814,3263.892197,3443.398926,3537.098511 +12.5,3533.076508,3435.3702,3254.354723,3085.816463,2931.618471,2794.229968,2676.418857,2581.029056,2510.729329,2467.739661,2453.570766,2468.76927,2512.770167,2583.994592,2680.137404,2798.484727,2936.149512,3090.281379,3258.239703,3437.659343,3531.316527 +12.6,3527.382536,3429.669377,3248.707654,3080.300237,2926.27793,2789.093753,2671.503618,2576.341468,2506.262732,2463.468413,2449.452094,2464.752558,2508.806479,2580.045311,2676.178718,2794.501678,2932.128326,3086.210711,3254.111113,3433.467229,3527.090485 +12.7,3524.725431,3426.996699,3246.062858,3077.74973,2923.855332,2786.818308,2669.385092,2574.382521,2504.455956,2461.790476,2447.864938,2463.211833,2507.27044,2578.483132,2674.574057,2792.845784,2930.412985,3084.430034,3252.261553,3431.548314,3525.136771 +12.8,3525.493558,3427.740383,3246.810223,3078.557876,2924.748346,2787.807744,2670.475664,2575.574798,2505.743788,2463.15484,2449.274263,2464.629493,2508.662949,2579.827921,2675.861936,2794.07313,2931.575406,3085.524588,3253.286443,3432.504663,3526.060101 +12.9,3528.325145,3430.549514,3249.625186,3081.442002,2927.731308,2790.906831,2673.701725,2578.934823,2509.238596,2466.77272,2452.990649,2468.413755,2512.486126,2583.670108,2679.713665,2797.926862,2935.420077,3089.348248,3257.075916,3436.248662,3529.780312 +13,3531.923755,3434.12799,3253.207056,3085.09262,2931.482545,2794.778367,2677.707111,2583.083759,2513.534858,2471.207838,2457.543261,2473.056012,2517.191333,2588.420025,2684.499019,2802.738409,2940.244083,3094.16926,3261.876221,3441.012468,3534.523798 +13.1,3535.10384,3437.287272,3256.353705,3088.284212,2934.744482,2798.124527,2681.145978,2586.620336,2517.168853,2474.927609,2461.325122,2476.870673,2521.011981,2592.229942,2688.291554,2806.507953,2943.982533,3097.86854,3265.527302,3444.610064,3538.094528 +13.2,3536.496255,3438.663577,3257.712344,3089.680638,2936.203497,2799.659253,2682.763739,2588.323936,2518.95495,2476.781042,2463.218325,2478.770434,2522.88829,2594.06414,2690.075928,2808.236956,2945.65031,3099.471063,3267.061091,3446.077306,3539.529124 +13.3,3535.567896,3437.728439,3256.767576,3088.786807,2935.391791,2798.948086,2682.164277,2587.840641,2518.584076,2476.505481,2463.007235,2478.586298,2522.696549,2593.841768,2689.810694,2807.919134,2945.271284,3099.02505,3266.543821,3445.491582,3538.908811 +13.4,3533.233777,3435.392149,3254.421721,3086.491835,2933.180275,2796.839088,2680.168964,2585.962355,2516.817029,2474.830205,2461.39034,2476.987597,2521.079139,2592.180765,2688.092049,2806.131965,2943.407466,3097.080402,3264.516884,3443.389389,3536.768825 +13.5,3530.92243,3433.077862,3252.090273,3084.198946,2930.955526,2794.698279,2678.120289,2584.006309,2514.945376,2473.022007,2459.611642,2475.198253,2519.242981,2590.274065,2686.101735,2804.048621,2941.225777,3094.799769,3262.140475,3440.929958,3534.268812 +13.6,3529.682612,3431.834289,3250.828025,3082.972879,2929.795978,2793.621336,2677.134656,2583.11322,2514.137791,2472.281158,2458.906452,2474.491558,2518.501388,2589.475713,2685.233732,2803.100728,2940.19159,3093.676849,3260.930022,3439.642698,3532.943815 +13.7,3530.166352,3432.313142,3251.289589,3083.472722,2930.366852,2794.28126,2677.894511,2583.976761,2515.101027,2473.329413,2460.013485,2475.624986,2519.631935,2590.584005,2686.306863,2804.126677,2941.160983,3094.582689,3261.768169,3440.41773,3533.687004 +13.8,3532.532713,3434.671057,3253.625492,3085.83856,2932.793991,2796.786353,2680.487757,2586.662105,2517.875694,2476.181516,2462.920937,2478.560131,2522.570146,2593.509427,2689.208223,2806.992529,2943.981888,3097.350509,3264.477353,3443.070766,3536.311695 +13.9,3536.117578,3438.244721,3257.171908,3089.404859,2936.409393,2800.465567,2684.239551,2590.489615,2521.77603,2480.143965,2466.925838,2482.582943,2526.589535,2597.512091,2693.184191,2810.931396,2947.875278,3101.190951,3268.260287,3446.799238,3540.013024 +14,3539.721257,3441.83852,3260.739974,3092.992645,2940.04717,2804.16904,2688.018188,2594.346893,2525.708974,2484.14202,2470.969981,2486.649449,2530.6578,2601.568722,2697.218113,2814.931276,2951.832159,3105.096778,3272.110584,3450.596761,3543.783956 +14.1,3542.363754,3444.474648,3263.354134,3095.629191,2942.737937,2806.931183,2690.861863,2597.275351,2528.717957,2487.219382,2474.095292,2489.797717,2533.807154,2604.703961,2700.325959,2817.999118,2954.850755,3108.058503,3275.012634,3453.443451,3546.602529 +14.2,3543.642981,3445.750688,3264.609568,3096.905508,2944.066626,2808.32912,2692.338154,2598.831313,2530.346371,2488.904877,2475.814601,2491.523463,2535.515438,2606.37744,2701.949511,2819.559977,2956.341157,3109.473741,3276.354607,3454.721345,3547.848329 +14.3,3543.669426,3445.777026,3264.617385,3096.934162,2944.147558,2808.479254,2692.565808,2599.136164,2530.718567,2489.326135,2476.259135,2491.961816,2535.921831,2606.73234,2702.235831,2819.764576,2956.457319,3109.499214,3276.29537,3454.590614,3547.682053 +14.4,3543.013967,3445.124162,3263.950052,3096.291477,2943.562236,2807.969573,2692.140597,2598.794886,2530.450318,2489.11136,2476.071171,2491.770622,2535.700815,2606.460238,2701.893493,2819.337669,2955.93857,3108.886631,3275.596159,3453.818591,3546.873541 +14.5,3542.558338,3444.671659,3263.484992,3095.852263,2943.181995,2807.667308,2691.925379,2598.666225,2530.397114,2489.114122,2476.10409,2491.804998,2535.711021,2606.424741,2701.792179,2819.15556,2955.667762,3108.524862,3275.150757,3453.30238,3546.321557 +14.6,3543.063002,3445.177735,3263.977244,3096.367129,2943.751565,2808.310201,2692.650205,2599.472372,2531.27372,2490.042663,2477.060901,2492.764271,2536.64964,2607.322306,2702.628868,2819.916653,2956.345222,3109.11639,3275.663592,3453.747826,3546.73284 +14.7,3544.793149,3446.907281,3265.691837,3098.101638,2945.5373,2810.165811,2694.584339,2601.484895,2533.354698,2492.175234,2479.224233,2494.936096,2538.80983,2609.451885,2704.708457,2821.931633,2958.286945,3110.981837,3277.458831,3455.481312,3548.434708 +14.8,3547.508608,3449.621007,3268.390684,3100.819508,2948.305244,2813.003094,2697.500153,2604.479873,2536.419939,2495.295383,2482.380946,2498.110212,2541.983678,2612.607404,2707.826353,2824.997038,2961.290306,3113.919216,3280.334804,3458.301178,3551.225372 +14.9,3550.652925,3452.763359,3271.518069,3103.964333,2951.497757,2816.262734,2700.836123,2607.892827,2539.901043,2498.829575,2485.951034,2501.698863,2545.574545,2616.182594,2711.366467,2828.487237,2964.72093,3117.286728,3283.643834,3461.555766,3554.451441 +15,3553.553466,3455.662937,3274.403012,3106.865333,2954.443984,2819.27351,2703.92024,2611.050228,2543.121942,2502.097873,2489.249158,2505.009763,2548.881803,2619.467493,2714.609105,2831.672909,2967.840568,3120.338439,3286.633837,3464.488811,3557.354795 +15.1,3555.670555,3457.781507,3276.50912,3108.988781,2956.613491,2821.508781,2706.229951,2613.433563,2545.567797,2504.588399,2491.765398,2507.533798,2551.39596,2621.951255,2717.041402,2834.038726,2970.131319,3122.554038,3288.782332,3466.576213,3559.41048 +15.2,3556.840488,3458.955865,3277.674068,3110.173793,2957.847159,2822.81139,2707.61022,2614.88995,2547.087836,2506.152344,2493.352623,2509.125145,2552.972079,2623.489507,2718.519342,2835.440808,2971.449322,3123.789599,3289.945139,3467.673538,3560.473905 +15.3,3557.31903,3459.441029,3278.15201,3110.673486,2958.3967,2823.431245,2708.308924,2615.665166,2547.925908,2507.031978,2494.251954,2510.024221,2553.850301,2624.322595,2719.283911,2836.121022,2972.037488,3124.289044,3290.366926,3468.026009,3560.790642 +15.4,3557.608022,3459.737709,3278.442753,3110.986755,2958.759941,2823.864937,2708.821501,2616.253831,2548.576468,2507.722514,2494.960377,2510.730782,2554.534067,2624.958461,2719.848108,2836.597562,2972.419036,3124.58001,3290.578733,3468.166992,3560.895176 +15.5,3558.229178,3460.366651,3279.06661,3111.633732,2959.456998,2824.632716,2709.668721,2617.177848,2549.56344,2508.751006,2496.009241,2511.781556,2555.56643,2625.947286,2720.76969,2837.435719,2973.166352,3125.241003,3291.163761,3468.68284,3561.375279 +15.6,3559.539361,3461.683927,3280.378895,3112.968811,2960.841194,2826.086701,2711.20159,2618.787397,2551.236677,2510.467668,2497.749852,2513.529627,2557.302911,2627.647673,2722.410783,2839.00129,2974.648835,3126.644564,3292.496955,3469.950159,3562.60835 +15.7,3561.601188,3463.751867,3282.441253,3115.052531,2962.971619,2828.284199,2713.475463,2621.135792,2553.647443,2512.921784,2500.229566,2516.02044,2559.787135,2630.101682,2724.812152,2841.333996,2976.90545,3128.829019,3294.616094,3472.006432,3564.631798 +15.8,3564.16612,3466.32246,3285.00602,3117.637501,2965.60116,2830.978306,2716.243592,2623.976305,2556.548765,2515.86578,2503.199685,2519.003543,2562.766366,2633.054009,2727.71579,2844.173148,2979.673043,3131.528962,3297.253876,3474.583105,3567.176487 +15.9,3566.80587,3468.968419,3287.646898,3120.298584,2968.30605,2833.746691,2719.085076,2626.889273,2559.521789,2518.880982,2506.240869,2522.057922,2565.81703,2636.077933,2730.691445,2847.084857,2982.514262,3134.303827,3299.967054,3477.235119,3569.796487 +16,3569.111052,3471.281205,3289.956059,3122.628717,2970.680037,2836.183807,2721.59489,2629.469864,2562.161348,2521.56122,2508.945075,2524.772665,2568.524506,2638.754595,2733.31572,2849.641185,2984.996912,3136.717553,3302.316416,3479.521171,3572.04953 +16.1,3570.845529,3473.025134,3291.698218,3124.393056,2972.488745,2838.055613,2723.539154,2631.484141,2564.233124,2523.671407,2511.07593,2526.909479,2570.64808,2640.840588,2735.342361,2851.593072,2986.869317,3138.516026,3304.045869,3481.183882,3573.677649 +16.2,3572.015435,3474.206367,3292.879798,3125.598512,2973.739741,2839.370361,2724.926848,2632.941899,2565.747813,2525.223254,2512.646191,2528.482075,2572.202387,2642.351524,2736.787932,2852.958018,2988.149798,3139.718107,3305.174647,3482.242765,3574.700469 +16.3,3572.849952,3475.053628,3293.729347,3126.473611,2974.661658,2840.356826,2725.986993,2634.072674,2566.935839,2526.448575,2513.889556,2529.726427,2573.426096,2643.529156,2737.897453,2853.98434,2989.089737,3140.577694,3305.958634,3482.955076,3575.375858 +16.4,3573.694564,3475.911617,3294.590861,3127.361573,2975.596883,2841.356471,2727.060157,2635.216409,2568.136975,2527.687611,2515.147425,2530.98573,2574.664865,2644.722201,2739.023055,2855.027747,2990.048236,3141.456763,3306.762133,3483.686744,3576.070506 +16.5,3574.85776,3477.088114,3295.771421,3128.568643,2976.850745,2842.673623,2728.44969,2636.675726,2569.65353,2529.242921,2516.723224,2532.564848,2576.225603,2646.240157,2740.47716,2856.403758,2991.343745,3142.676252,3307.908121,3484.762161,3577.109474 +16.6,3576.489224,3478.732485,3297.42008,3130.243486,2978.571521,2844.456161,2730.303104,2638.597948,2571.632887,2531.262264,2518.765394,2534.613156,2578.258933,2648.235182,2742.413637,2858.268056,2993.13362,3144.394881,3309.556459,3486.341974,3578.653764 +16.7,3578.539526,3480.795394,3299.487505,3132.336688,2980.709701,2846.65444,2732.570543,2640.932999,2574.024717,2533.694995,2521.222859,2537.07899,2580.712535,2650.654297,2744.778864,2860.566467,2995.363109,3146.557316,3311.651404,3488.370172,3580.647237 +16.8,3580.799228,3483.067815,3301.764918,3134.639622,2983.056776,2849.059984,2735.043382,2643.471913,2576.619442,2536.330546,2523.883599,2539.748379,2583.370124,2653.278657,2747.351335,2863.074904,2997.805627,3148.934717,3313.962395,3490.615027,3582.857635 +16.9,3582.992933,3485.27493,3303.978002,3136.878491,2985.339503,2851.400082,2737.449272,2645.942476,2579.144642,2538.895811,2526.473236,2542.345054,2585.953044,2655.826846,2749.846685,2865.506068,3000.170989,3151.234305,3316.194643,3492.78038,3584.988163 +17,3584.893886,3487.190491,3305.901053,3138.828245,2987.333603,2853.451264,2739.565435,2648.122445,2581.378362,2541.168738,2528.769145,2544.645327,2588.236138,2658.071908,2752.03598,2867.629006,3002.226184,3153.221198,3318.111819,3494.628894,3586.801007 +17.1,3586.411496,3488.724101,3307.443937,3140.399117,2988.949747,2855.124685,2741.303435,2649.923719,2583.232747,2543.061562,2530.683448,2546.561018,2590.13078,2659.924637,2753.829368,2869.353196,3003.87991,3154.803379,3319.621388,3496.06766,3588.20308 +17.2,3587.613809,3489.943651,3308.674455,3141.658861,2990.25569,2856.488137,2742.731079,2651.414158,2584.775829,2544.642584,2532.284837,2548.161368,2591.706927,2661.45579,2755.298493,2870.751167,3005.205403,3156.054713,3320.797767,3497.171455,3589.269328 +17.3,3588.683543,3491.031462,3309.774616,3142.789207,2991.432903,2857.722918,2744.029537,2652.77496,2586.189107,2546.093915,2533.75639,2549.630849,2593.150829,2662.853648,2756.633844,2872.015604,3006.397302,3157.171585,3321.838785,3498.139069,3590.198983 +17.4,3589.835443,3492.201816,3310.958289,3144.003592,2992.694401,2859.041694,2745.411207,2654.218428,2587.685108,2547.628666,2535.312228,2551.185099,2594.680094,2664.338084,2758.057771,2873.371328,3007.682664,3158.383072,3322.97517,3499.20233,3591.224385 +17.5,3591.229552,3493.614391,3312.384756,3145.460825,2994.198472,2860.602278,2747.033456,2655.901587,2589.420737,2549.403862,2537.109802,2552.982398,2596.454183,2666.069971,2759.732748,2874.982411,3009.226998,3159.856033,3324.374898,3500.529968,3592.514618 +17.6,3592.912329,3495.315521,3314.100149,3147.206752,2995.990612,2862.449832,2748.941104,2657.868908,2591.440169,2551.463413,2539.192825,2555.066436,2598.516901,2668.093301,2761.703049,2876.893386,3011.075034,3161.635467,3326.083215,3502.167387,3594.11517 +17.7,3594.808013,3497.229592,3316.02894,3149.165886,2997.995345,2864.508919,2751.058703,2660.044822,2593.667612,2553.731121,2541.484516,2557.359777,2600.790062,2670.329025,2763.888743,2879.02337,3013.144934,3163.638793,3328.01696,3504.03103,3595.942307 +17.8,3596.760523,3499.200851,3318.015658,3151.183045,3000.057767,2866.624932,2753.231883,2662.275012,2595.948578,2556.052003,2543.829061,2559.705539,2603.115472,2672.617404,2766.128437,2881.209207,3015.271832,3165.69973,3330.008726,3505.952722,3597.827499 +17.9,3598.602915,3501.062699,3319.894031,3153.09232,3002.01233,2868.632707,2755.295797,2664.394752,2598.118209,2558.260724,2546.060292,2561.936472,2605.324522,2674.788219,2768.250167,2883.277062,3017.280087,3167.64114,3331.880171,3507.753306,3599.591214 +18,3600.223392,3502.703574,3321.55275,3154.782719,3003.748376,2870.421962,2757.140519,2666.294327,2600.066824,2560.247391,2548.067874,2563.941664,2607.305547,2676.728875,2770.140297,2885.11211,3019.053733,3169.34613,3333.513643,3509.314622,3601.115059 +18.1,3599.874608,3502.460535,3321.489311,3154.906287,3004.068995,2870.941475,2757.851963,2667.185642,2601.120141,2561.438104,2549.363017,2565.301417,2608.691907,2678.109991,2771.491258,2886.413443,3020.283921,3170.483869,3334.542693,3510.221455,3601.956008 +18.2,3594.986868,3497.707077,3316.971804,3150.655692,3000.119143,2867.317761,2754.568735,2664.248769,2598.525205,2559.168547,2547.388395,2563.579056,2607.176006,2676.756808,2770.26081,2885.267403,3019.178679,3169.374454,3333.387425,3508.980226,3600.659422 +18.3,3586.477756,3489.336576,3308.824538,3142.746207,2992.465571,2859.931255,2747.450013,2657.390647,2591.910982,2552.770461,2541.16666,2557.484051,2601.157869,2670.771506,2764.272661,2879.246096,3013.092654,3163.195618,3327.09449,3502.556664,3594.162432 +18.4,3575.691676,3478.68369,3298.358565,3132.454494,2982.340681,2849.96187,2737.617112,2647.670134,2582.272333,2543.174808,2531.56606,2547.824302,2591.388317,2660.851888,2754.17634,2868.956267,3002.596285,3152.488706,3316.183989,3491.458236,3582.968689 +18.5,3563.262093,3466.399703,3286.281382,3120.582125,2970.675273,2838.501382,2726.350669,2636.580286,2571.333747,2532.351714,2520.811458,2537.083168,2580.607138,2649.985838,2743.192906,2857.830739,2991.306713,3141.021978,3304.537152,3479.637232,3571.056713 +18.6,3551.732045,3455.0229,3275.127767,3109.661619,2960.000728,2828.081364,2716.184575,2626.660431,2561.644249,2522.865606,2511.489504,2527.876377,2571.465136,2640.863667,2734.054436,2848.643252,2982.036909,3131.642703,3295.028408,3469.986393,3561.327217 +18.7,3544.183307,3447.614735,3267.911229,3102.632094,2953.157342,2821.421454,2709.699414,2620.337643,2555.467178,2516.810295,2505.522951,2521.958037,2565.553813,2634.923687,2728.058551,2842.566316,2975.85281,3125.331226,3288.575613,3463.385898,3554.64835 +18.8,3540.964844,3444.524559,3264.983929,3099.851084,2950.511123,2818.899332,2707.287839,2618.022751,2553.234527,2514.641428,2503.392933,2519.836075,2563.408603,2632.728802,2725.794651,2840.21398,2973.39046,3122.74194,3285.847126,3460.51316,3551.701037 +18.9,3540.256434,3443.945976,3264.573681,3099.599803,2950.414687,2818.954885,2707.490271,2618.36687,2553.714933,2515.248833,2504.111206,2520.642164,2564.276603,2633.634725,2726.717972,2841.129914,2974.269042,3123.55478,3286.567444,3461.120006,3552.246189 +19,3540.402988,3444.224013,3265.019702,3100.205427,2951.17726,2819.873472,2708.562331,2619.58996,2555.086727,2516.763712,2505.757152,2522.400137,2566.123768,2635.548954,2728.6789,2843.110981,2976.237713,3125.478901,3288.415232,3462.865589,3553.935131 +19.1,3539.916639,3443.867027,3264.814169,3100.131517,2951.222165,2820.02709,2708.814285,2619.930813,2555.508208,2517.255845,2506.305325,2522.98443,2566.721935,2636.141092,2729.248285,2843.636292,2976.694349,3125.844526,3288.66952,3462.996492,3554.002008 +19.2,3537.102916,3441.187509,3262.285226,3097.729409,2948.931022,2817.833624,2706.704943,2617.892274,2553.527688,2515.318791,2504.392829,2521.072872,2564.786086,2634.159153,2727.202656,2841.506352,2974.458891,3123.486403,3286.175391,3460.363746,3551.299195 +19.3,3531.350894,3435.580229,3256.844027,3092.435757,2943.774443,2812.804944,2701.793499,2613.085597,2548.811797,2510.676662,2499.802175,2516.505976,2560.213123,2629.55355,2722.541755,2836.765066,2969.613187,3118.517078,3281.068153,3455.116813,3545.98099 +19.4,3523.843577,3428.222126,3249.655688,3085.397407,2936.875213,2806.034588,2695.139978,2606.534218,2542.345587,2504.2757,2493.441592,2510.155686,2553.841186,2623.131592,2716.045392,2830.168553,2962.893757,3111.657755,3274.058297,3447.96009,3538.750141 +19.5,3516.349884,3420.875527,3242.471095,3078.348611,2929.94661,2799.211329,2688.406168,2599.871742,2535.734656,2497.694796,2486.865438,2503.554722,2547.184642,2616.392601,2709.200944,2823.195219,2955.772618,3104.376288,3266.611536,3440.358743,3531.072448 +19.6,3510.144567,3414.815239,3236.571113,3072.581614,2924.297746,2793.666531,2682.950929,2594.489697,2530.408179,2492.405423,2481.591575,2498.270542,2541.862579,2611.007757,2703.730366,2817.614684,2950.06199,3098.520657,3260.603321,3434.205973,3524.848119 +19.7,3506.028037,3410.841137,3232.757618,3068.902363,2920.74088,2790.22108,2679.606071,2591.233189,2527.226928,2489.286429,2478.519272,2495.224801,2538.820478,2607.947017,2700.627832,2814.444197,2946.799959,3095.146626,3257.103182,3430.580292,3521.159258 +19.8,3504.208935,3409.158651,3231.227524,3067.493975,2919.440556,2789.016763,2678.48699,2590.188237,2526.245215,2488.358821,2477.635398,2494.370125,2537.977408,2607.097308,2699.750338,2813.513883,2945.79348,3094.04238,3255.885557,3429.247649,3519.768798 +19.9,3503.890066,3408.971432,3231.184346,3067.558639,2919.596438,2789.24957,2678.784665,2590.539297,2526.639205,2488.788483,2478.093525,2494.845926,2538.457183,2607.565944,2700.188529,2813.898414,2946.102647,3094.255627,3255.988672,3429.240017,3519.70602 +20,3503.622762,3408.835675,3231.193868,3067.675867,2919.805208,2789.536202,2679.137719,2590.947774,2527.092854,2489.280653,2478.6181,2495.393251,2539.014615,2608.118618,2700.716342,2814.377708,2946.511373,3094.572742,3256.200196,3429.345274,3519.75814 +20.1,3502.22047,3407.567343,3230.075775,3066.669861,2918.895796,2788.710213,2678.383655,2590.25391,2526.447395,2488.675377,2478.045563,2494.842494,2538.471841,2607.567433,2700.134801,2813.741468,2945.798503,3093.763025,3255.281867,3428.319923,3518.679161 +20.2,3499.175114,3404.657915,3227.318968,3064.024831,2916.345311,2786.239308,2675.978452,2587.899689,2524.128683,2486.38036,2475.763679,2492.56006,2536.173002,2605.233983,2697.743536,2811.268797,2943.224791,3091.07196,3252.467625,3425.390413,3515.692551 +20.3,3494.575442,3400.196096,3223.012922,3059.831949,2912.24725,2782.219963,2672.022097,2583.989125,2520.24527,2482.509085,2471.891115,2488.669954,2532.24744,2601.252785,2693.682046,2807.103809,2938.93839,3086.651153,3247.911759,3420.712655,3510.954834 +20.4,3489.066151,3394.826216,3217.80357,3054.74099,2907.257242,2777.315751,2667.188146,2579.207822,2515.496965,2477.777635,2467.162089,2483.92606,2527.46971,2596.419416,2688.766646,2802.082417,2933.792795,3081.369022,3242.494183,3415.173908,3505.356229 +20.5,3483.692598,3389.591007,3212.729634,3049.78589,2902.403806,2772.549591,2662.494143,2574.568687,2510.893365,2473.194056,2462.585105,2479.339442,2522.855345,2591.755442,2684.026134,2797.241187,2928.832214,3076.276818,3237.271926,3409.835115,3499.959598 +20.6,3479.391155,3385.424019,3208.719457,3045.888088,2898.600047,2768.825359,2658.834333,2570.956486,2507.310547,2469.626979,2459.022914,2475.768749,2519.260639,2588.11642,2680.316776,2793.438094,2924.91692,3072.237397,3233.110214,3405.563239,3495.632991 +20.7,3476.535405,3382.698284,3206.145589,3043.420119,2896.218932,2766.517115,2656.584634,2568.749845,2505.130834,2467.463397,2456.868089,2473.612978,2517.09165,2585.915875,2678.059775,2791.101783,2922.48239,3069.692193,3230.455079,3402.807221,3492.826593 +20.8,3474.907514,3381.196776,3204.792551,3042.168916,2895.050399,2765.41836,2655.542542,2567.7505,2504.160307,2466.51364,2455.934928,2472.690048,2516.169464,2584.977629,2677.081373,2790.060511,2921.358525,3068.472438,3229.138603,3401.399478,3491.37286 +20.9,3473.897762,3380.310604,3204.051844,3041.525923,2894.485037,2764.917947,2655.094172,2567.340617,2503.775868,2466.14788,2455.585358,2472.35228,2515.835667,2584.631869,2676.7003,2789.621957,2920.842949,3067.867238,3228.443178,3400.617862,3490.547732 +21,3472.716045,3379.250987,3203.136075,3040.705104,2893.737657,2764.230816,2654.453658,2566.732288,2503.186104,2465.569474,2455.015639,2471.787079,2515.267292,2584.044243,2676.070484,2788.928535,2920.067457,3066.999275,3227.484212,3399.572834,3489.459528 +21.1,3470.677944,3377.33523,3201.365644,3039.03116,2892.137948,2762.691995,2652.961422,2565.270993,2501.74088,2464.131638,2453.581003,2470.350274,2513.819354,2582.567821,2674.542289,2787.327398,2918.375907,3065.209334,3225.599757,3397.600401,3487.443212 +21.2,3467.509362,3374.289959,3198.468638,3036.234416,2889.4189,2760.037372,2650.356375,2562.698604,2499.18486,2461.581476,2451.030465,2467.792198,2511.242875,2579.953829,2671.866819,2784.569239,2915.51848,3062.24704,3222.538766,3394.448939,3484.246847 +21.3,3463.431572,3370.335703,3194.664249,3032.532416,2885.79608,2756.48025,2646.849447,2559.223704,2495.724478,2458.123584,2447.567109,2464.314779,2507.738958,2576.402944,2668.244713,2780.8549,2911.696463,3058.314186,3218.503373,3390.320865,3480.073078 +21.4,3458.989444,3366.016088,3190.494204,3028.464773,2881.806935,2752.556001,2642.974342,2555.378967,2491.892285,2454.291461,2443.726495,2460.456715,2503.850376,2572.462825,2664.229035,2776.742966,2907.473784,3053.9794,3214.065833,3385.790915,3475.497817 +21.5,3454.805385,3361.95237,3186.578277,3024.649906,2878.068856,2748.881484,2639.348178,2551.78281,2488.309252,2450.71004,2440.138935,2456.855012,2500.221925,2568.786914,2660.482287,2772.904887,2903.530298,3049.92978,3209.91881,3381.555497,3471.219136 +21.6,3451.362912,3358.627,3183.397175,3021.566486,2875.058396,2745.931182,2636.443726,2548.906882,2485.446704,2447.851295,2437.278071,2453.985964,2497.333441,2565.859369,2657.493424,2769.834565,2900.364717,3046.66823,3206.568441,3378.122996,3467.746473 +21.7,3448.831443,3356.208813,3181.118428,3019.380259,2872.939114,2743.866109,2634.419312,2546.906819,2483.457684,2445.865877,2435.29242,2451.996232,2495.330053,2563.824203,2655.405698,2767.674809,2898.119706,3044.337341,3204.157224,3375.63596,3465.222482 +21.8,3447.006312,3354.493517,3179.538207,3017.887962,2871.508282,2742.483878,2633.072709,2545.580326,2482.139491,2444.55027,2433.977188,2450.679246,2494.003019,2562.470308,2654.005537,2766.20965,2896.577139,3042.717008,3202.463375,3373.871526,3463.423817 +21.9,3445.425907,3353.020529,3178.19763,3016.632943,2870.311711,2741.332667,2631.954244,2544.479484,2481.0453,2443.457912,2432.885104,2449.585997,2492.900703,2561.342799,2652.834389,2764.976779,2895.271136,3041.338042,3201.014921,3372.355859,3461.875748 +22,3443.5884,3351.289005,3176.597373,3015.117773,2868.853927,2739.918674,2630.571352,2543.11237,2479.682991,2442.095478,2431.520522,2448.21736,2491.519536,2559.933025,2651.378133,2763.456634,2893.677052,3039.6712,3199.27888,3370.553504,3460.041683 diff --git a/tests/data/currents_mdc/tension_c5/tension.dat b/tests/data/currents_mdc/tension_c5/tension.dat new file mode 100644 index 00000000..4e07f732 --- /dev/null +++ b/tests/data/currents_mdc/tension_c5/tension.dat @@ -0,0 +1,25 @@ +--------------------- MoorDyn Input File ------------------------------------ +Current tension parity deck (MoorDyn-C Currents 5): a cross-flow sheared along the line, in depth and time +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +rope 0.3 80.0 1.0e7 -1.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0.0 -30.0 -20.0 0 0 0 0 +2 Vessel 0.0 30.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 rope 2 1 70.0 20 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM time step to use in mooring integration (s) +22.0 TMax simulation length (s) +1025.0 WtrDnsty water density (kg/m^3) +50 WtrDpth water depth (m) +300.0 TmaxIC max time for ic gen (s) +1.0e-12 threshIC convergence threshold for ic gen (-) +0 WaveKin MoorDyn-C water kinematics mode (-) +5 Currents MoorDyn-C current mode (-) +------------------------- need this line -------------------------------------- diff --git a/tests/test_c_api.f90 b/tests/test_c_api.f90 index 4384b5e4..2b9c3691 100644 --- a/tests/test_c_api.f90 +++ b/tests/test_c_api.f90 @@ -26,6 +26,7 @@ PROGRAM test_c_api CALL case_lifecycle() CALL case_deck_init() CALL case_deck_dynamic_point_fluid() + CALL case_deck_current_in_time() CALL case_deck_bodies_rods() CALL case_init_update_output_step() CALL case_multiline_shared_map() @@ -203,6 +204,87 @@ SUBROUTINE case_deck_dynamic_point_fluid() CALL require(es == 0_C_INT .AND. .NOT. C_ASSOCIATED(hydro_handle), 'c-api-deck-fluid:close-hydro') END SUBROUTINE case_deck_dynamic_point_fluid + SUBROUTINE case_deck_current_in_time() + !! The C ABI has no simulation clock: a deck current that varies in time (MoorDyn-C + !! Currents 2) is refused, as deck waves are, rather than held at its t = 0 value; the same + !! table constant in time is the steady field the ABI applies, as Currents 1. + CHARACTER(*), PARAMETER :: DECK_PATH = 'capi_currents2_deck.dat' + CHARACTER(KIND=C_CHAR), TARGET :: c_path(LEN(DECK_PATH)) + CHARACTER(KIND=C_CHAR), TARGET :: msg(300) + TYPE(C_PTR) :: handle + INTEGER(C_INT) :: es + INTEGER :: i + + DO i = 1, LEN(DECK_PATH) + c_path(i) = DECK_PATH(i:i) + END DO + CALL write_capi_currents_deck(DECK_PATH, '0.2 0.2 0.0 0.0') + CALL CableDyn_Create(handle, es) + CALL require(es == 0_C_INT .AND. C_ASSOCIATED(handle), 'c-api-currents2:create') + CALL CableDyn_InitDeck(handle, C_LOC(c_path), INT(LEN(DECK_PATH), C_INT), es) + CALL require(es == 3_C_INT, 'c-api-currents2:varying-in-time-rejected') + CALL CableDyn_GetLastError(handle, C_LOC(msg), INT(SIZE(msg), C_INT)) + CALL require(INDEX(c_text(msg), 'no simulation clock') > 0 .AND. INDEX(c_text(msg), 'Currents 2') > 0, & + 'c-api-currents2:varying-in-time-message') + CALL write_capi_currents_deck(DECK_PATH, '0.1 0.1 0.0 0.0') + CALL CableDyn_InitDeck(handle, C_LOC(c_path), INT(LEN(DECK_PATH), C_INT), es) + CALL require(es == 0_C_INT, 'c-api-currents2:constant-in-time-applied') + CALL CableDyn_Close(handle, es) + CALL require(es == 0_C_INT .AND. .NOT. C_ASSOCIATED(handle), 'c-api-currents2:close') + END SUBROUTINE case_deck_current_in_time + + SUBROUTINE write_capi_currents_deck(path, row_later) + !! The smoke deck with Currents 2 and its current_profile_dynamic.txt: x velocities + !! 0.1 m/s at the two depths at t = 0 and the given row at t = 5 s. + CHARACTER(*), INTENT(IN) :: path, row_later + INTEGER :: u, ios + + OPEN (NEWUNIT=u, FILE='current_profile_dynamic.txt', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL require(ios == 0, 'c-api-currents2:create-table') + IF (ios /= 0) RETURN + WRITE (u, '(A)') 'MoorDyn dynamic currents' + WRITE (u, '(A)') 'header' + WRITE (u, '(A)') '' + WRITE (u, '(A)') '' + WRITE (u, '(A)') '-5.0 0.0' + WRITE (u, '(A)') 't ux uy' + WRITE (u, '(A)') '0.0 0.1 0.1 0.0 0.0' + WRITE (u, '(A)') '5.0 '//row_later + CLOSE (u) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL require(ios == 0, 'c-api-currents2:create-file') + IF (ios /= 0) RETURN + WRITE (u, '(A)') 'C API deck with a MoorDyn-C current table' + 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)') 'line 0.10 80.0 1.0e5 0.0 0.0 1.0 0.0 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 Fixed 0.0 0.0 -1.0' + WRITE (u, '(A)') '2 Coupled 0.8 0.0 -1.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 2 1 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 1.0 4' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '5.0 WtrDpth' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '1.0 TMax' + WRITE (u, '(A)') '2 Currents' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1 AnchTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_capi_currents_deck + SUBROUTINE case_init_update_output_step() TYPE(C_PTR) :: handle INTEGER(C_INT), TARGET :: elem_conn(2), fixed_dofs(6) @@ -543,11 +625,11 @@ SUBROUTINE case_deck_bodies_rods() !! deck dtM, and 20 driven steps reproduce CD_AGG driven directly bit-for-bit (loads and !! coupled motion), also across a SaveState / three trial steps / RestoreState rewind half !! way. A mismatched dt, load derivatives and point fluid fields fail closed by name; a - !! Coupled rod (a 6-DOF host node) and a CoupledPinned rod (a host-driven pin) are rejected - !! by the standalone deck rules. + !! Coupled rod (a 6-DOF host node), a CoupledPinned rod (a host-driven pin) and a + !! CoupledPinned body (a host-driven reference point) are rejected by the standalone deck rules. CHARACTER(*), PARAMETER :: ROD_DECK = 'capi_rod_deck.dat', BODY_DECK = 'capi_body_deck.dat', & HOST_DECK = 'capi_hostrod_deck.dat', PIN_DECK = 'capi_pinrod_deck.dat', & - HOST_PIN_DECK = 'capi_hostpin_deck.dat' + HOST_PIN_DECK = 'capi_hostpin_deck.dat', PIN_BODY_DECK = 'capi_pinbody_deck.dat' CHARACTER(KIND=C_CHAR), TARGET :: c_path(64) CHARACTER(KIND=C_CHAR), TARGET :: msg(300) TYPE(C_PTR) :: handle @@ -566,6 +648,7 @@ SUBROUTINE case_deck_bodies_rods() CALL write_capi_object_deck(HOST_DECK, 3) CALL write_capi_object_deck(PIN_DECK, 4) CALL write_capi_object_deck(HOST_PIN_DECK, 5) + CALL write_capi_object_deck(PIN_BODY_DECK, 6) DO ideck = 1, 3 SELECT CASE (ideck) CASE (1) @@ -670,12 +753,25 @@ SUBROUTINE case_deck_bodies_rods() CALL require(es == 3_C_INT .AND. INDEX(c_text(msg), 'requires a coupled host') > 0, & 'c-api-objects:host-pinned-rod-rejected') CALL CableDyn_Close(handle, es) + ! and a CoupledPinned body, whose reference point a coupled host moves + path = PIN_BODY_DECK + c_path = C_NULL_CHAR + DO i = 1, LEN_TRIM(path) + c_path(i) = path(i:i) + END DO + CALL CableDyn_Create(handle, es) + CALL CableDyn_InitDeck(handle, C_LOC(c_path), INT(LEN_TRIM(path), C_INT), es) + CALL CableDyn_GetLastError(handle, C_LOC(msg), INT(SIZE(msg), C_INT)) + CALL require(es == 3_C_INT .AND. INDEX(c_text(msg), 'BODY requires a coupled host') > 0, & + 'c-api-objects:host-pinned-body-rejected') + CALL CableDyn_Close(handle, es) END SUBROUTINE case_deck_bodies_rods SUBROUTINE write_capi_object_deck(path, kind) !! kind 1: a submerged free rod between a Fixed anchor and a Coupled fairlead; kind 2: the same !! with a free Rigid6 body; kind 3: a Coupled rod (a 6-DOF host node); kind 4: a Pinned rod - !! (End A on a fixed pin); kind 5: a CoupledPinned rod (its pin a host node). + !! (End A on a fixed pin); kind 5: a CoupledPinned rod (its pin a host node); kind 6: the + !! body of kind 2 as a CoupledPinned body (its reference point a host node). CHARACTER(*), INTENT(IN) :: path INTEGER, INTENT(IN) :: kind INTEGER :: u @@ -685,12 +781,16 @@ SUBROUTINE write_capi_object_deck(path, kind) WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' WRITE (u, '(A)') 'line 0.10 80.0 1.0e5 0.0 0.0 1.0 0.0 1.0 0.0' - IF (kind == 2) THEN + IF (kind == 2 .OR. kind == 6) THEN WRITE (u, '(A)') '--- BODIES ---' WRITE (u, '(A)') 'ID Type X Y Z Rot1 Rot2 Rot3 Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm/rad) (Nm/rad) (m2) (-) '// & '(kgm2) (kgm2) (kgm2)' - WRITE (u, '(A)') '1 Rigid6 0.0 0.0 -4.0 0.0 0.0 0.0 100.0 0.05 0.0 100.0 100.0 0.0 0.0 20.0 20.0 20.0' + IF (kind == 2) THEN + WRITE (u, '(A)') '1 Rigid6 0.0 0.0 -4.0 0.0 0.0 0.0 100.0 0.05 0.0 100.0 100.0 0.0 0.0 20.0 20.0 20.0' + ELSE + WRITE (u, '(A)') '1 CoupledPinned 0.0 0.0 -4.0 0.0 0.0 0.0 100.0 0.05 0.0 0.0 0.0 0.0 0.0 20.0 20.0 20.0' + END IF ELSE WRITE (u, '(A)') '--- ROD TYPES ---' WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' @@ -714,7 +814,7 @@ SUBROUTINE write_capi_object_deck(path, kind) 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 Fixed 2.0 0.0 -5.0 0.0 0.0 0.0 0.0' - IF (kind == 2) THEN + IF (kind == 2 .OR. kind == 6) THEN WRITE (u, '(A)') '2 Body1 0.0 0.0 0.0 0.0 0.0 0.0 0.0' WRITE (u, '(A)') '3 Coupled 0.0 0.0 -1.0 0.0 0.0 0.0 0.0' ELSE @@ -726,7 +826,7 @@ SUBROUTINE write_capi_object_deck(path, kind) WRITE (u, '(A)') 'ID NodeA NodeB Outputs' WRITE (u, '(A)') '(-) (-) (-) (-)' WRITE (u, '(A)') '1 2 1 -' - IF (kind == 2) THEN + IF (kind == 2 .OR. kind == 6) THEN WRITE (u, '(A)') '2 3 2 -' ELSE WRITE (u, '(A)') '2 3 4 -' @@ -734,7 +834,7 @@ SUBROUTINE write_capi_object_deck(path, kind) WRITE (u, '(A)') '--- SECTIONS ---' WRITE (u, '(A)') 'LineID LineType Length NumSegs' WRITE (u, '(A)') '(-) (-) (m) (-)' - IF (kind == 2) THEN + IF (kind == 2 .OR. kind == 6) THEN WRITE (u, '(A)') '1 line 2.5 3' WRITE (u, '(A)') '2 line 2.95 3' ELSE diff --git a/tests/test_mdc_currents.f90 b/tests/test_mdc_currents.f90 new file mode 100644 index 00000000..f18e724f --- /dev/null +++ b/tests/test_mdc_currents.f90 @@ -0,0 +1,273 @@ +! File: tests/test_mdc_currents.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> MoorDyn-C time-varying and gridded currents (Currents 2, current_profile_dynamic.txt, and +!> Currents 5, current_profile_4d.txt) on the shared inputs of tests/data/currents_mdc: the deck +!> current CableDyn samples (CD_Deck_Fluid_Probe) at given points and times against +!> - MoorDyn-C v2.7.1 itself (ref_moordyn_c.csv, validation/scripts/wavekin_mdc_probe.cpp) and an +!> independent Python evaluation of the files (ref_python.csv, +!> validation/scripts/currents_mdc_reference.py), both to 1e-14 m/s: a time-varying depth +!> profile with uneven times (c2, sampled past the table's last time, where MoorDyn-C's grid +!> repeats), single-precision depths and x velocities only (c2stof), a grid uniform in x and y +!> (c5uniform) and a grid sheared in x, y and z and varying in time (c5); the current has no +!> acceleration, as in MoorDyn-C; +!> - a second source of the same field: Currents 2 with the steady profile of current_profile.txt +!> at every time (c2const) equals Currents 1 (c1) to round-off, and the grid uniform in x and y +!> (c5uniform) equals the Currents 2 profile (c2) to round-off, inside and beyond its x-y span; +!> - a line-6 data row of current_profile_4d.txt (the layout of MoorDyn-C's documentation) is a +!> grid point, not a header; +!> - malformed tables, Currents 3 and 4 (no current source in MoorDyn-C v2.7.1) and a second +!> current source fail closed by name. +PROGRAM test_mdc_currents + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Deck_Fluid_Probe, CD_DECKDRV_OK + IMPLICIT NONE + INTEGER :: n_fail = 0 + CHARACTER(*), PARAMETER :: CASES(6) = [CHARACTER(9) :: 'c1', 'c2const', 'c2', 'c2stof', 'c5uniform', 'c5'] + INTEGER :: k + + DO k = 1, SIZE(CASES) + CALL check_reference(TRIM(CASES(k)), 'ref_moordyn_c.csv', 'MoorDyn-C v2.7.1') + CALL check_reference(TRIM(CASES(k)), 'ref_python.csv', 'the Python evaluation') + END DO + CALL check_same_field('c2const', 'c1', 1, 'Currents 2 (a constant table) vs Currents 1') + CALL check_same_field('c5uniform', 'c2', 2, 'Currents 5 (uniform in x and y) vs Currents 2') + CALL check_line6_row() + CALL check_rejections() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' MoorDyn-C current gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: MoorDyn-C Currents 2 and 5 match MoorDyn-C and the independent evaluation' + +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 read_reference(path, ref, ok) + !! The rows "t,x,y,z,zeta,ux,uy,uz,ax,ay,az" of a probe CSV into ref(11, n). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), ALLOCATABLE, INTENT(OUT) :: ref(:, :) + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios, n, i + CHARACTER(1024) :: buf + ok = .FALSE. + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + n = 0 + DO + READ (u, '(A)', IOSTAT=ios) buf + IF (ios /= 0) EXIT + IF (LEN_TRIM(buf) > 0) n = n + 1 + END DO + REWIND (u) + READ (u, '(A)') buf + ALLOCATE (ref(11, n - 1)) + DO i = 1, n - 1 + READ (u, *, IOSTAT=ios) ref(:, i) + IF (ios /= 0) THEN + CLOSE (u) + RETURN + END IF + END DO + CLOSE (u) + ok = n > 1 + END SUBROUTINE read_reference + + SUBROUTINE probe(deck, ref, vel, acc, ok) + !! The deck current at the reference rows' points and times. + CHARACTER(*), INTENT(IN) :: deck + REAL(wp), INTENT(IN) :: ref(:, :) + REAL(wp), ALLOCATABLE, INTENT(OUT) :: vel(:, :), acc(:, :) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), ALLOCATABLE :: eta(:) + INTEGER :: es + CHARACTER(512) :: em + ALLOCATE (eta(SIZE(ref, 2)), vel(3, SIZE(ref, 2)), acc(3, SIZE(ref, 2))) + CALL CD_Deck_Fluid_Probe(deck, ref(2:4, :), ref(1, :), eta, vel, acc, es, em) + ok = es == CD_DECKDRV_OK + CALL require(ok, deck//': deck current evaluated: '//TRIM(em)) + END SUBROUTINE probe + + SUBROUTINE check_reference(case, csv, label) + CHARACTER(*), INTENT(IN) :: case, csv, label + REAL(wp), ALLOCATABLE :: ref(:, :), vel(:, :), acc(:, :) + REAL(wp) :: e_vel, e_acc + LOGICAL :: ok + CALL read_reference('../currents_mdc/'//case//'/'//csv, ref, ok) + CALL require(ok, case//': reference '//csv//' readable') + IF (.NOT. ok) RETURN + CALL probe('../currents_mdc/'//case//'/currents.dat', ref, vel, acc, ok) + IF (.NOT. ok) RETURN + e_vel = nan_max_abs(vel - ref(6:8, :)) + e_acc = nan_max_abs(acc - ref(9:11, :)) + WRITE (*, '(A,A,A,A,A,A,I0,A,ES10.3,A,ES10.3,A,ES10.3,A)') case, ' vs ', label, ' (', csv, ', ', SIZE(ref, 2), & + ' samples): velocity ', e_vel, ' m/s of ', nan_max_abs(ref(6:8, :)), ' m/s, acceleration ', e_acc, ' m/s^2' + CALL require(e_vel <= 1.0e-14_wp, case//': the current matches '//label) + CALL require(e_acc <= 0.0_wp, case//': the current has no acceleration, as in '//label) + END SUBROUTINE check_reference + + SUBROUTINE check_same_field(case, other, repeat, label) + !! The current of case at the points of its reference equals that of other at the same depths + !! and times: each row of other's reference stands for repeat consecutive rows of case's (the + !! uniform grid's points are other's and points far outside its x-y span). + CHARACTER(*), INTENT(IN) :: case, other, label + INTEGER, INTENT(IN) :: repeat + REAL(wp), ALLOCATABLE :: ref(:, :), ref_o(:, :), vel(:, :), acc(:, :), vel_o(:, :), acc_o(:, :) + REAL(wp) :: err + INTEGER :: i, j + LOGICAL :: ok, ok_o + CALL read_reference('../currents_mdc/'//case//'/ref_python.csv', ref, ok) + CALL read_reference('../currents_mdc/'//other//'/ref_python.csv', ref_o, ok_o) + CALL require(ok .AND. ok_o, label//': points readable') + IF (.NOT. (ok .AND. ok_o)) RETURN + CALL require(SIZE(ref, 2) == repeat*SIZE(ref_o, 2), label//': point sets correspond') + IF (SIZE(ref, 2) /= repeat*SIZE(ref_o, 2)) RETURN + CALL probe('../currents_mdc/'//case//'/currents.dat', ref, vel, acc, ok) + CALL probe('../currents_mdc/'//other//'/currents.dat', ref_o, vel_o, acc_o, ok_o) + IF (.NOT. (ok .AND. ok_o)) RETURN + err = 0.0_wp + DO i = 1, SIZE(ref_o, 2) + DO j = 1, repeat + CALL require(ref(1, repeat*(i - 1) + j) == ref_o(1, i) .AND. ref(4, repeat*(i - 1) + j) == ref_o(4, i), & + label//': the same time and depth') + err = MAX(err, nan_max_abs(vel(:, repeat*(i - 1) + j) - vel_o(:, i))) + END DO + END DO + WRITE (*, '(A,A,I0,A,ES10.3,A)') label, ' (', SIZE(ref, 2), ' samples): velocity ', err, ' m/s' + CALL require(err <= 4.0_wp*EPSILON(1.0_wp), label//': the same current to round-off') + END SUBROUTINE check_same_field + + SUBROUTINE write_deck(path, currents, extra_option) + !! A one-line probe deck with the given Currents row (and an optional extra OPTIONS row). + CHARACTER(*), INTENT(IN) :: path, currents + CHARACTER(*), INTENT(IN), OPTIONAL :: extra_option + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '--------------------- MoorDyn Input File ------------------------------------' + WRITE (u, '(A)') 'MoorDyn-C current table checks' + WRITE (u, '(A)') '----------------------- LINE TYPES ------------------------------------------' + WRITE (u, '(A)') 'TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx' + WRITE (u, '(A)') '(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0' + WRITE (u, '(A)') '---------------------- POINT PROPERTIES --------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z Mass Volume CdA Ca' + WRITE (u, '(A)') '(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Fixed -30.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '2 Vessel 30.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '---------------------- LINES ----------------------------------------' + WRITE (u, '(A)') 'ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs' + WRITE (u, '(A)') '(#) (name) (#) (#) (m) (-) (-)' + WRITE (u, '(A)') '1 chain 2 1 70.0 20 -' + WRITE (u, '(A)') '---------------------- OPTIONS -----------------------------------------' + WRITE (u, '(A)') '0.002 dtM' + WRITE (u, '(A)') '10.0 TMax' + WRITE (u, '(A)') '50 WtrDpth' + WRITE (u, '(A)') currents//' Currents' + IF (PRESENT(extra_option)) WRITE (u, '(A)') extra_option + WRITE (u, '(A)') '------------------------- need this line --------------------------------------' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE write_text(path, lines) + CHARACTER(*), INTENT(IN) :: path, lines(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO i = 1, SIZE(lines) + WRITE (u, '(A)') TRIM(lines(i)) + END DO + CLOSE (u) + END SUBROUTINE write_text + + SUBROUTINE check_line6_row() + !! current_profile_4d.txt with its first grid point on line 6, as MoorDyn-C's documentation + !! lays the file out: that row is read (MoorDyn-C v2.7.1 starts at line 7 and leaves the point + !! at zero), so the current at the corner (x, y, z, t) = (-1, -2, -3, 0) is the row's. + REAL(wp) :: pos(3, 2), t(2), eta(2), vel(3, 2), acc(3, 2) + INTEGER :: es + CHARACTER(512) :: em + CALL write_deck('mdc_line6.dat', '5') + CALL write_text('current_profile_4d.txt', [CHARACTER(40) :: '2 2 2 2', '-1 1', '-2 2', '-3 0', '0 15', & + '-1 -2 -3 0 0.7 -0.2 0.05', '-1 -2 0 0 0.0 0.0 0.0', '-1 2 -3 0 0.0 0.0 0.0', & + '-1 2 0 0 0.0 0.0 0.0', '1 -2 -3 0 0.0 0.0 0.0', '1 -2 0 0 0.0 0.0 0.0', & + '1 2 -3 0 0.0 0.0 0.0', '1 2 0 0 0.0 0.0 0.0', '-1 -2 -3 15 -0.5 -0.5 0.0', & + '-1 -2 -0 15 -1.0 -1.0 0.0', '-1 2 -3 15 -0.5 0.5 0.0', '-1 2 -0 15 -1.0 1.0 0.0', & + '1 -2 -3 15 0.5 -0.5 0.0', '1 -2 -0 15 1.0 -1.0 0.0', '1 2 -3 15 0.5 0.5 0.0', & + '1 2 -0 15 1.0 1.0 0.0']) + pos(:, 1) = [-5.0_wp, -7.0_wp, -9.0_wp] + pos(:, 2) = [3.0_wp, 4.0_wp, 1.0_wp] + t = [0.0_wp, 7.5_wp] + CALL CD_Deck_Fluid_Probe('mdc_line6.dat', pos, t, eta, vel, acc, es, em) + CALL require(es == CD_DECKDRV_OK, 'line-6 row: evaluated: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + WRITE (*, '(A,3ES12.4,A,3ES12.4)') 'line-6 row: corner current ', vel(:, 1), '; (1, 2, 0) at 7.5 s ', vel(:, 2) + CALL require(nan_max_abs(vel(:, 1) - [0.7_wp, -0.2_wp, 0.05_wp]) <= 0.0_wp, & + 'line-6 row: the first grid point is the row on line 6') + ! "-0" is the coordinate 0 (matched by value): half of the 15 s value at the (1, 2, 0) corner + CALL require(nan_max_abs(vel(:, 2) - [0.5_wp, 0.5_wp, 0.0_wp]) <= 1.0e-15_wp, & + 'line-6 row: a "-0" coordinate is the grid coordinate 0') + END SUBROUTINE check_line6_row + + SUBROUTINE expect_failure(currents, file, lines, needle, extra_option) + !! The deck with the given Currents row and the table lines written to file fails, naming needle. + CHARACTER(*), INTENT(IN) :: currents, file, lines(:), needle + CHARACTER(*), INTENT(IN), OPTIONAL :: extra_option + REAL(wp) :: pos(3, 1), t(1), eta(1), vel(3, 1), acc(3, 1) + INTEGER :: es + CHARACTER(512) :: em + pos = 0.0_wp + pos(3, 1) = -5.0_wp + t = 0.0_wp + IF (PRESENT(extra_option)) THEN + CALL write_deck('mdc_fail.dat', currents, extra_option) + ELSE + CALL write_deck('mdc_fail.dat', currents) + END IF + IF (LEN_TRIM(file) > 0) CALL write_text(file, lines) + CALL CD_Deck_Fluid_Probe('mdc_fail.dat', pos, t, eta, vel, acc, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, needle) > 0, 'Currents '//currents// & + ' fails closed naming "'//needle//'": '//TRIM(em)) + END SUBROUTINE expect_failure + + SUBROUTINE check_rejections() + CHARACTER(*), PARAMETER :: DYN = 'current_profile_dynamic.txt', G4 = 'current_profile_4d.txt' + CHARACTER(40), PARAMETER :: HEAD(4) = [CHARACTER(40) :: 'MoorDyn dynamic currents', 'header', '', ''] + CALL expect_failure('3', '', [CHARACTER(1) :: ' '], 'no current source in MoorDyn-C v2.7.1') + CALL expect_failure('4', '', [CHARACTER(1) :: ' '], 'no current source in MoorDyn-C v2.7.1') + ! Currents 2: a row with a partial velocity set, times out of order, one time row, depths + ! out of order, a non-number + CALL expect_failure('2', DYN, [CHARACTER(40) :: HEAD, '-10 0', 'h', '0 0.1 0.2', '5 0.1 0.2 0.3'], & + 'found 4') + CALL expect_failure('2', DYN, [CHARACTER(40) :: HEAD, '-10 0', 'h', '5 0.1 0.2', '0 0.1 0.2'], & + 'times must be strictly increasing') + CALL expect_failure('2', DYN, [CHARACTER(40) :: HEAD, '-10 0', 'h', '0 0.1 0.2'], 'at least two time rows') + CALL expect_failure('2', DYN, [CHARACTER(40) :: HEAD, '0 -10', 'h', '0 0.1 0.2', '5 0.1 0.2'], & + 'depths must be strictly increasing') + CALL expect_failure('2', DYN, [CHARACTER(40) :: HEAD, '-10 0', 'h', '0 0.1 0.2', '5 0.1 1/2'], & + 'is not a plain finite number') + CALL expect_failure('2', DYN, [CHARACTER(40) :: HEAD, '-10 0', 'h', '0 0.1 0.2', '5 0.1 0.2'], & + 'double-counting', 'uniform 0.2 0 0 current') + ! Currents 5: a missing, a repeated and an off-grid point, one time, a short coordinate line + CALL expect_failure('5', G4, [CHARACTER(40) :: '1 1 1 2', '0', '0', '0', '0 5', '0 0 0 0 0.1 0 0'], & + 'has no row for the grid point') + CALL expect_failure('5', G4, [CHARACTER(40) :: '1 1 1 2', '0', '0', '0', '0 5', '0 0 0 0 0.1 0 0', & + '0 0 0 0 0.1 0 0'], 'repeats a grid point') + CALL expect_failure('5', G4, [CHARACTER(40) :: '1 1 1 2', '0', '0', '0', '0 5', '0 0 0 0 0.1 0 0', & + '0 0 0 6 0.1 0 0'], 'off the grid') + CALL expect_failure('5', G4, [CHARACTER(40) :: '1 1 1 1', '0', '0', '0', '0', '0 0 0 0 0.1 0 0'], & + 'at least two times') + CALL expect_failure('5', G4, [CHARACTER(40) :: '2 1 1 2', '0', '0', '0', '0 5', '0 0 0 0 0.1 0 0'], & + 'must list the 2 x coordinates') + CALL expect_failure('5', G4, [CHARACTER(40) :: '1 1 2 2', '0', '0', '0 -1', '0 5', '0 0 0 0 0.1 0 0'], & + 'coordinates must be strictly increasing') + END SUBROUTINE check_rejections +END PROGRAM test_mdc_currents diff --git a/tests/test_mdc_currents_runs.py b/tests/test_mdc_currents_runs.py new file mode 100644 index 00000000..12a09236 --- /dev/null +++ b/tests/test_mdc_currents_runs.py @@ -0,0 +1,260 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Standalone runs in the MoorDyn-C time-varying and gridded currents (Currents 2 and 5). + +The inputs are those of tests/data/currents_mdc (validation/scripts/currents_mdc_reference.py). +Gates, each run through the cabledyn driver with the line node tension channels Ten1N1..Ten1N21: + +* against MoorDyn-C v2.7.1 itself (ref_moordyn_c_tension.csv; a 70 m rope across the flow, held + at both ends, from rest in still water): the still-water tensions within 0.3 % of MoorDyn-C's, + and the tension change the current makes over 22 s (each code's run minus its own still-water + run) within 15 % of MoorDyn-C's largest change, for a depth profile that varies in time + (tension_c2) and for a grid sheared along the line, in depth and in time (tension_c5) (measured: + 0.8 % and 0.9 %; the still-water tensions 0.12 %); +* a second source of the same field, on the EI = 0 and the finite-EI routes: Currents 2 with the + steady profile at every time equals Currents 1 (c2const, c1), and the Currents 5 grid uniform in + x and y equals the Currents 2 profile (c5uniform, c2), every channel to the 8 significant digits + the .out file prints (measured: identical, and one unit of the last digit); +* the static start in a grid sheared along the line and in depth (the tension_c5 grid frozen in + time) is an equilibrium of the march on the EI = 0, the finite-EI and the point-connected EI = 0 + routes: over the first 2 s the tensions move by less than 1e-4 of the change the current makes + to the still-water start (a finite-EI static that samples the grid in its translated solve frame + instead of at the global node positions moves them by 0.8 of it); +* a current that is zero along the straight chord but not where the line sags (offchord: Currents 1 + and 2 on the EI = 0 route, Currents 2 on the finite-EI route) is in the static start: the march + then moves the tensions by less than 1e-4 of the change the current makes, and the EI = 0 start + is within 0.5 % of the finite-EI one (an EI = 0 start in still water drifted 192 N in 4 s). + +usage: test_mdc_currents_runs.py --exe --data --output

+""" + +from __future__ import annotations + +import argparse +import os +import shutil +import subprocess +import sys +from pathlib import Path + +import numpy as np + +FAILURES: list[str] = [] +END_LINE = "------------------------- need this line --------------------------------------" +OUTPUTS = "---------------------- OUTPUTS -----------------------------------------\n" + "\n".join( + f"Ten1N{j}" for j in range(1, 22) +) + + +def check(ok: bool, message: str) -> None: + print(("PASS: " if ok else "FAIL: ") + message) + if not ok: + FAILURES.append(message) + + +def deck_text(path: Path, finite_ei: bool = False, tmax: float | None = None) -> str: + """The MoorDyn-C deck with the tension channels (and optionally EI > 0, another TMax).""" + lines = [] + for line in path.read_text().splitlines(): + parts = line.split() + if line.startswith("------------------------- need this line"): + lines.append(OUTPUTS) + if finite_ei and len(parts) == 10 and parts[0] in {"chain", "rope"}: + parts[5] = "2.0e3" + line = " ".join(parts) + if tmax is not None and len(parts) >= 2 and parts[1] == "TMax": + line = f"{tmax} TMax" + lines.append(line) + return "\n".join(lines) + "\n" + + +def run(exe: str, folder: Path, name: str, text: str, tables: list[Path]) -> np.ndarray | None: + """Run text in folder (with the current tables copied in); the .out rows, time first.""" + folder.mkdir(parents=True, exist_ok=True) + for table in tables: + shutil.copy2(table, folder / table.name) + (folder / f"{name}.dat").write_text(text, encoding="utf-8", newline="\n") + proc = subprocess.run([exe, f"{name}.dat", name], cwd=folder, capture_output=True, text=True, + env=dict(os.environ, OMP_NUM_THREADS="1")) + check(proc.returncode == 0, f"{folder.name}/{name} runs (exit {proc.returncode})") + if proc.returncode != 0: + print(proc.stdout[-2000:], proc.stderr[-2000:]) + return None + lines = (folder / f"{name}.out").read_text().splitlines() + head = next(i for i, line in enumerate(lines) if line.split() and line.split()[0].startswith("Time")) + return np.array([[float(v) for v in line.split()] for line in lines[head + 1:] + if line.strip() and not line.lstrip().startswith("(")]) + + +def tables(case: Path) -> list[Path]: + return sorted(case.glob("current_profile*.txt")) + + +def against_moordyn_c(exe: str, data: Path, out: Path) -> None: + """Node tensions of the tension cases against MoorDyn-C's.""" + series = {} + for case in ("tension_c0", "tension_c2", "tension_c5"): + src = data / case + cd = run(exe, out / case, "tension", deck_text(src / "tension.dat"), tables(src)) + if cd is None: + return + mdc = np.loadtxt(src / "ref_moordyn_c_tension.csv", delimiter=",", skiprows=1) + # CableDyn's rows every dtM at MoorDyn-C's output times; CableDyn node J (from End A) is + # MoorDyn-C node J - 1 + rows = np.searchsorted(cd[:, 0], mdc[:, 0] - 1.0e-9) + check(bool(np.all(np.abs(cd[rows, 0] - mdc[:, 0]) < 1.0e-6)), f"{case}: the output times correspond") + series[case] = (cd[rows, 1:22], mdc[:, 1:22]) + # interior nodes 2-20, where both codes report the mean of the two adjacent segment tensions + # (at an end MoorDyn-C reports the end segment's, CableDyn the line-end force) + cd0, mdc0 = series["tension_c0"] + still = np.abs(cd0[:, 1:20] - mdc0[:, 1:20]).max() / np.abs(mdc0[:, 1:20]).max() + check(still <= 3.0e-3, f"still water: node tensions within {still:.2e} of MoorDyn-C's (0.3 %)") + for case in ("tension_c2", "tension_c5"): + cd, mdc = series[case] + d_cd, d_mdc = cd - cd0, mdc - mdc0 + scale = np.abs(d_mdc[:, 1:20]).max() + err = np.abs(d_cd[:, 1:20] - d_mdc[:, 1:20]).max() + rms = np.sqrt(np.mean((d_cd[:, 1:20] - d_mdc[:, 1:20]) ** 2)) + check(err <= 0.03 * scale, + f"{case}: the tension change of the current, MoorDyn-C's largest {scale:.0f} N, matches to " + f"{err:.1f} N ({err / scale:.1%}, rms {rms / scale:.1%}) at nodes 2-20 over 22 s (3 %)") + + +def same_field(exe: str, data: Path, out: Path) -> None: + """Two sources of the same current give the same run, on both routes.""" + for case, other, label in (("c2const", "c1", "Currents 2 (a constant table) vs Currents 1"), + ("c5uniform", "c2", "Currents 5 (uniform in x and y) vs Currents 2")): + for finite in (False, True): + route = "finite-EI" if finite else "EI = 0" + a = run(exe, out / f"{case}_{int(finite)}", "run", + deck_text(data / case / "currents.dat", finite, tmax=8.0), tables(data / case)) + b = run(exe, out / f"{other}_{int(finite)}", "run", + deck_text(data / other / "currents.dat", finite, tmax=8.0), tables(data / other)) + if a is None or b is None: + continue + # the runs agree to the 8 significant digits the .out file prints (the fields differ + # by round-off, which the Newton iterations of the march may carry to the last digit) + ok = a.shape == b.shape + if ok: + unit = 10.0 ** (np.floor(np.log10(np.maximum(np.abs(b[:, 1:]), 1.0e-300))) - 7.0) + digits = np.abs(a[:, 1:] - b[:, 1:]) / unit + ok = bool(np.all(digits <= 1.01)) + print(f" {label}, {route}: largest difference {np.abs(a - b).max():.1e} N, " + f"{digits.max():.2f} units of the last printed digit") + check(ok, f"{label}, {route}: every channel the same to the last printed digit") + + +def static_start(exe: str, data: Path, out: Path) -> None: + """The static start in a sheared grid, frozen in time, is an equilibrium of the march.""" + src = (data / "tension_c5" / "current_profile_4d.txt").read_text().splitlines() + head, rows = src[:6], src[6:] + dims = head[0].split() + frozen = [" ".join(dims[:3] + ["2"])] + head[1:4] + ["0.0 100.0"] + [head[5]] + t_keep = "15.0" + for t_new in ("0.0", "100.0"): + for row in rows: + parts = row.split() + if parts[3] == t_keep: + parts[3] = t_new + frozen.append(" ".join(parts)) + for kind in ("EI = 0", "finite-EI", "EI = 0 with a free point"): + tag = kind.replace(" ", "_").replace("=", "") + folder = out / f"static_{tag}" + folder.mkdir(parents=True, exist_ok=True) + (folder / "current_profile_4d.txt").write_text("\n".join(frozen) + "\n", encoding="utf-8", newline="\n") + if kind == "EI = 0 with a free point": + text_cur = two_line_deck(5) + text_still = two_line_deck(0) + else: + finite = kind == "finite-EI" + text_cur = deck_text(data / "tension_c5" / "tension.dat", finite, tmax=2.0) + text_still = deck_text(data / "tension_c0" / "tension.dat", finite, tmax=2.0) + cur = run(exe, folder, "run", text_cur, []) + still = run(exe, out / f"still_{tag}", "run", text_still, []) + if cur is None or still is None: + continue + step = np.abs(cur[0, 1:] - still[0, 1:]).max() + drift = np.abs(cur[:, 1:] - cur[0, 1:]).max() + check(step > 0.05 * np.abs(still[0, 1:]).max() and drift <= 1.0e-4 * step, + f"{kind}: the static start in the sheared grid moves the tensions by {step:.0f} N from still " + f"water; the march then moves them by {drift:.2e} N ({drift / step:.1e}, 1e-4) over 2 s") + + +def current_below_the_chord(exe: str, data: Path, out: Path) -> None: + """The static start in a current that is zero along the straight chord but not where the line + sags (offchord: 0.8 m/s below z = -32 m, the ends at z = -20 m) carries the current: the march + then holds the start, and the EI = 0 start agrees with the finite-EI one.""" + src = data / "offchord" + tables = [src / "current_profile.txt", src / "current_profile_dynamic.txt"] + runs = {} + for name, finite in (("c1", False), ("c2", False), ("c2", True)): + tag = f"{name}_{'fei' if finite else 'ei0'}" + text = deck_text(src / f"{name}.dat", finite) + runs[tag] = run(exe, out / f"offchord_{tag}", "run", text, tables) + still = run(exe, out / "offchord_still", "run", deck_text(data / "tension_c0" / "tension.dat", tmax=4.0), []) + if still is None or any(r is None for r in runs.values()): + return + for tag, r in runs.items(): + step = np.abs(r[0, 1:] - still[0, 1:]).max() + drift = np.abs(r[:, 1:] - r[0, 1:]).max() + check(step > 0.05 * np.abs(still[0, 1:]).max() and drift <= 1.0e-4 * step, + f"current below the chord, {tag}: the static start carries it ({step:.0f} N from still water); " + f"the march then moves the tensions by {drift:.2e} N over 4 s (1e-4 of that)") + ei0, fei = runs["c2_ei0"][0, 1:], runs["c2_fei"][0, 1:] + gap = np.abs(ei0 - fei).max() / np.abs(fei).max() + check(gap <= 5.0e-3 and np.array_equal(runs["c1_ei0"][0, 1:], ei0), + f"current below the chord: the EI = 0 start within {gap:.1e} of the finite-EI one (0.5 %), and " + "Currents 1 and 2 give the same start") + + +def two_line_deck(currents: int) -> str: + """The tension rope as two EI = 0 lines meeting at a free point (the point-connected route).""" + return f"""--------------------- MoorDyn Input File ------------------------------------ +two lines meeting at a free point (Currents {currents}) +----------------------- LINE TYPES ------------------------------------------ +TypeName Diam Mass/m EA BA/-zeta EI Cd Ca CdAx CaAx +(name) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +rope 0.3 80.0 1.0e7 -1.0 0 1.2 1.0 0.2 0.0 +---------------------- POINT PROPERTIES -------------------------------- +ID Type X Y Z Mass Volume CdA Ca +(#) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 0.0 -30.0 -20.0 0 0 0 0 +2 Free 4.0 0.0 -32.0 200 0.05 0.5 1.0 +3 Vessel 0.0 30.0 -20.0 0 0 0 0 +---------------------- LINES ---------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs LineOutputs +(#) (name) (#) (#) (m) (-) (-) +1 rope 2 1 35.0 10 - +2 rope 3 2 35.0 10 - +---------------------- OPTIONS ----------------------------------------- +0.002 dtM +2.0 TMax +1025.0 WtrDnsty +50 WtrDpth +0 WaveKin +{currents} Currents +{OUTPUTS.split(chr(10))[0]} +""" + "\n".join(f"Ten{line}N{j}" for line in (1, 2) for j in range(1, 12)) + f"\n{END_LINE}\n" + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument("--exe", required=True) + parser.add_argument("--data", required=True) + parser.add_argument("--output", required=True) + args = parser.parse_args() + data, out = Path(args.data), Path(args.output) + if out.exists(): + shutil.rmtree(out) + out.mkdir(parents=True) + against_moordyn_c(args.exe, data, out) + same_field(args.exe, data, out) + static_start(args.exe, data, out) + current_below_the_chord(args.exe, data, out) + print(f"{len(FAILURES)} failure(s)") + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tests/test_openfast_pinned_body.f90 b/tests/test_openfast_pinned_body.f90 new file mode 100644 index 00000000..d47deb78 --- /dev/null +++ b/tests/test_openfast_pinned_body.f90 @@ -0,0 +1,1668 @@ +! File: tests/test_openfast_pinned_body.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_openfast_pinned_body + !! CoupledPinned/VesselPinned BODIES on the OpenFAST CompMooring = 5 aggregate (MoorDyn-F's coupled + !! pinned body: the host prescribes the translation of the body reference point and takes its + !! force; the body's rotation about it is integrated). Gates: + !! 1) a dry compound pendulum (CG 2 m below the node, a line attached at the node) whose node is + !! held swings with the period of the complete elliptic integral (1e-3 at dt = T/100), its + !! reference point stays on the node, the node moment is zero and the node force is the + !! analytic pin reaction plus the line force at the node (1e-10 of m g); + !! 2) under a constant node acceleration a it swings about -atan(a/g) with the period of the + !! effective gravity sqrt(g^2 + a^2); + !! 3) a second route: a body with the mass, CG and inertia of a CoupledPinned ROD, carrying the + !! rod's End B line at the same arm, follows the rod (axis, angular velocity and node force) + !! under a harmonic node surge to 1e-9; + !! 4) a body on four symmetric lines whose node heaves does not turn (|omega| <= 1e-12 rad/s) + !! and its node force is the sum of the line forces plus weight, buoyancy and the + !! translational inertia (m + rhoW V Ca) a (1e-10); + !! 5) an output probe returns -m (I_cg/I_p) a_p for a node acceleration a_p (the re-solved + !! rotation) besides the change of the line force at the node, with zero moment; + !! 6) snapshot / step / restore / step is bit-identical, a probe restored as the shell + !! restores it leaves the march bit-identical, and a fresh instance overlaid with the + !! checkpoint state returns the same loads before the next step and continues bit for bit; + !! 7) PtfmInit moves the node and turns the body with the platform, and the static initial + !! condition balances the moment about the node (1e-6); + !! 8) a body held by stiff tethers sub-cycles a coarse coupling step it could not take + !! explicitly and matches a run at the sub-step size; the node orientation and angular + !! rates are ignored; + !! 9) beside a Coupled body (a 6-DOF host node, deck BODY order) the pinned body keeps its own + !! motion: the same as alone to 1e-12; + !! 10) the OpenFAST shell's order (a state-mirror restore after the output call at t = 0, before + !! the first step) starts every integrated object from its solved start acceleration: the + !! pinned body (line at the node, and at an arm), a Free Rigid6 body, and Free, Pinned and + !! CoupledPinned rods march bit for bit as without the restore; + !! 11) a CoupledPinned body outside a coupled host, without inertia, or under the linearisation + !! probe (coupled_positions) is refused by name, and so is MoorDyn-F's inertialF 0 (CableDyn + !! always returns the inertia; inertialF 1 is accepted); + !! 12) in a host fluid field (a current and a fluid acceleration at every node) a Free Rigid6 body + !! and a Free rod start from their accelerations in that field: after CD_AGG_SetFluidFields + !! the body's start acceleration differs from the still-water one by the drag over the + !! effective mass, 0.5 rhoW CdA |U| U / (m + rhoW V Ca) (1e-5: the lines' end-node mass is + !! left out), and the first steps of + !! SetFluidFields then Step, of the shell's order (the t = 0 field at Init, the output call + !! and its mirror restore, the field again before the step) and of a correction rewind to + !! before the first step are those of a run whose start accelerations are solved in the + !! field at a step-start transfer, bit for bit, and differ from the still-water start. + USE CableDyn_Precision, ONLY: wp + 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_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_Snapshot, CD_AGG_Restore, & + CD_AGG_End, CD_AGG_OK, CD_AGG_HasRigid6, CD_AGG_HasRod, & + CD_AGG_Rigid6_MirrorSize, CD_AGG_Get_Rigid6_States, & + CD_AGG_Set_Rigid6_States, CD_AGG_Rod_MirrorSize, CD_AGG_Get_Rod_States, & + CD_AGG_Set_Rod_States, CD_AGG_NFluidNodes, CD_AGG_SetFluidFields + USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_Get_System_Line_State, & + CD_Update_System_Line_Interior_State, CD_SYSTEM_OK, CD_System_NSystemCoupledDOF, & + CD_Get_System_CoupledMotion, CD_Update_System_CoupledMotion, CD_Calc_System_CoupledLoads + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp, G = 9.80665_wp, RHO = 1025.0_wp + ! the dry compound pendulum: mass MB, CG HCG below the node at z = ZPIN, Iyy about the CG + REAL(wp), PARAMETER :: MB = 1000.0_wp, HCG = 2.0_wp, IYY = 500.0_wp, ZPIN = 20.0_wp + ! the arm of the second route: a 4 m rod, 0.3 m diameter, 75 kg/m, pinned at z = 5 m, 20 deg + REAL(wp), PARAMETER :: LA = 4.0_wp, DA = 0.3_wp, MA = 300.0_wp, ZA = 5.0_wp, THA = 20.0_wp + ! the Free body of gate 12: mass, volume, CdA and Ca + REAL(wp), PARAMETER :: FB_M = 5000.0_wp, FB_V = 4.0_wp, FB_CDA = 6.0_wp, FB_CA = 0.8_wp + ! gate 12's host field (a current and a fluid acceleration), coupling step and step count + REAL(wp), PARAMETER :: FS_U(3) = [0.8_wp, 0.3_wp, 0.0_wp], FS_A(3) = [0.2_wp, 0.0_wp, 0.1_wp], FS_DT = 0.01_wp + INTEGER, PARAMETER :: FS_NSTEP = 5 + INTEGER :: nfail + + nfail = 0 + CALL case_pendulum_held() + CALL case_constant_acceleration() + CALL case_rod_second_route() + CALL case_symmetric_heave() + CALL case_probe() + CALL case_state() + CALL case_ptfm_static() + CALL case_substep() + CALL case_mixed_hosts() + CALL case_shell_start() + CALL case_refusals() + CALL case_fluid_start('pinbody_fluid_body.dat', .FALSE.) + CALL case_fluid_start('pinbody_fluid_rod.dat', .TRUE.) + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: CoupledPinned bodies on the coupled aggregate' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + WRITE (*, '(A)') 'MISMATCH: '//msg + nfail = nfail + 1 + END IF + END SUBROUTINE require + + ! --------------------------------------------------------------------------------------------- ! + ! decks ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_header(u, title) + INTEGER, INTENT(IN) :: u + CHARACTER(*), INTENT(IN) :: title + WRITE (u, '(A)') title + 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)') 'line 0.10 80.0 1.0e6 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') 'tether 0.05 4.0 2.0e5 0.0 0.0 1.0 0.0 1.0 0.0' + END SUBROUTINE write_header + + SUBROUTINE write_md_body(u, attachment, pos, rot_deg, mass, cg, inertia, vol) + !! A MoorDyn v2 14-column BODIES section with one body (no drag, no added mass). + INTEGER, INTENT(IN) :: u + CHARACTER(*), INTENT(IN) :: attachment + REAL(wp), INTENT(IN) :: pos(3), rot_deg(3), mass, cg(3), inertia(3), vol + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Attachment X0 Y0 Z0 r0 p0 y0 Mass CG* I* Volume CdA* Ca*' + WRITE (u, '(A)') '(#) (word) (m) (m) (m) (deg) (deg) (deg) (kg) (m) (kg-m^2) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 '//attachment//' '//num(pos(1))//' '//num(pos(2))//' '//num(pos(3))//' '// & + num(rot_deg(1))//' '//num(rot_deg(2))//' '//num(rot_deg(3))//' '//num(mass)//' '//bar3(cg)//' '// & + bar3(inertia)//' '//num(vol)//' 0 0' + END SUBROUTINE write_md_body + + FUNCTION num(x) RESULT(s) + !! A real as a token without blanks (14 digits: a bar list of three stays within a deck token). + REAL(wp), INTENT(IN) :: x + CHARACTER(:), ALLOCATABLE :: s + CHARACTER(32) :: buf + WRITE (buf, '(ES20.13)') x + s = TRIM(ADJUSTL(buf)) + END FUNCTION num + + FUNCTION bar3(x) RESULT(s) + !! A MoorDyn bar list x1|x2|x3. + REAL(wp), INTENT(IN) :: x(3) + CHARACTER(:), ALLOCATABLE :: s + s = num(x(1))//'|'//num(x(2))//'|'//num(x(3)) + END FUNCTION bar3 + + SUBROUTINE write_options(u, depth, body_ic, extra) + INTEGER, INTENT(IN) :: u + REAL(wp), INTENT(IN) :: depth + CHARACTER(*), INTENT(IN) :: body_ic + CHARACTER(*), INTENT(IN), OPTIONAL :: extra + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(F8.2,A)') depth, ' WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') body_ic//' bodyIC' + IF (PRESENT(extra)) WRITE (u, '(A)') extra + WRITE (u, '(A)') '--- end ---' + END SUBROUTINE write_options + + SUBROUTINE write_pendulum_deck(path, phi_deg, standalone) + !! A dry CoupledPinned body (MB kg, CG HCG below the reference point in the body frame, Iyy + !! about the CG) whose node is at (0, 0, ZPIN), above the water, released with its CG at phi_deg + !! from the downward vertical towards +x (deck pose, bodyIC deck). A line hangs from a Body1 + !! point at the node to a Coupled point: it loads the node, but has no arm about it. + !! standalone adds the dtM/TMax clock of a standalone run. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: phi_deg + LOGICAL, INTENT(IN), OPTIONAL :: standalone + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + CALL write_header(u, 'CoupledPinned body pendulum on the coupled aggregate') + ! R = Ry(p) carries the body -z axis to (-sin p, 0, -cos p): p = -phi + CALL write_md_body(u, 'CoupledPinned', [0.0_wp, 0.0_wp, ZPIN], [0.0_wp, -phi_deg, 0.0_wp], MB, & + [0.0_wp, 0.0_wp, -HCG], [IYY, IYY, IYY], 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 0.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '2 Coupled 4.0 0.0 12.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 line 9.5 6' + IF (PRESENT(standalone)) THEN + CALL write_options(u, 10.0_wp, 'deck', '0.01 dtM'//NEW_LINE('a')//'0.1 TMax') + ELSE + CALL write_options(u, 10.0_wp, 'deck') + END IF + CLOSE (u) + END SUBROUTINE write_pendulum_deck + + SUBROUTINE write_arm_deck(path, as_rod, body_ic, rod_type) + !! The arm of the second route, pinned at (0, 0, ZA) and hanging at THA from the downward + !! vertical towards +x, above the water: as_rod a CoupledPinned ROD (LA long, DA diameter, MA kg, + !! no drag or added mass), else a CoupledPinned BODY with the rod's mass, its CG at the rod + !! centre and the rod's inertia about it (body x axis along the rod). A slack line runs from + !! End B (the body point at LA along x) to an anchor at (30, 0, -20) and pulls the arm round. + !! rod_type replaces CoupledPinned for the rod; a Free rod takes a second line from End A to an + !! anchor at (-30, 0, -20). + CHARACTER(*), INTENT(IN) :: path, body_ic + LOGICAL, INTENT(IN) :: as_rod + CHARACTER(*), INTENT(IN), OPTIONAL :: rod_type + REAL(wp) :: th, xb, zb, r, i1, i2 + INTEGER :: u + CHARACTER(16) :: rt + rt = 'CoupledPinned' + IF (PRESENT(rod_type)) rt = rod_type + th = THA*PI/180.0_wp + xb = LA*SIN(th) + zb = ZA - LA*COS(th) + r = 0.5_wp*DA + i1 = 0.5_wp*MA*r*r + i2 = MA*(3.0_wp*r*r + LA*LA)/12.0_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + CALL write_header(u, 'CoupledPinned arm on the coupled aggregate') + IF (as_rod) THEN + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,1X,ES24.16,A)') 'arm ', DA, MA/LA, ' 0 0 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,ES24.16,A,ES24.16,A,ES24.16,A)') '1 arm '//TRIM(rt)//' 0 0 ', ZA, ' ', xb, ' 0 ', zb, ' 4 -' + ELSE + ! R = Ry(p) carries the body x axis to (cos p, 0, -sin p) = (sin th, 0, -cos th): p = 90 - th + CALL write_md_body(u, 'CoupledPinned', [0.0_wp, 0.0_wp, ZA], [0.0_wp, 90.0_wp - THA, 0.0_wp], MA, & + [0.5_wp*LA, 0.0_wp, 0.0_wp], [i1, i2, i2], 0.0_wp) + 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 Fixed 30.0 0.0 -20.0 0 0 0 0' + IF (.NOT. as_rod) WRITE (u, '(A,ES24.16,A)') '2 Body1 ', LA, ' 0.0 0.0 0 0 0 0' + IF (TRIM(rt) == 'Free') WRITE (u, '(A)') '3 Fixed -30.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + IF (as_rod) THEN + WRITE (u, '(A)') '1 R1B 1 -' + IF (TRIM(rt) == 'Free') WRITE (u, '(A)') '2 R1A 3 -' + ELSE + WRITE (u, '(A)') '1 2 1 -' + END IF + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 40.0 20' + IF (TRIM(rt) == 'Free') WRITE (u, '(A)') '2 line 38.0 20' + CALL write_options(u, 20.0_wp, body_ic) + CLOSE (u) + END SUBROUTINE write_arm_deck + + SUBROUTINE write_symmetric_deck(path, free_body) + !! A submerged VesselPinned body (18-column row: 200 kg, 0.1 m^3, Ca 0.5, inertia 50 kg m^2, + !! CG at the reference point) at (0, 0, -5) on four identical lines from (+-3, 0, 0) and + !! (0, +-3, 0) in the body frame to anchors 40 m out on the 50 m seabed. free_body: a Free + !! Rigid6 body instead, started 1 m above the pose, pitched 10 deg (out of balance). + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN), OPTIONAL :: free_body + INTEGER :: u + LOGICAL :: fb + fb = .FALSE. + IF (PRESENT(free_body)) fb = free_body + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + CALL write_header(u, 'symmetric VesselPinned body on the coupled aggregate') + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Rot1 Rot2 Rot3 Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm/rad) (Nm/rad) (m2) (-) '// & + '(kgm2) (kgm2) (kgm2)' + IF (fb) THEN + WRITE (u, '(A)') '1 Rigid6 0.0 0.0 -4.0 0.0 10.0 0.0 200.0 0.1 0.0 0.0 0.0 0.0 0.5 50.0 50.0 50.0' + ELSE + WRITE (u, '(A)') '1 VesselPinned 0.0 0.0 -5.0 0.0 0.0 0.0 200.0 0.1 0.0 0.0 0.0 0.0 0.5 50.0 50.0 50.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 Body1 3.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 -3.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '3 Body1 0.0 3.0 0.0 0 0 0 0' + WRITE (u, '(A)') '4 Body1 0.0 -3.0 0.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed 40.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -40.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '7 Fixed 0.0 40.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed 0.0 -40.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 5 -' + WRITE (u, '(A)') '2 2 6 -' + WRITE (u, '(A)') '3 3 7 -' + WRITE (u, '(A)') '4 4 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 line 62.0 12' + WRITE (u, '(A)') '2 line 62.0 12' + WRITE (u, '(A)') '3 line 62.0 12' + WRITE (u, '(A)') '4 line 62.0 12' + CALL write_options(u, 50.0_wp, 'deck') + CLOSE (u) + END SUBROUTINE write_symmetric_deck + + SUBROUTINE write_tethered_deck(path, body_ic) + !! A submerged CoupledPinned body (100 kg, 0.0628 m^3, inertia 10 kg m^2, CG 1 m below the + !! reference point) at (0, 0, -10), held at its Body1 point 2 m below the node by two horizontal + !! tethers to anchors at x = +-10 m (EA 2e5 N, 0.5 % pretension): the rotation about y meets + !! their axial stiffness, a mode of about 38 rad/s. body_ic: the bodyIC option. + CHARACTER(*), INTENT(IN) :: path, body_ic + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + CALL write_header(u, 'tethered CoupledPinned body on the coupled aggregate') + CALL write_md_body(u, 'CoupledPinned', [0.0_wp, 0.0_wp, -10.0_wp], [0.0_wp, 0.0_wp, 0.0_wp], 100.0_wp, & + [0.0_wp, 0.0_wp, -1.0_wp], [10.0_wp, 10.0_wp, 10.0_wp], 0.0628_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 0.0 0.0 -2.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 10.0 0.0 -12.0 0 0 0 0' + WRITE (u, '(A)') '3 Fixed -10.0 0.0 -12.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 1 3 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 tether 9.95 10' + WRITE (u, '(A)') '2 tether 9.95 10' + CALL write_options(u, 20.0_wp, body_ic) + CLOSE (u) + END SUBROUTINE write_tethered_deck + + ! --------------------------------------------------------------------------------------------- ! + ! helpers ! + ! --------------------------------------------------------------------------------------------- ! + + REAL(wp) FUNCTION body_angle(s) RESULT(th) + !! Angle of the pendulum's CG direction (the body -z axis) from the downward vertical, + !! positive towards +x: atan2(-R13, R33) for the mirror s (R column-major at 16:24). + REAL(wp), INTENT(IN) :: s(:) + th = ATAN2(-s(22), s(24)) + END FUNCTION body_angle + + REAL(wp) FUNCTION ellip_k(k) RESULT(kk) + !! Complete elliptic integral of the first kind by the arithmetic-geometric mean. + REAL(wp), INTENT(IN) :: k + REAL(wp) :: a, b, c + INTEGER :: i + a = 1.0_wp + b = SQRT(1.0_wp - k*k) + DO i = 1, 30 + c = 0.5_wp*(a + b) + b = SQRT(a*b) + a = c + END DO + kk = PI/(2.0_wp*a) + END FUNCTION ellip_k + + SUBROUTINE crossings(t, x, xm, period, mean) + !! Mean period between the up-crossings of x through xm and the mean of x over those whole + !! periods (trapezoidal); period = -1 with fewer than three crossings. + REAL(wp), INTENT(IN) :: t(:), x(:), xm + REAL(wp), INTENT(OUT) :: period, mean + REAL(wp) :: tc, t0, t1, area + INTEGER :: i, n, i0, i1 + n = 0 + t0 = 0.0_wp + t1 = 0.0_wp + i0 = 0 + i1 = 0 + DO i = 1, SIZE(x) - 1 + IF (x(i) - xm < 0.0_wp .AND. x(i + 1) - xm >= 0.0_wp) THEN + tc = t(i) + (xm - x(i))*(t(i + 1) - t(i))/(x(i + 1) - x(i)) + IF (n == 0) THEN + t0 = tc + i0 = i + END IF + t1 = tc + i1 = i + n = n + 1 + END IF + END DO + period = -1.0_wp + mean = 0.0_wp + IF (n < 3) RETURN + period = (t1 - t0)/REAL(n - 1, wp) + area = 0.5_wp*(xm + x(i0 + 1))*(t(i0 + 1) - t0) + 0.5_wp*(x(i1) + xm)*(t1 - t(i1)) + DO i = i0 + 1, i1 - 1 + area = area + 0.5_wp*(x(i) + x(i + 1))*(t(i + 1) - t(i)) + END DO + mean = area/(t1 - t0) + END SUBROUTINE crossings + + FUNCTION solve3(a, b) RESULT(x) + !! x = a^-1 b by Cramer's rule (a 3x3, well conditioned here). + REAL(wp), INTENT(IN) :: a(3, 3), b(3) + REAL(wp) :: x(3), d, c(3, 3) + INTEGER :: k + d = det3(a) + DO k = 1, 3 + c = a + c(:, k) = b + x(k) = det3(c)/d + END DO + END FUNCTION solve3 + + PURE REAL(wp) FUNCTION det3(m) RESULT(d) + REAL(wp), INTENT(IN) :: m(3, 3) + d = m(1, 1)*(m(2, 2)*m(3, 3) - m(2, 3)*m(3, 2)) - m(1, 2)*(m(2, 1)*m(3, 3) - m(2, 3)*m(3, 1)) + & + m(1, 3)*(m(2, 1)*m(3, 2) - m(2, 2)*m(3, 1)) + END FUNCTION det3 + + PURE FUNCTION cross(x, y) RESULT(z) + REAL(wp), INTENT(IN) :: x(3), y(3) + REAL(wp) :: z(3) + z = [x(2)*y(3) - x(3)*y(2), x(3)*y(1) - x(1)*y(3), x(1)*y(2) - x(2)*y(1)] + END FUNCTION cross + + PURE FUNCTION skew(a) RESULT(s) + REAL(wp), INTENT(IN) :: a(3) + REAL(wp) :: s(3, 3) + s(1, :) = [0.0_wp, -a(3), a(2)] + s(2, :) = [a(3), 0.0_wp, -a(1)] + s(3, :) = [-a(2), a(1), 0.0_wp] + END FUNCTION skew + + FUNCTION pendulum_reaction(s, a_pin) RESULT(f) + !! The force the dry pendulum body exerts on its node at state s (body mirror) for a node + !! acceleration a_pin: Euler's equation about the node, I_p alpha + w x (I_p w) = c x m (g - a_pin) + !! with I_p = R J R^T - m [c]x [c]x, then f = m g - m (a_pin + alpha x c + w x (w x c)). + REAL(wp), INTENT(IN) :: s(:), a_pin(3) + REAL(wp) :: f(3), rot(3, 3), ip(3, 3), c(3), w(3), alpha(3), gv(3) + INTEGER :: k + rot = RESHAPE(s(16:24), [3, 3]) + ip = 0.0_wp + DO k = 1, 3 + ip(k, k) = IYY + END DO + c = -HCG*rot(:, 3) + ip = MATMUL(rot, MATMUL(ip, TRANSPOSE(rot))) - MB*MATMUL(skew(c), skew(c)) + w = s(10:12) + gv = [0.0_wp, 0.0_wp, -G] + alpha = solve3(ip, cross(c, MB*(gv - a_pin)) - cross(w, MATMUL(ip, w))) + f = MB*gv - MB*(a_pin + cross(alpha, c) + cross(w, cross(w, c))) + END FUNCTION pendulum_reaction + + INTEGER FUNCTION coupled_block(agg, x) RESULT(ib) + !! The coupled 3-DOF block of the line system whose committed position is x (0: none). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(IN) :: x(3) + REAL(wp), ALLOCATABLE :: q(:), v(:), a(:) + INTEGER :: ncd, k, es + CHARACTER(512) :: em + ncd = CD_System_NSystemCoupledDOF(agg%sys%fast%system) + ALLOCATE (q(ncd), v(ncd), a(ncd)) + CALL CD_Get_System_CoupledMotion(agg%sys%fast%system, q, v, a, es, em) + ib = 0 + DO k = 1, ncd/3 + IF (nan_max_abs(q(3*k - 2:3*k) - x) <= 1.0e-9_wp) ib = k + END DO + END FUNCTION coupled_block + + FUNCTION line_loads(agg) RESULT(l) + !! The line loads on the coupled points of the line system (CD_Calc_System_CoupledLoads). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), ALLOCATABLE :: l(:) + INTEGER :: es + CHARACTER(512) :: em + ALLOCATE (l(CD_System_NSystemCoupledDOF(agg%sys%fast%system))) + CALL CD_Calc_System_CoupledLoads(agg%sys%fast%system, l, es, em) + CALL require(es == CD_SYSTEM_OK, 'line loads: '//TRIM(em)) + END FUNCTION line_loads + + SUBROUTINE march(agg, dt, nstep, host, ang, t, ok, force, states) + !! March nstep coupling steps with every moving column translated rigidly by host(t) = + !! [displacement, velocity, acceleration] from its initial position; ang(0:nstep) the pendulum + !! angle (body_angle), t the times. Before the first step the host kinematics at t = 0 are + !! transferred (the start of the run, as the coupled shell does). force: the node force (the + !! last column) after each step; states: the body mirror after each step. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(IN) :: dt + INTEGER, INTENT(IN) :: nstep + INTERFACE + FUNCTION host(time) RESULT(k) + IMPORT :: wp + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + END FUNCTION host + END INTERFACE + REAL(wp), INTENT(OUT) :: ang(0:nstep), t(0:nstep) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(OUT), OPTIONAL :: force(3, 0:nstep), states(24, 0:nstep) + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), p0(:, :), s(:) + INTEGER :: n, es, it, step + LOGICAL :: cv, st + CHARACTER(512) :: em + + ok = .FALSE. + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), p0(3, n), s(CD_AGG_Rigid6_MirrorSize(agg))) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f, es, em) + DO step = 0, nstep + t(step) = REAL(step, wp)*dt + CALL host_columns(host(t(step)), p0, p, v, a) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em) + CALL require(es == CD_AGG_OK, 'march:start-transfer: '//TRIM(em)) + ELSE + CALL CD_AGG_Step_Moving(agg, dt, p, v, a, cv, st, it, es, em, t_committed=t(step)) + CALL require(es == CD_AGG_OK .AND. cv, 'march:step: '//TRIM(em)) + END IF + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Get_Rigid6_States(agg, s, es, em) + ang(step) = body_angle(s) + IF (PRESENT(states)) states(:, step) = s + IF (PRESENT(force)) THEN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em) + force(:, step) = f(:, n) + END IF + END DO + ok = ALL(IEEE_IS_FINITE(ang)) + END SUBROUTINE march + + SUBROUTINE host_columns(k, p0, p, v, a) + !! Every moving column translated rigidly by k = [displacement, velocity, acceleration]. + REAL(wp), INTENT(IN) :: k(9), p0(:, :) + REAL(wp), INTENT(OUT) :: p(:, :), v(:, :), a(:, :) + INTEGER :: i + DO i = 1, SIZE(p0, 2) + p(:, i) = p0(:, i) + k(1:3) + v(:, i) = k(4:6) + a(:, i) = k(7:9) + END DO + END SUBROUTINE host_columns + + FUNCTION host_rest(time) RESULT(k) + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + k = 0.0_wp*time + END FUNCTION host_rest + + FUNCTION host_const(time) RESULT(k) + !! The node accelerating uniformly along +x from rest: a = 2 m/s^2. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + REAL(wp), PARAMETER :: AX = 2.0_wp + k = 0.0_wp + k(1) = 0.5_wp*AX*time*time + k(4) = AX*time + k(7) = AX + END FUNCTION host_const + + FUNCTION host_surge(time) RESULT(k) + !! x_p = X (1 - cos W t), X = 0.2 m, a 5 s period. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9), w + REAL(wp), PARAMETER :: X = 0.2_wp + w = 2.0_wp*PI/5.0_wp + k = 0.0_wp + k(1) = X*(1.0_wp - COS(w*time)) + k(4) = X*w*SIN(w*time) + k(7) = X*w*w*COS(w*time) + END FUNCTION host_surge + + FUNCTION host_heave(time) RESULT(k) + !! z_p = Z sin W t, Z = 0.5 m, a 6 s period. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9), w + REAL(wp), PARAMETER :: Z = 0.5_wp + w = 2.0_wp*PI/6.0_wp + k = 0.0_wp + k(3) = Z*SIN(w*time) + k(6) = Z*w*COS(w*time) + k(9) = -Z*w*w*SIN(w*time) + END FUNCTION host_heave + + FUNCTION host_drift(time) RESULT(k) + !! The node drifting along +x at a constant 0.05 m/s from t = 0. + REAL(wp), INTENT(IN) :: time + REAL(wp) :: k(9) + k = 0.0_wp + k(1) = 0.05_wp*time + k(4) = 0.05_wp + END FUNCTION host_drift + + ! --------------------------------------------------------------------------------------------- ! + ! 1: the held compound pendulum ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_pendulum_held() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), PARAMETER :: TH0 = 30.0_wp + INTEGER, PARAMETER :: NSTEP = 500 + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), mo(:, :), p0(:, :), l(:) + REAL(wp) :: ang(0:NSTEP), t(0:NSTEP), s(24), ip, t_ref, dt, period, mean, err_pin, err_force, fref(3) + INTEGER :: es, n, step, it, ib + LOGICAL :: cv, st + CHARACTER(512) :: em + + ip = IYY + MB*HCG*HCG + t_ref = 4.0_wp*SQRT(ip/(MB*G*HCG))*ellip_k(SIN(0.5_wp*TH0*PI/180.0_wp)) + dt = t_ref/100.0_wp + CALL write_pendulum_deck('pinbody_pendulum.dat', TH0) + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_pendulum.dat', dt, es, em) + CALL require(es == CD_AGG_OK, 'pendulum:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + CALL require(CD_AGG_HasRigid6(agg) .AND. n == 2, 'pendulum:one host node for the body after the fairlead') + IF (n /= 2) RETURN + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), mo(3, n), p0(3, n)) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f, es, em) + CALL require(nan_max_abs(p0(:, 2) - [0.0_wp, 0.0_wp, ZPIN]) <= 0.0_wp, 'pendulum:host node at the reference point') + ib = coupled_block(agg, [0.0_wp, 0.0_wp, ZPIN]) + CALL require(ib > 0, 'pendulum:the node line end is a coupled point') + IF (ib == 0) RETURN + p = p0 + v = 0.0_wp + a = 0.0_wp + err_pin = 0.0_wp + err_force = 0.0_wp + DO step = 0, NSTEP + IF (step > 0) THEN + CALL CD_AGG_Step_Moving(agg, dt, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*dt) + CALL require(es == CD_AGG_OK .AND. cv, 'pendulum:step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END IF + CALL CD_AGG_Get_Rigid6_States(agg, s, es, em) + t(step) = REAL(step, wp)*dt + ang(step) = body_angle(s) + err_pin = MAX(err_pin, nan_max_abs(s(1:3) - [0.0_wp, 0.0_wp, ZPIN]), nan_max_abs(s(4:9))) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + CALL require(es == CD_AGG_OK, 'pendulum:mesh: '//TRIM(em)) + CALL require(nan_max_abs(mo(:, 2)) <= 0.0_wp, 'pendulum:node moment is zero') + l = line_loads(agg) + fref = pendulum_reaction(s, [0.0_wp, 0.0_wp, 0.0_wp]) + l(3*ib - 2:3*ib) + err_force = MAX(err_force, nan_max_abs(f(:, 2) - fref)/(MB*G)) + p = p0 + v = 0.0_wp + a = 0.0_wp + END DO + CALL crossings(t, ang, 0.0_wp, period, mean) + WRITE (*, '(A,2F12.6,A,ES10.3)') 'CoupledPinned body pendulum period got/analytic [s]: ', period, t_ref, & + '; rel. error ', ABS(period - t_ref)/t_ref + WRITE (*, '(A,ES10.3,A,ES10.3)') 'max |reference point motion off the held node| ', err_pin, & + '; node force vs pin reaction + line force / mg ', err_force + CALL require(ABS(period - t_ref) <= 1.0e-3_wp*t_ref, 'pendulum:period (elliptic integral)') + CALL require(err_pin <= 0.0_wp, 'pendulum:the reference point stays on the held node') + CALL require(err_force <= 1.0e-10_wp, 'pendulum:node force is the pin reaction plus the line force') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_pendulum_held + + ! --------------------------------------------------------------------------------------------- ! + ! 2: constant node acceleration ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_constant_acceleration() + !! In the frame of a node accelerating at a along x the body is a pendulum in the effective + !! gravity (-a, 0, -g): it swings about phi_eq = -atan(a/g) (trailing) with the period + !! 4 sqrt(I_p/(m h g_eff)) K(sin(delta/2)), g_eff = sqrt(g^2 + a^2), for an amplitude delta. + !! The line at the node moves with it (its Coupled end takes the same translation). + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), PARAMETER :: AX = 2.0_wp, DELTA = 5.0_wp + INTEGER, PARAMETER :: NSTEP = 500 + REAL(wp) :: ang(0:NSTEP), t(0:NSTEP), ip, th_eq, geff, t_ref, dt, period, mean + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + + th_eq = -ATAN(AX/G) + geff = SQRT(G*G + AX*AX) + ip = IYY + MB*HCG*HCG + t_ref = 4.0_wp*SQRT(ip/(MB*geff*HCG))*ellip_k(SIN(0.5_wp*DELTA*PI/180.0_wp)) + dt = t_ref/100.0_wp + CALL write_pendulum_deck('pinbody_accel.dat', th_eq*180.0_wp/PI + DELTA) + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_accel.dat', dt, es, em) + CALL require(es == CD_AGG_OK, 'accel:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL march(agg, dt, NSTEP, host_const, ang, t, ok) + CALL require(ok, 'accel:march finite') + IF (.NOT. ok) RETURN + CALL crossings(t, ang, th_eq, period, mean) + WRITE (*, '(A,2F12.6,A,2F10.6)') 'constant node acceleration: period got/analytic [s] ', period, t_ref, & + '; mean angle got/-atan(a/g) [rad] ', mean, th_eq + CALL require(ABS(period - t_ref) <= 1.0e-3_wp*t_ref, 'accel:period with g_eff') + CALL require(ABS(mean - th_eq) <= 1.0e-4_wp, 'accel:mean angle -atan(a/g)') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_constant_acceleration + + ! --------------------------------------------------------------------------------------------- ! + ! 3: the second route, a CoupledPinned rod ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_rod_second_route() + !! The body with the rod's mass, CG and inertia, its line at the rod's End B, follows the + !! CoupledPinned rod (an independent route: the rod's pinned solve about End A with its mass at + !! the centre, against the body's CG coupling blocks about its reference point) under a + !! harmonic node surge: same axis, angular velocity and node force to 1e-9. + TYPE(CD_AGG_ModuleType) :: rod, body + REAL(wp), PARAMETER :: DT = 0.01_wp + INTEGER, PARAMETER :: NSTEP = 600 + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), p0(:, :), pr0(:, :), fr(:, :) + REAL(wp) :: sr(24), sb(24), k(9), err_axis, err_w, err_f, famp, wamp, turn + INTEGER :: es, n, nr, step, it + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_arm_deck('pinbody_arm_rod.dat', .TRUE., 'deck') + CALL write_arm_deck('pinbody_arm_body.dat', .FALSE., 'deck') + CALL CD_AGG_Init_From_Deck(rod, 'pinbody_arm_rod.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'route:rod init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(body, 'pinbody_arm_body.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'route:body init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_HasRod(rod) .AND. CD_AGG_HasRigid6(body), 'route:a rod deck and a body deck') + n = CD_AGG_NMovingPoints(body, es, em) + nr = CD_AGG_NMovingPoints(rod, es, em) + CALL require(n == 1 .AND. nr == 1, 'route:one host node each') + IF (n /= 1 .OR. nr /= 1) RETURN + ALLOCATE (p(3, 1), v(3, 1), a(3, 1), f(3, 1), p0(3, 1), pr0(3, 1), fr(3, 1)) + CALL CD_AGG_GetMovingPointMesh(body, p0, v, a, f, es, em) + CALL CD_AGG_GetMovingPointMesh(rod, pr0, v, a, fr, es, em) + CALL require(nan_max_abs(p0 - pr0) <= 1.0e-14_wp, 'route:the same node') + err_axis = 0.0_wp + err_w = 0.0_wp + err_f = 0.0_wp + famp = 0.0_wp + wamp = 0.0_wp + turn = 0.0_wp + DO step = 0, NSTEP + k = host_surge(REAL(step, wp)*DT) + CALL host_columns(k, p0, p, v, a) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(body, p, v, a, es, em) + CALL CD_AGG_UpdateStates_Moving(rod, p, v, a, es, em) + ELSE + CALL CD_AGG_Step_Moving(body, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK .AND. cv, 'route:body step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Step_Moving(rod, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK .AND. cv, 'route:rod step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END IF + CALL CD_AGG_Get_Rigid6_States(body, sb, es, em) + CALL CD_AGG_Get_Rod_States(rod, sr, es, em) + CALL CD_AGG_CalcOutput(body, es, em) + CALL CD_AGG_GetMovingPointMesh(body, p, v, a, f, es, em) + CALL CD_AGG_CalcOutput(rod, es, em) + CALL CD_AGG_GetMovingPointMesh(rod, p, v, a, fr, es, em) + err_axis = MAX(err_axis, nan_max_abs(sb(16:18) - sr(16:18))) + err_w = MAX(err_w, nan_max_abs(sb(10:12) - sr(10:12))) + err_f = MAX(err_f, nan_max_abs(f(:, 1) - fr(:, 1))) + famp = MAX(famp, nan_max_abs(fr(:, 1))) + wamp = MAX(wamp, nan_max_abs(sr(10:12))) + turn = MAX(turn, ABS(ATAN2(sr(16), -sr(18)) - THA*PI/180.0_wp)) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,F8.4,A)') 'body vs CoupledPinned rod: axis ', err_axis, & + '; omega ', err_w, ' of ', wamp, ' rad/s; node force ', err_f/famp, ' rel. (arm turned ', turn, ' rad)' + CALL require(turn > 0.05_wp, 'route:the line and the surge turn the arm') + CALL require(err_axis <= 1.0e-9_wp .AND. err_w <= 1.0e-9_wp*wamp .AND. err_f <= 1.0e-9_wp*famp, & + 'route:the body follows the CoupledPinned rod') + CALL CD_AGG_End(rod, es, em) + CALL CD_AGG_End(body, es, em) + END SUBROUTINE case_rod_second_route + + ! --------------------------------------------------------------------------------------------- ! + ! 4: symmetric mooring under heave ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_symmetric_heave() + !! Four identical lines at 90 deg about a body with its CG at the node: a heaving node gives + !! no moment, so the body keeps its pose (|omega| and the turn below 1e-12), and the node force + !! is the line force sum plus the net weight and the translational inertia, rhoW g V - m g + !! along z less (m + rhoW V Ca) a. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), PARAMETER :: DT = 0.02_wp, M = 200.0_wp, VOL = 0.1_wp, CA = 0.5_wp + INTEGER, PARAMETER :: NSTEP = 300 + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), mo(:, :), p0(:, :), l(:) + REAL(wp) :: s(24), k(9), fref(3), err_w, err_turn, err_f, famp, lamp + INTEGER :: es, n, step, it, ip, ib(4) + REAL(wp), PARAMETER :: ARMS(3, 4) = RESHAPE([3.0_wp, 0.0_wp, 0.0_wp, -3.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 3.0_wp, 0.0_wp, 0.0_wp, -3.0_wp, 0.0_wp], [3, 4]) + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_symmetric_deck('pinbody_sym.dat') + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_sym.dat', DT, es, em, external_fluid=.TRUE.) + CALL require(es == CD_AGG_OK, 'sym:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + CALL require(n == 1, 'sym:one host node (the VesselPinned body)') + IF (n /= 1) RETURN + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), mo(3, n), p0(3, n)) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f, es, em) + err_w = 0.0_wp + err_turn = 0.0_wp + err_f = 0.0_wp + famp = 0.0_wp + lamp = 0.0_wp + DO step = 0, NSTEP + k = host_heave(REAL(step, wp)*DT) + CALL host_columns(k, p0, p, v, a) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em) + ELSE + CALL CD_AGG_Step_Moving(agg, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK .AND. cv, 'sym:step: '//TRIM(em)) + END IF + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Get_Rigid6_States(agg, s, es, em) + err_w = MAX(err_w, nan_max_abs(s(10:12))) + err_turn = MAX(err_turn, nan_max_abs(s(16:24) - [1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp])) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + l = line_loads(agg) + fref = [0.0_wp, 0.0_wp, (RHO*VOL - M)*G] - (M + RHO*VOL*CA)*k(7:9) + DO ip = 1, 4 + IF (step == 0) THEN + ib(ip) = coupled_block(agg, p0(:, 1) + ARMS(:, ip)) + CALL require(ib(ip) > 0, 'sym:the line ends are coupled points') + IF (ib(ip) == 0) RETURN + END IF + fref = fref + l(3*ib(ip) - 2:3*ib(ip)) + lamp = MAX(lamp, nan_max_abs(l(3*ib(ip) - 2:3*ib(ip)))) + END DO + err_f = MAX(err_f, nan_max_abs(f(:, 1) - fref)) + famp = MAX(famp, nan_max_abs(f(:, 1))) + CALL require(nan_max_abs(mo(:, 1)) <= 0.0_wp, 'sym:zero node moment') + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A)') 'symmetric heave: max |omega| ', err_w, & + ' rad/s, max |R - I| ', err_turn, '; |node force - (line sum + weight, buoyancy, inertia)| ', & + err_f/famp, ' rel. (line force ', lamp, ' N)' + CALL require(err_w <= 1.0e-12_wp .AND. err_turn <= 1.0e-12_wp, 'sym:the body does not turn') + CALL require(err_f <= 1.0e-10_wp*famp, 'sym:node force is the line sum plus the body load') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_symmetric_heave + + ! --------------------------------------------------------------------------------------------- ! + ! 5: the output probe ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_probe() + !! On the hanging dry pendulum at rest, a probe node acceleration a_p along x returns the rest + !! force plus -M_eff a_p, M_eff = m I_cg/I_p (the rotation re-solved at a_p; the committed + !! angular acceleration would give -m a_p), besides the change of the line force at the node. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), f0(:, :), mo(:, :), p0(:, :), l0(:), l1(:) + REAL(wp) :: ap, ip, df, dl + INTEGER :: es, n, ib + CHARACTER(512) :: em + + CALL write_pendulum_deck('pinbody_probe.dat', 0.0_wp) + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_probe.dat', 0.01_wp, es, em) + CALL require(es == CD_AGG_OK, 'probe:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), f0(3, n), mo(3, n), p0(3, n)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f0, es, em) + ib = coupled_block(agg, p0(:, n)) + l0 = line_loads(agg) + ap = 1.5_wp + p = p0 + v = 0.0_wp + a = 0.0_wp + a(1, n) = ap + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em, output_probe=.TRUE.) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + l1 = line_loads(agg) + ip = IYY + MB*HCG*HCG + df = f(1, n) - f0(1, n) + dl = l1(3*ib - 2) - l0(3*ib - 2) + WRITE (*, '(A,F11.4,A,F11.4,A,F11.4,A,F11.4)') 'probe node acceleration: dF_x got ', df, ' N (line ', dl, & + ' N); body part ', df - dl, ' N; -m (I_cg/I_p) a_p ', -MB*IYY/ip*ap + CALL require(ib > 0 .AND. ABS(dl) > 1.0_wp, 'probe:the node line carries the node acceleration') + CALL require(ABS(df - dl + MB*IYY/ip*ap) <= 1.0e-10_wp*MB*G, 'probe:-M_eff a_p (re-solved rotation)') + CALL require(nan_max_abs(f(2:3, n) - f0(2:3, n) - (l1(3*ib - 1:3*ib) - l0(3*ib - 1:3*ib))) <= 1.0e-10_wp*MB*G & + .AND. nan_max_abs(mo(:, n)) <= 0.0_wp, 'probe:no other force change, zero moment') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_probe + + ! --------------------------------------------------------------------------------------------- ! + ! 6: snapshot / restore, probe restore and the restart overlay ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE overlay_state(src, dst, p, v, a, so, sw, sal) + !! What the coupled shell restores, src -> dst: the host kinematics, the line interiors, the + !! body states and finally the committed line-end motion. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: src, dst + REAL(wp), INTENT(IN) :: p(:, :), v(:, :), a(:, :) + REAL(wp), INTENT(IN), OPTIONAL :: so(:, :, :), sw(:, :), sal(:, :) + REAL(wp), ALLOCATABLE :: lq(:), lv(:), la(:), bs(:), cq(:), cvv(:), ca(:) + INTEGER :: es, nl, il, ndof, ncd + CHARACTER(512) :: em + IF (PRESENT(so)) THEN + CALL CD_AGG_UpdateStates_Moving(dst, p, v, a, es, em, output_probe=.TRUE., orientation=so, & + angular_velocity=sw, angular_acceleration=sal) + ELSE + CALL CD_AGG_UpdateStates_Moving(dst, p, v, a, es, em) + END IF + CALL require(es == CD_AGG_OK, 'overlay:host: '//TRIM(em)) + nl = CD_System_NLines(src%sys%fast%system, es, em) + DO il = 1, nl + ndof = CD_System_Line_NDOF(src%sys%fast%system, il, es, em) + ALLOCATE (lq(ndof), lv(ndof), la(ndof)) + CALL CD_Get_System_Line_State(src%sys%fast%system, il, lq, lv, la, es, em) + CALL CD_Update_System_Line_Interior_State(dst%sys%fast%system, il, lq(4:ndof - 3), lv(4:ndof - 3), es, em, & + a_interior=la(4:ndof - 3)) + CALL require(es == CD_SYSTEM_OK, 'overlay:interior: '//TRIM(em)) + DEALLOCATE (lq, lv, la) + END DO + ALLOCATE (bs(CD_AGG_Rigid6_MirrorSize(src))) + CALL CD_AGG_Get_Rigid6_States(src, bs, es, em) + CALL CD_AGG_Set_Rigid6_States(dst, bs, es, em) + CALL require(es == CD_AGG_OK, 'overlay:body states: '//TRIM(em)) + ncd = CD_System_NSystemCoupledDOF(src%sys%fast%system) + ALLOCATE (cq(ncd), cvv(ncd), ca(ncd)) + CALL CD_Get_System_CoupledMotion(src%sys%fast%system, cq, cvv, ca, es, em) + CALL CD_Update_System_CoupledMotion(dst%sys%fast%system, cq, cvv, ca, es, em) + CALL require(es == CD_SYSTEM_OK, 'overlay:coupled motion: '//TRIM(em)) + END SUBROUTINE overlay_state + + SUBROUTINE case_state() + !! On the arm body under the harmonic surge: snapshot / step / restore / step is bit-identical; + !! a probe (node moved, accelerated) restored as the shell restores it leaves the march + !! bit-identical to a twin that was never probed; a fresh instance overlaid with the checkpoint + !! state returns the same loads before the next step and continues bit for bit. + TYPE(CD_AGG_ModuleType) :: agg, twin, agg_b + REAL(wp), PARAMETER :: DT = 0.02_wp + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), fb(:, :), mo(:, :), mb(:, :), p0(:, :) + REAL(wp), ALLOCATABLE :: sp(:, :), sv(:, :), sa(:, :), so(:, :, :), sw(:, :), sal(:, :) + REAL(wp) :: bs(24), bs2(24), k(9), err + INTEGER :: es, n, step, it + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_arm_deck('pinbody_state.dat', .FALSE., 'deck') + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_state.dat', DT, es, em) + CALL CD_AGG_Init_From_Deck(twin, 'pinbody_state.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'state:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), fb(3, n), mo(3, n), mb(3, n), p0(3, n)) + ALLOCATE (sp(3, n), sv(3, n), sa(3, n), so(3, 3, n), sw(3, n), sal(3, n)) + CALL CD_AGG_GetMovingPointMesh(agg, p0, v, a, f, es, em) + DO step = 0, 40 + CALL host_columns(host_surge(REAL(step, wp)*DT), p0, p, v, a) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em) + CALL CD_AGG_UpdateStates_Moving(twin, p, v, a, es, em) + CYCLE + END IF + CALL CD_AGG_Step_Moving(agg, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL CD_AGG_Step_Moving(twin, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK, 'state:march: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + IF (step /= 20) CYCLE + ! the shell's probe: save the committed host kinematics and the state, probe, restore + CALL CD_AGG_GetMovingPointMesh(agg, sp, sv, sa, f, es, em, orientation=so, angular_velocity=sw, & + angular_acceleration=sal) + CALL CD_AGG_Snapshot(twin, es, em) + p(1, n) = p(1, n) + 0.3_wp + a(1, n) = a(1, n) + 4.0_wp + v(1, n) = v(1, n) - 0.5_wp + CALL CD_AGG_UpdateStates_Moving(agg, p, v, a, es, em, output_probe=.TRUE.) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + CALL require(ALL(IEEE_IS_FINITE(f)) .AND. nan_max_abs(mo(:, n)) <= 0.0_wp, 'state:probe force, zero moment') + CALL overlay_state(twin, agg, sp, sv, sa, so, sw, sal) + CALL CD_AGG_Get_Rigid6_States(agg, bs, es, em) + CALL CD_AGG_Get_Rigid6_States(twin, bs2, es, em) + CALL require(nan_max_abs(bs - bs2) <= 0.0_wp, 'state:probe restored the body state') + END DO + CALL CD_AGG_Get_Rigid6_States(agg, bs, es, em) + CALL CD_AGG_Get_Rigid6_States(twin, bs2, es, em) + CALL require(nan_max_abs(bs - bs2) <= 0.0_wp, 'state:probed run equals the twin bit for bit') + ! snapshot -> step A -> restore -> step B reproduces step A + k = host_surge(41.0_wp*DT) + CALL host_columns(k, p0, p, v, a) + CALL CD_AGG_Snapshot(agg, es, em) + CALL CD_AGG_Step_Moving(agg, DT, p, v, a, cv, st, it, es, em, t_committed=41.0_wp*DT) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, sp, sv, sa, fb, es, em, moment=mb) + CALL CD_AGG_Get_Rigid6_States(agg, bs, es, em) + CALL CD_AGG_Restore(agg, es, em) + CALL CD_AGG_Step_Moving(agg, DT, p, v, a, cv, st, it, es, em, t_committed=41.0_wp*DT) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, sp, sv, sa, f, es, em, moment=mo) + CALL CD_AGG_Get_Rigid6_States(agg, bs2, es, em) + CALL require(nan_max_abs(f - fb) <= 0.0_wp .AND. nan_max_abs(mo - mb) <= 0.0_wp .AND. & + nan_max_abs(bs - bs2) <= 0.0_wp, 'state:snapshot-step-restore-step bit-identical') + CALL require(nan_max_abs(mo(:, n)) <= 0.0_wp .AND. nan_max_abs(f(:, n)) > 0.0_wp, 'state:force only at the node') + ! restart: a fresh instance takes the host kinematics, the line interiors and the body states + CALL CD_AGG_Init_From_Deck(agg_b, 'pinbody_state.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'restart:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL overlay_state(agg, agg_b, p, v, a) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, sp, sv, sa, f, es, em, moment=mo) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, sp, sv, sa, fb, es, em, moment=mb) + WRITE (*, '(A,ES10.3)') 'CoupledPinned body restart overlay: |node force difference| before the next step = ', & + nan_max_abs(f - fb) + CALL require(nan_max_abs(f - fb) <= 0.0_wp .AND. nan_max_abs(mo - mb) <= 0.0_wp, & + 'restart:bit-identical loads of the restored state before the next step') + err = 0.0_wp + DO step = 42, 70 + CALL host_columns(host_surge(REAL(step, wp)*DT), p0, p, v, a) + CALL CD_AGG_Step_Moving(agg, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL CD_AGG_Step_Moving(agg_b, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK, 'restart:march: '//TRIM(em)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, sp, sv, sa, f, es, em, moment=mo) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, sp, sv, sa, fb, es, em, moment=mb) + err = MAX(err, nan_max_abs(f - fb), nan_max_abs(mo - mb)) + END DO + CALL CD_AGG_Get_Rigid6_States(agg, bs, es, em) + CALL CD_AGG_Get_Rigid6_States(agg_b, bs2, es, em) + WRITE (*, '(A,ES10.3,A,ES10.3)') 'CoupledPinned body restart overlay: max |load difference| over 29 steps = ', & + err, '; body state ', nan_max_abs(bs - bs2) + CALL require(err <= 0.0_wp .AND. nan_max_abs(bs - bs2) <= 0.0_wp, 'restart:bit-identical continuation') + CALL CD_AGG_End(agg_b, es, em) + CALL CD_AGG_End(agg, es, em) + CALL CD_AGG_End(twin, es, em) + END SUBROUTINE case_state + + ! --------------------------------------------------------------------------------------------- ! + ! 7: PtfmInit and the static initial condition ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_ptfm_static() + !! PtfmInit (surge 1 m, sway 0.5 m, yaw 10 deg) moves the node and turns the tethered body with + !! the platform (deck pose: the body frame is M^T R0); with bodyIC static the body is then + !! turned about the displaced node, held, against the now unequal tethers until the moment + !! about the node of its weight, buoyancy and tethers vanishes. Its CG and both tethers lie on + !! one body axis through the node, so the spin about that axis is neutral. + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), mo(:, :), l(:) + REAL(wp) :: ptfm(6), dcm(3, 3), node(3), s(24), rot(3, 3), mom(3), c(3), arm(3), fsc, tilt + INTEGER :: es, n, ib, ic + CHARACTER(512) :: em + + ptfm = [1.0_wp, 0.5_wp, 0.0_wp, 0.0_wp, 0.0_wp, 10.0_wp*PI/180.0_wp] + dcm = 0.0_wp + dcm(1, 1) = COS(ptfm(6)) + dcm(1, 2) = SIN(ptfm(6)) + dcm(2, 1) = -SIN(ptfm(6)) + dcm(2, 2) = COS(ptfm(6)) + dcm(3, 3) = 1.0_wp + node = ptfm(1:3) + MATMUL(TRANSPOSE(dcm), [0.0_wp, 0.0_wp, -10.0_wp]) + DO ic = 1, 2 + IF (ic == 1) THEN + CALL write_tethered_deck('pinbody_ptfm.dat', 'deck') + ELSE + CALL write_tethered_deck('pinbody_ptfm.dat', 'static') + END IF + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_ptfm.dat', 0.02_wp, es, em, ptfm_init=ptfm) + CALL require(es == CD_AGG_OK, 'ptfm:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + IF (.NOT. ALLOCATED(p)) ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), mo(3, n)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, f, es, em, moment=mo) + CALL CD_AGG_Get_Rigid6_States(agg, s, es, em) + rot = RESHAPE(s(16:24), [3, 3]) + CALL require(nan_max_abs(p(:, n) - node) <= 1.0e-12_wp .AND. nan_max_abs(s(1:3) - node) <= 1.0e-12_wp, & + 'ptfm:node and reference point at the displaced pin') + IF (ic == 1) THEN + WRITE (*, '(A,ES10.3,A,ES10.3)') 'PtfmInit, deck pose: |node - displaced pin| ', nan_max_abs(p(:, n) - node), & + '; |R - M^T R0| ', nan_max_abs(rot - TRANSPOSE(dcm)) + CALL require(nan_max_abs(rot - TRANSPOSE(dcm)) <= 1.0e-12_wp, 'ptfm:the body turns with the platform') + ELSE + arm = -2.0_wp*rot(:, 3) + c = -1.0_wp*rot(:, 3) + ib = coupled_block(agg, s(1:3) + arm) + CALL require(ib > 0, 'ptfm:the tether end is a coupled point') + IF (ib == 0) RETURN + l = line_loads(agg) + mom = cross(c, [0.0_wp, 0.0_wp, (RHO*0.0628_wp - 100.0_wp)*G]) + cross(arm, l(3*ib - 2:3*ib)) + fsc = 2.0_wp*MAX(100.0_wp*G, nan_max_abs(l(3*ib - 2:3*ib))) + tilt = ACOS(MIN(1.0_wp, rot(3, 3))) + WRITE (*, '(A,F8.4,A,ES10.3,A,ES10.3)') 'PtfmInit + static IC: body tilted ', tilt, & + ' rad; |moment about the node| / (arm max(mg, |f|)) ', nan_max_abs(mom)/fsc, '; |omega| ', & + nan_max_abs(s(10:12)) + CALL require(tilt > 1.0e-3_wp, 'ptfm:the static solve turned the body') + CALL require(nan_max_abs(mom) <= 1.0e-6_wp*fsc, 'ptfm:net moment about the node vanishes') + END IF + CALL require(nan_max_abs(mo(:, n)) <= 0.0_wp, 'ptfm:no node moment') + CALL CD_AGG_End(agg, es, em) + END DO + END SUBROUTINE case_ptfm_static + + ! --------------------------------------------------------------------------------------------- ! + ! 8: sub-stepping and the ignored node rotation ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_substep() + !! The tethered body's stiff mode (about 38 rad/s) makes omega dt about 3.8 at a 0.1 s + !! coupling step, beyond the explicit limit of 2: the march must sub-cycle it. Against a run at + !! the sub-step size, a node drifting at constant velocity (which the linear interpolation of + !! the node motion inside a step represents exactly) gives the same body motion and node force. + !! The node orientation and angular rates do not reach the body. + TYPE(CD_AGG_ModuleType) :: coarse, fine, turned + REAL(wp), PARAMETER :: DTC = 0.1_wp + INTEGER, PARAMETER :: NSUB = 10, NC = 40 + REAL(wp), ALLOCATABLE :: angc(:), tc(:), angf(:), tf(:), fc(:, :), ff(:, :), sc(:, :), sf(:, :) + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), p0(:, :), orr(:, :, :), w(:, :), al(:, :) + REAL(wp) :: err_s, err_f, famp, samp, bs(24), bs2(24), th, err + INTEGER :: es, i, n, step, it + LOGICAL :: ok, cv, st + CHARACTER(512) :: em + + CALL write_tethered_deck('pinbody_tether.dat', 'deck') + ALLOCATE (angc(0:NC), tc(0:NC), angf(0:NC*NSUB), tf(0:NC*NSUB), fc(3, 0:NC), ff(3, 0:NC*NSUB)) + ALLOCATE (sc(24, 0:NC), sf(24, 0:NC*NSUB)) + CALL CD_AGG_Init_From_Deck(coarse, 'pinbody_tether.dat', DTC, es, em) + CALL require(es == CD_AGG_OK, 'substep:coarse-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(fine, 'pinbody_tether.dat', DTC/REAL(NSUB, wp), es, em) + CALL require(es == CD_AGG_OK, 'substep:fine-init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL march(coarse, DTC, NC, host_drift, angc, tc, ok, force=fc, states=sc) + CALL require(ok, 'substep:coarse march finite (the stiff mode is sub-cycled)') + CALL march(fine, DTC/REAL(NSUB, wp), NC*NSUB, host_drift, angf, tf, ok, force=ff, states=sf) + CALL require(ok, 'substep:fine march finite') + IF (.NOT. ok) RETURN + err_s = 0.0_wp + err_f = 0.0_wp + DO i = 0, NC + err_s = MAX(err_s, nan_max_abs(sc(10:24, i) - sf(10:24, NSUB*i))) + err_f = MAX(err_f, nan_max_abs(fc(:, i) - ff(:, NSUB*i))) + END DO + famp = nan_max_abs(ff) + samp = nan_max_abs(sf(10:12, :)) + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3)') 'sub-cycled coarse step vs sub-step run: rotation state ', & + err_s, ' (|omega| up to ', samp, '); node force ', err_f, ' of ', famp + CALL require(samp > 1.0e-3_wp, 'substep:the drift turns the body') + CALL require(err_s <= 1.0e-8_wp*MAX(1.0_wp, samp) .AND. err_f <= 1.0e-8_wp*famp, & + 'substep:drifting node: coarse equals fine') + CALL CD_AGG_End(fine, es, em) + CALL CD_AGG_End(coarse, es, em) + + ! the node orientation and angular rates do not reach a CoupledPinned body + CALL CD_AGG_Init_From_Deck(turned, 'pinbody_tether.dat', DTC, es, em) + CALL CD_AGG_Init_From_Deck(fine, 'pinbody_tether.dat', DTC, es, em) + n = CD_AGG_NMovingPoints(turned, es, em) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), p0(3, n), orr(3, 3, n), w(3, n), al(3, n)) + CALL CD_AGG_GetMovingPointMesh(turned, p0, v, a, f, es, em) + err = 0.0_wp + DO step = 0, 20 + CALL host_columns(host_surge(REAL(step, wp)*DTC), p0, p, v, a) + th = 0.3_wp*SIN(REAL(step, wp)) + orr = 0.0_wp + DO i = 1, n + orr(1, 1, i) = COS(th) + orr(1, 3, i) = -SIN(th) + orr(2, 2, i) = 1.0_wp + orr(3, 1, i) = SIN(th) + orr(3, 3, i) = COS(th) + END DO + w = 0.0_wp + al = 0.0_wp + w(2, :) = 0.3_wp*COS(REAL(step, wp)) + al(2, :) = -0.3_wp*SIN(REAL(step, wp)) + IF (step == 0) THEN + CALL CD_AGG_UpdateStates_Moving(turned, p, v, a, es, em, orientation=orr, angular_velocity=w, & + angular_acceleration=al) + CALL CD_AGG_UpdateStates_Moving(fine, p, v, a, es, em) + ELSE + CALL CD_AGG_Step_Moving(turned, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DTC, & + orientation=orr, angular_velocity=w, angular_acceleration=al) + CALL require(es == CD_AGG_OK, 'orient:turned step: '//TRIM(em)) + CALL CD_AGG_Step_Moving(fine, DTC, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DTC) + END IF + CALL CD_AGG_Get_Rigid6_States(turned, bs, es, em) + CALL CD_AGG_Get_Rigid6_States(fine, bs2, es, em) + err = MAX(err, nan_max_abs(bs - bs2)) + END DO + CALL require(err <= 0.0_wp, 'orient:node orientation and rates ignored by the pinned body') + CALL CD_AGG_End(turned, es, em) + CALL CD_AGG_End(fine, es, em) + END SUBROUTINE case_substep + + ! --------------------------------------------------------------------------------------------- ! + ! 9: beside a Coupled body ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_mixed_hosts() + !! The pendulum deck with a Coupled body (body 2, at (0, 10, -2), on its own line) added after + !! it: the host nodes follow the deck BODY order (the pinned body's node, then the Coupled + !! body's 6-DOF node), and with every node held the pendulum swings as it does alone (its lines + !! are independent of the Coupled body's) while the Coupled body returns a finite wrench. + TYPE(CD_AGG_ModuleType) :: alone, mixed + REAL(wp), PARAMETER :: DT = 0.01_wp + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), mo(:, :), pa(:, :), fa(:, :) + REAL(wp) :: sa(24), sm(48), err + CHARACTER(512) :: rows(200), line + INTEGER :: es, n, na, step, it, u, ios, nr, i + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_pendulum_deck('pinbody_alone.dat', 25.0_wp) + nr = 0 + OPEN (NEWUNIT=u, FILE='pinbody_alone.dat', STATUS='OLD', ACTION='READ') + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + nr = nr + 1 + rows(nr) = line + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE='pinbody_mixed.dat', STATUS='REPLACE', ACTION='WRITE') + DO i = 1, nr + WRITE (u, '(A)') TRIM(rows(i)) + IF (INDEX(rows(i), '1 CoupledPinned') == 1) & + WRITE (u, '(A)') '2 Coupled 0.0 10.0 -2.0 0.0 0.0 0.0 200.0 0.0|0.0|0.0 30.0 0.1 0.0 0.0' + IF (INDEX(rows(i), '2 Coupled 4.0') == 1) THEN + WRITE (u, '(A)') '3 Body2 1.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 8.0 10.0 -8.0 0 0 0 0' + END IF + IF (TRIM(rows(i)) == '1 1 2 -') WRITE (u, '(A)') '2 3 4 -' + IF (TRIM(rows(i)) == '1 line 9.5 6') WRITE (u, '(A)') '2 line 9.5 6' + END DO + CLOSE (u) + CALL CD_AGG_Init_From_Deck(alone, 'pinbody_alone.dat', DT, es, em) + CALL CD_AGG_Init_From_Deck(mixed, 'pinbody_mixed.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'mixed:init: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(mixed, es, em) + na = CD_AGG_NMovingPoints(alone, es, em) + CALL require(n == 3 .AND. na == 2 .AND. CD_AGG_Rigid6_MirrorSize(mixed) == 48, 'mixed:layout') + IF (n /= 3) RETURN + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), mo(3, n), pa(3, na), fa(3, na)) + CALL CD_AGG_GetMovingPointMesh(mixed, p, v, a, f, es, em) + CALL CD_AGG_GetMovingPointMesh(alone, pa, v(:, 1:na), a(:, 1:na), fa, es, em) + CALL require(nan_max_abs(p(:, 2) - [0.0_wp, 0.0_wp, ZPIN]) <= 0.0_wp .AND. & + nan_max_abs(p(:, 3) - [0.0_wp, 10.0_wp, -2.0_wp]) <= 0.0_wp, 'mixed:host nodes in deck BODY order') + v = 0.0_wp + a = 0.0_wp + err = 0.0_wp + DO step = 1, 300 + CALL CD_AGG_Step_Moving(mixed, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK .AND. cv, 'mixed:step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Step_Moving(alone, DT, pa, v(:, 1:na), a(:, 1:na), cv, st, it, es, em, & + t_committed=REAL(step, wp)*DT) + CALL CD_AGG_Get_Rigid6_States(mixed, sm, es, em) + CALL CD_AGG_Get_Rigid6_States(alone, sa, es, em) + err = MAX(err, nan_max_abs(sm(1:24) - sa)) + END DO + CALL CD_AGG_CalcOutput(mixed, es, em) + CALL CD_AGG_GetMovingPointMesh(mixed, p, v, a, f, es, em, moment=mo) + WRITE (*, '(A,ES10.3,A,ES10.3)') 'beside a Coupled body: pendulum state vs alone ', err, & + '; Coupled body moment ', nan_max_abs(mo(:, 3)) + CALL require(err <= 1.0e-12_wp, 'mixed:the pinned body moves as alone') + CALL require(ALL(IEEE_IS_FINITE(f)) .AND. nan_max_abs(mo(:, 3)) > 0.0_wp .AND. nan_max_abs(mo(:, 2)) <= 0.0_wp, & + 'mixed:a moment at the Coupled node only') + CALL CD_AGG_End(alone, es, em) + CALL CD_AGG_End(mixed, es, em) + END SUBROUTINE case_mixed_hosts + + ! --------------------------------------------------------------------------------------------- ! + ! 10: the shell's state-mirror restore before the first step ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_shell_start() + !! The OpenFAST shell evaluates its outputs at t = 0 before the first step and restores the + !! state mirror afterwards, which marks every object's acceleration committed. The mirror must + !! then already carry the start accelerations (solved at Init): with every node held, each deck + !! (out of balance at its deck pose) marches bit for bit with and without that restore. + CHARACTER(32) :: deck(6) + INTEGER :: k + CALL write_pendulum_deck('pinbody_shell1.dat', 30.0_wp) + CALL write_symmetric_deck('pinbody_shell2.dat', free_body=.TRUE.) + CALL write_arm_deck('pinbody_shell3.dat', .TRUE., 'deck', rod_type='Free') + CALL write_arm_deck('pinbody_shell4.dat', .TRUE., 'deck', rod_type='Pinned') + CALL write_arm_deck('pinbody_shell5.dat', .TRUE., 'deck') + CALL write_arm_deck('pinbody_shell6.dat', .FALSE., 'deck') + deck = ['pinbody_shell1.dat', 'pinbody_shell2.dat', 'pinbody_shell3.dat', 'pinbody_shell4.dat', & + 'pinbody_shell5.dat', 'pinbody_shell6.dat'] + DO k = 1, 6 + CALL shell_start_one(TRIM(deck(k)), k >= 3 .AND. k <= 5, k == 2) + END DO + END SUBROUTINE case_shell_start + + SUBROUTINE shell_start_one(path, rod, extf) + !! One deck of case_shell_start: rod selects the rod mirror, extf the host fluid field. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: rod, extf + REAL(wp), PARAMETER :: DT = 0.01_wp + TYPE(CD_AGG_ModuleType) :: direct, shell + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :), ms(:), s1(:), s2(:) + REAL(wp) :: err, amp, w0 + INTEGER :: es, n, step, it, nm + LOGICAL :: cv, st + CHARACTER(512) :: em + CALL CD_AGG_Init_From_Deck(direct, path, DT, es, em, external_fluid=extf) + CALL CD_AGG_Init_From_Deck(shell, path, DT, es, em, external_fluid=extf) + CALL require(es == CD_AGG_OK, 'shell-start:init '//path//': '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + n = CD_AGG_NMovingPoints(shell, es, em) + IF (rod) THEN + nm = CD_AGG_Rod_MirrorSize(shell) + ELSE + nm = CD_AGG_Rigid6_MirrorSize(shell) + END IF + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n), ms(nm), s1(nm), s2(nm)) + ! the shell's output call at t = 0: evaluate, then restore the state mirror + CALL CD_AGG_CalcOutput(shell, es, em) + CALL CD_AGG_GetMovingPointMesh(shell, p, v, a, f, es, em) + IF (rod) THEN + CALL CD_AGG_Get_Rod_States(shell, ms, es, em) + CALL CD_AGG_Set_Rod_States(shell, ms, es, em) + ELSE + CALL CD_AGG_Get_Rigid6_States(shell, ms, es, em) + CALL CD_AGG_Set_Rigid6_States(shell, ms, es, em) + END IF + CALL require(es == CD_AGG_OK, 'shell-start:mirror '//path//': '//TRIM(em)) + v = 0.0_wp + a = 0.0_wp + err = 0.0_wp + amp = 0.0_wp + w0 = 0.0_wp + DO step = 1, 100 + CALL CD_AGG_Step_Moving(direct, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL CD_AGG_Step_Moving(shell, DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*DT) + CALL require(es == CD_AGG_OK, 'shell-start:step '//path//': '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + IF (rod) THEN + CALL CD_AGG_Get_Rod_States(direct, s1, es, em) + CALL CD_AGG_Get_Rod_States(shell, s2, es, em) + ELSE + CALL CD_AGG_Get_Rigid6_States(direct, s1, es, em) + CALL CD_AGG_Get_Rigid6_States(shell, s2, es, em) + END IF + IF (step == 1) w0 = MAXVAL(ABS([s1(4:6), s1(10:12)])) + err = MAX(err, nan_max_abs(s1 - s2)) + amp = MAX(amp, nan_max_abs(s1)) + END DO + WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') 'shell order (mirror restore at t = 0), ', path, & + ': |state difference| ', err, '; first-step velocity ', w0 + CALL require(w0 > 0.0_wp, 'shell-start:the deck starts out of balance '//path) + CALL require(err <= 0.0_wp, 'shell-start:the restore keeps the start acceleration '//path) + CALL CD_AGG_End(direct, es, em) + CALL CD_AGG_End(shell, es, em) + END SUBROUTINE shell_start_one + + ! --------------------------------------------------------------------------------------------- ! + ! 11: refusals ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE case_refusals() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: cp(3, 2) + INTEGER :: es + LOGICAL :: conv + CHARACTER(1024) :: em + + ! a standalone deck has no host to move the node + CALL write_pendulum_deck('pinbody_standalone.dat', 10.0_wp, standalone=.TRUE.) + CALL CD_Run_Deck_Driver('pinbody_standalone.dat', 'pinbody_standalone', conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'CoupledPinned/VesselPinned BODY requires a coupled host') > 0, & + 'refusal:standalone: '//TRIM(em)) + ! the linearisation probe holds every body + CALL write_pendulum_deck('pinbody_probe_pos.dat', 0.0_wp) + cp(:, 1) = [4.0_wp, 0.0_wp, 12.0_wp] + cp(:, 2) = [0.0_wp, 0.0_wp, ZPIN] + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_probe_pos.dat', 0.01_wp, es, em, coupled_positions=cp) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'Coupled/Vessel or CoupledPinned BODIES') > 0, & + 'refusal:coupled_positions: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + ! its rotation is integrated: the inertias must be positive + CALL write_symmetric_deck('pinbody_noinertia.dat') + CALL write_zero_inertia('pinbody_noinertia.dat') + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_noinertia.dat', 0.01_wp, es, em, external_fluid=.TRUE.) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'requires Ixx/Iyy/Izz > 0') > 0, 'refusal:inertia: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + ! MoorDyn-F's inertialF: CableDyn always returns the inertia (inertialF 1, accepted); 0 and 2 + ! are refused by name + CALL write_pendulum_deck('pinbody_inertialf.dat', 0.0_wp) + CALL add_option_row('pinbody_inertialf.dat', '1 inertialF') + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_inertialf.dat', 0.01_wp, es, em) + CALL require(es == CD_AGG_OK, 'refusal:inertialF 1 is accepted: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + CALL write_pendulum_deck('pinbody_inertialf.dat', 0.0_wp) + CALL add_option_row('pinbody_inertialf.dat', '0 inertialF') + CALL CD_AGG_Init_From_Deck(agg, 'pinbody_inertialf.dat', 0.01_wp, es, em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'inertialF 0 (MoorDyn-F''s default') > 0, & + 'refusal:inertialF 0: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_refusals + + SUBROUTINE add_option_row(path, row) + !! Insert an OPTIONS row before the end marker of a deck. + CHARACTER(*), INTENT(IN) :: path, row + CHARACTER(512) :: rows(200), line + INTEGER :: u, ios, n, i + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ') + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + n = n + 1 + rows(n) = line + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO i = 1, n + IF (TRIM(rows(i)) == '--- end ---') WRITE (u, '(A)') row + WRITE (u, '(A)') TRIM(rows(i)) + END DO + CLOSE (u) + END SUBROUTINE add_option_row + + SUBROUTINE write_zero_inertia(path) + !! The symmetric deck with a 15-column BODIES row (no inertias) for its VesselPinned body. + CHARACTER(*), INTENT(IN) :: path + CHARACTER(512), ALLOCATABLE :: rows(:) + CHARACTER(512) :: line + INTEGER :: u, ios, n, i + ALLOCATE (rows(200)) + n = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ') + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + n = n + 1 + rows(n) = line + IF (INDEX(line, '1 VesselPinned') == 1) rows(n) = '1 VesselPinned 0.0 0.0 -5.0 0.0 0.0 0.0 200.0 0.1 0.0 0.0 '// & + '0.0 0.0 0.5' + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO i = 1, n + WRITE (u, '(A)') TRIM(rows(i)) + END DO + CLOSE (u) + END SUBROUTINE write_zero_inertia + + ! --------------------------------------------------------------------------------------------- ! + ! 12: start accelerations in the host's fluid field ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_fluid_deck(path, rod) + !! A submerged Free object on two taut, nearly massless lines (0.01 kg/m, EA 1e5 N) without + !! hydrodynamic coefficients (their end forces neither see the field nor add inertia) to + !! anchors at x = +-40 m on the 50 m seabed: rod a horizontal + !! Free rod (6 m, 0.5 m diameter, 200 kg/m, Cd 1.2, Ca 1) at z = -20 m, else a Free Rigid6 + !! body (5000 kg, 4 m^3, CdA 6 m^2, Ca 0.8, CG at the reference point) there with its line + !! points 3 m out along x. Released at its deck pose (out of balance). + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: rod + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Free object in a host fluid field' + 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)') 'dry 0.002 0.01 1.0e5 0.0 0.0 0.0 0.0 0.0 0.0' + IF (rod) THEN + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') 'arm 0.5 200.0 1.2 1.0 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 arm Free -3.0 0.0 -20.0 3.0 0.0 -20.0 6 -' + ELSE + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Rot1 Rot2 Rot3 Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm/rad) (Nm/rad) (m2) (-) '// & + '(kgm2) (kgm2) (kgm2)' + WRITE (u, '(A,ES24.16,1X,ES24.16,A,ES24.16,1X,ES24.16,A)') '1 Rigid6 0.0 0.0 -20.0 0.0 0.0 0.0 ', FB_M, & + FB_V, ' 0.0 0.0 0.0 ', FB_CDA, FB_CA, ' 1.0e4 1.0e4 1.0e4' + 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) (-)' + IF (.NOT. rod) THEN + WRITE (u, '(A)') '1 Body1 3.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 -3.0 0.0 0.0 0 0 0 0' + END IF + WRITE (u, '(A)') '3 Fixed 40.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -40.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + IF (rod) THEN + WRITE (u, '(A)') '1 R1B 3 -' + WRITE (u, '(A)') '2 R1A 4 -' + ELSE + WRITE (u, '(A)') '1 1 3 -' + WRITE (u, '(A)') '2 2 4 -' + END IF + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 dry 47.0 10' + WRITE (u, '(A)') '2 dry 47.0 10' + CALL write_options(u, 50.0_wp, 'deck') + CLOSE (u) + END SUBROUTINE write_fluid_deck + + SUBROUTINE set_field(agg, u_c, a_c) + !! The uniform host field u_c, a_c at every fluid node, the free surface at z = 0. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(IN) :: u_c(3), a_c(3) + REAL(wp), ALLOCATABLE :: uf(:, :), af(:, :), wz(:) + INTEGER :: nf, es, i + CHARACTER(512) :: em + nf = CD_AGG_NFluidNodes(agg, es, em) + ALLOCATE (uf(3, nf), af(3, nf), wz(nf)) + DO i = 1, nf + uf(:, i) = u_c + af(:, i) = a_c + END DO + wz = 0.0_wp + CALL CD_AGG_SetFluidFields(agg, uf, af, wz, es, em) + CALL require(es == CD_AGG_OK, 'fluid-start:the host field is accepted: '//TRIM(em)) + END SUBROUTINE set_field + + SUBROUTINE get_mirror(agg, rod, s) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + LOGICAL, INTENT(IN) :: rod + REAL(wp), INTENT(OUT) :: s(:) + INTEGER :: es + CHARACTER(512) :: em + IF (rod) THEN + CALL CD_AGG_Get_Rod_States(agg, s, es, em) + ELSE + CALL CD_AGG_Get_Rigid6_States(agg, s, es, em) + END IF + END SUBROUTINE get_mirror + + SUBROUTINE case_fluid_start(path, rod) + !! Gate 12 for one deck (rod: the Free rod, else the Free Rigid6 body). Every run in the field + !! holds FS_U, FS_A and takes FS_NSTEP steps; the mirror after them is compared. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: rod + TYPE(CD_AGG_ModuleType) :: still, direct, oracle, shell, rewound, drag_only + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), f(:, :) + REAL(wp) :: s_still(24), s_dir(24), s_or(24), s_sh(24), s_rw(24) + REAL(wp) :: s0(24), s1(24), da(3), da_o(3), ms(24), err_drag + INTEGER :: es, n, it + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL write_fluid_deck(path, rod) + CALL CD_AGG_Init_From_Deck(still, path, FS_DT, es, em, external_fluid=.TRUE.) + CALL require(es == CD_AGG_OK, 'fluid-start:init '//path//': '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Init_From_Deck(direct, path, FS_DT, es, em, external_fluid=.TRUE.) + CALL CD_AGG_Init_From_Deck(oracle, path, FS_DT, es, em, external_fluid=.TRUE.) + CALL CD_AGG_Init_From_Deck(shell, path, FS_DT, es, em, external_fluid=.TRUE.) + CALL CD_AGG_Init_From_Deck(rewound, path, FS_DT, es, em, external_fluid=.TRUE.) + n = CD_AGG_NMovingPoints(still, es, em) + CALL require(n == 0, 'fluid-start:no host node '//path) + ALLOCATE (p(3, n), v(3, n), a(3, n), f(3, n)) + p = 0.0_wp + v = 0.0_wp + a = 0.0_wp + ! the body: the start acceleration in a current over the still-water one, against the drag + IF (.NOT. rod) THEN + CALL CD_AGG_Init_From_Deck(drag_only, path, FS_DT, es, em, external_fluid=.TRUE.) + CALL get_mirror(drag_only, rod, s0) + CALL set_field(drag_only, FS_U, [0.0_wp, 0.0_wp, 0.0_wp]) + CALL get_mirror(drag_only, rod, s1) + da = s1(7:9) - s0(7:9) + da_o = 0.5_wp*RHO*FB_CDA*NORM2(FS_U)*FS_U/(FB_M + RHO*FB_V*FB_CA) + err_drag = NORM2(da - da_o)/NORM2(da_o) + WRITE (*, '(A,3ES14.6,A,ES10.3)') 'start acceleration in a current, Free body: change ', da, & + ' m/s^2, against the drag over the effective mass ', err_drag + CALL require(err_drag <= 1.0e-5_wp, 'fluid-start:the body starts from its acceleration in the current') + CALL require(MAXVAL(ABS(s1(13:15) - s0(13:15))) <= 1.0e-12_wp*MAX(1.0_wp, MAXVAL(ABS(s0(13:15)))), & + 'fluid-start:the drag at the reference point turns nothing') + CALL CD_AGG_End(drag_only, es, em) + END IF + ! still water + CALL march_in_field(still, .FALSE., path, p, v, a) + CALL get_mirror(still, rod, s_still) + ! the host's field, then the steps + CALL set_field(direct, FS_U, FS_A) + CALL march_in_field(direct, .FALSE., path, p, v, a) + CALL get_mirror(direct, rod, s_dir) + ! the oracle: the field, then a committed step-start transfer solves the start accelerations + CALL set_field(oracle, FS_U, FS_A) + CALL CD_AGG_UpdateStates_Moving(oracle, p, v, a, es, em) + CALL require(es == CD_AGG_OK, 'fluid-start:step-start transfer: '//TRIM(em)) + CALL march_in_field(oracle, .FALSE., path, p, v, a) + CALL get_mirror(oracle, rod, s_or) + ! the OpenFAST shell: the t = 0 field at Init, the output call and its mirror restore, the + ! field of the step's end before the step + CALL set_field(shell, FS_U, FS_A) + CALL CD_AGG_CalcOutput(shell, es, em) + CALL CD_AGG_GetMovingPointMesh(shell, p, v, a, f, es, em) + CALL get_mirror(shell, rod, ms) + IF (rod) THEN + CALL CD_AGG_Set_Rod_States(shell, ms, es, em) + ELSE + CALL CD_AGG_Set_Rigid6_States(shell, ms, es, em) + END IF + CALL require(es == CD_AGG_OK, 'fluid-start:mirror restore: '//TRIM(em)) + CALL march_in_field(shell, .TRUE., path, p, v, a) + CALL get_mirror(shell, rod, s_sh) + ! a correction rewind of the first step to the snapshot before it, then the field and the steps + ! again + CALL CD_AGG_Snapshot(rewound, es, em) + CALL set_field(rewound, FS_U, FS_A) + CALL CD_AGG_Step_Moving(rewound, FS_DT, p, v, a, cv, st, it, es, em, t_committed=FS_DT) + CALL require(es == CD_AGG_OK .AND. cv, 'fluid-start:first step before the rewind: '//TRIM(em)) + CALL CD_AGG_Restore(rewound, es, em) + CALL require(es == CD_AGG_OK, 'fluid-start:rewind: '//TRIM(em)) + CALL set_field(rewound, FS_U, FS_A) + CALL march_in_field(rewound, .FALSE., path, p, v, a) + CALL get_mirror(rewound, rod, s_rw) + WRITE (*, '(A,A,A,ES10.3,A,3ES10.3)') 'start in the host field, ', path, ': field vs still water ', & + nan_max_abs(s_dir - s_still), '; vs the transfer-solved start: direct, shell order, rewind ', & + nan_max_abs(s_dir - s_or), nan_max_abs(s_sh - s_or), nan_max_abs(s_rw - s_or) + CALL require(nan_max_abs(s_dir - s_still) > 1.0e-6_wp, 'fluid-start:the field changes the first steps '//path) + CALL require(nan_max_abs(s_dir - s_or) <= 0.0_wp, & + 'fluid-start:SetFluidFields then Step starts from the accelerations in the field '//path) + CALL require(nan_max_abs(s_sh - s_or) <= 0.0_wp, 'fluid-start:the shell order starts from them '//path) + CALL require(nan_max_abs(s_rw - s_or) <= 0.0_wp, 'fluid-start:a rewind before the first step too '//path) + CALL CD_AGG_End(still, es, em) + CALL CD_AGG_End(direct, es, em) + CALL CD_AGG_End(oracle, es, em) + CALL CD_AGG_End(shell, es, em) + CALL CD_AGG_End(rewound, es, em) + END SUBROUTINE case_fluid_start + + SUBROUTINE march_in_field(agg, refresh, path, p, v, a) + !! FS_NSTEP steps of gate 12 with the host node set (p, v, a) held; refresh sets the field + !! again before each step, as the shell samples it at every step's end. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + LOGICAL, INTENT(IN) :: refresh + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: p(:, :), v(:, :), a(:, :) + INTEGER :: step, it, es + LOGICAL :: cv, st + CHARACTER(512) :: em + DO step = 1, FS_NSTEP + IF (refresh) CALL set_field(agg, FS_U, FS_A) + CALL CD_AGG_Step_Moving(agg, FS_DT, p, v, a, cv, st, it, es, em, t_committed=REAL(step, wp)*FS_DT) + CALL require(es == CD_AGG_OK .AND. cv, 'fluid-start:step '//path//': '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + END DO + END SUBROUTINE march_in_field + +END PROGRAM test_openfast_pinned_body diff --git a/tests/test_parity_integration.f90 b/tests/test_parity_integration.f90 new file mode 100644 index 00000000..9e58d579 --- /dev/null +++ b/tests/test_parity_integration.f90 @@ -0,0 +1,603 @@ +! File: tests/test_parity_integration.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_parity_integration + !! Gates where the MoorDyn-parity features meet: CoupledPinned bodies, active line control of + !! viscoelastic and Syrope segments, the MoorDyn-C Currents 2 and 5 fields, and ATTACHMENTS on a + !! line restrained in torsion. + !! 1. A CoupledPinned body in a Currents 2 or Currents 5 deck: the coupled aggregate (the + !! OpenFAST CompMooring = 5 route, with and without the host fluid field) refuses the deck + !! for its current files, by the aggregate's water-kinematics rule (the host supplies the + !! water kinematics there), while the same deck without them initialises; the standalone + !! driver refuses it for the body (no host moves its node). + !! 2. CONTROL on a viscoelastic (ElasticMod 2) and on a Syrope segment of a taut rope in a + !! cross-flow the host prescribes (external_fluid fields at every node, and its steady + !! current for the static start): with a zero command a still run keeps the static start; + !! after a pay-out (viscoelastic, the static law is history free) or a haul-in (Syrope, + !! onto the original working curve, which the static start also takes) and a hold, the + !! line rests where the static start of the deck with that segment longer or shorter + !! lies in the same current (a second route: the static solver against the controlled + !! march). The rope's cross-flow deflection is printed: the current is not negligible. + !! 3. The lazy wave of test_torsion_attachments (25 buoyancy modules with drag, one turn of + !! pretwist, the nodal twist), turned by 30 deg about z and moved off the origin, in a + !! Currents 5 grid sheared in x, y and z: the twisted discrete static start (the attachment + !! drag fixed point after the polish samples the grid at the modules' global positions) is + !! an equilibrium of the march, which samples the grid at the nodes: a still 10 s run keeps + !! the fairlead tension, both end torques and the twist. A grid that varies in depth only + !! gives the start of the same field as a Currents 1 profile (a second source of the field). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_Step_Moving, CD_AGG_Apply_LineControl, CD_AGG_NFluidNodes, & + CD_AGG_SetFluidFields, CD_AGG_End, CD_AGG_OK + USE CableDyn_System, ONLY: CD_System_Line_NElem, CD_Get_System_Line_Tension, CD_SYSTEM_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, DT = 0.05_wp + INTEGER :: n_fail = 0 + CHARACTER(512) :: lazy_wave + + IF (COMMAND_ARGUMENT_COUNT() /= 1) THEN + WRITE (*, '(A)') 'usage: test_parity_integration ' + ERROR STOP 2 + END IF + CALL GET_COMMAND_ARGUMENT(1, lazy_wave) + CALL case_pinned_body_currents(2) + CALL case_pinned_body_currents(5) + CALL case_control_host_current('viscoelastic', 100.4_wp, 0.6_wp, 0.3_wp) + CALL case_control_host_current('syrope', 102.0_wp, 1.0_wp, -0.2_wp) + CALL case_attachments_grid() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' integration check(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: CoupledPinned bodies, line control and attachments with currents' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + FUNCTION num(x) RESULT(s) + !! A real as a deck token without blanks. + REAL(wp), INTENT(IN) :: x + CHARACTER(:), ALLOCATABLE :: s + CHARACTER(32) :: buf + WRITE (buf, '(ES23.15)') x + s = TRIM(ADJUSTL(buf)) + END FUNCTION num + + ! --------------------------------------------------------------------------------------------- ! + ! 1. a CoupledPinned body in a Currents 2/5 deck ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_pinned_body_deck(path, currents, standalone) + !! A CoupledPinned body (1000 kg, CG 2 m below its reference point at (0, 0, -5), inertias + !! 500 kg m^2, no drag or added mass) carrying a line from a Body1 point at its node to a Coupled point, with the + !! MoorDyn-C Currents mode currents (0: none) and, standalone, the dtM/TMax clock. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: currents + LOGICAL, INTENT(IN) :: standalone + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'CoupledPinned body in a MoorDyn-C current field' + 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)') 'line 0.10 80.0 1.0e6 0.0 0.0 1.0 0.0 1.0 0.0' + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Attachment X0 Y0 Z0 r0 p0 y0 Mass CG* I* Volume CdA* Ca*' + WRITE (u, '(A)') '(#) (word) (m) (m) (m) (deg) (deg) (deg) (kg) (m) (kg-m^2) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 CoupledPinned 0.0 0.0 -5.0 0.0 0.0 0.0 1000.0 0.0|0.0|-2.0 500.0|500.0|500.0 0.5 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 Body1 0.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '2 Coupled 4.0 0.0 -13.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 line 9.5 6' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') 'deck bodyIC' + IF (currents > 0) WRITE (u, '(I0,A)') currents, ' Currents' + IF (standalone) THEN + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '0.1 TMax' + END IF + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_pinned_body_deck + + SUBROUTINE write_current_files() + !! A Currents 2 depth profile in time and a Currents 5 grid (2 x 2 x 2 x 2), both varying in + !! time, beside the decks. + INTEGER :: u, ix, iy, iz, it + REAL(wp), PARAMETER :: XS(2) = [-20.0_wp, 20.0_wp], YS(2) = [-20.0_wp, 20.0_wp], ZS(2) = [-50.0_wp, 0.0_wp], & + TS(2) = [0.0_wp, 10.0_wp] + OPEN (NEWUNIT=u, FILE='current_profile_dynamic.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Currents 2 profile in time' + WRITE (u, '(A)') 'depths on line 5, then t ux(z)' + WRITE (u, '(A)') '-' + WRITE (u, '(A)') '-' + WRITE (u, '(A)') '-50.0 0.0' + WRITE (u, '(A)') 't ux' + WRITE (u, '(A)') '0.0 0.2 0.4' + WRITE (u, '(A)') '10.0 0.3 0.6' + CLOSE (u) + OPEN (NEWUNIT=u, FILE='current_profile_4d.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '2 2 2 2' + WRITE (u, '(A)') '-20.0 20.0' + WRITE (u, '(A)') '-20.0 20.0' + WRITE (u, '(A)') '-50.0 0.0' + WRITE (u, '(A)') '0.0 10.0' + WRITE (u, '(A)') 'x y z t ux uy uz' + DO ix = 1, 2 + DO iy = 1, 2 + DO iz = 1, 2 + DO it = 1, 2 + WRITE (u, '(7(A,1X))') num(XS(ix)), num(YS(iy)), num(ZS(iz)), num(TS(it)), & + num(0.2_wp + 0.01_wp*XS(ix) + 0.1_wp*REAL(it - 1, wp)), num(0.005_wp*YS(iy)), num(0.0_wp) + END DO + END DO + END DO + END DO + CLOSE (u) + END SUBROUTINE write_current_files + + SUBROUTINE case_pinned_body_currents(currents) + INTEGER, INTENT(IN) :: currents + TYPE(CD_AGG_ModuleType) :: agg + INTEGER :: es + LOGICAL :: conv + CHARACTER(2048) :: em + CHARACTER(16) :: tag + WRITE (tag, '(A,I0)') 'Currents ', currents + CALL write_current_files() + ! the deck without the current files is a valid coupled deck + CALL write_pinned_body_deck('pint_pin_none.dat', 0, .FALSE.) + CALL CD_AGG_Init_From_Deck(agg, 'pint_pin_none.dat', 0.01_wp, es, em) + CALL require(es == CD_AGG_OK, '1 '//TRIM(tag)//': the CoupledPinned body deck without currents initialises: '// & + TRIM(em)) + CALL CD_AGG_End(agg, es, em) + CALL write_pinned_body_deck('pint_pin.dat', currents, .FALSE.) + CALL CD_AGG_Init_From_Deck(agg, 'pint_pin.dat', 0.01_wp, es, em) + WRITE (*, '(A)') '1 '//TRIM(tag)//', coupled aggregate: '//TRIM(em) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'Currents 1/2/5 files are not supported on the aggregate route') > 0 & + .AND. INDEX(em, 'coupled runs take water kinematics from the host') > 0, & + '1 '//TRIM(tag)//': the coupled aggregate refuses the current files of a CoupledPinned body deck') + CALL CD_AGG_End(agg, es, em) + ! as the OpenFAST shell builds it, with the host's fluid field + CALL CD_AGG_Init_From_Deck(agg, 'pint_pin.dat', 0.01_wp, es, em, external_fluid=.TRUE.) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'Currents 1/2/5 files are not supported on the aggregate route') > 0, & + '1 '//TRIM(tag)//': the coupled aggregate with the host field refuses them too: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + CALL write_pinned_body_deck('pint_pin_sa.dat', currents, .TRUE.) + CALL CD_Run_Deck_Driver('pint_pin_sa.dat', 'pint_pin_sa', conv, es, em) + WRITE (*, '(A)') '1 '//TRIM(tag)//', standalone driver: '//TRIM(em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'CoupledPinned/VesselPinned BODY requires a coupled host') > 0, & + '1 '//TRIM(tag)//': the standalone driver refuses the CoupledPinned body') + END SUBROUTINE case_pinned_body_currents + + ! --------------------------------------------------------------------------------------------- ! + ! 2. CONTROL on a viscoelastic or Syrope segment in the host's current ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_rope_deck(path, kind, span, l_first, control) + !! A taut rope between a Coupled fairlead at (0, 0, -100) and a Fixed anchor span away at the + !! same depth, written fairlead first (the controlled end at NodeA): a first segment of + !! l_first and nine of 10 m. kind viscoelastic: Es|Ed = 1e8|3e8 N, Bs|Bd = 1e6|1e5 N s; kind + !! syrope: the polyester of test_syrope_control (OWC table, LINEAR working curve, k1 = 0.5). + !! Both are nearly neutrally buoyant (0.05 kg/m above the displaced water's), Cdn = 1.2. + CHARACTER(*), INTENT(IN) :: path, kind + REAL(wp), INTENT(IN) :: span, l_first + LOGICAL, INTENT(IN) :: control + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Controlled rope in a host cross-flow ('//kind//')' + 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) (-) (-) (-) (-)' + IF (kind == 'syrope') THEN + WRITE (u, '(A)') 'rope 0.1438 16.70 "SYROPE:pint_settings.dat|1.53e8|23.12" 1.0e6|1.0e5 0.0 1.2 0.2 1.0 0.0' + ELSE + WRITE (u, '(A)') 'rope 0.1438 16.70 1.0e8|3.0e8 1.0e6|1.0e5 0.0 1.2 0.2 1.0 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 Coupled 0.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed '//num(span)//' 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 rope '//num(l_first)//' 1' + WRITE (u, '(A)') '1 rope 90.0 9' + IF (control) THEN + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Lines' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') '1 1' + END IF + 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)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_rope_deck + + SUBROUTINE write_syrope_files() + !! The OWC table of test_syrope_control (the shipped data/syrope/syrope_owc.dat) and its + !! settings file. + INTEGER :: u, k + REAL(wp), PARAMETER :: OWC_EPS(30) = [ & + 0.00000e+00_wp, 2.06897e-03_wp, 4.13793e-03_wp, 6.20690e-03_wp, 8.27586e-03_wp, & + 1.03448e-02_wp, 1.24138e-02_wp, 1.44828e-02_wp, 1.65517e-02_wp, 1.86207e-02_wp, & + 2.06897e-02_wp, 2.27586e-02_wp, 2.48276e-02_wp, 2.68966e-02_wp, 2.89655e-02_wp, & + 3.10345e-02_wp, 3.31034e-02_wp, 3.51724e-02_wp, 3.72414e-02_wp, 3.93103e-02_wp, & + 4.13793e-02_wp, 4.34483e-02_wp, 4.55172e-02_wp, 4.75862e-02_wp, 4.96552e-02_wp, & + 5.17241e-02_wp, 5.37931e-02_wp, 5.58621e-02_wp, 5.79310e-02_wp, 6.00000e-02_wp] + REAL(wp), PARAMETER :: OWC_TEN(30) = [ & + 0.00000e+00_wp, 1.71768e+05_wp, 3.30952e+05_wp, 4.78788e+05_wp, 6.16510e+05_wp, & + 7.45355e+05_wp, 8.66556e+05_wp, 9.81351e+05_wp, 1.09097e+06_wp, 1.19666e+06_wp, & + 1.29964e+06_wp, 1.40116e+06_wp, 1.50245e+06_wp, 1.60474e+06_wp, 1.70927e+06_wp, & + 1.81728e+06_wp, 1.93000e+06_wp, 2.04866e+06_wp, 2.17450e+06_wp, 2.30876e+06_wp, & + 2.45267e+06_wp, 2.60747e+06_wp, 2.77439e+06_wp, 2.95467e+06_wp, 3.14954e+06_wp, & + 3.36024e+06_wp, 3.58800e+06_wp, 3.83406e+06_wp, 4.09965e+06_wp, 4.38601e+06_wp] + OPEN (NEWUNIT=u, FILE='pint_owc.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Strain Tension' + WRITE (u, '(A)') '(-) (N)' + DO k = 1, SIZE(OWC_EPS) + WRITE (u, '(ES14.6,1X,ES14.6)') OWC_EPS(k), OWC_TEN(k) + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE='pint_settings.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pint_owc.dat OWC - Original working-curve table file' + WRITE (u, '(A)') 'LINEAR WCType - Working-curve formulation' + WRITE (u, '(A)') '0.5 k1 - First working-curve shape parameter' + WRITE (u, '(A)') '0.0 k2 - Second working-curve shape parameter' + CLOSE (u) + END SUBROUTINE write_syrope_files + + SUBROUTINE init_in_cross_flow(agg, deck, what, u_cross, ok) + !! Initialise deck on the coupled aggregate with the host's fluid field and its steady + !! cross-flow u_cross (along +y) for the static start, and hold the cross-flow at every fluid + !! node. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + CHARACTER(*), INTENT(IN) :: deck, what + REAL(wp), INTENT(IN) :: u_cross + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: sc(4, 2) + INTEGER :: es + CHARACTER(1024) :: em + sc(:, 1) = [-250.0_wp, 0.0_wp, u_cross, 0.0_wp] + sc(:, 2) = [0.0_wp, 0.0_wp, u_cross, 0.0_wp] + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em, external_fluid=.TRUE., static_current=sc) + ok = es == CD_AGG_OK + CALL require(ok, '2 '//what//': '//deck//' initialises in the host cross-flow: '//TRIM(em)) + IF (ok) CALL hold_cross_flow(agg, u_cross, ok) + END SUBROUTINE init_in_cross_flow + + SUBROUTINE hold_cross_flow(agg, u_cross, ok) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(IN) :: u_cross + LOGICAL, INTENT(OUT) :: ok + REAL(wp), ALLOCATABLE :: uf(:, :), af(:, :), wz(:) + INTEGER :: nf, es + CHARACTER(1024) :: em + nf = CD_AGG_NFluidNodes(agg, es, em) + ALLOCATE (uf(3, nf), af(3, nf), wz(nf)) + uf = 0.0_wp + uf(2, :) = u_cross + af = 0.0_wp + wz = 0.0_wp + CALL CD_AGG_SetFluidFields(agg, uf, af, wz, es, em) + ok = es == CD_AGG_OK + CALL require(ok, '2: the host fluid field is accepted: '//TRIM(em)) + END SUBROUTINE hold_cross_flow + + SUBROUTINE case_control_host_current(kind, span, u_cross, dl) + !! The controlled rope of kind (anchor span away) in the host's cross-flow u_cross: a 10 s + !! still run at a zero command, then the first segment's length changed by dl on a half-cosine + !! over 10 s and held 40 s, against the static start of the deck whose first segment is + !! 10 + dl long. + CHARACTER(*), INTENT(IN) :: kind + REAL(wp), INTENT(IN) :: span, u_cross, dl + TYPE(CD_AGG_ModuleType) :: agg, ref + INTEGER, PARAMETER :: NSTILL = 200, NRAMP = 200, NHOLD = 800 + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), t, cmd, cmd_dot, drift, dten, dq, dt_rel, defl + REAL(wp), ALLOCATABLE :: q0(:), ten0(:), ten(:), ten_ref(:) + INTEGER :: es, ni, il, ne, s + LOGICAL :: ok, cv, st + CHARACTER(1024) :: em + CHARACTER(64) :: deck, deck_ref + + IF (kind == 'syrope') CALL write_syrope_files() + deck = 'pint_ctrl_'//kind//'.dat' + deck_ref = 'pint_ref_'//kind//'.dat' + CALL write_rope_deck(TRIM(deck), kind, span, 10.0_wp, .TRUE.) + CALL write_rope_deck(TRIM(deck_ref), kind, span, 10.0_wp + dl, .FALSE.) + CALL init_in_cross_flow(agg, TRIM(deck), kind, u_cross, ok) + IF (.NOT. ok) RETURN + CALL init_in_cross_flow(ref, TRIM(deck_ref), kind, u_cross, ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (ten0(ne), ten(ne), ten_ref(ne)) + q0 = agg%sys%fast%system%lines(il)%q + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten0, es, em) + drift = 0.0_wp + dten = 0.0_wp + DO s = 1, NSTILL + NRAMP + NHOLD + t = REAL(s, wp)*DT - REAL(NSTILL, wp)*DT + cmd = 0.0_wp + cmd_dot = 0.0_wp + IF (t >= REAL(NRAMP, wp)*DT) THEN + cmd = dl + ELSE IF (t > 0.0_wp) THEN + cmd = dl*0.5_wp*(1.0_wp - COS(PI*t/(REAL(NRAMP, wp)*DT))) + cmd_dot = dl*0.5_wp*(PI/(REAL(NRAMP, wp)*DT))*SIN(PI*t/(REAL(NRAMP, wp)*DT)) + END IF + CALL hold_cross_flow(agg, u_cross, ok) + IF (.NOT. ok) RETURN + CALL CD_AGG_Apply_LineControl(agg, [cmd], [cmd_dot], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg, DT, r0, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + CALL require(.FALSE., '2 '//kind//': step '//TRIM(num(t))//': '//TRIM(em)) + RETURN + END IF + IF (s <= NSTILL) THEN + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + drift = MAX(drift, MAXVAL(ABS(agg%sys%fast%system%lines(il)%q - q0))) + dten = MAX(dten, MAXVAL(ABS(ten - ten0))/MAXVAL(ten0)) + END IF + END DO + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + CALL CD_Get_System_Line_Tension(ref%sys%fast%system, 1, ten_ref, es, em) + ! the controlled segment is the deck's first (the fairlead's), as the changed deck's + CALL require(MAXVAL(ABS(agg%sys%fast%system%lines(il)%l0 - ref%sys%fast%system%lines(1)%l0)) <= 1.0e-12_wp, & + '2 '//kind//': the controlled line takes the segment lengths of the changed deck') + ASSOCIATE (q => agg%sys%fast%system%lines(il)%q, qr => ref%sys%fast%system%lines(1)%q) + dq = MAXVAL(ABS(q - qr)) + defl = MAXVAL(ABS(qr(2::3))) + END ASSOCIATE + dt_rel = MAXVAL(ABS(ten - ten_ref))/MAXVAL(ten_ref) + WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') '2 ', kind, ': still 10 s at a zero command: node drift ', drift, & + ' m, tension change / T ', dten + WRITE (*, '(A,A,A,F6.3,A,ES12.5,A,ES12.5,A,F7.4,A)') '2 ', kind, ': after DeltaL = ', dl, & + ' m and a 40 s hold: T ', MAXVAL(ten), ' N, the static start of the changed deck ', MAXVAL(ten_ref), & + ' N (cross-flow deflection ', defl, ' m)' + WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') '2 ', kind, ': max |x - x_static| ', dq, ' m, max |T - T_static| / T ', dt_rel + CALL require(drift <= 1.0e-9_wp .AND. dten <= 1.0e-9_wp, & + '2 '//kind//': a still run at a zero command keeps the static start in the host current') + CALL require(defl > 0.05_wp, '2 '//kind//': the cross-flow deflects the rope') + CALL require(dq <= 1.0e-5_wp .AND. dt_rel <= 1.0e-5_wp, & + '2 '//kind//': the controlled line rests at the static start of the changed deck') + CALL CD_AGG_End(agg, es, em) + CALL CD_AGG_End(ref, es, em) + END SUBROUTINE case_control_host_current + + ! --------------------------------------------------------------------------------------------- ! + ! 3. ATTACHMENTS on a line restrained in torsion in a Currents 5 grid ! + ! --------------------------------------------------------------------------------------------- ! + + SUBROUTINE write_turned_lazy_wave(path, currents) + !! The lazy wave of lazy_wave_torsion_attachments.dat turned by PSI about z and moved by + !! (X_OFF, Y_OFF), its END CONNECTIONS directions turned with it, in the MoorDyn-C Currents + !! mode currents. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: currents + REAL(wp), PARAMETER :: PSI = 30.0_wp*PI/180.0_wp, X_OFF = 100.0_wp, Y_OFF = -50.0_wp + REAL(wp) :: c, s + INTEGER :: u + c = COS(PSI) + s = SIN(PSI) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Turned lazy wave with buoyancy modules, restrained in torsion, in a MoorDyn-C current' + 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)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.5e4 1.0 1.0 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)') '7 Coupled '//num(X_OFF + 30.0_wp*c)//' '//num(Y_OFF + 30.0_wp*s)//' -20.0' + WRITE (u, '(A)') '8 Fixed '//num(X_OFF + 500.0_wp*c)//' '//num(Y_OFF + 500.0_wp*s)//' -200.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '4 7 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '4 bare 80.0 20' + WRITE (u, '(A)') '4 bare 100.0 25' + WRITE (u, '(A)') '4 bare 420.0 42' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '4 80.0:4.0:176.0 91.32 0.18378 1.392 1.0 0.0' + 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)') '4 A Rigid '//num(0.1058_wp*c)//' '//num(0.1058_wp*s)//' -0.9944 Rigid '//num(-s)//' '// & + num(c)//' 0 0' + WRITE (u, '(A)') '4 B Rigid '//num(c)//' '//num(s)//' 0 Rigid '//num(-s)//' '//num(c)//' 0 360' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.35 frictionMu' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') '0.025 dtM' + WRITE (u, '(A)') '10.0 TMax' + WRITE (u, '(I0,A)') currents, ' Currents' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen4' + WRITE (u, '(A)') 'Torq4N1' + WRITE (u, '(A)') 'Torq4N88' + WRITE (u, '(A)') 'Twist4' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_turned_lazy_wave + + PURE FUNCTION grid_speed(x, y, z, sheared) RESULT(sp) + !! The speed of the grid field, across the turned line (direction (-sin 30, cos 30, 0)): + !! (0.15 + 3e-4 x - 2e-4 y)(1 + z/400) when sheared, else 0.15 (1 + z/400). Trilinear, so the + !! grid reproduces it between its points. + REAL(wp), INTENT(IN) :: x, y, z + LOGICAL, INTENT(IN) :: sheared + REAL(wp) :: sp + IF (sheared) THEN + sp = (0.15_wp + 3.0e-4_wp*x - 2.0e-4_wp*y)*(1.0_wp + z/400.0_wp) + ELSE + sp = 0.15_wp*(1.0_wp + z/400.0_wp) + END IF + END FUNCTION grid_speed + + SUBROUTINE write_grid(sheared) + !! current_profile_4d.txt: x in {-100, 300, 700}, y in {-200, 100, 400}, z in {-250, -100, 0}, + !! t in {0, 100} (steady), the velocity grid_speed along (-sin 30, cos 30, 0). + LOGICAL, INTENT(IN) :: sheared + REAL(wp), PARAMETER :: XS(3) = [-100.0_wp, 300.0_wp, 700.0_wp], YS(3) = [-200.0_wp, 100.0_wp, 400.0_wp], & + ZS(3) = [-250.0_wp, -100.0_wp, 0.0_wp], TS(2) = [0.0_wp, 100.0_wp] + REAL(wp) :: sp, nx, ny + INTEGER :: u, ix, iy, iz, it + nx = -SIN(30.0_wp*PI/180.0_wp) + ny = COS(30.0_wp*PI/180.0_wp) + OPEN (NEWUNIT=u, FILE='current_profile_4d.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '3 3 3 2' + WRITE (u, '(3(A,1X))') num(XS(1)), num(XS(2)), num(XS(3)) + WRITE (u, '(3(A,1X))') num(YS(1)), num(YS(2)), num(YS(3)) + WRITE (u, '(3(A,1X))') num(ZS(1)), num(ZS(2)), num(ZS(3)) + WRITE (u, '(2(A,1X))') num(TS(1)), num(TS(2)) + WRITE (u, '(A)') 'x y z t ux uy uz' + DO ix = 1, 3 + DO iy = 1, 3 + DO iz = 1, 3 + DO it = 1, 2 + sp = grid_speed(XS(ix), YS(iy), ZS(iz), sheared) + WRITE (u, '(7(A,1X))') num(XS(ix)), num(YS(iy)), num(ZS(iz)), num(TS(it)), num(sp*nx), num(sp*ny), & + num(0.0_wp) + END DO + END DO + END DO + END DO + CLOSE (u) + END SUBROUTINE write_grid + + SUBROUTINE write_profile() + !! current_profile.txt (Currents 1): the depth-only grid field at the grid's levels. + REAL(wp), PARAMETER :: ZS(3) = [-250.0_wp, -100.0_wp, 0.0_wp] + REAL(wp) :: sp, nx, ny + INTEGER :: u, iz + nx = -SIN(30.0_wp*PI/180.0_wp) + ny = COS(30.0_wp*PI/180.0_wp) + OPEN (NEWUNIT=u, FILE='current_profile.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Currents 1 profile' + WRITE (u, '(A)') 'the depth-only grid field' + WRITE (u, '(A)') 'z (m), ux (m/s), uy (m/s), uz (m/s)' + DO iz = 1, 3 + sp = grid_speed(0.0_wp, 0.0_wp, ZS(iz), .FALSE.) + WRITE (u, '(4(A,1X))') num(ZS(iz)), num(sp*nx), num(sp*ny), num(0.0_wp) + END DO + CLOSE (u) + END SUBROUTINE write_profile + + SUBROUTINE run_still(root, currents, label, first, spread, ok) + !! Write and run the turned lazy wave as root.dat in Currents mode currents; first holds the + !! first output row (FairTen, Torq A, Torq B, Twist) and spread the relative spread of each + !! column over the 10 s run. + CHARACTER(*), INTENT(IN) :: root, label + INTEGER, INTENT(IN) :: currents + REAL(wp), INTENT(OUT) :: first(4), spread(4) + LOGICAL, INTENT(OUT) :: ok + INTEGER, PARAMETER :: MAXROW = 1000 + REAL(wp) :: vals(5, MAXROW) + INTEGER :: u, ios, nrow, j, es + LOGICAL :: conv + CHARACTER(2048) :: em, buf + first = 0.0_wp + spread = HUGE(1.0_wp) + CALL write_turned_lazy_wave(root//'.dat', currents) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + ok = es == CD_DECKDRV_OK .AND. conv + CALL require(ok, '3 '//label//': the turned lazy wave with modules and torsion solves and runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + nrow = 0 + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios == 0) THEN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO WHILE (nrow < MAXROW) + READ (u, *, IOSTAT=ios) vals(:, nrow + 1) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + END IF + ok = nrow == 401 + IF (ok) ok = ALL(IEEE_IS_FINITE(vals(:, 1:nrow))) + CALL require(ok, '3 '//label//': 401 finite output rows') + IF (.NOT. ok) RETURN + first = vals(2:5, 1) + DO j = 1, 4 + spread(j) = (MAXVAL(vals(j + 1, 1:nrow)) - MINVAL(vals(j + 1, 1:nrow)))/ABS(vals(j + 1, 1)) + END DO + WRITE (*, '(A,A,A,4ES14.6,A,4ES10.2)') '3 ', label, ': FairTen, Torq A, Torq B, Twist ', first, & + '; relative spread over 10 s ', spread + END SUBROUTINE run_still + + SUBROUTINE case_attachments_grid() + REAL(wp) :: f_grid(4), s_grid(4), f_z(4), s_z(4), f_c1(4), s_c1(4), f_still(4), s_still(4) + LOGICAL :: ok + ! the current-free start, for the size of the current's effect + CALL run_still('pint_lw_still', 0, 'still water', f_still, s_still, ok) + IF (.NOT. ok) RETURN + CALL write_grid(.TRUE.) + CALL run_still('pint_lw_grid', 5, 'Currents 5 grid sheared in x, y and z', f_grid, s_grid, ok) + IF (.NOT. ok) RETURN + CALL require(ABS(f_grid(4)) > 300.0_wp, '3: the static start in the grid is twisted (one turn of pretwist)') + CALL require(MAXVAL(s_grid) <= 1.0e-6_wp, '3: a still run keeps the twisted discrete start in the sheared grid') + WRITE (*, '(A,4ES10.2)') '3 the grid changes the start (relative to still water): ', & + ABS(f_grid - f_still)/ABS(f_still) + CALL require(ABS(f_grid(1) - f_still(1)) > 1.0e-3_wp*ABS(f_still(1)), '3: the grid current loads the line') + CALL write_grid(.FALSE.) + CALL run_still('pint_lw_gridz', 5, 'Currents 5 grid in depth only', f_z, s_z, ok) + IF (.NOT. ok) RETURN + CALL write_profile() + CALL run_still('pint_lw_c1', 1, 'Currents 1 profile of the same field', f_c1, s_c1, ok) + IF (.NOT. ok) RETURN + WRITE (*, '(A,4ES10.2)') '3 depth-only grid against the Currents 1 profile, relative: ', ABS(f_z - f_c1)/ABS(f_c1) + CALL require(MAXVAL(s_z) <= 1.0e-6_wp .AND. MAXVAL(s_c1) <= 1.0e-6_wp, & + '3: still runs keep the starts in the depth-only grid and in the profile') + CALL require(MAXVAL(ABS(f_z - f_c1)/ABS(f_c1)) <= 1.0e-9_wp, & + '3: a depth-only grid gives the start of the same Currents 1 profile') + END SUBROUTINE case_attachments_grid + +END PROGRAM test_parity_integration diff --git a/tests/test_step_allocations.f90 b/tests/test_step_allocations.f90 index e5bc065c..df0ccab8 100644 --- a/tests/test_step_allocations.f90 +++ b/tests/test_step_allocations.f90 @@ -25,8 +25,13 @@ PROGRAM test_step_allocations !! the same cable carries the nodal twist (polar inertia and torsional damping), with its !! 7-DOF-per-node band and the node-torque and element-twist queries. !! + !! With "current_grid" the gate runs the evaluation of a MoorDyn-C current grid (Currents 2 and + !! 5) that every standalone step makes at every node: CD_Current_Grid_Velocity, and the gradient + !! of the EI = 0 static tangent (CD_Current_Grid_Gradient), at points inside and outside a + !! sheared grid and at times before, inside and past its last sample. + !! !! Usage: test_step_allocations [ranges] - !! test_step_allocations torsion | nodal + !! test_step_allocations torsion | nodal | current_grid USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_LONG_LONG USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -37,6 +42,8 @@ PROGRAM test_step_allocations USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HermiteCable_Dyn_Energy, & CD_HermiteCable_Dyn_Torsion_State, CD_HermiteCable_Dyn_Node_Torque, & CD_HermiteCable_Dyn_Element_Twist + USE CableDyn_Hydro, ONLY: CD_CurrentGridType, CD_Current_Grid_Resample, CD_Current_Grid_Velocity, & + CD_Current_Grid_Gradient USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & CD_AGG_NFluidNodes, CD_AGG_NumChannels, CD_AGG_GetMovingPointMesh, & CD_AGG_Snapshot, CD_AGG_SetFluidFields, CD_AGG_Step_Moving, & @@ -67,7 +74,12 @@ END SUBROUTINE cd_test_allocation_counting IF (COMMAND_ARGUMENT_COUNT() == 1) THEN CALL GET_COMMAND_ARGUMENT(1, arg) - IF (TRIM(arg) /= 'torsion' .AND. TRIM(arg) /= 'nodal') ERROR STOP 'a single argument must be "torsion" or "nodal"' + IF (TRIM(arg) == 'current_grid') THEN + CALL current_grid_gate() + STOP + END IF + IF (TRIM(arg) /= 'torsion' .AND. TRIM(arg) /= 'nodal') & + ERROR STOP 'a single argument must be "torsion", "nodal" or "current_grid"' CALL torsion_gate(TRIM(arg) == 'nodal') STOP END IF @@ -278,6 +290,51 @@ SUBROUTINE torsion_gate(nodal) PRINT '(A)', 'PASS: no heap allocation in the per-step advance or outputs of a cable with torsion after warm-up' END SUBROUTINE torsion_gate + SUBROUTINE current_grid_gate() + TYPE(CD_CurrentGridType) :: grid + REAL(wp) :: xc(4), yc(2), zc(4), tc(4), v_in(3, 4, 2, 4, 4), u(3), g(3, 3), p(3), t, total + INTEGER(C_LONG_LONG) :: n0, n1 + INTEGER :: ix, iy, iz, it, k + xc = [-60.0_wp, -20.0_wp, 10.0_wp, 50.0_wp] + yc = [-30.0_wp, 30.0_wp] + zc = [-50.0_wp, -25.0_wp, -10.0_wp, 0.0_wp] + tc = [0.0_wp, 5.0_wp, 12.0_wp, 20.0_wp] + DO it = 1, 4 + DO iz = 1, 4 + DO iy = 1, 2 + DO ix = 1, 4 + v_in(:, ix, iy, iz, it) = [0.4_wp + 0.006_wp*xc(ix) + 0.01_wp*tc(it), 0.003_wp*yc(iy), 0.001_wp*zc(iz)] + END DO + END DO + END DO + END DO + CALL CD_Current_Grid_Resample(xc, yc, zc, tc, v_in, grid, es, em) + CALL check('current grid resample') + total = 0.0_wp + ! warm-up (any lazy runtime set-up outside the counted window) + CALL CD_Current_Grid_Velocity(grid, [1.0_wp, 2.0_wp, -3.0_wp], 1.0_wp, u, es, em) + CALL check('current grid warm-up') + CALL cd_test_allocation_counting(1_C_INT) + n0 = cd_test_allocation_count() + DO k = 1, 20000 + t = -1.0_wp + 0.0037_wp*REAL(k, wp) + p = [-80.0_wp + 0.0071_wp*REAL(k, wp), -45.0_wp + 0.0047_wp*REAL(k, wp), -60.0_wp + 0.0033_wp*REAL(k, wp)] + CALL CD_Current_Grid_Velocity(grid, p, t, u, es, em) + CALL check('current grid velocity') + CALL CD_Current_Grid_Gradient(grid, p, t, g, es, em) + CALL check('current grid gradient') + total = total + SUM(u) + SUM(g) + END DO + n1 = cd_test_allocation_count() + CALL cd_test_allocation_counting(0_C_INT) + PRINT '(A,I0,A,ES12.4,A)', 'current grid: 20000 evaluations, ', n1 - n0, ' heap allocations (checksum ', total, ')' + IF (n1 /= n0) THEN + PRINT '(A)', 'FAIL: the current grid evaluation allocated' + ERROR STOP 1 + END IF + PRINT '(A)', 'PASS: no heap allocation in the current grid evaluation' + END SUBROUTINE current_grid_gate + SUBROUTINE check(stage) CHARACTER(*), INTENT(IN) :: stage diff --git a/tests/test_syrope.f90 b/tests/test_syrope.f90 index 31658bc6..c9a658ce 100644 --- a/tests/test_syrope.f90 +++ b/tests/test_syrope.f90 @@ -7,7 +7,10 @@ PROGRAM test_syrope !! constants -- working-curve generation for all three shapes, the static strain split, the !! rate/tension evaluation on !! both branches, the running-max regeneration event, and the fail-closed - !! battery. + !! battery. The backward-Euler state solve also converges when its root sits at the top + !! sample of the working curve (a rope at rest on its OWC at its running maximum), where the + !! safeguarded Newton step alone crept along one side of the bracket and the solve failed, and + !! when R is so steep (light BA) that it changes sign between two adjacent reals. USE CableDyn_Precision, ONLY: wp USE CableDyn_Syrope, ONLY: CD_SyropeType, CD_Syrope_Init, CD_Syrope_End, & CD_Syrope_Working_Curve, CD_Syrope_Find_Strains, & @@ -68,6 +71,8 @@ PROGRAM test_syrope CALL case_owc_branch_and_running_max() CALL case_interp_clamps() CALL case_projected_state_advance() + CALL case_state_advance_at_wc_top() + CALL case_state_advance_steep() CALL case_element_load() CALL case_model_legacy_ba_mask() CALL case_model_held() @@ -353,6 +358,118 @@ SUBROUTINE case_projected_state_advance() CALL CD_Syrope_End(td) END SUBROUTINE case_projected_state_advance + SUBROUTINE case_state_advance_at_wc_top() + !! A rope held at rest on its OWC at its running maximum: the backward-Euler root lies just + !! above the top sample of the working curve's slow strains, where T_mean(eps_slow) stops + !! rising (it clamps at T_max up to the branch divider), closer to it than the Newton + !! step's difference interval. The state of a run (LINEAR, k1 = 0.5, BA_s|BA_d = 1e6|1e5, + !! a line hauled in and held) on which the safeguarded Newton step crept 80 iterations + !! along that kink and the solve failed; the bisection that finishes the solve meets the + !! residual test, between the kink and the divider, at the curve's top tension. + TYPE(CD_SyropeType) :: td + REAL(wp), PARAMETER :: TMAX = 1.7790941510791376e6_wp, SLOW0 = 2.0004433178640910e-2_wp, & + EPS = 3.0303024894996432e-2_wp, DEPS = -1.4208693414705444e-13_wp, DT = 5.0e-2_wp + REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC) + REAL(wp) :: slow_next, t_mean, divider, rate, tension, mean, residual + INTEGER :: es + CHARACTER(200) :: em + CALL CD_Syrope_Init(td, OWC_EPS, OWC_TEN, CD_SYROPE_WC_LINEAR, 0.5_wp, 0.0_wp, & + ALPHA, BETA, 1.0e6_wp, 1.0e5_wp, es, em) + CALL require(es == CD_SYROPE_OK, 'wc-top:init') + CALL CD_Syrope_Working_Curve(td, TMAX, ws, wt, wsl, es, em) + CALL require(es == CD_SYROPE_OK, 'wc-top:wc') + divider = CD_Syrope_Branch_Divider(td, TMAX) + CALL CD_Syrope_State_Advance(td, SLOW0 < divider, ws, wt, wsl, SLOW0, EPS, DEPS, DT, slow_next, t_mean, & + es, em, divider=divider) + CALL require(es == CD_SYROPE_OK, 'wc-top:the solve converges: '//TRIM(em)) + CALL CD_Syrope_Rate_And_Tension(td, slow_next < divider, ws, wt, wsl, slow_next, EPS, DEPS, rate, tension, & + mean, es, em) + residual = slow_next - SLOW0 - DT*rate + WRITE (*, '(A,ES16.9,A,ES10.3,A,ES12.5,A)') ' wc-top: slow strain ', slow_next, ', residual ', residual, & + ', mean tension ', mean, ' N' + CALL require(ABS(residual) <= 5.0e-13_wp .AND. slow_next > wsl(CD_SYROPE_NWC) .AND. slow_next < divider .AND. & + bits_same(mean, wt(CD_SYROPE_NWC)) .AND. bits_same(mean, t_mean), 'wc-top:root at the curve top') + CALL CD_Syrope_End(td) + END SUBROUTINE case_state_advance_at_wc_top + + SUBROUTINE case_state_advance_steep() + !! Twelve states of a light rope (QUADRATIC, p2 = 0.5, BA_s|BA_d = 1e4|1e3) next to the top + !! of the working curve, from a fuzz of the solve, on which it failed: R' = 1 - dt + !! d(rate)/d(eps_slow) is of order 1e6, so R changes sign between two adjacent reals with |R| + !! above the residual test on both. The solve returns the root to machine precision: R + !! changes sign between the result and its neighbour on the other side, and the returned + !! mean tension is the one at the result. + INTEGER, PARAMETER :: NS = 12 + ! k1, T_max, slow_old, eps, deps, dt + REAL(wp), PARAMETER :: ST(6, NS) = RESHAPE([ & + 0.5_wp, 1.36633017834277474e6_wp, 1.39304174224812102e-2_wp, & + 2.20484956584058520e-2_wp, -2.91917316204991001e-5_wp, 5.00000000000000028e-2_wp, & + 0.5_wp, 1.37680196069096052e6_wp, 5.35760113574383894e-3_wp, & + 2.22609221334421868e-2_wp, -5.34676314308176825e-13_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.36922682379846880e6_wp, 1.39737625858687414e-2_wp, & + 2.21031832264193540e-2_wp, -1.54171755685975461e-10_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.37055211343974154e6_wp, 1.39940856061747162e-2_wp, & + 2.21297981068623792e-2_wp, -1.34624093812978118e-5_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.37527118954379787e6_wp, 6.58388926223281434e-3_wp, & + 2.22260959754430436e-2_wp, 9.20479632170825829e-10_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.37087072085890593e6_wp, 1.35832674506310615e-2_wp, & + 2.21347560532284236e-2_wp, 2.40447604051167914e-5_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.36645106216464797e6_wp, 1.39322344956098881e-2_wp, & + 2.20511942008235519e-2_wp, -2.02603337569392040e-13_wp, 5.00000000000000028e-2_wp, & + 0.5_wp, 1.36815732104760036e6_wp, 1.39584978679733341e-2_wp, & + 2.20753893183824081e-2_wp, -5.23605833892740875e-6_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.37059169344443991e6_wp, 1.39949247390703350e-2_wp, & + 2.21338733365970056e-2_wp, 0.00000000000000000e0_wp, 2.00000000000000011e-1_wp, & + 0.5_wp, 1.38033403057004604e6_wp, 1.35405334447999213e-2_wp, & + 2.23240330306617440e-2_wp, 0.00000000000000000e0_wp, 2.00000000000000011e-1_wp, & + 0.3_wp, 4.73718757443073089e5_wp, 3.14555534663941896e-3_wp, & + 6.13349734479911885e-3_wp, -1.55116580233012027e-13_wp, 2.00000000000000011e-1_wp, & + 0.3_wp, 4.71172300428577990e5_wp, 6.16859346183203398e-4_wp, & + 6.09875211747266683e-3_wp, -2.98940253643357627e-5_wp, 2.00000000000000011e-1_wp], [6, NS]) + TYPE(CD_SyropeType) :: td + REAL(wp) :: ws(CD_SYROPE_NWC), wt(CD_SYROPE_NWC), wsl(CD_SYROPE_NWC) + REAL(wp) :: slow_next, t_mean, divider, rate, tension, mean, r0, r1, other, worst + INTEGER :: es, k, n_ok + CHARACTER(200) :: em + n_ok = 0 + worst = 0.0_wp + DO k = 1, NS + CALL CD_Syrope_Init(td, OWC_EPS, OWC_TEN, CD_SYROPE_WC_QUADRATIC, ST(1, k), 0.5_wp, & + ALPHA, BETA, 1.0e4_wp, 1.0e3_wp, es, em) + CALL require(es == CD_SYROPE_OK, 'steep:init') + CALL CD_Syrope_Working_Curve(td, ST(2, k), ws, wt, wsl, es, em) + CALL require(es == CD_SYROPE_OK, 'steep:wc') + divider = CD_Syrope_Branch_Divider(td, ST(2, k)) + CALL CD_Syrope_State_Advance(td, ST(3, k) < divider, ws, wt, wsl, ST(3, k), ST(4, k), ST(5, k), ST(6, k), & + slow_next, t_mean, es, em, divider=divider) + IF (es /= CD_SYROPE_OK) THEN + CALL require(.FALSE., 'steep:the solve converges: '//TRIM(em)) + CALL CD_Syrope_End(td) + CYCLE + END IF + CALL CD_Syrope_Rate_And_Tension(td, slow_next < divider, ws, wt, wsl, slow_next, ST(4, k), ST(5, k), rate, & + tension, mean, es, em) + r0 = slow_next - ST(3, k) - ST(6, k)*rate + other = NEAREST(slow_next, MERGE(1.0_wp, -1.0_wp, r0 < 0.0_wp)) + CALL CD_Syrope_Rate_And_Tension(td, other < divider, ws, wt, wsl, other, ST(4, k), ST(5, k), rate, & + tension, mean, es, em) + r1 = other - ST(3, k) - ST(6, k)*rate + worst = MAX(worst, ABS(r0)) + CALL CD_Syrope_Rate_And_Tension(td, slow_next < divider, ws, wt, wsl, slow_next, ST(4, k), ST(5, k), rate, & + tension, mean, es, em) + IF ((r0 < 0.0_wp .NEQV. r1 < 0.0_wp) .AND. bits_same(mean, t_mean)) n_ok = n_ok + 1 + CALL CD_Syrope_End(td) + END DO + WRITE (*, '(A,I0,A,I0,A,ES10.3)') ' steep: ', n_ok, ' of ', NS, & + ' roots located to machine precision, largest |R| ', worst + CALL require(n_ok == NS, 'steep:roots to machine precision') + END SUBROUTINE case_state_advance_steep + + LOGICAL FUNCTION bits_same(a, b) RESULT(same) + REAL(wp), INTENT(IN) :: a, b + same = TRANSFER(a, 0_8) == TRANSFER(b, 0_8) + END FUNCTION bits_same + SUBROUTINE case_element_load() !! The element load wraps the kernel: a colinear element stretched to a !! chosen total strain reports the MoorDyn tension along its tangent, the diff --git a/tests/test_syrope_control.f90 b/tests/test_syrope_control.f90 new file mode 100644 index 00000000..db15c97e --- /dev/null +++ b/tests/test_syrope_control.f90 @@ -0,0 +1,930 @@ +! File: tests/test_syrope_control.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_syrope_control + !! Active line control (CONTROL, the OpenFAST CableDeltaL route of CD_Init_Deck_Aggregate) of a + !! Syrope polyester segment. MoorDyn-F and MoorDyn-C keep each segment's slow STRETCH + !! dl_1 = eps_slow*l as its state and leave it as it is when the unstretched length l changes; + !! the slow strain after a change is dl_1/l at the new length. The oracles below evaluate the + !! MoorDyn law from the shipped OWC table and the working-curve formula, independently of the + !! CableDyn_Syrope kernel. The decks are written here: 100 m of polyester (10 segments) held + !! taut between a Coupled fairlead and a Fixed anchor 102 m apart at mid-depth, nearly neutrally + !! buoyant so that the tension is uniform, with a LINEAR working curve (k1 = 0.5) and a light + !! BA_s|BA_d = 1e6|1e5 N s (slow-spring relaxation time (BA_s + BA_d)/K1 of about 6 ms). + !! 1. Quasi-static pay-out and haul-in: the fairlead segment is paid out by 0.5 m over 20 s, + !! hauled in to -1 m over 40 s and paid back to 0 over 20 s, with 4 s holds. Every element's + !! tension follows the rest curve of its load history at the line's strain D/L(t) - 1: the + !! working curve of the static tension while unloading, the OWC beyond it (the running + !! maximum ratchets), then the working curve of the new maximum, which ends the cycle below + !! the initial tension. Gated over the ramps (the lag of the slow spring) and at the ends + !! of the holds (the rest point). + !! 2. A length step from rest (pay-out 5 cm, haul-in 4 cm): the tension right after the + !! change is MoorDyn's at the carried stretch, T = T_mean + BA_s d(eps_slow)/dt with + !! eps_slow = eps_slow,0 l_1/l_2, and the slow strain after one step is the backward-Euler + !! step of d(dl_1)/dt = l_2 d(eps_slow)/dt from the carried stretch; the other elements are + !! untouched. The strain-carrying alternative (eps_slow kept) is printed for contrast. + !! 3. Checkpoint restart in the middle of a pay-out ramp and in the hold after it: a fresh + !! instance takes the coupled kinematics, the line interior [q; v; a] and the Syrope states + !! of the first, re-applies the command as the committed one (restored), and both continue + !! bit for bit. + !! 4. Composite lines: a polyester-chain line (the controlled segment is Syrope) takes the + !! oracle of 2 at its fairlead element and runs a ramp; a chain-polyester-chain line (the + !! controlled segment is chain) leaves its Syrope states untouched and runs the ramp. + !! 5. Without CONTROL, under False alpha_force_blend: the fairlead pulled out 1 m over 40 s and + !! held, so the rope rests on its OWC at its new running maximum. The backward-Euler root + !! then lies next to the top sample of the working curve, where the safeguarded Newton step + !! alone crept and stopped the run (CableDyn_Syrope, CD_Syrope_State_Advance); every step + !! converges and the held tension is the OWC tension at the line strain. + !! 6. A length change inside sub-steps: the fairlead sways sideways, y = 0.05 t^3, while its + !! segment is paid out at 0.1 m/s for 2 s, with ei0_substep_angle 1e-5 deg and + !! ei0_substep_max 4, so every step (0.05 s) is solved again in 4 sub-steps that spread + !! the length change over them. The oracle is the same run with ei0_substeps off in plain + !! steps of 0.0125 s with the command at the sub-step times (the + !! quintic end motion of a sub-step reproduces the cubic sway, and the interpolated lengths + !! the constant pay-out rate), compared at every 0.05 s. + !! Gates 1-3 and the polyester-chain line of 4 stopped at initialisation before (CONTROL on a + !! Syrope segment was refused). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_UpdateStates_Moving, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & + CD_AGG_Apply_LineControl, CD_AGG_Get_Substep_Counts, CD_AGG_End, & + CD_AGG_OK + USE CableDyn_System, ONLY: CD_System_NLines, CD_System_Line_NDOF, CD_System_Line_NElem, & + CD_Get_System_Line_State, CD_Get_System_Line_Tension, & + CD_Get_System_Line_Syrope_State, CD_Set_System_Line_Syrope_State, & + CD_Update_System_Line_Interior_State, CD_SYSTEM_OK + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + IMPLICIT NONE + + INTEGER, PARAMETER :: NOWC = 30, NWC = 30 + ! the shipped data/syrope/syrope_owc.dat table + REAL(wp), PARAMETER :: OWC_EPS(NOWC) = [ & + 0.00000e+00_wp, 2.06897e-03_wp, 4.13793e-03_wp, 6.20690e-03_wp, 8.27586e-03_wp, & + 1.03448e-02_wp, 1.24138e-02_wp, 1.44828e-02_wp, 1.65517e-02_wp, 1.86207e-02_wp, & + 2.06897e-02_wp, 2.27586e-02_wp, 2.48276e-02_wp, 2.68966e-02_wp, 2.89655e-02_wp, & + 3.10345e-02_wp, 3.31034e-02_wp, 3.51724e-02_wp, 3.72414e-02_wp, 3.93103e-02_wp, & + 4.13793e-02_wp, 4.34483e-02_wp, 4.55172e-02_wp, 4.75862e-02_wp, 4.96552e-02_wp, & + 5.17241e-02_wp, 5.37931e-02_wp, 5.58621e-02_wp, 5.79310e-02_wp, 6.00000e-02_wp] + REAL(wp), PARAMETER :: OWC_TEN(NOWC) = [ & + 0.00000e+00_wp, 1.71768e+05_wp, 3.30952e+05_wp, 4.78788e+05_wp, 6.16510e+05_wp, & + 7.45355e+05_wp, 8.66556e+05_wp, 9.81351e+05_wp, 1.09097e+06_wp, 1.19666e+06_wp, & + 1.29964e+06_wp, 1.40116e+06_wp, 1.50245e+06_wp, 1.60474e+06_wp, 1.70927e+06_wp, & + 1.81728e+06_wp, 1.93000e+06_wp, 2.04866e+06_wp, 2.17450e+06_wp, 2.30876e+06_wp, & + 2.45267e+06_wp, 2.60747e+06_wp, 2.77439e+06_wp, 2.95467e+06_wp, 3.14954e+06_wp, & + 3.36024e+06_wp, 3.58800e+06_wp, 3.83406e+06_wp, 4.09965e+06_wp, 4.38601e+06_wp] + ! the polyester constants of the decks: alpha|beta of the EA column, BA_s|BA_d, the LINEAR k1 + REAL(wp), PARAMETER :: ALPHA = 1.53e8_wp, BETA = 23.12_wp, BA_S = 1.0e6_wp, BA_D = 1.0e5_wp, K1W = 0.5_wp + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp, DT = 0.05_wp + INTEGER :: nfail = 0 + + CALL write_owc('sctl_owc.dat') + CALL write_settings('sctl_settings.dat', 'sctl_owc.dat') + CALL write_deck('sctl_single.dat', 'single') + CALL write_deck('sctl_poly_chain.dat', 'poly_chain') + CALL write_deck('sctl_chain_poly_chain.dat', 'chain_poly_chain') + CALL write_deck('sctl_single_noblend.dat', 'single', no_force_blend=.TRUE.) + CALL write_deck('sctl_hold_noblend.dat', 'single', no_force_blend=.TRUE., no_control=.TRUE.) + CALL write_deck('sctl_sub.dat', 'single', options=[CHARACTER(24) :: '1.0e-5 ei0_substep_angle', & + '4 ei0_substep_max']) + CALL write_deck('sctl_sub_ref.dat', 'single', options=[CHARACTER(24) :: '1.0e-5 ei0_substep_angle', & + 'off ei0_substeps']) + + CALL case_quasi_static('sctl_single.dat', 'quasi-static') + CALL case_quasi_static('sctl_single_noblend.dat', 'quasi-static, False alpha_force_blend') + CALL case_length_step('sctl_single.dat', 0.05_wp, 'pay-out step') + CALL case_length_step('sctl_single.dat', -0.04_wp, 'haul-in step') + CALL case_restart() + CALL case_composite() + CALL case_hold_at_maximum() + CALL case_substep_length_change() + + IF (nfail > 0) THEN + PRINT '(I0,A)', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + PRINT '(A)', 'all Syrope line-control checks passed' + +CONTAINS + + ! --------------------------------------------------------------------------------------------- + ! 1. quasi-static pay-out and haul-in + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_quasi_static(deck, what) + CHARACTER(*), INTENT(IN) :: deck, what + TYPE(CD_AGG_ModuleType) :: agg + INTEGER, PARAMETER :: NSTEP = 1840 + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), dl, dldot, t, chord, l_tot, eps, t_o, tmax_o + REAL(wp) :: t0, err_ramp, err_hold, hold_at(3), t_end, wc_lo + REAL(wp), ALLOCATABLE :: ten(:) + INTEGER :: es, ni, s, il, ec, ne, k, n_hold + LOGICAL :: cv, st, ok + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//': the controlled Syrope deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (ten(ne)) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + CALL require(md%has_syrope .AND. md%syrope_is(ec), what//': the controlled segment is Syrope') + chord = NORM2(md%q(3*md%elem_conn(2, ne) - 2:3*md%elem_conn(2, ne)) - & + md%q(3*md%elem_conn(1, 1) - 2:3*md%elem_conn(1, 1))) + l_tot = SUM(md%l0) + END ASSOCIATE + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + t0 = ten(ec) + ! a virgin rope: the static tension on the OWC, and the running maximum starts there + tmax_o = owc_t(chord/l_tot - 1.0_wp) + PRINT '(A,F9.4,A,F9.4,A,ES12.5,A,ES12.5,A)', ' line chord ', chord, ' m, unstretched ', l_tot, & + ' m: static tension ', t0, ' N, OWC ', tmax_o, ' N' + CALL require(ABS(t0 - tmax_o) <= 1.0e-8_wp*tmax_o .AND. MAXVAL(ABS(ten - t0)) <= 1.0e-8_wp*t0, & + what//': the line starts on its OWC with a uniform tension') + hold_at = [24.0_wp, 68.0_wp, 92.0_wp] + err_ramp = 0.0_wp + err_hold = 0.0_wp + n_hold = 0 + wc_lo = HUGE(1.0_wp) + ok = .TRUE. + DO s = 1, NSTEP + t = REAL(s, wp)*DT + CALL cycle_command(t, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg, [dl], [dldot], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg, DT, r0, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + ok = .FALSE. + CALL require(.FALSE., what//': step at t = '//TRIM(fmt_real(t))//': '//TRIM(em)) + EXIT + END IF + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + ! the oracle: the rest curve of the load history at the line's strain + eps = chord/(l_tot + dl) - 1.0_wp + t_o = rest_tension(eps, tmax_o) + wc_lo = MIN(wc_lo, t_o) + err_ramp = MAX(err_ramp, MAXVAL(ABS(ten - t_o))/t0) + DO k = 1, 3 + IF (ABS(t - hold_at(k)) < 0.5_wp*DT) THEN + err_hold = MAX(err_hold, MAXVAL(ABS(ten - t_o))/t_o) + n_hold = n_hold + 1 + PRINT '(A,F6.1,A,F7.3,A,ES12.5,A,ES12.5,A,ES10.3)', ' '//what//', end of hold t = ', t, ' s, DeltaL = ', dl, & + ' m: tension ', ten(ec), ' N, rest curve ', t_o, ' N, rel. difference ', ABS(ten(ec) - t_o)/t_o + END IF + END DO + END DO + IF (ok) THEN + t_end = ten(ec) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + PRINT '(A,ES12.5,A,ES12.5,A)', ' running maximum after the haul-in ', md%syrope_tmax(ec), ' N (oracle ', & + tmax_o, ' N)' + CALL require(ABS(md%syrope_tmax(ec) - tmax_o) <= 1.0e-6_wp*tmax_o, & + what//': the haul-in ratchets the running maximum to the OWC tension at its top') + CALL require(bits_eq(md%l0(ec), agg%ctrl_base_l0(1)), & + what//': the cycle returns the segment to its base length') + END ASSOCIATE + PRINT '(A,ES10.3,A,ES10.3)', ' max |T - T_rest| / T0 over the ramps ', err_ramp, & + '; at the ends of the holds / T_rest ', err_hold + PRINT '(A,ES12.5,A,ES12.5,A)', ' back at the base length: tension ', t_end, ' N, initial ', t0, & + ' N (the working curve of the new maximum)' + CALL require(n_hold == 3 .AND. err_hold <= 1.0e-6_wp, & + what//': at rest the tension is the rest-curve tension of the load history') + CALL require(err_ramp <= 3.0e-3_wp, what//': along the ramps the tension follows the rest curve') + CALL require(t_end < 0.6_wp*t0, what//': the cycle ends on the lower working curve of the new maximum') + END IF + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_quasi_static + + SUBROUTINE cycle_command(t, dl, dldot) + !! The command of gate 1: pay out 0.5 m on a half-cosine over 20 s, hold 4 s, haul in to + !! -1 m over 40 s, hold 4 s, pay back to 0 over 20 s, hold. + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: dl, dldot + IF (t < 20.0_wp) THEN + CALL half_cosine(t, 0.0_wp, 20.0_wp, 0.0_wp, 0.5_wp, dl, dldot) + ELSE IF (t < 24.0_wp) THEN + dl = 0.5_wp + dldot = 0.0_wp + ELSE IF (t < 64.0_wp) THEN + CALL half_cosine(t, 24.0_wp, 40.0_wp, 0.5_wp, -1.0_wp, dl, dldot) + ELSE IF (t < 68.0_wp) THEN + dl = -1.0_wp + dldot = 0.0_wp + ELSE IF (t < 88.0_wp) THEN + CALL half_cosine(t, 68.0_wp, 20.0_wp, -1.0_wp, 0.0_wp, dl, dldot) + ELSE + dl = 0.0_wp + dldot = 0.0_wp + END IF + END SUBROUTINE cycle_command + + SUBROUTINE half_cosine(t, t_start, span, a, b, x, xdot) + !! From a to b on a half-cosine over [t_start, t_start + span]. + REAL(wp), INTENT(IN) :: t, t_start, span, a, b + REAL(wp), INTENT(OUT) :: x, xdot + x = a + (b - a)*0.5_wp*(1.0_wp - COS(PI*(t - t_start)/span)) + xdot = (b - a)*0.5_wp*(PI/span)*SIN(PI*(t - t_start)/span) + END SUBROUTINE half_cosine + + REAL(wp) FUNCTION rest_tension(eps, tmax) RESULT(t) + !! The rest (quasi-static) tension at strain eps of a rope with running maximum tmax: the OWC + !! beyond the curve's top eps_owc(tmax), where tmax ratchets to it, else the LINEAR working + !! curve tmax (eps - eps_min)/(eps_max - eps_min), eps_min = eps_0 + k1 (eps_max - eps_0), + !! zero below eps_min. + REAL(wp), INTENT(IN) :: eps + REAL(wp), INTENT(INOUT) :: tmax + REAL(wp) :: e_max, e_min + e_max = owc_e(tmax) + IF (eps >= e_max) THEN + t = owc_t(eps) + tmax = MAX(tmax, t) + RETURN + END IF + e_min = OWC_EPS(1) + K1W*(e_max - OWC_EPS(1)) + t = 0.0_wp + IF (eps > e_min) t = tmax*(eps - e_min)/(e_max - e_min) + END FUNCTION rest_tension + + ! --------------------------------------------------------------------------------------------- + ! 2. a length step from rest + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_length_step(deck, step_dl, what) + CHARACTER(*), INTENT(IN) :: deck, what + REAL(wp), INTENT(IN) :: step_dl + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), l1, l2, eps, deps, t_md, t_alt, s_carry, s_be + REAL(wp), ALLOCATABLE :: slow0(:), tmax0(:), slow1(:), tmax1(:), ten0(:), ten1(:) + INTEGER :: es, ni, il, ec, ne, others + INTEGER(INT64) :: calls, events, capped, fallbacks + INTEGER :: max_used + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//': the deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (slow0(ne), tmax0(ne), slow1(ne), tmax1(ne), ten0(ne), ten1(ne)) + CALL CD_Get_System_Line_Syrope_State(agg%sys%fast%system, il, slow0, tmax0, es, em) + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten0, es, em) + l1 = agg%sys%fast%system%lines(il)%l0(ec) + CALL CD_AGG_Apply_LineControl(agg, [step_dl], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK, what//': the command applies: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + l2 = md%l0(ec) + CALL require(md%syrope_is(ec) .AND. bits_eq(l2, l1 + step_dl), what//': the Syrope segment takes l1 + DeltaL') + CALL element_kinematics(md%q, md%v, md%elem_conn(:, ec), l2, eps, deps) + END ASSOCIATE + ! right after the change: MoorDyn's tension at the carried stretch, and the strain-carrying + ! alternative for contrast + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten1, es, em) + s_carry = slow0(ec)*l1/l2 + t_md = kernel_tension(s_carry, eps, deps, tmax0(ec)) + t_alt = kernel_tension(slow0(ec), eps, deps, tmax0(ec)) + others = COUNT(.NOT. bits_eq_v(ten1, ten0)) - MERGE(1, 0,.NOT. bits_eq(ten1(ec), ten0(ec))) + PRINT '(A,A,F6.3,A,ES12.5,A,ES12.5,A,ES12.5,A,ES10.3)', ' ', what, step_dl, ' m: tension ', ten0(ec), & + ' -> ', ten1(ec), ' N, MoorDyn (stretch carried) ', t_md, ' N, rel. difference ', ABS(ten1(ec) - t_md)/t_md + PRINT '(A,ES12.5,A,ES10.3,A)', ' strain carried instead: ', t_alt, ' N (', ABS(t_alt - t_md)/t_md, & + ' off MoorDyn)' + CALL require(ABS(ten1(ec) - t_md) <= 1.0e-10_wp*t_md, & + what//': the tension after the change is MoorDyn''s at the carried slow stretch') + CALL require(ABS(t_alt - t_md) > 1.0e-4_wp*t_md, what//': the oracle tells the stretch from the strain carry') + CALL require(others == 0, what//': the other elements keep their tension') + ! one step from the carried stretch: the backward-Euler step of d(dl_1)/dt = l2 d(eps_slow)/dt + CALL CD_AGG_Step_Moving(agg, DT, r0, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, what//': the step after the change converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Get_Substep_Counts(agg, calls, events, max_used, capped, fallbacks) + CALL CD_Get_System_Line_Syrope_State(agg%sys%fast%system, il, slow1, tmax1, es, em) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + CALL element_kinematics(md%q, md%v, md%elem_conn(:, ec), l2, eps, deps) + END ASSOCIATE + s_be = backward_euler(s_carry, eps, deps, tmax0(ec), DT) + PRINT '(A,ES16.9,A,ES16.9,A,ES10.3,A,I0,A)', ' slow strain after one step ', slow1(ec), ', oracle ', s_be, & + ' (rel. ', ABS(slow1(ec) - s_be)/s_be, '; ', events, ' sub-stepped steps)' + CALL require(events == 0 .AND. ABS(slow1(ec) - s_be) <= 1.0e-9_wp*s_be, & + what//': the step advances the carried slow stretch (backward Euler at the new length)') + IF (step_dl < 0.0_wp) THEN + PRINT '(A,ES12.5,A,ES12.5,A)', ' running maximum ', tmax0(ec), ' -> ', tmax1(ec), ' N' + CALL require(tmax1(ec) > tmax0(ec), what//': the haul-in onto the OWC ratchets the running maximum') + ELSE + CALL require(bits_eq(tmax1(ec), tmax0(ec)), what//': the pay-out leaves the running maximum') + END IF + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_length_step + + SUBROUTINE element_kinematics(q, v, conn, l0, eps, deps) + !! Strain and strain rate of one element, MoorDyn's dl/l and lstrd/l (the chord rate). + REAL(wp), INTENT(IN) :: q(:), v(:), l0 + INTEGER, INTENT(IN) :: conn(2) + REAL(wp), INTENT(OUT) :: eps, deps + REAL(wp) :: chord(3), length + chord = q(3*conn(2) - 2:3*conn(2)) - q(3*conn(1) - 2:3*conn(1)) + length = NORM2(chord) + eps = (length - l0)/l0 + deps = DOT_PRODUCT(chord/length, v(3*conn(2) - 2:3*conn(2)) - v(3*conn(1) - 2:3*conn(1)))/l0 + END SUBROUTINE element_kinematics + + REAL(wp) FUNCTION backward_euler(s0, eps, deps, tmax, h) RESULT(s) + !! The projected backward-Euler step s = max(0, root of s - s0 - h r(s)), by bisection. + REAL(wp), INTENT(IN) :: s0, eps, deps, tmax, h + REAL(wp) :: lo, hi, mid, rate, ten + INTEGER :: it + lo = 0.0_wp + CALL kernel_rate(lo, eps, deps, tmax, rate, ten) + s = 0.0_wp + IF (lo - s0 - h*rate >= 0.0_wp) RETURN + hi = 0.2_wp + DO it = 1, 200 + mid = 0.5_wp*(lo + hi) + CALL kernel_rate(mid, eps, deps, tmax, rate, ten) + IF (mid - s0 - h*rate < 0.0_wp) THEN + lo = mid + ELSE + hi = mid + END IF + END DO + s = 0.5_wp*(lo + hi) + END FUNCTION backward_euler + + REAL(wp) FUNCTION kernel_tension(slow, eps, deps, tmax) RESULT(t) + REAL(wp), INTENT(IN) :: slow, eps, deps, tmax + REAL(wp) :: rate + CALL kernel_rate(slow, eps, deps, tmax, rate, t) + END FUNCTION kernel_tension + + SUBROUTINE kernel_rate(slow, eps, deps, tmax, rate, ten) + !! MoorDyn's Syrope segment law (MoorDyn-C Line::getStateDeriv, MoorDyn-F Line_GetStateDeriv, + !! ElasticMod 4) in strain form: the mean tension from the slow strain on the working curve + !! of tmax (30 samples) below the OWC's slow strain at tmax and on the OWC from it, + !! K1 = alpha + beta T_mean, d(eps_slow)/dt = (K1 (eps - eps_curve(T_mean)) + BA_d deps)/(BA_s + + !! BA_d) and T = T_mean (eps >= 0) + BA_s d(eps_slow)/dt, clamped at zero (a line cannot push). + REAL(wp), INTENT(IN) :: slow, eps, deps, tmax + REAL(wp), INTENT(OUT) :: rate, ten + REAL(wp) :: we(NWC), wt(NWC), ws(NWC), os(NOWC), e_max, e_min, t_mean, e_curve + INTEGER :: k + DO k = 1, NOWC + os(k) = OWC_EPS(k) - fast_strain(OWC_TEN(k)) + END DO + e_max = owc_e(tmax) + e_min = OWC_EPS(1) + K1W*(e_max - OWC_EPS(1)) + DO k = 1, NWC + we(k) = e_min + (e_max - e_min)*REAL(k - 1, wp)/REAL(NWC - 1, wp) + wt(k) = tmax*(we(k) - e_min)/(e_max - e_min) + ws(k) = we(k) - fast_strain(wt(k)) + END DO + IF (slow < lin(tmax, OWC_TEN, os)) THEN + t_mean = lin(slow, ws, wt) + e_curve = lin(t_mean, wt, we) + ELSE + t_mean = lin(slow, os, OWC_TEN) + e_curve = lin(t_mean, OWC_TEN, OWC_EPS) + END IF + rate = ((ALPHA + BETA*t_mean)*(eps - e_curve) + BA_D*deps)/(BA_S + BA_D) + ten = BA_S*rate + IF (eps >= 0.0_wp) ten = ten + t_mean + ten = MAX(ten, 0.0_wp) + END SUBROUTINE kernel_rate + + REAL(wp) FUNCTION fast_strain(t) RESULT(e) + !! The exponential fast spring, eps_fast = ln(1 + (beta/alpha) T)/beta. + REAL(wp), INTENT(IN) :: t + e = LOG(1.0_wp + BETA/ALPHA*t)/BETA + END FUNCTION fast_strain + + ! --------------------------------------------------------------------------------------------- + ! 3. checkpoint restart + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_restart() + !! The shell's rebuild recipe (CableDyn_OF): a fresh instance B takes A's coupled kinematics, + !! re-applies the restored command, then reloads the line interior and the Syrope mirror. + TYPE(CD_AGG_ModuleType) :: agg_a, agg_b + INTEGER, PARAMETER :: NPOST = 12 + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), pa(3, 1), la(3, 1), pb(3, 1), lb(3, 1), v2(3, 1), a2(3, 1) + REAL(wp) :: dl, dldot, dmax + REAL(wp), ALLOCATABLE :: qL(:), vL(:), aL(:), slow(:), tmax(:), slow_b(:), tmax_b(:) + INTEGER :: es, ni, s, il, ndof, ne, npre, pass + LOGICAL :: cv, st, same + CHARACTER(512) :: em + + DO pass = 1, 2 + npre = MERGE(15, 50, pass == 1) + CALL CD_AGG_Init_From_Deck(agg_a, 'sctl_single.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'restart: A initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg_a, r0, vel, acc, la, es, em) + vel = 0.0_wp + acc = 0.0_wp + DO s = 1, npre + CALL restart_command(s, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg_a, DT, r0, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + CALL require(.FALSE., 'restart: A marches: '//TRIM(em)) + RETURN + END IF + END DO + CALL CD_AGG_Init_From_Deck(agg_b, 'sctl_single.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'restart: B initialises: '//TRIM(em)) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_UpdateStates_Moving(agg_b, pa, v2, a2, es, em) + ! the restored command is the one A's committed state was reached with + CALL restart_command(npre, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em, restored=.TRUE.) + CALL require(es == CD_AGG_OK, 'restart: B re-applies the command: '//TRIM(em)) + il = agg_a%ctrl_line(1) + ndof = CD_System_Line_NDOF(agg_a%sys%fast%system, il, es, em) + ne = CD_System_Line_NElem(agg_a%sys%fast%system, il, es, em) + IF (ALLOCATED(qL)) DEALLOCATE (qL, vL, aL, slow, tmax, slow_b, tmax_b) + ALLOCATE (qL(ndof), vL(ndof), aL(ndof), slow(ne), tmax(ne), slow_b(ne), tmax_b(ne)) + CALL CD_Get_System_Line_State(agg_a%sys%fast%system, il, qL, vL, aL, es, em) + CALL CD_Update_System_Line_Interior_State(agg_b%sys%fast%system, il, qL(4:ndof - 3), vL(4:ndof - 3), & + es, em, a_interior=aL(4:ndof - 3)) + CALL require(es == CD_SYSTEM_OK, 'restart: B takes the line interior: '//TRIM(em)) + CALL CD_Get_System_Line_Syrope_State(agg_a%sys%fast%system, il, slow, tmax, es, em) + CALL CD_Set_System_Line_Syrope_State(agg_b%sys%fast%system, il, slow, tmax, es, em) + CALL require(es == CD_SYSTEM_OK, 'restart: B takes the Syrope mirror: '//TRIM(em)) + ASSOCIATE (ma => agg_a%sys%fast%system%lines(il), mb => agg_b%sys%fast%system%lines(il)) + same = ALL(bits_eq_v(ma%l0, mb%l0)) .AND. ALL(bits_eq_v(ma%l0_c, mb%l0_c)) + END ASSOCIATE + CALL require(same, 'restart: B carries the lengths and the committed lengths of A') + dmax = 0.0_wp + DO s = npre + 1, npre + NPOST + CALL restart_command(s, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(agg_a, DT, r0, vel, acc, cv, st, ni, es, em) + same = same .AND. es == CD_AGG_OK .AND. cv + CALL CD_AGG_Step_Moving(agg_b, DT, r0, vel, acc, cv, st, ni, es, em) + same = same .AND. es == CD_AGG_OK .AND. cv + CALL CD_AGG_CalcOutput(agg_a, es, em) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, pb, v2, a2, lb, es, em) + CALL CD_Get_System_Line_Syrope_State(agg_a%sys%fast%system, il, slow, tmax, es, em) + CALL CD_Get_System_Line_Syrope_State(agg_b%sys%fast%system, il, slow_b, tmax_b, es, em) + dmax = MAX(dmax, MAXVAL(ABS(la - lb)), MAXVAL(ABS(slow - slow_b))) + same = same .AND. ALL(bits_eq_v(RESHAPE(la, [3]), RESHAPE(lb, [3]))) .AND. & + ALL(bits_eq_v(slow, slow_b)) .AND. ALL(bits_eq_v(tmax, tmax_b)) .AND. & + ALL(bits_eq_v(agg_a%sys%fast%system%lines(il)%q, agg_b%sys%fast%system%lines(il)%q)) + END DO + PRINT '(A,I0,A,F5.2,A,ES10.3)', ' restart after step ', npre, ' (DeltaL ', & + agg_a%sys%fast%system%lines(il)%l0(agg_a%ctrl_elem(1)) - agg_a%ctrl_base_l0(1), & + ' m): max difference of the fairlead load and the slow strains ', dmax + CALL require(same, 'restart: the restarted run continues bit for bit ('// & + MERGE('mid-ramp', 'hold ', pass == 1)//')') + CALL CD_AGG_End(agg_a, es, em) + CALL CD_AGG_End(agg_b, es, em) + END DO + END SUBROUTINE case_restart + + SUBROUTINE restart_command(step, dl, dldot) + !! A 0.4 m pay-out on a half-cosine over 2 s, then held (gate 3). + INTEGER, INTENT(IN) :: step + REAL(wp), INTENT(OUT) :: dl, dldot + REAL(wp) :: t + t = REAL(step, wp)*DT + IF (t < 2.0_wp) THEN + CALL half_cosine(t, 0.0_wp, 2.0_wp, 0.0_wp, 0.4_wp, dl, dldot) + ELSE + dl = 0.4_wp + dldot = 0.0_wp + END IF + END SUBROUTINE restart_command + + ! --------------------------------------------------------------------------------------------- + ! 4. composite lines + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_composite() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1) + REAL(wp), ALLOCATABLE :: slow0(:), tmax0(:), slow1(:), tmax1(:), ten0(:), ten1(:) + INTEGER :: es, il, ec, ne + CHARACTER(512) :: em + + ! the polyester at the fairlead: the controlled segment is Syrope (the oracle of gate 2) + CALL case_length_step('sctl_poly_chain.dat', 0.04_wp, 'polyester-chain pay-out step') + CALL ramp_runs('sctl_poly_chain.dat', 'polyester-chain') + + ! chain at the fairlead: the controlled segment is chain and the Syrope states stay as they are + CALL CD_AGG_Init_From_Deck(agg, 'sctl_chain_poly_chain.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'chain-polyester-chain: the deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (slow0(ne), tmax0(ne), slow1(ne), tmax1(ne), ten0(ne), ten1(ne)) + CALL require(.NOT. agg%sys%fast%system%lines(il)%syrope_is(ec) .AND. & + COUNT(agg%sys%fast%system%lines(il)%syrope_is) == 8, & + 'chain-polyester-chain: the controlled segment is chain, the polyester Syrope') + CALL CD_Get_System_Line_Syrope_State(agg%sys%fast%system, il, slow0, tmax0, es, em) + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten0, es, em) + CALL CD_AGG_Apply_LineControl(agg, [0.2_wp], [0.0_wp], es, em) + CALL CD_Get_System_Line_Syrope_State(agg%sys%fast%system, il, slow1, tmax1, es, em) + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten1, es, em) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + CALL require(ALL(bits_eq_v(slow1, slow0)) .AND. ALL(bits_eq_v(tmax1, tmax0)) .AND. & + ALL(bits_eq_v(PACK(ten1, md%syrope_is), PACK(ten0, md%syrope_is))) .AND. ten1(ec) < ten0(ec), & + 'chain-polyester-chain: a chain command leaves the Syrope states and tensions as they are') + END ASSOCIATE + CALL CD_AGG_End(agg, es, em) + CALL ramp_runs('sctl_chain_poly_chain.dat', 'chain-polyester-chain') + END SUBROUTINE case_composite + + SUBROUTINE ramp_runs(deck, what) + !! Pay the fairlead segment out 0.4 m over 2 s, hold 1 s, haul it in to -0.4 m over 4 s and + !! hold 1 s: every step converges and the fairlead tension falls and rises with the command. + CHARACTER(*), INTENT(IN) :: deck, what + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), dl, dldot, t, t_lo, t_hi, t0 + REAL(wp), ALLOCATABLE :: ten(:) + INTEGER :: es, ni, s, il, ec, ne + LOGICAL :: cv, st, ok + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//' ramp: the deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (ten(ne)) + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + t0 = ten(ec) + t_lo = t0 + t_hi = t0 + ok = .TRUE. + DO s = 1, 160 + t = REAL(s, wp)*DT + IF (t < 2.0_wp) THEN + CALL half_cosine(t, 0.0_wp, 2.0_wp, 0.0_wp, 0.4_wp, dl, dldot) + ELSE IF (t < 3.0_wp) THEN + dl = 0.4_wp + dldot = 0.0_wp + ELSE IF (t < 7.0_wp) THEN + CALL half_cosine(t, 3.0_wp, 4.0_wp, 0.4_wp, -0.4_wp, dl, dldot) + ELSE + dl = -0.4_wp + dldot = 0.0_wp + END IF + CALL CD_AGG_Apply_LineControl(agg, [dl], [dldot], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg, DT, r0, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + ok = .FALSE. + EXIT + END IF + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + t_lo = MIN(t_lo, ten(ec)) + t_hi = MAX(t_hi, ten(ec)) + END DO + PRINT '(A,A,A,ES12.5,A,ES12.5,A,ES12.5,A)', ' ', what, ' ramp: fairlead-segment tension ', t0, & + ' N, from ', t_lo, ' to ', t_hi, ' N' + CALL require(ok .AND. t_lo < 0.9_wp*t0 .AND. t_hi > 1.05_wp*t0, & + what//' ramp: every step converges and the tension follows the command: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE ramp_runs + + ! --------------------------------------------------------------------------------------------- + ! 5. a rope held at its running maximum, no CONTROL + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_hold_at_maximum() + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: r0(3, 1), pos(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), x, xdot, t, chord, l_tot, t_o + REAL(wp), ALLOCATABLE :: ten(:) + INTEGER :: es, ni, s, il, ne + LOGICAL :: cv, st, ok + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, 'sctl_hold_noblend.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'held at the maximum: the deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + il = 1 + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (ten(ne)) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + l_tot = SUM(md%l0) + END ASSOCIATE + ok = .TRUE. + DO s = 1, 960 + t = REAL(s, wp)*DT + IF (t < 40.0_wp) THEN + CALL half_cosine(t, 0.0_wp, 40.0_wp, 0.0_wp, -1.0_wp, x, xdot) + ELSE + x = -1.0_wp + xdot = 0.0_wp + END IF + pos = r0 + pos(1, 1) = r0(1, 1) + x + vel = 0.0_wp + vel(1, 1) = xdot + acc = 0.0_wp + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + ok = .FALSE. + CALL require(.FALSE., 'held at the maximum: step at t = '//TRIM(fmt_real(t))//': '//TRIM(em)) + EXIT + END IF + END DO + IF (ok) THEN + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + chord = NORM2(md%q(3*md%elem_conn(2, ne) - 2:3*md%elem_conn(2, ne)) - & + md%q(3*md%elem_conn(1, 1) - 2:3*md%elem_conn(1, 1))) + END ASSOCIATE + t_o = owc_t(chord/l_tot - 1.0_wp) + PRINT '(A,ES12.5,A,ES12.5,A,ES10.3)', ' held at the maximum for 8 s: tension ', MAXVAL(ten), ' N, OWC ', t_o, & + ' N, rel. difference ', MAXVAL(ABS(ten - t_o))/t_o + CALL require(MAXVAL(ABS(ten - t_o)) <= 1.0e-6_wp*t_o, & + 'held at the maximum: every step converges and the rope rests on its OWC') + END IF + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_hold_at_maximum + + ! --------------------------------------------------------------------------------------------- + ! 6. a length change inside sub-steps + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_substep_length_change() + INTEGER, PARAMETER :: NSTEP = 40, NSUB = 4 + REAL(wp), PARAMETER :: C_SWAY = 0.05_wp, RATE = 0.1_wp + TYPE(CD_AGG_ModuleType) :: agg, ref + REAL(wp) :: r0(3, 1), pos(3, 1), vel(3, 1), acc(3, 1), la(3, 1), lr(3, 1), v2(3, 1), a2(3, 1), t, h + REAL(wp) :: d_load, d_slow, d_ten, load_scale, rate_k + REAL(wp), ALLOCATABLE :: slow_a(:), tmax_a(:), slow_r(:), tmax_r(:), ten_a(:), ten_r(:) + INTEGER :: es, ni, s, k, il, ec, ne, max_a, max_r, n_sub, n_ref + INTEGER(INT64) :: calls, ev_a, ev_prev, ev_r, capped, fallbacks + LOGICAL :: cv, st, ok, sub + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, 'sctl_sub.dat', DT, es, em) + CALL require(es == CD_AGG_OK, 'sub-steps: the deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + h = DT/REAL(NSUB, wp) + CALL CD_AGG_Init_From_Deck(ref, 'sctl_sub_ref.dat', h, es, em) + CALL require(es == CD_AGG_OK, 'sub-steps: the reference deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, la, es, em) + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (slow_a(ne), tmax_a(ne), slow_r(ne), tmax_r(ne), ten_a(ne), ten_r(ne)) + d_load = 0.0_wp + d_slow = 0.0_wp + d_ten = 0.0_wp + load_scale = 0.0_wp + n_sub = 0 + n_ref = 0 + ev_prev = 0 + ok = .TRUE. + DO s = 1, NSTEP + t = REAL(s, wp)*DT + CALL sway(t, r0, C_SWAY, pos, vel, acc) + CALL CD_AGG_Apply_LineControl(agg, [RATE*t], [RATE], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, cv, st, ni, es, em) + ok = ok .AND. es == CD_AGG_OK .AND. cv + CALL CD_AGG_Get_Substep_Counts(agg, calls, ev_a, max_a, capped, fallbacks) + sub = ev_a > ev_prev + ev_prev = ev_a + ! the reference: the step in NSUB plain steps (A must have sub-stepped it) + IF (sub) THEN + n_sub = n_sub + 1 + DO k = 1, NSUB + t = (REAL(s - 1, wp) + REAL(k, wp)/REAL(NSUB, wp))*DT + CALL sway(t, r0, C_SWAY, pos, vel, acc) + ! a sub-step's rate is interpolated from the committed one as its length is (no effect + ! on a Syrope segment, whose law takes the chord rate) + rate_k = RATE + IF (s == 1) rate_k = RATE*REAL(k, wp)/REAL(NSUB, wp) + CALL CD_AGG_Apply_LineControl(ref, [RATE*t], [rate_k], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(ref, h, pos, vel, acc, cv, st, ni, es, em) + ok = ok .AND. es == CD_AGG_OK .AND. cv + n_ref = n_ref + 1 + END DO + ELSE + ok = .FALSE. + em = 'the step was not sub-stepped' + END IF + IF (.NOT. ok) THEN + CALL require(.FALSE., 'sub-steps: step at t = '//TRIM(fmt_real(t))//': '//TRIM(em)) + EXIT + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_CalcOutput(ref, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, v2, a2, la, es, em) + CALL CD_AGG_GetMovingPointMesh(ref, pos, v2, a2, lr, es, em) + CALL CD_Get_System_Line_Syrope_State(agg%sys%fast%system, il, slow_a, tmax_a, es, em) + CALL CD_Get_System_Line_Syrope_State(ref%sys%fast%system, il, slow_r, tmax_r, es, em) + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten_a, es, em) + CALL CD_Get_System_Line_Tension(ref%sys%fast%system, il, ten_r, es, em) + load_scale = MAX(load_scale, NORM2(lr(:, 1))) + d_load = MAX(d_load, NORM2(la(:, 1) - lr(:, 1))) + d_slow = MAX(d_slow, MAXVAL(ABS(slow_a - slow_r))/MAXVAL(slow_r)) + d_ten = MAX(d_ten, MAXVAL(ABS(ten_a - ten_r))/MAXVAL(ten_r)) + END DO + IF (ok) THEN + CALL CD_AGG_Get_Substep_Counts(ref, calls, ev_r, max_r, capped, fallbacks) + PRINT '(A,I0,A,I0,A,I0,A,F7.4,A)', ' sub-steps: ', n_sub, ' of ', NSTEP, ' steps sub-stepped (at most ', & + max_a, '), the segment paid out to ', agg%sys%fast%system%lines(il)%l0(ec) - agg%ctrl_base_l0(1), ' m' + PRINT '(A,ES10.3,A,ES10.3,A,ES10.3)', ' against the plain reference steps: fairlead load / its peak ', & + d_load/load_scale, ', tensions ', d_ten, ', slow strains ', d_slow + CALL require(n_sub == NSTEP .AND. n_ref == NSUB*NSTEP .AND. max_a == NSUB .AND. ev_r == 0, & + 'sub-steps: every step is solved in 4 sub-steps, the reference in none') + CALL require(d_load <= 1.0e-10_wp*load_scale .AND. d_ten <= 1.0e-10_wp .AND. d_slow <= 1.0e-10_wp, & + 'sub-steps: the sub-stepped length change is the plain steps'' at the sub-step times') + END IF + CALL CD_AGG_End(agg, es, em) + CALL CD_AGG_End(ref, es, em) + END SUBROUTINE case_substep_length_change + + SUBROUTINE sway(t_s, r0, c, p, v, a) + !! The fairlead moving sideways as y = c t^3 from its static position r0 (at rest at t = 0; + !! a cubic, which the C2 quintic of a sub-stepped step reproduces). + REAL(wp), INTENT(IN) :: t_s, r0(3, 1), c + REAL(wp), INTENT(OUT) :: p(3, 1), v(3, 1), a(3, 1) + p = r0 + p(2, 1) = r0(2, 1) + c*t_s**3 + v = 0.0_wp + v(2, 1) = 3.0_wp*c*t_s**2 + a = 0.0_wp + a(2, 1) = 6.0_wp*c*t_s + END SUBROUTINE sway + + ! --------------------------------------------------------------------------------------------- + ! the OWC table, files and helpers + ! --------------------------------------------------------------------------------------------- + + REAL(wp) FUNCTION owc_t(eps) RESULT(t) + REAL(wp), INTENT(IN) :: eps + t = lin(eps, OWC_EPS, OWC_TEN) + END FUNCTION owc_t + + REAL(wp) FUNCTION owc_e(t) RESULT(eps) + REAL(wp), INTENT(IN) :: t + eps = lin(t, OWC_TEN, OWC_EPS) + END FUNCTION owc_e + + REAL(wp) FUNCTION lin(x, xp, fp) RESULT(y) + !! Piecewise-linear interpolation, constant beyond the ends. + REAL(wp), INTENT(IN) :: x, xp(:), fp(:) + INTEGER :: k, n + n = SIZE(xp) + y = fp(n) + IF (x <= xp(1)) THEN + y = fp(1) + RETURN + END IF + DO k = 2, n + IF (x <= xp(k)) THEN + y = fp(k - 1) + (fp(k) - fp(k - 1))*(x - xp(k - 1))/(xp(k) - xp(k - 1)) + RETURN + END IF + END DO + END FUNCTION lin + + SUBROUTINE write_owc(path) + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Strain Tension' + WRITE (u, '(A)') '(-) (N)' + DO k = 1, NOWC + WRITE (u, '(ES14.6,1X,ES14.6)') OWC_EPS(k), OWC_TEN(k) + END DO + CLOSE (u) + END SUBROUTINE write_owc + + SUBROUTINE write_settings(path, owc_path) + CHARACTER(*), INTENT(IN) :: path, owc_path + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') owc_path//' OWC - Original working-curve table file' + WRITE (u, '(A)') 'LINEAR WCType - Working-curve formulation' + WRITE (u, '(A)') '0.5 k1 - First working-curve shape parameter' + WRITE (u, '(A)') '0.0 k2 - Second working-curve shape parameter' + CLOSE (u) + END SUBROUTINE write_settings + + SUBROUTINE write_deck(path, kind, no_force_blend, no_control, options) + !! A Coupled fairlead at x = 0 and a Fixed anchor at mid-depth, the line written fairlead first + !! (its only host-driven end at NodeA, the controlled end), with a CONTROL row on channel 1: + !! single: 100 m of polyester in 10 segments, the anchor 102 m away; + !! poly_chain: 80 m of polyester (8 segments) then 20 m of chain (2), 101.6 m; + !! chain_poly_chain: 10 m of chain, 80 m of polyester, 10 m of chain (1, 8, 1), 101.6 m. + !! The polyester is nearly neutrally buoyant (0.05 kg/m above the displaced water's). + !! no_force_blend writes False alpha_force_blend, no_control leaves the CONTROL section out, + !! options are further OPTIONS rows. + CHARACTER(*), INTENT(IN) :: path, kind + LOGICAL, INTENT(IN), OPTIONAL :: no_force_blend, no_control + CHARACTER(*), INTENT(IN), OPTIONAL :: options(:) + LOGICAL :: ctrl + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Syrope line-control test deck ('//kind//')' + 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)') 'chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') 'poly 0.1438 16.70 "SYROPE:sctl_settings.dat|1.53e8|23.12" 1.0e6|1.0e5 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -100.0 0 0 0 0' + IF (kind == 'single') THEN + WRITE (u, '(A)') '2 Fixed 102.0 0.0 -100.0 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Fixed 101.6 0.0 -100.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) (-)' + SELECT CASE (kind) + CASE ('single') + WRITE (u, '(A)') '1 poly 100.0 10' + CASE ('poly_chain') + WRITE (u, '(A)') '1 poly 80.0 8' + WRITE (u, '(A)') '1 chain 20.0 2' + CASE DEFAULT + WRITE (u, '(A)') '1 chain 10.0 1' + WRITE (u, '(A)') '1 poly 80.0 8' + WRITE (u, '(A)') '1 chain 10.0 1' + END SELECT + ctrl = .TRUE. + IF (PRESENT(no_control)) ctrl = .NOT. no_control + IF (ctrl) THEN + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Lines' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') '1 1' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + IF (PRESENT(no_force_blend)) THEN + IF (no_force_blend) WRITE (u, '(A)') 'False alpha_force_blend' + END IF + IF (PRESENT(options)) THEN + DO k = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(k)) + END DO + END IF + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_deck + + ELEMENTAL LOGICAL FUNCTION bits_eq(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x, y + same = TRANSFER(x, 0_INT64) == TRANSFER(y, 0_INT64) + END FUNCTION bits_eq + + FUNCTION bits_eq_v(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x(:), y(:) + LOGICAL :: same(SIZE(x)) + same = bits_eq(x, y) + END FUNCTION bits_eq_v + + FUNCTION fmt_real(x) RESULT(s) + REAL(wp), INTENT(IN) :: x + CHARACTER(24) :: s + WRITE (s, '(F10.3)') x + s = ADJUSTL(s) + END FUNCTION fmt_real + + 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_syrope_control diff --git a/tests/test_viscoelastic.f90 b/tests/test_viscoelastic.f90 index 18220e13..62e6c14b 100644 --- a/tests/test_viscoelastic.f90 +++ b/tests/test_viscoelastic.f90 @@ -725,7 +725,8 @@ SUBROUTINE case_model_copy_midstate() END SUBROUTINE case_model_copy_midstate SUBROUTINE case_model_fail_closed() - !! The init validation battery and the control-composition choke point. + !! The init validation battery and the control composition: a segment-length change on a + !! viscoelastic element leaves its dl_1 stretch as it is (MoorDyn-F/C), and the line steps. TYPE(CD_ModelType) :: model TYPE(GenAlphaConfig) :: cfg INTEGER :: conn(2, 2), fixed(6), es, n_iter @@ -775,15 +776,20 @@ SUBROUTINE case_model_fail_closed() ve_ea_d=ve_ead, ve_ba=ve_ba, ve_ba_d=ve_bad) CALL require(es /= CD_MODEL_OK .AND. INDEX(em, 'plain element') > 0, 'fail:plain-with-dashpots') ! MIXED line: element 1 viscoelastic, element 2 plain -- the segment-length - ! control fails closed by name on the viscoelastic element and stays - ! available on the plain one + ! control applies to both; the viscoelastic element keeps its dl_1 stretch bit for bit ve_ba = [7.0_wp, 0.0_wp] ve_bad = [3.0_wp, 0.0_wp] CALL CD_Init_Model(model, q0, v0, conn, l0, ea, rho_a, .FALSE., f_ext, fixed, cfg, es, em, & ve_ea_d=ve_ead, ve_ba=ve_ba, ve_ba_d=ve_bad) CALL require(es == CD_MODEL_OK, 'fail:mixed-init-ok') - CALL CD_Update_Model_SegmentLength(model, 1, 1.01_wp, 0.0_wp, es, em) - CALL require(es /= CD_MODEL_OK .AND. INDEX(em, 'viscoelastic') > 0, 'fail:control-on-viscoelastic') + BLOCK + REAL(wp) :: dl1_before(2), dl1_after(2) + CALL CD_Get_Model_VE_Dl1(model, dl1_before, es, em) + CALL CD_Update_Model_SegmentLength(model, 1, 1.01_wp, 0.0_wp, es, em) + CALL CD_Get_Model_VE_Dl1(model, dl1_after, es, em) + CALL require(es == CD_MODEL_OK .AND. ALL(TRANSFER(dl1_after, 0_8, 2) == TRANSFER(dl1_before, 0_8, 2)), & + 'fail:control-on-viscoelastic-keeps-dl1') + END BLOCK CALL CD_Update_Model_SegmentLength(model, 2, 1.01_wp, 0.0_wp, es, em) CALL require(es == CD_MODEL_OK, 'fail:control-on-plain-ok') ! the mixed model still steps (the plain element keeps its EA elastic force) diff --git a/tests/test_viscoelastic_control.f90 b/tests/test_viscoelastic_control.f90 new file mode 100644 index 00000000..cbd27710 --- /dev/null +++ b/tests/test_viscoelastic_control.f90 @@ -0,0 +1,469 @@ +! File: tests/test_viscoelastic_control.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_viscoelastic_control + !! Active line control (CONTROL, the OpenFAST CableDeltaL route of CD_Init_Deck_Aggregate) of a + !! viscoelastic segment (MoorDyn ElasticMod 2, Es|Ed, and 3, Es|alphaMBL|vbeta). MoorDyn-F + !! (MD_CalcContStateDeriv sets l(N) and ld(N); Line_GetStateDeriv) and MoorDyn-C + !! (Line::setUnstretchedLength; Line::getStateDeriv) keep each segment's slow-branch stretch + !! dl_1 as its state, leave it as it is when the unstretched length l changes and read it at + !! the new length: MagT = EA_1 dl_1/l, MagTd = BA ld_1/l, + !! ld_1 = (EA_D dl - (EA_D + EA_1) dl_1 + BA_D lstrd)/(BA_D + BA), dl = lstr - l, + !! EA_1 = EA_D EA/(EA_D - EA), and for ElasticMod 3 EA_D(dl_1, l). The oracles below evaluate + !! these formulas independently of CableDyn_Viscoelastic. The decks are written here: 100 m of + !! rope (10 segments) held taut between a Coupled fairlead and a Fixed anchor 102 m apart at + !! mid-depth, nearly neutrally buoyant so that the tension is uniform, with Es = 1e8 N, + !! Ed = 3e8 N (or alphaMBL = 3e8 N, vbeta = 20) and BA = Bs|Bd = 1e6|1e5 N s (a slow-branch + !! relaxation time (BA_D + BA)/(EA_D + EA_1) of about 2.4 ms). + !! 1. Quasi-static pay-out and haul-in: the fairlead segment is paid out by 0.5 m over 20 s, + !! hauled in to -1 m over 40 s and paid back to 0 over 20 s, with 4 s holds. Every element's + !! tension follows the static viscoelastic law, the composite EA times the line's strain + !! D/L(t) - 1: gated over the ramps (the lag of the slow branch) and at the ends of the + !! holds (the rest point), for ElasticMod 2 with and without the force blend and for 3. + !! 2. A length step from rest (pay-out 5 cm, haul-in 4 cm; ElasticMod 2 and 3): the tension + !! right after the change is MoorDyn's at the carried stretch dl_1, and dl_1 after one step + !! is the backward-Euler step of MoorDyn's ODE at the new length (EA_D at the step-start + !! state, as CableDyn lags it); the other elements are untouched. The strain-carrying + !! alternative (dl_1 l_2/l_1) is printed for contrast and must differ. + !! 3. Checkpoint restart in the middle of a pay-out ramp and in the hold after it: a fresh + !! instance takes the coupled kinematics, the line interior [q; v; a] and the dl_1 mirror of + !! the first, re-applies the command as the committed one (restored), and both continue + !! bit for bit. + !! Every gate stopped at initialisation before (CONTROL on a viscoelastic segment was refused). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_UpdateStates_Moving, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & + CD_AGG_Apply_LineControl, CD_AGG_Get_Substep_Counts, CD_AGG_End, & + CD_AGG_OK + USE CableDyn_System, ONLY: CD_System_Line_NDOF, CD_System_Line_NElem, CD_Get_System_Line_State, & + CD_Get_System_Line_Tension, CD_Get_System_Line_VE_Dl1, CD_Set_System_Line_VE_Dl1, & + CD_Update_System_Line_Interior_State, CD_SYSTEM_OK + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + IMPLICIT NONE + + ! the deck constants: Es, Ed (ElasticMod 2), alphaMBL|vbeta (ElasticMod 3), Bs|Bd + REAL(wp), PARAMETER :: EA_S = 1.0e8_wp, EA_D2 = 3.0e8_wp, AMBL = 3.0e8_wp, VBETA = 20.0_wp + REAL(wp), PARAMETER :: BA_S = 1.0e6_wp, BA_D = 1.0e5_wp + REAL(wp), PARAMETER :: PI = 3.141592653589793_wp, DT = 0.05_wp + INTEGER :: nfail = 0 + + CALL write_deck('vctl_mod2.dat', '1.0e8|3.0e8', .FALSE.) + CALL write_deck('vctl_mod2_noblend.dat', '1.0e8|3.0e8', .TRUE.) + CALL write_deck('vctl_mod3.dat', '1.0e8|3.0e8|20.0', .FALSE.) + + CALL case_quasi_static('vctl_mod2.dat', 'ElasticMod 2 quasi-static') + CALL case_quasi_static('vctl_mod2_noblend.dat', 'ElasticMod 2 quasi-static, False alpha_force_blend') + CALL case_quasi_static('vctl_mod3.dat', 'ElasticMod 3 quasi-static') + CALL case_length_step('vctl_mod2.dat', 2, 0.05_wp, 'ElasticMod 2 pay-out step') + CALL case_length_step('vctl_mod2.dat', 2, -0.04_wp, 'ElasticMod 2 haul-in step') + CALL case_length_step('vctl_mod3.dat', 3, 0.05_wp, 'ElasticMod 3 pay-out step') + CALL case_length_step('vctl_mod3.dat', 3, -0.04_wp, 'ElasticMod 3 haul-in step') + CALL case_restart('vctl_mod2.dat', 'ElasticMod 2') + CALL case_restart('vctl_mod3.dat', 'ElasticMod 3') + + IF (nfail > 0) THEN + PRINT '(I0,A)', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + PRINT '(A)', 'all viscoelastic line-control checks passed' + +CONTAINS + + ! --------------------------------------------------------------------------------------------- + ! 1. quasi-static pay-out and haul-in + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_quasi_static(deck, what) + CHARACTER(*), INTENT(IN) :: deck, what + TYPE(CD_AGG_ModuleType) :: agg + INTEGER, PARAMETER :: NSTEP = 1840 + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), dl, dldot, t, chord, l_tot, t_o, t0 + REAL(wp) :: err_ramp, err_hold, hold_at(3) + REAL(wp), ALLOCATABLE :: ten(:) + INTEGER :: es, ni, s, il, ec, ne, k, n_hold + LOGICAL :: cv, st, ok + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//': the controlled viscoelastic deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (ten(ne)) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + CALL require(md%has_viscoelastic .AND. md%ve_mode(ec) /= 0, what//': the controlled segment is viscoelastic') + chord = NORM2(md%q(3*md%elem_conn(2, ne) - 2:3*md%elem_conn(2, ne)) - & + md%q(3*md%elem_conn(1, 1) - 2:3*md%elem_conn(1, 1))) + l_tot = SUM(md%l0) + END ASSOCIATE + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + t0 = ten(ec) + t_o = EA_S*(chord/l_tot - 1.0_wp) + CALL require(ABS(t0 - t_o) <= 1.0e-6_wp*t_o .AND. MAXVAL(ABS(ten - t0)) <= 1.0e-6_wp*t0, & + what//': the line starts on the static law with a uniform tension') + hold_at = [24.0_wp, 68.0_wp, 92.0_wp] + err_ramp = 0.0_wp + err_hold = 0.0_wp + n_hold = 0 + ok = .TRUE. + DO s = 1, NSTEP + t = REAL(s, wp)*DT + CALL cycle_command(t, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg, [dl], [dldot], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg, DT, r0, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + ok = .FALSE. + CALL require(.FALSE., what//': step at t = '//TRIM(fmt_real(t))//': '//TRIM(em)) + EXIT + END IF + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten, es, em) + ! the oracle: the static (composite EA) law at the line's strain + t_o = EA_S*(chord/(l_tot + dl) - 1.0_wp) + err_ramp = MAX(err_ramp, MAXVAL(ABS(ten - t_o))/t0) + DO k = 1, 3 + IF (ABS(t - hold_at(k)) < 0.5_wp*DT) THEN + err_hold = MAX(err_hold, MAXVAL(ABS(ten - t_o))/t_o) + n_hold = n_hold + 1 + END IF + END DO + END DO + IF (ok) THEN + PRINT '(A,A,A,ES12.5,A,ES10.3,A,ES10.3)', ' ', what, ': T0 ', t0, ' N; max |T - EA eps| / T0 over the ramps ', & + err_ramp, ', at the ends of the holds / T ', err_hold + CALL require(n_hold == 3 .AND. err_hold <= 1.0e-6_wp, what//': at rest the tension is the static law''s') + CALL require(err_ramp <= 3.0e-3_wp, what//': along the ramps the tension follows the static law') + CALL require(bits_eq(agg%sys%fast%system%lines(il)%l0(ec), agg%ctrl_base_l0(1)), & + what//': the cycle returns the segment to its base length') + END IF + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_quasi_static + + SUBROUTINE cycle_command(t, dl, dldot) + !! Pay out 0.5 m on a half-cosine over 20 s, hold 4 s, haul in to -1 m over 40 s, hold 4 s, + !! pay back to 0 over 20 s, hold. + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: dl, dldot + IF (t < 20.0_wp) THEN + CALL half_cosine(t, 0.0_wp, 20.0_wp, 0.0_wp, 0.5_wp, dl, dldot) + ELSE IF (t < 24.0_wp) THEN + dl = 0.5_wp + dldot = 0.0_wp + ELSE IF (t < 64.0_wp) THEN + CALL half_cosine(t, 24.0_wp, 40.0_wp, 0.5_wp, -1.0_wp, dl, dldot) + ELSE IF (t < 68.0_wp) THEN + dl = -1.0_wp + dldot = 0.0_wp + ELSE IF (t < 88.0_wp) THEN + CALL half_cosine(t, 68.0_wp, 20.0_wp, -1.0_wp, 0.0_wp, dl, dldot) + ELSE + dl = 0.0_wp + dldot = 0.0_wp + END IF + END SUBROUTINE cycle_command + + SUBROUTINE half_cosine(t, t_start, span, a, b, x, xdot) + REAL(wp), INTENT(IN) :: t, t_start, span, a, b + REAL(wp), INTENT(OUT) :: x, xdot + x = a + (b - a)*0.5_wp*(1.0_wp - COS(PI*(t - t_start)/span)) + xdot = (b - a)*0.5_wp*(PI/span)*SIN(PI*(t - t_start)/span) + END SUBROUTINE half_cosine + + ! --------------------------------------------------------------------------------------------- + ! 2. a length step from rest + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_length_step(deck, mode, step_dl, what) + CHARACTER(*), INTENT(IN) :: deck, what + INTEGER, INTENT(IN) :: mode + REAL(wp), INTENT(IN) :: step_dl + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), ld(3, 1), l1, l2, length, lstrd, t_md, t_alt, dl1_be + REAL(wp), ALLOCATABLE :: dl1_0(:), dl1_1(:), ten0(:), ten1(:) + INTEGER :: es, ni, il, ec, ne, others, max_used + INTEGER(INT64) :: calls, events, capped, fallbacks + LOGICAL :: cv, st + CHARACTER(512) :: em + + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//': the deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, r0, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + il = agg%ctrl_line(1) + ec = agg%ctrl_elem(1) + ne = CD_System_Line_NElem(agg%sys%fast%system, il, es, em) + ALLOCATE (dl1_0(ne), dl1_1(ne), ten0(ne), ten1(ne)) + CALL CD_Get_System_Line_VE_Dl1(agg%sys%fast%system, il, dl1_0, es, em) + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten0, es, em) + l1 = agg%sys%fast%system%lines(il)%l0(ec) + CALL CD_AGG_Apply_LineControl(agg, [step_dl], [0.0_wp], es, em) + CALL require(es == CD_AGG_OK, what//': the command applies: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + l2 = md%l0(ec) + CALL require(md%ve_mode(ec) == mode .AND. bits_eq(l2, l1 + step_dl), & + what//': the viscoelastic segment takes l1 + DeltaL') + CALL element_kinematics(md%q, md%v, md%elem_conn(:, ec), length, lstrd) + END ASSOCIATE + CALL CD_Get_System_Line_Tension(agg%sys%fast%system, il, ten1, es, em) + t_md = md_tension(mode, dl1_0(ec), length, lstrd, l2) + t_alt = md_tension(mode, dl1_0(ec)*l2/l1, length, lstrd, l2) + others = COUNT(.NOT. bits_eq_v(ten1, ten0)) - MERGE(1, 0,.NOT. bits_eq(ten1(ec), ten0(ec))) + PRINT '(A,A,F6.3,A,ES12.5,A,ES12.5,A,ES12.5,A,ES10.3)', ' ', what, step_dl, ' m: tension ', ten0(ec), & + ' -> ', ten1(ec), ' N, MoorDyn (stretch carried) ', t_md, ' N, rel. difference ', ABS(ten1(ec) - t_md)/t_md + PRINT '(A,ES12.5,A,ES10.3,A)', ' strain carried instead: ', t_alt, ' N (', ABS(t_alt - t_md)/t_md, & + ' off MoorDyn)' + CALL require(t_md > 0.0_wp .AND. ABS(ten1(ec) - t_md) <= 1.0e-10_wp*t_md, & + what//': the tension after the change is MoorDyn''s at the carried stretch') + CALL require(ABS(t_alt - t_md) > 1.0e-3_wp*t_md, what//': the oracle tells the stretch from the strain carry') + CALL require(others == 0, what//': the other elements keep their tension') + CALL CD_AGG_Step_Moving(agg, DT, r0, vel, acc, cv, st, ni, es, em) + CALL require(es == CD_AGG_OK .AND. cv, what//': the step after the change converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_Get_Substep_Counts(agg, calls, events, max_used, capped, fallbacks) + CALL CD_Get_System_Line_VE_Dl1(agg%sys%fast%system, il, dl1_1, es, em) + ASSOCIATE (md => agg%sys%fast%system%lines(il)) + CALL element_kinematics(md%q, md%v, md%elem_conn(:, ec), length, lstrd) + END ASSOCIATE + dl1_be = md_backward_euler(mode, dl1_0(ec), length, lstrd, l2, DT) + PRINT '(A,ES16.9,A,ES16.9,A,ES10.3,A,I0,A)', ' dl_1 after one step ', dl1_1(ec), ' m, oracle ', dl1_be, & + ' (rel. ', ABS(dl1_1(ec) - dl1_be)/ABS(dl1_be), '; ', events, ' sub-stepped steps)' + CALL require(events == 0 .AND. ABS(dl1_1(ec) - dl1_be) <= 1.0e-10_wp*ABS(dl1_be), & + what//': the step advances the carried stretch (backward Euler at the new length)') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE case_length_step + + SUBROUTINE element_kinematics(q, v, conn, length, lstrd) + !! Stretched length and its rate (the chord rate, MoorDyn's lstr and lstrd) of one element. + REAL(wp), INTENT(IN) :: q(:), v(:) + INTEGER, INTENT(IN) :: conn(2) + REAL(wp), INTENT(OUT) :: length, lstrd + REAL(wp) :: chord(3) + chord = q(3*conn(2) - 2:3*conn(2)) - q(3*conn(1) - 2:3*conn(1)) + length = NORM2(chord) + lstrd = DOT_PRODUCT(chord/length, v(3*conn(2) - 2:3*conn(2)) - v(3*conn(1) - 2:3*conn(1))) + END SUBROUTINE element_kinematics + + SUBROUTINE md_coeffs(mode, dl_1, l, ea_d, ea_1) + !! MoorDyn's EA_D (ElasticMod 2: Ed; ElasticMod 3: the mean-load-dependent root of + !! MoorDyn-F Line_GetStateDeriv / MoorDyn-C Line::getStateDeriv at dl_1 > 0) and + !! EA_1 = EA_D EA/(EA_D - EA). + INTEGER, INTENT(IN) :: mode + REAL(wp), INTENT(IN) :: dl_1, l + REAL(wp), INTENT(OUT) :: ea_d, ea_1 + REAL(wp) :: k + IF (mode == 2) THEN + ea_d = EA_D2 + ELSE IF (dl_1 > 0.0_wp) THEN + k = EA_S/l + ea_d = 0.5_wp*(AMBL + VBETA*dl_1*k + EA_S + SQRT(AMBL*AMBL + 2.0_wp*AMBL*k*(VBETA*dl_1 - l) + & + (k*(VBETA*dl_1 + l))**2)) + ELSE + ea_d = AMBL + END IF + ea_1 = ea_d*EA_S/(ea_d - EA_S) + END SUBROUTINE md_coeffs + + REAL(wp) FUNCTION md_tension(mode, dl_1, length, lstrd, l) RESULT(t) + !! MoorDyn's segment tension MagT + MagTd at the state dl_1 and unstretched length l. + INTEGER, INTENT(IN) :: mode + REAL(wp), INTENT(IN) :: dl_1, length, lstrd, l + REAL(wp) :: ea_d, ea_1, ld_1 + CALL md_coeffs(mode, dl_1, l, ea_d, ea_1) + ld_1 = (ea_d*(length - l) - (ea_d + ea_1)*dl_1 + BA_D*lstrd)/(BA_D + BA_S) + t = BA_S*ld_1/l + IF (length >= l) t = t + ea_1*dl_1/l + END FUNCTION md_tension + + REAL(wp) FUNCTION md_backward_euler(mode, dl_1, length, lstrd, l, h) RESULT(dl1_next) + !! The backward-Euler step of MoorDyn's linear dl_1 ODE at length l, EA_D at the step-start + !! dl_1 (CableDyn lags it over the step). + INTEGER, INTENT(IN) :: mode + REAL(wp), INTENT(IN) :: dl_1, length, lstrd, l, h + REAL(wp) :: ea_d, ea_1, b + CALL md_coeffs(mode, dl_1, l, ea_d, ea_1) + b = BA_D + BA_S + dl1_next = (dl_1 + h*(ea_d*(length - l) + BA_D*lstrd)/b)/(1.0_wp + h*(ea_d + ea_1)/b) + END FUNCTION md_backward_euler + + ! --------------------------------------------------------------------------------------------- + ! 3. checkpoint restart + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE case_restart(deck, what) + !! The shell's rebuild recipe (CableDyn_OF): a fresh instance B takes A's coupled kinematics, + !! re-applies the restored command, then reloads the line interior and the dl_1 mirror. + CHARACTER(*), INTENT(IN) :: deck, what + TYPE(CD_AGG_ModuleType) :: agg_a, agg_b + INTEGER, PARAMETER :: NPOST = 12 + REAL(wp) :: r0(3, 1), vel(3, 1), acc(3, 1), pa(3, 1), la(3, 1), pb(3, 1), lb(3, 1), v2(3, 1), a2(3, 1) + REAL(wp) :: dl, dldot, dmax + REAL(wp), ALLOCATABLE :: qL(:), vL(:), aL(:), dl1(:), dl1_b(:) + INTEGER :: es, ni, s, il, ndof, ne, npre, pass + LOGICAL :: cv, st, same + CHARACTER(512) :: em + + DO pass = 1, 2 + npre = MERGE(15, 50, pass == 1) + CALL CD_AGG_Init_From_Deck(agg_a, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//' restart: A initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_GetMovingPointMesh(agg_a, r0, vel, acc, la, es, em) + vel = 0.0_wp + acc = 0.0_wp + DO s = 1, npre + CALL restart_command(s, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg_a, DT, r0, vel, acc, cv, st, ni, es, em) + IF (es /= CD_AGG_OK .OR. .NOT. cv) THEN + CALL require(.FALSE., what//' restart: A marches: '//TRIM(em)) + RETURN + END IF + END DO + CALL CD_AGG_Init_From_Deck(agg_b, deck, DT, es, em) + CALL require(es == CD_AGG_OK, what//' restart: B initialises: '//TRIM(em)) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_UpdateStates_Moving(agg_b, pa, v2, a2, es, em) + ! the restored command is the one A's committed state was reached with + CALL restart_command(npre, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em, restored=.TRUE.) + CALL require(es == CD_AGG_OK, what//' restart: B re-applies the command: '//TRIM(em)) + il = agg_a%ctrl_line(1) + ndof = CD_System_Line_NDOF(agg_a%sys%fast%system, il, es, em) + ne = CD_System_Line_NElem(agg_a%sys%fast%system, il, es, em) + IF (ALLOCATED(qL)) DEALLOCATE (qL, vL, aL, dl1, dl1_b) + ALLOCATE (qL(ndof), vL(ndof), aL(ndof), dl1(ne), dl1_b(ne)) + CALL CD_Get_System_Line_State(agg_a%sys%fast%system, il, qL, vL, aL, es, em) + CALL CD_Update_System_Line_Interior_State(agg_b%sys%fast%system, il, qL(4:ndof - 3), vL(4:ndof - 3), & + es, em, a_interior=aL(4:ndof - 3)) + CALL require(es == CD_SYSTEM_OK, what//' restart: B takes the line interior: '//TRIM(em)) + CALL CD_Get_System_Line_VE_Dl1(agg_a%sys%fast%system, il, dl1, es, em) + CALL CD_Set_System_Line_VE_Dl1(agg_b%sys%fast%system, il, dl1, es, em) + CALL require(es == CD_SYSTEM_OK, what//' restart: B takes the dl_1 mirror: '//TRIM(em)) + ASSOCIATE (ma => agg_a%sys%fast%system%lines(il), mb => agg_b%sys%fast%system%lines(il)) + same = ALL(bits_eq_v(ma%l0, mb%l0)) .AND. ALL(bits_eq_v(ma%l0_c, mb%l0_c)) + END ASSOCIATE + CALL require(same, what//' restart: B carries the lengths and the committed lengths of A') + dmax = 0.0_wp + DO s = npre + 1, npre + NPOST + CALL restart_command(s, dl, dldot) + CALL CD_AGG_Apply_LineControl(agg_a, [dl], [dldot], es, em) + CALL CD_AGG_Apply_LineControl(agg_b, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(agg_a, DT, r0, vel, acc, cv, st, ni, es, em) + same = same .AND. es == CD_AGG_OK .AND. cv + CALL CD_AGG_Step_Moving(agg_b, DT, r0, vel, acc, cv, st, ni, es, em) + same = same .AND. es == CD_AGG_OK .AND. cv + CALL CD_AGG_CalcOutput(agg_a, es, em) + CALL CD_AGG_CalcOutput(agg_b, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_a, pa, v2, a2, la, es, em) + CALL CD_AGG_GetMovingPointMesh(agg_b, pb, v2, a2, lb, es, em) + CALL CD_Get_System_Line_VE_Dl1(agg_a%sys%fast%system, il, dl1, es, em) + CALL CD_Get_System_Line_VE_Dl1(agg_b%sys%fast%system, il, dl1_b, es, em) + dmax = MAX(dmax, MAXVAL(ABS(la - lb)), MAXVAL(ABS(dl1 - dl1_b))) + same = same .AND. ALL(bits_eq_v(RESHAPE(la, [3]), RESHAPE(lb, [3]))) .AND. ALL(bits_eq_v(dl1, dl1_b)) .AND. & + ALL(bits_eq_v(agg_a%sys%fast%system%lines(il)%q, agg_b%sys%fast%system%lines(il)%q)) + END DO + PRINT '(A,A,A,I0,A,ES10.3)', ' ', what, ' restart after step ', npre, & + ': max difference of the fairlead load and dl_1 ', dmax + CALL require(same, what//' restart: the restarted run continues bit for bit ('// & + MERGE('mid-ramp', 'hold ', pass == 1)//')') + CALL CD_AGG_End(agg_a, es, em) + CALL CD_AGG_End(agg_b, es, em) + END DO + END SUBROUTINE case_restart + + SUBROUTINE restart_command(step, dl, dldot) + !! A 0.4 m pay-out on a half-cosine over 2 s, then held. + INTEGER, INTENT(IN) :: step + REAL(wp), INTENT(OUT) :: dl, dldot + REAL(wp) :: t + t = REAL(step, wp)*DT + IF (t < 2.0_wp) THEN + CALL half_cosine(t, 0.0_wp, 2.0_wp, 0.0_wp, 0.4_wp, dl, dldot) + ELSE + dl = 0.4_wp + dldot = 0.0_wp + END IF + END SUBROUTINE restart_command + + ! --------------------------------------------------------------------------------------------- + ! decks and helpers + ! --------------------------------------------------------------------------------------------- + + SUBROUTINE write_deck(path, ea, no_force_blend) + !! A Coupled fairlead at x = 0 and a Fixed anchor 102 m away at mid-depth, 100 m of rope in 10 + !! segments written fairlead first (its only host-driven end at NodeA, the controlled end), + !! with a CONTROL row on channel 1. The rope is nearly neutrally buoyant (0.05 kg/m above the + !! displaced water's). no_force_blend writes False alpha_force_blend. + CHARACTER(*), INTENT(IN) :: path, ea + LOGICAL, INTENT(IN) :: no_force_blend + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'Viscoelastic line-control test deck' + 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)') 'rope 0.1438 16.70 '//ea//' 1.0e6|1.0e5 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 102.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 rope 100.0 10' + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Lines' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') '1 1' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + IF (no_force_blend) WRITE (u, '(A)') 'False alpha_force_blend' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- end ---' + CLOSE (u) + END SUBROUTINE write_deck + + ELEMENTAL LOGICAL FUNCTION bits_eq(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x, y + same = TRANSFER(x, 0_INT64) == TRANSFER(y, 0_INT64) + END FUNCTION bits_eq + + FUNCTION bits_eq_v(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x(:), y(:) + LOGICAL :: same(SIZE(x)) + same = bits_eq(x, y) + END FUNCTION bits_eq_v + + FUNCTION fmt_real(x) RESULT(s) + REAL(wp), INTENT(IN) :: x + CHARACTER(24) :: s + WRITE (s, '(F10.3)') x + s = ADJUSTL(s) + END FUNCTION fmt_real + + 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_viscoelastic_control diff --git a/tests/test_wavekin_modes.f90 b/tests/test_wavekin_modes.f90 index d85f2004..896e9b30 100644 --- a/tests/test_wavekin_modes.f90 +++ b/tests/test_wavekin_modes.f90 @@ -257,8 +257,8 @@ SUBROUTINE check_rejections() CALL expect_failure('2', '0', 'FFT_GRID') CALL expect_failure('4', '0', 'no kinematics source in MoorDyn-C') CALL expect_failure('6', '0', 'no kinematics source in MoorDyn-C') - CALL expect_failure('0', '2', 'current_profile_dynamic.txt') - CALL expect_failure('0', '5', 'current_profile_4d.txt') + CALL expect_failure('0', '3', 'no current source in MoorDyn-C') + CALL expect_failure('0', '4', 'no current source in MoorDyn-C') ! short-crested components (rows with different directions) OPEN (NEWUNIT=u, FILE='wave_frequencies.txt', STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') '0.0 0.0 0.0 0.0' diff --git a/validation/scripts/currents_mdc_reference.py b/validation/scripts/currents_mdc_reference.py new file mode 100644 index 00000000..26c6004e --- /dev/null +++ b/validation/scripts/currents_mdc_reference.py @@ -0,0 +1,231 @@ +# SPDX-License-Identifier: Apache-2.0 +"""Regenerate the MoorDyn-C current references of tests/data/currents_mdc. + +Every case folder holds a MoorDyn-C deck (currents.dat), its fixed-name current file and probe +points (points.txt, rows ``t x y z``). For each case this script writes + +* ``ref_python.csv``: the current evaluated here, independently of CableDyn, from the file as + MoorDyn-C v2.7.1 reads and interpolates it (constructDynamicCurrentGrid and + construct4DCurrentGrid of source/Waves/WaveGrid.cpp, CurrentGrid::getCurrentKin of + source/Waves.cpp): the table resampled at the smallest time interval dt from t = 0 to its last + time, linear in time between samples with the upper sample index taken modulo the sample count + (so the grid repeats past its last sample), and trilinear in x, y and z, held beyond the end + coordinates. ``Currents 2`` depths are read in single precision, as MoorDyn-C's ``stof``. + ``Currents 5`` rows are read from line 6 (a text line 6 is a header) and matched to the grid by + value. Currents 1 is a steady depth profile, linear in z and held beyond its end rows. +* ``ref_moordyn_c.csv`` (with ``--moordyn-c``): the same points from MoorDyn-C itself, through + validation/scripts/wavekin_mdc_probe.cpp compiled against a MoorDyn-C build (CD_MDC_SRC, + CD_MDC_BUILD and CD_GXX as for the bodies scripts). + +The tension case folders (tension_c0, tension_c2, tension_c5) hold a MoorDyn-C deck +(tension.dat) and its current file; with ``--moordyn-c`` each gets ``ref_moordyn_c_tension.csv``, +the line node tensions MoorDyn-C reports every 0.1 s over 22 s +(validation/scripts/currents_mdc_tension.cpp), which tests/test_mdc_currents_runs.py compares +with CableDyn's. + +Rows are ``t,x,y,z,zeta,ux,uy,uz,ax,ay,az`` (zeta and the accelerations zero: MoorDyn-C gives a +current no acceleration). The currents_mdc CTest compares CableDyn against both. +""" + +from __future__ import annotations + +import argparse +import math +import os +import shutil +import subprocess +import tempfile +from pathlib import Path + +import numpy as np + +REPO = Path(__file__).resolve().parents[2] +DATA = REPO / "tests" / "data" / "currents_mdc" +FILES = {1: "current_profile.txt", 2: "current_profile_dynamic.txt", 5: "current_profile_4d.txt"} + + +def tokens(line: str) -> list[str]: + """Whitespace tokens up to the first one holding '#' (MoorDyn-C's str::split).""" + out = [] + for tok in line.split(): + if "#" in tok: + break + out.append(tok) + return out + + +def currents_mode(deck: Path) -> int: + for line in deck.read_text().splitlines(): + parts = line.split() + if len(parts) >= 2 and parts[1].lower() == "currents": + return int(float(parts[0])) + raise ValueError(f"{deck}: no Currents option") + + +class Grid: + """A current tabulated on x, y, z and the times t, values v[3, nx, ny, nz, nt].""" + + def __init__(self, x, y, z, t_in, v_in): + self.x, self.y, self.z = (np.asarray(c, dtype=float) for c in (x, y, z)) + t_in = np.asarray(t_in, dtype=float) + self.dt = float(np.min(np.diff(t_in))) + self.nt = math.floor(t_in[-1] / self.dt) + 1 + ts = np.arange(self.nt) * self.dt + # linear in time, held at the end rows + flat = v_in.reshape(-1, len(t_in)) + self.v = np.array([np.interp(ts, t_in, row) for row in flat]).reshape(v_in.shape[:-1] + (self.nt,)) + + @staticmethod + def weights(c: np.ndarray, x: float) -> tuple[int, int, float]: + """Bracketing indices and the weight of the upper one, held beyond the ends.""" + if len(c) == 1 or x <= c[0]: + return 0, 0, 0.0 + if x >= c[-1]: + return len(c) - 1, len(c) - 1, 0.0 + i = int(np.searchsorted(c, x)) + return i - 1, i, (x - c[i - 1]) / (c[i] - c[i - 1]) + + def velocity(self, x: float, y: float, z: float, t: float) -> np.ndarray: + if self.nt > 1: + q = t / self.dt + n = math.floor(q) + ft = q - n + hi = (n + 1) % self.nt + lo = hi - 1 if hi > 0 else 0 + else: + lo = hi = 0 + ft = 0.0 + out = np.zeros(3) + for ia, ib, wx in [self.weights(self.x, x)]: + for ja, jb, wy in [self.weights(self.y, y)]: + for ka, kb, wz in [self.weights(self.z, z)]: + for i, wi in ((ia, 1.0 - wx), (ib, wx)): + for j, wj in ((ja, 1.0 - wy), (jb, wy)): + for k, wk in ((ka, 1.0 - wz), (kb, wz)): + w = wi * wj * wk + if w == 0.0: + continue + vt = self.v[:, i, j, k, lo] * (1.0 - ft) + self.v[:, i, j, k, hi] * ft + out += w * vt + return out + + +def read_steady(path: Path) -> Grid: + rows = [list(map(float, tokens(line))) for line in path.read_text().splitlines()[3:] if tokens(line)] + z = [r[0] for r in rows] + v = np.zeros((3, 1, 1, len(z), 2)) + for k, r in enumerate(rows): + for c in range(3): + v[c, 0, 0, k, :] = r[c + 1] if len(r) > c + 1 else 0.0 + return Grid([0.0], [0.0], z, [0.0, 1.0], v) + + +def read_dynamic(path: Path) -> Grid: + lines = path.read_text().splitlines() + z = [float(np.float32(tok)) for tok in tokens(lines[4])] + nz = len(z) + t, cols = [], [] + for line in lines[6:]: + tok = tokens(line) + if not tok: + continue + t.append(float(tok[0])) + vals = [float(s) for s in tok[1:]] + cols.append(vals + [0.0] * (3 * nz - len(vals))) + v = np.zeros((3, 1, 1, nz, len(t))) + for n, vals in enumerate(cols): + for c in range(3): + v[c, 0, 0, :, n] = vals[c * nz:(c + 1) * nz] + return Grid([0.0], [0.0], z, t, v) + + +def read_4d(path: Path) -> Grid: + lines = path.read_text().splitlines() + dims = [int(s) for s in tokens(lines[0])] + axes = [[float(s) for s in tokens(lines[k + 1])] for k in range(4)] + v = np.zeros((3, *dims)) + seen = np.zeros(dims, dtype=bool) + for k, line in enumerate(lines[5:]): + tok = tokens(line) + if not tok: + continue + try: + row = [float(s) for s in tok] + except ValueError: + if k == 0: + continue # a text header on line 6 + raise + idx = tuple(axes[a].index(row[a]) for a in range(4)) + assert not seen[idx], f"{path}: grid point repeated" + seen[idx] = True + v[(slice(None),) + idx] = row[4:7] + assert seen.all(), f"{path}: grid point missing" + return Grid(axes[0], axes[1], axes[2], axes[3], v) + + +def write_csv(path: Path, rows) -> None: + with open(path, "w", newline="\n") as fh: + fh.write("t,x,y,z,zeta,ux,uy,uz,ax,ay,az\n") + for t, x, y, z, u in rows: + fh.write(",".join(f"{v:.17g}" for v in (t, x, y, z, 0.0, *u, 0.0, 0.0, 0.0)) + "\n") + + +def python_reference(case: Path) -> None: + mode = currents_mode(case / "currents.dat") + grid = {1: read_steady, 2: read_dynamic, 5: read_4d}[mode](case / FILES[mode]) + points = np.loadtxt(case / "points.txt", ndmin=2) + write_csv(case / "ref_python.csv", [(t, x, y, z, grid.velocity(x, y, z, t)) for t, x, y, z in points]) + print(f"wrote {case / 'ref_python.csv'}") + + +def moordyn_c_reference(cases: list[Path], tension_cases: list[Path]) -> None: + """Run MoorDyn-C on the probe cases (wavekin_mdc_probe.cpp) and on the tension cases + (currents_mdc_tension.cpp: line node tensions every 0.1 s over TMax = 22 s).""" + src = Path(os.environ.get("CD_MDC_SRC", "MoorDyn")) + build = Path(os.environ.get("CD_MDC_BUILD", "MoorDyn-build")) + gxx = os.environ.get("CD_GXX", "g++") + dll = build / "source" / "libmoordyn.dll" + if not dll.exists(): + raise FileNotFoundError(f"MoorDyn-C library not found: {dll} (set CD_MDC_BUILD)") + with tempfile.TemporaryDirectory() as tmp: + work = Path(tmp) + env = dict(os.environ) + env["PATH"] = str(Path(gxx).parent) + os.pathsep + str(work) + os.pathsep + env.get("PATH", "") + exes = {} + for name in ("wavekin_mdc_probe", "currents_mdc_tension"): + exes[name] = work / f"{name}.exe" + subprocess.run([gxx, "-O2", "-std=c++17", f"-I{src / 'source'}", f"-I{build / 'source'}", + str(REPO / "validation" / "scripts" / f"{name}.cpp"), str(dll), "-o", str(exes[name])], + check=True, env=env) + shutil.copy2(dll, work / "libmoordyn.dll") + for case in cases + tension_cases: + run = work / case.name + run.mkdir() + for f in case.iterdir(): + if not f.name.startswith("ref_"): + shutil.copy2(f, run / f.name) + if case in cases: + args, out = [str(exes["wavekin_mdc_probe"]), "currents.dat", "points.txt", "out.csv"], "ref_moordyn_c.csv" + else: + args, out = [str(exes["currents_mdc_tension"]), "tension.dat", "0.1", "22.0", "out.csv"], \ + "ref_moordyn_c_tension.csv" + subprocess.run(args, cwd=run, check=True, env=env, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + # the repository keeps LF line endings (the probes write CRLF on Windows) + (case / out).write_bytes((run / "out.csv").read_bytes().replace(b"\r\n", b"\n")) + print(f"wrote {case / out}") + + +def main() -> None: + parser = argparse.ArgumentParser(description=__doc__.splitlines()[0]) + parser.add_argument("--moordyn-c", action="store_true", help="also run MoorDyn-C on every case") + args = parser.parse_args() + cases = sorted(p for p in DATA.iterdir() if (p / "currents.dat").exists()) + tension_cases = sorted(p for p in DATA.iterdir() if (p / "tension.dat").exists()) + for case in cases: + python_reference(case) + if args.moordyn_c: + moordyn_c_reference(cases, tension_cases) + + +if __name__ == "__main__": + main() diff --git a/validation/scripts/currents_mdc_tension.cpp b/validation/scripts/currents_mdc_tension.cpp new file mode 100644 index 00000000..5788d9a0 --- /dev/null +++ b/validation/scripts/currents_mdc_tension.cpp @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: Apache-2.0 +// Line node tensions of a MoorDyn-C deck whose coupled points are held at their deck positions. +// +// currents_mdc_tension +// +// The system is initialised (the deck's TmaxIC sets the stationary initial condition) and stepped +// to t_end in steps of dt_out (MoorDyn-C sub-steps each at the deck's dtM). Output rows: +// "t,T0,...,TN" with Tk the tension magnitude MoorDyn_GetLineNodeTen reports at node k of line 1 +// (the mean of the adjacent segment tensions at an interior node). +#include "MoorDyn2.h" + +#include +#include +#include +#include +#include + +int +main(int argc, char** argv) +{ + if (argc != 5) { + std::cerr << "usage: currents_mdc_tension " << std::endl; + return 2; + } + const double dt_out = std::atof(argv[2]), t_end = std::atof(argv[3]); + MoorDyn system = MoorDyn_Create(argv[1]); + if (!system) + return 3; + unsigned int n_dof = 0, n_points = 0; + if (MoorDyn_NCoupledDOF(system, &n_dof) != MOORDYN_SUCCESS || + MoorDyn_GetNumberPoints(system, &n_points) != MOORDYN_SUCCESS) + return 3; + std::vector x, dx(n_dof, 0.0); + for (unsigned int i = 1; i <= n_points; i++) { + MoorDynPoint point = MoorDyn_GetPoint(system, i); + int type = 0; + double pos[3]; + if (!point || MoorDyn_GetPointType(point, &type) != MOORDYN_SUCCESS || + MoorDyn_GetPointPos(point, pos) != MOORDYN_SUCCESS) + return 3; + if (type == -1) + x.insert(x.end(), pos, pos + 3); + } + if (x.size() != n_dof) { + std::cerr << "the deck may couple points only" << std::endl; + return 3; + } + std::vector f(n_dof + 3, 0.0); + if (MoorDyn_Init(system, x.data(), dx.data()) != MOORDYN_SUCCESS) + return 4; + MoorDynLine line = MoorDyn_GetLine(system, 1); + unsigned int n = 0; + if (!line || MoorDyn_GetLineN(line, &n) != MOORDYN_SUCCESS) + return 5; + FILE* out = std::fopen(argv[4], "w"); + if (!out) + return 6; + std::fprintf(out, "t"); + for (unsigned int k = 0; k <= n; k++) + std::fprintf(out, ",T%u", k); + std::fprintf(out, "\n"); + const long nstep = std::lround(t_end / dt_out); + double t = 0.0; + for (long s = 0; s <= nstep; s++) { + if (s > 0) { + double dt = dt_out; + if (MoorDyn_Step(system, x.data(), dx.data(), f.data(), &t, &dt) != MOORDYN_SUCCESS) + return 7; + } + std::fprintf(out, "%.10g", t); + for (unsigned int k = 0; k <= n; k++) { + double ten[3]; + MoorDyn_GetLineNodeTen(line, k, ten); + std::fprintf(out, ",%.10g", std::sqrt(ten[0] * ten[0] + ten[1] * ten[1] + ten[2] * ten[2])); + } + std::fprintf(out, "\n"); + } + std::fclose(out); + MoorDyn_Close(system); + return 0; +} From ffc57c095a3e200790aec97ee9b09b0f08689af6 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 06:13:11 +0900 Subject: [PATCH 24/51] feat(torsion): OpenFAST linearisation, active line control and modal analysis of lines restrained in torsion (#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squash title: `feat(torsion): OpenFAST linearisation, active line control and modal analysis of lines restrained in torsion` ## What changed Three torsion route limits are lifted. Each one was built and reviewed on its own branch from dev 66e3e83; here they are combined on dev (after #71 and #72). ### OpenFAST linearisation (`Linearize = True`) A finite-EI line restrained in torsion no longer fails closed under linearisation. Its nodal twist joins the continuous states: the twist angle of every node the end frames do not hold, after the cables' positions and tangents, and their rates after the velocities (`Cable 1 node 2 twist, rad`, `... twist rate, rad/s`). The coupled point's orientation turns the torsion frame of the host-driven end, `CD_HFMF_Set_Twist_Frame_Rates` gives that frame the point's angular velocity and acceleration (so the torsional damping and the held end section's inertia get their `B` and `D` columns), and the fairlead moment carries the torque. Under linearisation the coupled-point rotation is stepped by 1e-4 rad instead of 0.1 rad, also in the input Jacobians of the time march before the linearisation times; a run without `Linearize` keeps 0.1 rad. A `Rigid` bending end connection still fails closed. ### Active line control (`CONTROL`) A controlled finite-EI line restrained in torsion is no longer refused. Every torsion term that depends on the unstretched length follows the command: the condensed compliance, the nodal twist's `GJ/l` and `Bt/l`, the torque–tension coupling `(K/GJ)(l − l0)`, the lumped polar inertia `Irn l0/2`, and a `-ζ` torsional damping, which now keeps its `ζ` and is re-resolved at the new length. The torsional damping acts on the rate of the twist per length, as the axial damping acts on the strain rate. The committed force keeps the committed lengths, so a ramp does not lag at `α_f > 0`. The checkpoint mirror of a nodal-twist line gains one value, its committed torque, so a reload brings it back as it was formed. ### Modal analysis (`nModes`) The modes of a line restrained in torsion carry the twist angle of every node, with the lumped polar inertia as its mass and the second variation of the twist energy at the static torque. The finite-EI modal route now also takes the end connections (finite springs; a rigid end's tangent in its basis) and the attachments' masses from the model, which it ignored, and writes the positions of a line with a heading in the deck's axes. `.modes.out` adds `PolarShare` and `dTwist` when a line carries twist. ## Gates - `lin_torsion` (the shell's `lin_eval` recipe on the aggregate) and `validation/scripts/openfast_lin_torsion.py` (OpenFAST): on a straight taut 100 m line (GJ 5e4 N·m², Irn 2 kg·m, 50 elements) the first three torsional modes from `eig(A)` are the lumped chain's to 5e-14 and lie 1.6e-4, 6.6e-4 and 1.5e-3 below the continuum's `nπ/L √(GJ/Irn)`; the roll stiffness `−(D − C A⁻¹ B)` is `GJ/L` to 1.5e-14, against the feedthrough `GJ/l_e` alone (50 times stiffer); a 90° twisted lazy wave matches the deck's static solutions for a rolled and a moved fairlead to 4.9e-4. Condensed torsion, an elastic end and the frame-rate columns (`Bt/L`, `Irn l_e/2`) are gated to 1e-6. - `control_torsion`: a taut line paid out and hauled in carries `GJ Φ/L(t) + K (H − L)/L` to 1.5e-12 (a frozen compliance misses by 6.5e-3 and 0.23) and its tension to 3.6e-6; a constant pay-out carries the Kelvin–Voigt torque to 5.8e-6 N·m of its 0.642 N·m damping share; the length-rate damping matches central differences to 1.3e-10 and the torque tangent to 1.1e-9; a pay-out under a ringing twist balances the energy to 7.8e-5 of the work done; restarts mid-ramp (snapshot, checkpoint mirror, a `CONTROL` deck on the aggregate) are bit-identical. - `modal_torsion`, `modal_torsion_deck`: clamped 10 m line, torsional modes are the lumped chain's to 1e-16 and the continuum's within the chain's own error (2.6e-4 on the first); elastic torsional ends against the continuum to 1.5e-4; coupled axial–torsional modes to 8.6e-4; lateral modes under a torque `M = 4 EI/L` match the clamped Greenhill cable to 3.2e-7; eliminating the angles gives back the condensed static tangent to 1.4e-16. ## Changed results - The modes of finite-EI decks with `END CONNECTIONS` or `ATTACHMENTS` and `nModes` (no shipped example): a clamped lazy wave's first twelve frequencies rise by 0.1 to 3.8 %, those of `lazy_wave_buoyancy_modules.dat` with `nModes` drop by 13 to 29 % (the ends and the modules' masses were ignored). - Under `Linearize = True` the rotation columns of a deck with a hang-off spring move by up to 0.17 % (the 1e-4 rad rotation step). - OpenFAST checkpoints of decks with the nodal twist written before this change do not reload (the mirror gained the committed torque). ## Combining the branches The six commits are cherry-picked in order (lin, control, modal; each with its review fix) onto #71 and then rebased onto #72. Conflicts were in the documentation and the CHANGELOG (every entry kept; the OpenFAST coverage paragraph and the active-tensioning bullet merge #72's viscoelastic and Syrope control with this PR's linearisation and torsion), the exact-real compile options of the new tests in `CMakeLists.txt` (both kept), and in the deck driver's torsion stage, where #71 renamed the stage's meshes (`ld`, `lf`) and control added the kept `ζ` of a `-ζ` damping: the merged stage resolves the damping on `lf`. The control branch's extra value in the nodal-twist mirror composes with the lin branch's slot arithmetic: the twist slots are taken from the end of the mirror (`MirrorSize − Twist_Mirror_Size`) and the angles are the first block of the twist tail, so the appended torque does not move them. The VALIDATION entries are T-14 (control) and T-15 (modal). `python/tests/test_native_model.py` is dev's (the identity-based handle-release test of #72); the control fix's `gc.collect()` variant is dropped, so that commit's message still names a change it no longer makes. ## Checks - Full ctest suite (333) passes; `pytest python/tests tests` (2124 passed, 114 skipped; the native parity tests with `CABLEDYN_TEST_DRIVER`: 212 passed); ruff check/format clean; pre-commit clean; the docs build with `-W` clean. - All 53 example decks are bit-identical to the reference driver (dev 0f53412). Signed-off-by: Jae Hoon Seo --- ARCHITECTURE.md | 6 +- CHANGELOG.md | 39 +- CMakeLists.txt | 44 + VALIDATION.md | 80 +- doc/capabilities.rst | 25 +- doc/coupling.rst | 17 +- doc/coupling_boundary.md | 10 +- doc/driver_format.md | 30 +- doc/openfast.rst | 53 +- doc/options.rst | 6 +- doc/outputs.rst | 23 +- doc/theory.rst | 80 +- doc/troubleshooting.rst | 8 +- examples/torsion_lazy_wave_hangoff_twist.dat | 5 +- python/cabledyn/deck_file.py | 16 +- python/tests/test_deck_native_parity.py | 4 +- src/CableDyn_DeckDriver.f90 | 134 ++- src/CableDyn_HermiteCableDynamic.f90 | 208 +++- src/CableDyn_HermiteTorsion.f90 | 33 + src/CableDyn_Modal.f90 | 344 +++++- src/CableDyn_OpenFAST_HermiteFMF.f90 | 81 +- src/openfast/CableDyn_OF.f90 | 159 ++- tests/data/torsion_lazy_wave_modes.dat | 46 + tests/test_control_torsion.f90 | 1048 ++++++++++++++++++ tests/test_hermite_cable_control.f90 | 10 +- tests/test_lin_torsion.f90 | 586 ++++++++++ tests/test_modal_torsion.f90 | 804 ++++++++++++++ tests/test_modal_torsion_deck.py | 218 ++++ tests/test_torsion_deck.f90 | 18 +- validation/scripts/openfast_lin_torsion.py | 414 +++++++ 30 files changed, 4320 insertions(+), 229 deletions(-) create mode 100644 tests/data/torsion_lazy_wave_modes.dat create mode 100644 tests/test_control_torsion.f90 create mode 100644 tests/test_lin_torsion.f90 create mode 100644 tests/test_modal_torsion.f90 create mode 100644 tests/test_modal_torsion_deck.py create mode 100644 validation/scripts/openfast_lin_torsion.py diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index c1acf3b6..4493aa34 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -325,7 +325,11 @@ consistent mass plus Morison added mass. `K` and `M` are assembled in symmetric band storage; LAPACK `DSBGVX` gives the eigenvalues and inverse iteration on the banded pencil gives each mode shape, so the cost grows with line length rather than with its square. Dense `DSYGV` is kept as the test reference. Both line paths -are supported (`nModes`). +are supported (`nModes`). A finite-EI line's modes (`CD_Modal_Hermite_Line`) take +its end connections and attachments from the dynamic model, and a line restrained +in torsion adds the twist angle of every node: its lumped polar inertia and the +second variation of the nodal-twist energy (`CD_HermiteCable_Dyn_Twist_Hessian`) +in a band of 7 DOFs per node. ### Outputs diff --git a/CHANGELOG.md b/CHANGELOG.md index e1061aa3..9001b2f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,18 @@ All notable changes to CableDyn are recorded in this file. The format follows load-dependent) and 4e-9 at rest; after a length step it is MoorDyn's at the carried stretch to 4e-16 (carrying the strain instead would be off by 0.4 to 4.6 %); a restart in the ramp continues bit for bit. +- OpenFAST linearisation of finite-EI lines restrained in torsion: the twist angles of the nodes + the end frames do not hold, and their rates, are continuous states (`Cable 1 node 2 twist, + rad`); the coupled point's orientation turns the torsion frame of the line's coupled + (host-driven) end, its angular velocity and acceleration reach the torsional damping and the + held end section's inertia, and the fairlead + moment carries the torque. A straight line's torsional modes from the eigenvalues of `A` are + the lumped chain's to 5e-14 (the continuum's `nπ/L √(GJ/Irn)` less the discretisation error, + 1.6e-4 for the first mode at 50 elements) and its roll stiffness `D − C A⁻¹ B` is `GJ/L` to + 1.5e-14; a 90° twisted lazy wave matches the deck's static solutions for a rolled and a moved + fairlead to 4.9e-4. In a `Linearize = True` run every input Jacobian, those of the time march + included, steps the coupled-point rotation by 1e-4 rad instead of 0.1 rad, which changes the + rotation columns of a deck with a hang-off spring by up to 0.17 %. - 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 @@ -63,8 +75,8 @@ All notable changes to CableDyn are recorded in this file. The format follows and the Syrope slow strain are first-order states, so the reduction gives these ropes' relaxed static stiffness (each matches its deck's static solutions to 7e-5; held, they would read the chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end - connection, VIV lines, bodies, rods, buoys, torsion and `CONTROL` fail closed with named - messages. This replaces the quasi-static linearisation without states. + connection, VIV lines, bodies, rods, buoys and `CONTROL` fail closed with named messages. This + replaces the quasi-static linearisation without states. - Composite Syrope lines: a Syrope polyester section between plain `EI = 0` sections, such as a chain-polyester-chain mooring, in one LINE. The static start puts every Syrope element on the rest curve of its load history with its own secant EA (the tension varies along a sagging @@ -83,6 +95,23 @@ All notable changes to CableDyn are recorded in this file. The format follows and the OpenFAST checkpoint mirror. Decks with torsion whose `Irn` was a placeholder (the column was unused before) need the section's real value. The Python deck reader and builder take `GJ|K|Bt` (builder `gj=(GJ, K, Bt)`). +- Active line control (`CONTROL`) of a finite-EI cable restrained in torsion, which was refused: + the torsional compliance, the nodal twist's `GJ`/l and `Bt`/l, the torque–tension coupling and + the polar inertia take the new lengths, a `-ζ` torsional damping keeps its `ζ`, and the damping + acts on the rate of the twist per length. A taut line paid out and hauled in carries + `GJ Φ/L(t) + K (H − L)/L` to 1.5e-12 and its tension to 4e-6; a constant pay-out carries the + Kelvin–Voigt torque to 6e-6 N m of its 0.64 N m damping share; a pay-out under a ringing twist + balances the energy to 8e-5 of the work done; restarts mid-ramp (snapshot, checkpoint mirror, + a coupled deck) are bit-identical. The checkpoint mirror of a line with the nodal twist gains + one value, its committed torque. +- Modal analysis (`nModes`) of finite-EI lines restrained in torsion: the modes carry the twist + angle of every node, as the dynamics do, with the lumped polar inertia and the second variation + of the twist energy at the static torque. A clamped straight line's torsional modes match + `nπ/L √(GJ/Irn)` within the lumped chain's own error (2.6e-4 on the first), elastic ends and + the torque–tension coupling their continuum solutions to 1e-3, and under a torque its lateral + modes match the clamped Greenhill cable to 3e-7; eliminating the angles reproduces the + condensed static tangent to 1e-16. `.modes.out` adds `PolarShare` and `dTwist` when a + line carries twist. - 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. @@ -230,6 +259,12 @@ All notable changes to CableDyn are recorded in this file. The format follows The static tangent takes the current's gradient along the line, so the Newton iteration also converges in a current sheared across the line. A later `current` row now discards the levels of an earlier profile row. +- The modal analysis of finite-EI lines ignored the end connections and the discrete + attachments: a clamped end was solved pinned (the first twelve frequencies of the lazy wave + of `torsion_lazy_wave_hangoff_twist.dat`, untwisted, rise by 0.1 % to 3.8 % with its clamps) + 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 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 7960bd80..da62485d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -715,6 +715,15 @@ target_link_libraries(test_hermite_cable_control PRIVATE cabledyn_core) add_test(NAME hermite_cable_control COMMAND test_hermite_cable_control) set_tests_properties(hermite_cable_control PROPERTIES LABELS "fortran;unit;dynamic;hermite") +# Active line control of a line restrained in torsion: the quasi-static torque GJ Phi/L(t) (with +# torque-tension coupling), the torsional damping of the twist per length, the length terms a +# fresh build carries, the energy of a length change with a real Irn, no lag at alpha_f > 0, +# restart mid-ramp (snapshot, mirror) and a CONTROL deck on the coupled aggregate. +add_executable(test_control_torsion tests/test_control_torsion.f90) +target_link_libraries(test_control_torsion PRIVATE cabledyn_core) +add_test(NAME control_torsion COMMAND test_control_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(control_torsion PROPERTIES LABELS "fortran;unit;dynamic;hermite;openfast") + add_executable(test_hermite_added_mass tests/test_hermite_added_mass.f90) target_link_libraries(test_hermite_added_mass PRIVATE cabledyn_core) add_test(NAME hermite_added_mass COMMAND test_hermite_added_mass) @@ -2005,6 +2014,13 @@ add_executable(test_modal tests/test_modal.f90 tests/blas_config_probe.c) target_link_libraries(test_modal PRIVATE cabledyn_core) add_test(NAME modal COMMAND test_modal) set_tests_properties(modal PROPERTIES LABELS "fortran;unit;driver;static;validation") +# Modal analysis of a line restrained in torsion: the twist angle of every node joins the modes +# (torsional, elastic-end and torque-tension coupled modes, the lateral modes under a torque, the +# Schur complement of the angles against the condensed static tangent). +add_executable(test_modal_torsion tests/test_modal_torsion.f90) +target_link_libraries(test_modal_torsion PRIVATE cabledyn_core) +add_test(NAME modal_torsion COMMAND test_modal_torsion) +set_tests_properties(modal_torsion PROPERTIES LABELS "fortran;unit;static;validation") # The modal eigensolves through CableDyn's LAPACK layer with every argument array against a # no-access page: no read or write outside the arrays the modal code passes. if(NOT CABLEDYN_STATIC_WINDOWS_RELEASE) @@ -2188,6 +2204,14 @@ target_link_libraries(test_coupled_torsion PRIVATE cabledyn_core) add_test(NAME coupled_torsion COMMAND test_coupled_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(coupled_torsion PROPERTIES LABELS "fortran;unit;static;dynamic;openfast") +# OpenFAST linearisation of a line restrained in torsion, by the shell's lin_eval recipe on the +# aggregate: the twist modes of A against n pi/L sqrt(GJ/Irn), the reduced roll stiffness GJ/L +# (nodal twist and condensed), the damping and inertia columns of the platform's angular rates. +add_executable(test_lin_torsion tests/test_lin_torsion.f90) +target_link_libraries(test_lin_torsion PRIVATE cabledyn_core) +add_test(NAME lin_torsion COMMAND test_lin_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(lin_torsion PROPERTIES LABELS "fortran;unit;dynamic;openfast") + add_executable(test_torsion_orcaflex tests/test_torsion_orcaflex.f90) target_link_libraries(test_torsion_orcaflex PRIVATE cabledyn_core) add_test(NAME torsion_orcaflex @@ -2385,6 +2409,13 @@ add_test(NAME driver_cli_mixed_nmodes "-DMUST_MATCH=nModes is not supported for mixed EI=0/finite-EI decks" -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_cli_mixed_nmodes PROPERTIES LABELS "fortran;driver;cli") +# A lazy wave restrained in torsion and twisted two turns writes its modes with the twist. +add_test(NAME driver_cli_torsion_nmodes + COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 + "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/torsion_lazy_wave_modes.dat|${CMAKE_CURRENT_BINARY_DIR}/driver_cli_torsion_nmodes" + "-DMUST_MATCH=torsion solved, imposed twist 7.20000E\\+02 deg;converged run written" + -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) +set_tests_properties(driver_cli_torsion_nmodes PROPERTIES LABELS "fortran;driver;cli") # Non-ASCII, reserved-device, input-clobbering, and concurrently used output paths. add_test( NAME driver_cli_paths @@ -2724,6 +2755,16 @@ if(Python3_Interpreter_FOUND) --output ${CMAKE_CURRENT_BINARY_DIR}/lozon_example_equilibrium) set_tests_properties(lozon_example_equilibrium PROPERTIES LABELS "python;driver;integration;example;lozon;validation") + # Modal analysis of decks restrained in torsion: the torsional modes of a straight clamped + # line against the chain and the continuum, its other modes against TorsStiffness Free, and + # the twisted lazy wave's modes. + add_test( + NAME modal_torsion_deck + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_modal_torsion_deck.py + --exe $ + --source ${CMAKE_CURRENT_SOURCE_DIR} + --output ${CMAKE_CURRENT_BINARY_DIR}/modal_torsion_deck) + set_tests_properties(modal_torsion_deck PROPERTIES LABELS "python;driver;integration;validation") # Static-initialization robustness matrix: a deterministic sample of EI=0 mooring regimes # (catenary, semi-taut, taut, suspended, composite, slack/vertical, anchors off the seabed, # sloped seabed, fine mesh, soft seabed, current, one/two segments, Free/Connect points) @@ -2837,6 +2878,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_hermite_drag_dynamics test_hermite_axial_damping test_hermite_cable_control + test_control_torsion test_endconn_spring test_torsion_coupling) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) @@ -2849,6 +2891,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") target_compile_options(test_hermite_cable_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_syrope_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_viscoelastic_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) + target_compile_options(test_control_torsion PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) endif() if(CABLEDYN_ENABLE_COVERAGE) @@ -2900,6 +2943,7 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_drag_dynamics test_hermite_axial_damping test_hermite_cable_control + test_control_torsion test_hermite_added_mass test_hermite_wave_forcing test_lazywave_dynamics diff --git a/VALIDATION.md b/VALIDATION.md index ffa88d62..1ce8ef0c 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-14** | Active line control of a line restrained in torsion | `GJ Φ/L(t) + K (H − L)/L`; Kelvin–Voigt torque of a pay-out; finite differences; energy of a length change; `ρ∞ = 0`; uninterrupted run | torque ≤1.5e-12, tension 3.6e-6; damping 5.8e-6 N·m of 0.64 N·m; FD 1.3e-10, tangent 1.1e-9; energy 7.8e-5; no lag (1.4e-3 of the per-step change); restart bit-identical | see [Torsion](#torsion) | Pass | | **T-13** | Nodal twist (torsional inertia and damping) | condensed torsion in the limit of no inertia; continuum torsional wave; `ζ = ω Bt/(2 GJ)`; energy; restart | ≤6e-7 against the condensed torsion; wave torque 0.07 %; decrement 6 %; energy band 4.9e-4; restart bit-identical | see [Torsion](#torsion) | Pass | | **T-12** | Torque–tension coupling | `T = EA ε + K τ`, `M = GJ τ + K ε` closed forms; kernel FD; march | ≤1e-7 against every closed form; kernel gradient 1.7e-10, Hessian 9.8e-11 | see [Torsion](#torsion) | Pass | | **T-11** | Torsion on the coupled OpenFAST / FAST.Farm route | `GJ (−roll)/L`; single coupled cable; uninterrupted run | twist ≤1.8e-15°, torque ≤1.7e-13 N·m; aggregate = single cable bit for bit; restart bit-identical (aggregate and `openfast -restart`) | see [Torsion](#torsion) | Pass | @@ -407,6 +408,28 @@ scripts, results, and source provenance are in and pitch are 7.29e6 N·m/rad below the module-level 6×6 for both mooring modules. A run with no mooring and only a constant −6.084e6 N vertical load at the platform reference point (HydroDyn `AddF0`) reproduces this term, so it comes from ElastoDyn/glue code and not from the mooring module. + - *Linearisation of a line restrained in torsion* + ([`validation/scripts/openfast_lin_torsion.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_torsion.py), + same case): the twist angles of the free nodes and their rates are states, and the platform + rotation turns the torsion frame of the coupled (host-driven) end. A straight, taut 100 m line (`GJ` 5e4 N·m², `Irn` 2 kg·m, 50 + elements, rigid in torsion at both ends) has torsional modes in the eigenvalues of `A` equal + to the lumped chain's `2 √(GJ/Irn)/h sin(nπ/2N)` to 5e-14. They lie −1.6e-4, −6.6e-4 and + −1.5e-3 below the continuum's `nπ/L √(GJ/Irn)`, the discretisation error. The fairlead moment + about the line per unit platform rotation about it, `D − C A⁻¹ B`, is `GJ/L` to 1.5e-14. The + feedthrough `D` alone is the end element's `GJ/lₑ`, fifty times more, which is what the + reduction would give without twist states. The lazy-wave cable of the mixed deck, twisted + 90° and alone (pinned in bending, rigid in torsion, 3470 states), matches the deck's own + static solutions to ≤4.9e-4. These are the moment about the End A director per unit + rotation about it (82.4268 / 82.4263 N·m/rad, from `Pretwist(A) ± 0.5°`), the forces and + that moment per unit fairlead translation, and the forces per unit rotation against the + reciprocal moment row. `tests/test_lin_torsion.f90` repeats the straight-line gates with the + shell's evaluation sequence on the aggregate. It adds the condensed torsion, an elastic + torsional end (`1/(L/GJ + 1/kₜ)`), and the platform's angular rates: `Bt/L` per unit angular + velocity and the held end section's `Irn lₑ/2` per unit angular acceleration. In a + `Linearize = True` run every input Jacobian steps the platform rotation by 1e-4 rad instead of + 0.1 rad. On a straight + line with a 2e5 N·m/rad hang-off spring, this brings the force per unit rotation to 4e-8 of + the static solutions (6.8e-6 with 0.1 rad). The mooring-only A/B compares an all-chain system that both codes model in the same way; the finite-EI cable under coupled motion is compared with OrcaFlex in L4-1c. @@ -801,7 +824,7 @@ stop with a named error. | Correction iterations (`NumCrctn > 0`) | Pass verified | bit-identical to own `NumCrctn = 0` run | | SeaState wave/current kinematics | Pass verified | wave A/B ≤0.16% of range | | Checkpoint-restart (incl. Free/Connect points) | Pass verified | restarted window = continuous run to 0.0; also with supercycling (`dtM` > `DT`, the held SeaState fields and the predictor loads checkpointed): IEA-15 VolturnUS-S, turbulent wind and JONSWAP sea, `openfast -restart` at 50 s reproduces every later OpenFAST and `.CD.out` row of the chain mooring at `dtM` = 4 `DT` (extrapolated and held loads) and `DT`, and of the chain + 248-element power-cable mooring at `dtM` = 2 `DT`. A finite-EI cable also checkpoints its committed boundary (held DOFs, end-connection directions, vessel frame): before, the rebuild took its fairlead from the restored input mesh, which differs in the last bits, and on the IEA-15 mixed deck restarted at 6 s the lazy-wave cable's `.CD.out` channels drifted by up to 9.4e-7 (relative) within 4 s; now all rows to 10 s match bit for bit at `dtM` = `DT` and 2 `DT`, `NumCrctn` 0 and 1, and with a rigid fairlead END CONNECTIONS row | -| Linearisation | Pass verified (line dynamics) | line states as MoorDyn-F's (882 on the UMaine chains); zero-frequency reduction `D − C A⁻¹ B` compared entry by entry with stock MoorDyn's (full-precision `.lin` output): fairlead stiffness ≤0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; lowest nine line-mode frequencies 0.04–0.30%, both state matrices stable; a mixed deck with a lazy-wave power cable (2976 cable states) matches its own static solutions at every coupled point to ≤3.3e-4, also with a hang-off spring ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)) | +| Linearisation | Pass verified (line dynamics) | line states as MoorDyn-F's (882 on the UMaine chains); zero-frequency reduction `D − C A⁻¹ B` compared entry by entry with stock MoorDyn's (full-precision `.lin` output): fairlead stiffness ≤0.10%, transverse `H/X` term 0.29%, platform 6×6 diagonals ≤0.10%; lowest nine line-mode frequencies 0.04–0.30%, both state matrices stable; a mixed deck with a lazy-wave power cable (2976 cable states) matches its own static solutions at every coupled point to ≤3.3e-4, also with a hang-off spring ([`openfast_lin_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_ab.py)); a line restrained in torsion adds its twist angles as states: the straight line's torsional modes equal the lumped chain's to 5e-14 and its roll stiffness `GJ/L` to 1.5e-14, and a twisted lazy wave matches its static solutions to ≤4.9e-4 ([`openfast_lin_torsion.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/openfast_lin_torsion.py)) | | FAST.Farm shared moorings + clumps + channel record | Pass verified | 600 s A/B of the r-test `MD_Shared` farm against stock MoorDyn (same deck, analysis from 100 s; [`fastfarm_shared_ab.py`](https://github.com/SMI-Lab-Inha/CableDyn/blob/main/validation/scripts/fastfarm_shared_ab.py)): tension means ≤0.02%, minima and maxima ≤0.25%, platform motions within millimetres and 0.001°; shared-line tension std 2.2–2.7% lower, 1.0% at half the mooring step (CableDyn's implicit step at the 0.05 s coupling step against MoorDyn's 1e-4 s explicit step). On the shared lines, which have no Fixed end, `FairTen`/`AnchTen` name the opposite ends from MoorDyn's (see the migration guide). MoorDyn's initial settling does not converge for the anchor legs 6 and 7 (2.4 m excess length at t = 0), a start-up transient over by 100 s that most likely set the 3% end of the earlier 60 s record | | Slack-line tension convention | Pass verified | tension-only dynamics; BA on slack lines matches `MoorDyn_Line.f90` | | Farm + restart / Farm + linearisation | Not applicable | FAST.Farm has no restart and does not call module linearisation; the same applies to stock MoorDyn | @@ -1025,11 +1048,64 @@ in parentheses). roll (`GJ (−roll)/l_e`) against the frozen interior. The example `torsion_lazy_wave_hangoff_twist.dat` (Irn of the section) moves by at most 7e-5 of the torque against the condensed torsion. +- **T-14 active line control** (`control_torsion`). The fairlead span (2 of 10 elements) of a + taut straight line between rigid torsional ends 10.1 m apart (EA 1e5 N, GJ 80 N·m², + `Φ = 90°`) is commanded: + - paid out and hauled in by ±0.065 m over 10 s, the line carries `GJ Φ/L(t) + K (H − L)/L` + (condensed 2.8e-16, with `K = 500 N·m` 9.6e-15, nodal twist with `Irn = 1e-9 kg·m` + 1.5e-12; a frozen compliance would miss by 6.5e-3 and 0.23) and the tension + `EA (H − L)/L + K Φ/L` with the axial damping's share to 3.6e-6; + - paid out at 0.01 m/s under `Bt = 100 N·m²·s` with `K`, every element keeps one twist per + length χ and the torque is `GJ χ + Bt χ̇` to 5.8e-6 N·m of its 0.642 N·m damping share + (0.646 N·m off without the length rate); + - on a bowed line the length-rate share of the damping torque equals `Bt l̇0 ∂(τ/l0)/∂l0` by + central differences of the element twist to 1.3e-10 on interior elements, at both rigid + torsional ends (End A the fairlead) and with `K/GJ = 0.5` (the straight-line value is up to + a factor 5 off), and the torque tangent a step assembles matches central differences of the + torque to 1.1e-9, where its length-rate share is 1.6e-3 to 7.6e-3 of it; + - the polar inertia and a `-ζ` damping a command rebuilds equal those of a model built with + the new lengths bit for bit, and a committed-state evaluation, a saved control state and a + snapshot take the committed lengths and terms; + - paid out by 0.5 m under a ringing twist (`Irn = 0.5 kg·m`, `ρ∞ = 1`, centreline held), the + twist and polar kinetic energy change by the work of the length change to 7.8e-5 of it; + - paid out slowly, the run at `ρ∞ = 0.4` follows the one at `ρ∞ = 0` to 1.4e-3 of the + per-step torque change, also with the committed force evaluated afresh each step (taken at + the new lengths it would lag by the expected `α_f = 2/7` of the change; an ablation of the + committed lengths measured 0.289); + - restarts mid-ramp from a snapshot, from the checkpoint mirror with the command re-applied, + and of a `CONTROL` deck on the coupled aggregate (whose `Torq1N1` follows `GJ Twist1/L(t)` + to 6e-11) continue bit-identically; after a non-stepping frame write the snapshot and the + checkpoint mirror bring back the committed torque bit for bit (re-derived as `(Φ − Θ)/C` it + would differ by 1.8e-15 N·m). +- **T-15 modal analysis with torsion** (`modal_torsion`, `modal_torsion_deck`, + `driver_cli_torsion_nmodes`). The modes carry the twist angle of every node. On the 10 m line + (EI 100 N·m², GJ 80 N·m², EA 1e4 N, T 10 N, 40 elements), clamped: + - rigid torsional ends, `Irn = 0.04 kg·m`: the torsional modes are the lumped chain's to 1e-16 + and `nπ/L √(GJ/Irn)` within the chain's own `1 − sin(x)/x` (2.6e-4, 1.0e-3); the bending and + axial modes equal those of the line without torsion bit for bit, with no twist; + - elastic torsional ends `k = 2 GJ/L`: the continuum's `tan(βL) = 2kGJβ/((GJβ)² − k²)` to + 1.5e-4, the lumped chain to 4e-14; + - torque–tension coupling `K = 300 N·m`: the coupled axial–torsional modes + `ω² = (nπ/L)² eig([[EA, K], [K, GJ]], diag(m, Irn))` within the chain's error (≤ 8.6e-4); + - under a torque `M = 4 EI/L` with a negligible `Irn = 1e-6 kg·m` (100 elements), the four + lowest lateral pairs match the clamped Greenhill-cable determinant + (`EI u'''' − i M u''' − T u'' = m ω² u`) to 3.2e-7, 5.5 % to 1.2 % below the untwisted ones. + + On a bowed, twisted 12-element line (pinned and clamped bending ends, rigid and elastic + torsional ends, coupling) the Schur complement of the angles equals the condensed static + tangent to 1.4e-16 and the central differences of the condensed static residual to 7.6e-10. + The modal route without the twist finds no torsional mode, misses the torque (4e-4 to 4e-3 + of the tangent) and, ignoring the end connections, puts the clamped line's first lateral + frequency 41 % low; finite bending springs at both ends now put it between the pinned and + the clamped line's, within 3.6e-5 of the clamp at `k = 1e5 EI/L`. In the deck the same + straight line's torsional modes and its bending and axial modes against `TorsStiffness Free` + hold to the table's nine digits, turned 30° about +z it keeps its frequencies and writes its + positions in the deck's axes, and the lazy wave twisted two turns writes its modes. - **Backward compatibility and refusals** (`torsion_deck`, full suite). Without torsion columns, with `Free` columns (whatever their normal), or with one restrained end, every output is byte-identical to the 6-column deck, and `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` give the same run. Malformed rows, a missing `GJ`, an `EI = 0` line, a rod end, a `Point3` body, - `ATTACHMENTS`, modal analysis, the configuration blend (also on the coupled entries), misuse of + `ATTACHMENTS`, the configuration blend (also on the coupled entries), misuse of the roll column, channels on an unrestrained line, a coupled caller that passes no orientation (the C API) and a standalone mixed `EI = 0` + finite-EI deck without a body stop with named errors. diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 77f203d5..a1ba6767 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -93,15 +93,15 @@ Line and constitutive capability torsional damping (``GJ|K|Bt``), with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm - runs (torque returned to the platform, ``PtfmInit``, checkpoints; see - :doc:`openfast`) and through the C API with the host's rotations - (``CableDyn_InitDeckRotating``, :doc:`capi`); ``Torq``/``Twist`` channels and standalone - range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI aggregate and - ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by translation only), - OpenFAST linearisation of a line restrained in torsion, - rod ends, bodies other than Rigid6, modal analysis, and - ``False alpha_force_blend``. Not modelled: seabed friction against twist, anisotropic - sections, self-contact of a loop (see :ref:`theory-torsion`) + runs (torque returned to the platform, ``PtfmInit``, checkpoints, linearisation with the + twist angles as states; see :doc:`openfast`) and through the C API with the host's + rotations (``CableDyn_InitDeckRotating``, :doc:`capi`), active line control + (``CONTROL``) of the fairlead segment on the coupled route; ``Torq``/``Twist`` channels and + standalone range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI + aggregate and ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by + translation only), rod ends, bodies other than Rigid6 and ``False alpha_force_blend``. + Modal analysis carries the twist angle of every node. Not modelled: seabed friction + against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws - Not provided - the buckling onset and the post-buckled shape are computed, but a loop that closes on @@ -121,8 +121,9 @@ Line and constitutive capability * - Modal analysis (``nModes``) - Standalone only - natural frequencies and mode shapes of each line about its static equilibrium (all - ``EI = 0`` lines, or all finite-EI lines on the Hermite route; flat seabed); a deck with - torsion is rejected + ``EI = 0`` lines, or all finite-EI lines on the Hermite route with their end connections + and attachments; flat seabed); a line restrained in torsion adds the twist angle of every + node, so its torsional modes and the torque's effect on the others appear * - Cross-flow VIV (LINE TYPES ``Cl``, ``dF``, ``cF``) - Standalone and coupled - MoorDyn v2's synchronisation model on ``EI = 0`` lines and, as a distributed lift, on @@ -217,7 +218,7 @@ OpenFAST coverage The ``CompMooring = 5`` shell covers normal coupled time-domain stepping with its own ``dtM``, nonzero ``PtfmInit``, correction iterations, SeaState fields, checkpoint/restart, scoped -quasi-static ``dYdu`` linearisation, line failures, active-tension control of ``EI = 0`` lines +linearisation with the line dynamics, line failures, active-tension control of ``EI = 0`` lines (linear-elastic, viscoelastic or Syrope segments) and finite-EI cables, and FAST.Farm shared moorings. Restart and linearisation do not arise under FAST.Farm, which does not call those module operations, and active-tension control is rejected diff --git a/doc/coupling.rst b/doc/coupling.rst index 5ce5b2f1..a5097995 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -27,7 +27,8 @@ angle convention visible directly in an OpenFAST run log. The module covers Moor integration surface: coupled time-domain analysis at a 0.1 s CableDyn step by default (with deck ``dtM`` control), a nonzero initial platform displacement (``PtfmInit``), glue correction iterations (``NumCrctn > 0``), SeaState wave/current kinematics on the moorings and finite-EI cables, -checkpoint-restart, quasi-static linearisation (``dYdu``), FAST.Farm farm-level shared moorings +checkpoint-restart, linearisation with the line dynamics (the line, cable and twist states, as +MoorDyn-F's; see :doc:`openfast`), FAST.Farm farm-level shared moorings (``Mod_SharedMooring = 5``), coupled ``Rigid6`` 6-DOF rigid bodies (buoyancy, ``C33``/``C44``/``C55`` hydrostatic restoring, restart state, and SeaState drag / Froude-Krylov / added-mass), including MoorDyn-F's coupled pinned bodies (``CoupledPinned``, force only), coupled @@ -36,12 +37,14 @@ coupled rigid rods with host-driven endpoints, correction rewind, checkpoint sta Gauss SeaState sampling, including MoorDyn-F's coupled pinned rods (``CoupledPinned``, force only) and rods pinned to a fixed point. -The input/output Jacobian has two deliberately different contracts. During an ordinary nonlinear -OpenFAST run, CableDyn returns the partial direct-feedthrough derivative at fixed committed internal -state, which is the derivative required by OpenFAST's algebraic input/output solve. During formal -linearisation, where CableDyn exposes a zero-state quasi-static representation, it instead returns -the re-equilibrated zero-frequency mooring stiffness. Substituting the latter into the runtime glue -solve is mathematically incorrect; changing ``NumCrctn`` does not change that derivative contract. +The input/output Jacobian is a partial derivative in both kinds of run. During an ordinary +nonlinear OpenFAST run, CableDyn returns the direct-feedthrough derivative at fixed committed +internal state, which is the derivative OpenFAST's algebraic input/output solve requires. During +formal linearisation (``Linearize = True``) the line and cable degrees of freedom, and the twist +angles of a line restrained in torsion, are continuous states, and ``A``, ``B``, ``C`` and ``D`` +are partial derivatives of the line dynamics at the operating point; the static mooring stiffness +is their zero-frequency reduction ``D − C A⁻¹ B``, not a derivative CableDyn returns. Changing +``NumCrctn`` does not change either contract. .. admonition:: Remaining integration surface :class: warning diff --git a/doc/coupling_boundary.md b/doc/coupling_boundary.md index 666c336d..d2276308 100644 --- a/doc/coupling_boundary.md +++ b/doc/coupling_boundary.md @@ -59,10 +59,12 @@ contributions. The `eps_fd` argument must be non-negative and does not affect th call leaves the handle at the supplied operating point; a caller that needs its previous state must save and restore it. -**Two derivative contracts in OpenFAST.** During a nonlinear OpenFAST run the shell returns the +**Derivatives in OpenFAST.** During a nonlinear OpenFAST run the shell returns the direct-feedthrough derivative at fixed committed internal state, which the host's input–output -solve requires. During linearisation it returns the re-equilibrated zero-frequency mooring -stiffness. The two are not interchangeable. +solve requires. During linearisation the line and cable degrees of freedom (with the twist angles +of a line restrained in torsion) are continuous states and the shell returns the partial +derivatives `A`, `B`, `C`, `D` of the line dynamics; the static mooring stiffness is their +zero-frequency reduction `D − C A⁻¹ B` (see [OpenFAST](openfast.rst)). ## Cadence @@ -126,7 +128,7 @@ point mesh. It supports: - nonzero `PtfmInit` and correction iterations; - checkpoint/restart, with continuous states (including constitutive and rigid-body states) stored in the OpenFAST state record; -- quasi-static linearisation; +- linearisation with the line dynamics (line, cable and twist states, as MoorDyn-F's); - FAST.Farm shared moorings; - line failures, and active tension control of `EI = 0` lines and finite-EI cables; - WaterKin files with independent selection of host wave and host current. SeaState's standard diff --git a/doc/driver_format.md b/doc/driver_format.md index a9890723..22872dd0 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -274,8 +274,9 @@ cable or wire rope (`T = EA ε + K τ`, `M = GJ τ + K ε`; see `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 -`l0 √(GJ Irn)` on the final mesh, as `BA` is for the axial damping. It needs a finite-EI type; -`GJ|0|Bt` is damping without coupling. +`l0 √(GJ Irn)` on the final mesh, as `BA` is for the axial damping (an element whose length +active line control changes keeps its `ζ`). It needs a finite-EI type; `GJ|0|Bt` is damping +without coupling. **Viscoelastic axial stiffness (MoorDyn `ElasticMod`).** The EA and BA columns accept bar-separated parts: @@ -811,8 +812,8 @@ Behaviour: - Connection moments are included in the OpenFAST coupled-load mesh. Rows on an `EI = 0` line, duplicate rows, unknown line ids, null directions, negative stiffnesses, -and non-finite values fail deck validation. OpenFAST linearisation with a platform-relative end -connection is rejected at initialisation. +and non-finite values fail deck validation. OpenFAST linearisation with a `Rigid` end connection +is rejected at initialisation. #### Torsion columns @@ -876,14 +877,15 @@ Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B `Body` point; in a coupled OpenFAST or FAST.Farm run the End A frame turns with the platform (see the manual's OpenFAST page, Line torsion). Each of the following stops with a named error: torsion on an `EI = 0` line, on a rod end or on a `Point3` body, -modal analysis (`nModes`), a dynamic or coupled run with `False alpha_force_blend`, any +a dynamic or coupled run with `False alpha_force_blend`, any restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines without a body or through the C API's `CableDyn_InitDeck`/`InitDeckAt`, which move the line ends by translation only (`a line restrained in torsion needs a host that turns its fairlead frame ...`; with a body such a deck runs on the multibody route, which supports torsion, and a C -API host passes its rotations after `CableDyn_InitDeckRotating`), OpenFAST linearisation of a line -restrained in torsion, and a `Torq`/`Twist` channel on a line that is not restrained at both -ends. Seabed friction does not resist twist (the laid part of a line twists freely), and there +API host passes its rotations after `CableDyn_InitDeckRotating`), and a `Torq`/`Twist` channel +on a line that is not restrained at both ends. OpenFAST linearisation includes the twist angles +as states; like any cable, the line must not have a `Rigid` bending connection there. Seabed +friction does not resist twist (the laid part of a line twists freely), and there is no torque–tension coupling. ### EQUIVALENT BUOYANCY (optional) @@ -1142,8 +1144,14 @@ bounds that would make it zero or negative (possible when it is shorter than hal the bounds above, a cable of one section scales each element within [0.5, 2] of its initial length; on a cable of several sections the scaling can leave that range, beyond the resolution its static mesh was built for, so keep large commands on a fairlead section whose - segments are at least `UnstrLen`/N long. A cable restrained in torsion cannot be controlled - (the coupled route rejects torsion stiffness in END CONNECTIONS). + segments are at least `UnstrLen`/N long. +- On a cable restrained in torsion at both ends the torsion follows the lengths too: the line's + torsional compliance, the elements' torsional stiffness `GJ`/l and damping `Bt`/l, the + torque–tension coupling and the polar inertia `Irn` l/2 at the nodes take the new lengths, a + torsional damping written as `-ζ` keeps its `ζ` (`Bt` = ζ l √(GJ `Irn`) at the new length; a + positive `Bt` stays), and the damping acts on the rate of the twist per unit length, so a + segment paid out at constant twist per length carries no damping torque. A haul-in raises the + torque of a fixed end-to-end twist as `GJ` Twist/L does. The host input arrays are sized to the highest channel id. @@ -1197,7 +1205,7 @@ syntax form. The most frequently edited keywords are: | `WaveDirections` | direction bins of a spread train | 9 | | `WaveComponents` | frequency components per train and direction (at least 2) | 200 | | `StreamOrder` | Fourier terms of a `stream` wave: 0 (default, 20) or 2 to 60 | 0 | -| `nModes` | modal analysis: the N lowest natural frequencies and mode shapes of every line about its static equilibrium, written to `.modes.out` (EI = 0 decks, or finite-EI decks on the Hermite route; flat seabed; 0 = off) | 0 | +| `nModes` | modal analysis: the N lowest natural frequencies and mode shapes of every line about its static equilibrium, written to `.modes.out` (EI = 0 decks, or finite-EI decks on the Hermite route, where a line restrained in torsion adds the twist angle of every node; flat seabed; 0 = off) | 0 | | `WaveSeed` | integer from 1 to 2147483646; seed of the random spectral sea (the same seed gives the same sea on every platform; train *i* uses seed + 7919 (*i* − 1)) | 1 | | `rampTime` | half-cosine start-up ramp of the wave amplitudes [s]; the current is not ramped. `0` disables it | 0 | | `motionFile` | path to a prescribed-motion time series for `Coupled`/`Vessel` points, rod end rows, and prescribed Rigid6 `Body` points; `0` or `none` disables it | — | diff --git a/doc/openfast.rst b/doc/openfast.rst index cad5ffc3..3ba7a555 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -267,10 +267,9 @@ channels ``AnchFz``, ``AnchFH`` and ``TDPGrd``) and units are in :doc:` - CableDyn-owned, always written: the static-equilibrium profile of every line, one row per node (arc length, coordinates, effective tension, curvature, bend moment, declination, inclination, azimuth) — the coupled range graph, at the state of the printed line summary - * - ``.CD.rst.dat``, ``.CD.lin.dat`` - - temporary CableDyn-owned copies of the deck, written in the ``MooringFile`` folder only - when a run restarts from a checkpoint or linearises (see *Lifecycle features*), and - removed after use + * - ``.CD.rst.dat`` + - temporary CableDyn-owned copy of the deck, written in the ``MooringFile`` folder only + when a run restarts from a checkpoint (see *Lifecycle features*), and removed after use With ``WrVTK > 0`` OpenFAST writes its VTK visualisation files as usual, but CableDyn provides no mooring or cable meshes to them, and says so at initialisation: the lines do not appear in the @@ -344,11 +343,11 @@ step the line may turn by more than 90° about its end direction, because the st substeps; an output probe moves the frame without a step, is limited to 90° from the committed twist, and stops by name beyond it (a restart first restores the checkpoint's twist, so it is not limited this way). Formal -linearisation of a line restrained in torsion fails during initialisation: the torque's -rotational stiffness has no column in the translation-only quasi-static reduction. The C API's -``CableDyn_InitDeck``/``InitDeckAt`` and the standalone deck that mixes ``EI = 0`` and finite-EI -lines without a body move the line ends by translation only and refuse torsion columns; a C API -host that initialises with ``CableDyn_InitDeckRotating`` passes its rotations (:doc:`capi`). +linearisation takes the line's twist angles as states and the platform rotation as an input +(see `Linearisation`_). The C API's ``CableDyn_InitDeck``/``InitDeckAt`` and the standalone +deck that mixes ``EI = 0`` and finite-EI lines without a body move the line ends by translation +only and refuse torsion columns; a C API host that initialises with +``CableDyn_InitDeckRotating`` passes its rotations (:doc:`capi`). Lifecycle features ------------------ @@ -365,18 +364,13 @@ without an auxiliary process: temporary deck copy, ``.CD.rst.dat``, beside the ``MooringFile``, rebuilds the model from it and removes it; files the deck names (``bathymetryFile``, a WaterKin file, Syrope tables) resolve against the ``MooringFile`` folder as in the original run. Keep restart files with the exact executable and complete input set. -* **Linearisation** publishes the quasi-static mooring load derivative at a committed boundary. - It rebuilds the model from a temporary deck copy, ``.CD.lin.dat``, written beside the - ``MooringFile`` and removed after use, so side files resolve as on restart. Set ``dtM = DT`` and linearise at the initial - operating point (``CalcSteady = False``, +* **Linearisation** differentiates the line dynamics at the committed state (`Linearisation`_). + Set ``dtM = DT`` and linearise at the initial operating point (``CalcSteady = False``, ``LinTimes = 0``, platform at its still-water equilibrium, rotor speed and pitch at their steady values). Contact switching makes derivatives near touchdown non-smooth. OpenFAST writes the ``.lin`` matrices in the ``.fst`` ``OutFmt``; to compare them with MoorDyn's ``D - C A^-1 B``, use a full-precision format such as ``"ES24.15E3"``, because the usual - 4-digit format cannot resolve that reduction. A deck with - Rigid6 bodies, rods or ``Point3`` buoys is rejected at initialisation: the quasi-static - reduction would hold them at their deck pose instead of re-solving their equilibrium (a - ``Free`` point with the buoy's ``Mass``, ``Vol``, ``CdA`` and ``Ca`` is re-solved). + 4-digit format cannot resolve that reduction. * **FAST.Farm** selects CableDyn with ``Mod_SharedMooring = 5`` for shared lines and connections. Gravity, water density, depth, and ``TMax`` are host-owned and must agree across turbines, otherwise initialisation fails. @@ -388,7 +382,8 @@ without an auxiliary process: (:doc:`driver_format`, CONTROL). A viscoelastic or Syrope polyester segment carries its slow stretch over the length change, as MoorDyn-F and MoorDyn-C do. On a finite-EI cable the command scales every cable element - of that segment, and needs the force-blended generalised-α (the default). On both kinds a + of that segment, and needs the force-blended generalised-α (the default); on a cable + restrained in torsion the torsion follows the new lengths (:ref:`theory-torsion`). On both kinds a command outside MoorDyn-F's bounds, from minus half to plus one ``UnstrLen``/N of the line (the controlled segment's initial length on a line of one section), stops the run with a message that names the line, as it stops MoorDyn-F; so does a command that would make the @@ -453,6 +448,22 @@ Positions, tangents and coupled-point displacements are stepped by 1 µm, which seabed penetration of a light cable and the stretch of every taut element. Velocities are stepped by 0.1 m/s, MoorDyn-F's step. +A line restrained in torsion adds the twist angle of every node that its end frames do not hold +(all nodes but a torsionally ``Rigid`` end), after the cables' positions and tangents, and their +rates after the cables' velocities: ``Cable 1 node 2 twist, rad`` and ``Cable 1 node 2 twist +rate, rad/s``. The angles' accelerations come from the same evaluation as the cable's, with their +polar inertia ``Irn``. The coupled point's orientation turns the torsion frame of the line's +coupled (host-driven) end, so a platform rotation twists the line; the point's angular velocity and +acceleration turn that frame too, for the torsional damping ``Bt`` and the held end section's polar +inertia. The fairlead moment carries the torque. Angles are stepped by 1 µrad, as positions, and +their rates by 0.01 rad/s (they enter only the linear damping). In a ``Linearize = True`` run the +coupled-point rotation is stepped by 1e-4 rad, also in the input Jacobians of the time march +before the linearisation times (a rotation moves no node, so no contact or slack limits it, and the +turn of an end frame or connection direction is nonlinear); a run without linearisation keeps +0.1 rad. The ``.lin`` operating-point outputs are those of the committed step; at a settled +operating point, such as the still-water start, they lie on the linearised surface, while at a +moving one the accelerations and the end-frame rates of the last step enter them. + The zero-frequency reduction ``D − C A⁻¹ B`` is the static mooring stiffness. It agrees with MoorDyn-F and with CableDyn's own static solutions (:doc:`validation`). Quadratic drag has no slope at rest, so the 0.1 m/s step gives its equivalent linear damping at that velocity amplitude. @@ -469,9 +480,9 @@ stick anchors (a stuck laid run). Linearise from a settled operating point, such start at ``t = 0``. Initialisation fails with a named message for Free and Connect points, Point3 buoys, Rigid6 bodies -and rods, a line restrained in torsion, a line with VIV (``Cl > 0``: it oscillates about a lock-in -cycle, not an equilibrium), a ``CONTROL`` section, a cable with a ``Rigid`` end connection, and -FAST.Farm. Their states are not linearisation states. Time-domain runs support all of them. +and rods, a line with VIV (``Cl > 0``: it oscillates about a lock-in cycle, not an equilibrium), a +``CONTROL`` section, a cable with a ``Rigid`` end connection, and FAST.Farm. Their states are not +linearisation states. Time-domain runs support all of them. Performance ----------- diff --git a/doc/options.rst b/doc/options.rst index 90482631..63fe7acf 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -614,9 +614,9 @@ Ambient fluid and prescribed motion 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 lines stops with ``OPTION nModes is not supported for mixed EI=0/finite-EI decks; - remove it or set it to 0``; a deck with a torsional line stops with ``modal analysis - (OPTION nModes) of a line with torsion is not yet supported``. The banded solver has no - line-length limit: a + 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 + no line-length limit: a 1024-element finite-EI cable takes a few seconds. See :doc:`theory` - standalone - ``10 nModes`` diff --git a/doc/outputs.rst b/doc/outputs.rst index 31dc068e..eda174c4 100644 --- a/doc/outputs.rst +++ b/doc/outputs.rst @@ -456,6 +456,21 @@ row: scaled so that the largest nodal displacement of the mode is 1. Nodes are numbered End A first, as in the other line files; the held end nodes have zero displacement. +When a line is restrained in torsion (both ends, see :doc:`driver_format`), its modes carry the +twist angle of every node (:ref:`nodal twist `) and both tables gain a +column, for every line of the file (``0`` on a line without torsion): + +* ``PolarShare`` (frequency table): the polar share of the mode's kinetic energy, + :math:`\sum_k I_k \varphi_k^2` of the mass-normalised mode with :math:`I_k` the lumped polar + inertia, 1 for a pure torsional mode and 0 for one without twist; +* ``dTwist`` (shape table): the rotation of the node's section about the line tangent, + positive right-handed about the direction from End A to End B, End A being the reader's + (the fairlead on a deck written anchor-first, as in the other line files). Like ``dX dY dZ`` + it is a normalised shape value, marked ``(-)``: the mode is scaled so that its largest nodal + displacement is 1, and ``dTwist`` is then in rad per metre of that displacement; a torsional + mode (``PolarShare`` above 0.5) is scaled to a unit largest ``dTwist`` instead, and its + translations are then in metres per radian of that twist. + Per-rod files (``RODS`` ``Outputs`` flag) ----------------------------------------- @@ -985,10 +1000,10 @@ output root: selected * - ``.FarmCD.static.out`` / ``.FarmCD.out`` - the same two files for a FAST.Farm run, named from the FAST.Farm output root - * - ``.CD.rst.dat`` / ``.CD.lin.dat`` - - temporary copies of the CableDyn deck, written in the ``MooringFile`` folder when a run - restarts from a checkpoint or linearises; the module rebuilds its model from them and - removes them after use (see :doc:`openfast`) + * - ``.CD.rst.dat`` + - temporary copy of the CableDyn deck, written in the ``MooringFile`` folder when a run + restarts from a checkpoint; the module rebuilds its model from it and removes it after use + (see :doc:`openfast`) ``.CD.out`` layout — note that it differs from the standalone ``.out``: diff --git a/doc/theory.rst b/doc/theory.rst index f1098f58..fd9f148b 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -559,6 +559,47 @@ between steps (the direct feedthrough) twists the end element against the frozen the end's translation stretches it. The node torque (``TorqN``) is the mean of its two elements', and the material twists of the elements sum to the twist channels. +**Active line control.** A length command on a controlled element (see Active line control +below) changes every torsion term that reads :math:`L_0`: the condensed compliance +:math:`C = \sum_e L_{0,e}/GJ_e + 1/k_1 + 1/k_2`, the element stiffness :math:`GJ/L_0` and damping +:math:`B_t/L_0` of the nodal twist, the coupling term :math:`(K/GJ)(l - L_0)` and, through the +Hermite interpolant, the element holonomy. Each is evaluated with the lengths of its time level, +as the rest of the residual: the committed force with the lengths the committed state was reached +with, the step's force with the new ones. The lumped polar inertia :math:`I_{rn} L_0/2` is rebuilt +with the consistent mass (its rate term is not modelled either), and a torsional damping written +as :math:`-\zeta` is resolved again at the new length, :math:`B_t = \zeta L_0 \sqrt{GJ I_{rn}}`, so +the element keeps its fraction of critical damping; a positive :math:`B_t` is a section property +and stays (the axial ``BA`` keeps its initial resolution, as in MoorDyn). The torsional damping +takes the rate of the twist per unit length :math:`\hat\tau/L_0` that the elastic torque reads, as +the axial damping takes the rate of the strain: + +.. math:: + + M_e = \frac{GJ_e}{L_{0,e}}\,\hat\tau_e + B_{t,e}\,\frac{d}{dt}\frac{\hat\tau_e}{L_{0,e}} + = \frac{GJ_e}{L_{0,e}}\,\hat\tau_e + \frac{B_{t,e}}{L_{0,e}} + \Big(\dot{\hat\tau}_e - \hat\tau_e\,\frac{\dot L_{0,e}}{L_{0,e}}\Big) . + +At fixed :math:`\mathbf{q}` the twist changes with :math:`L_0` through the coupling term and the +element's shape. Write :math:`\mathbf{a}_1, \mathbf{a}_2` for the tangent DOFs of the element's two +nodes (the nodal :math:`\mathbf{m} = d\mathbf{r}/ds`). The reference twist :math:`m_e` depends on +them only through :math:`L_0\mathbf{a}_i` (the Hermite :math:`\mathbf{r}'` and +:math:`\mathbf{r}''`) and :math:`\mathbf{a}_i/|\mathbf{a}_i|`, and the stretched length +:math:`l_e` only through :math:`L_0\mathbf{a}_i`, so with :math:`c_e = K_e/GJ_e` +:math:`L_0\,\partial(m_e + c_e l_e)/\partial L_0 = \sum_i \mathbf{a}_i\cdot\partial(m_e + c_e +l_e)/\partial\mathbf{a}_i`, and + +.. math:: + + \dot{\hat\tau}_e = \dot\varphi_{k+1} - \dot\varphi_k + \nabla\hat\tau_e\cdot\dot{\mathbf{q}} + + \frac{\dot L_{0,e}}{L_{0,e}}\Big(\mathbf{a}_1\cdot\frac{\partial\hat\tau_e}{\partial\mathbf{a}_1} + + \mathbf{a}_2\cdot\frac{\partial\hat\tau_e}{\partial\mathbf{a}_2} - c_e L_{0,e}\Big) , + +with the matching tangent terms. A segment paid out at a constant twist per length carries no +damping torque. The test suite checks the quasi-static torque :math:`GJ\Phi/L(t) + K(H - L)/L` of a +taut line paid out and hauled in (condensed and nodal twist), the Kelvin–Voigt torque of a constant +pay-out, the length-rate term against finite differences on a bowed line, the energy a length +change puts into a ringing twist, and that the step does not lag at :math:`\alpha_f > 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 anisotropic or pre-twisted section, and no self-contact: a loop that @@ -1788,6 +1829,42 @@ tension :math:`H`, and the symmetric in-plane modes satisfy with :math:`\lambda^2 = (wL/H)^2\,L/(H L_e/EA)` (:ref:`Irvine & Caughey, 1974 `); the modal analysis reproduces both. +A finite-EI line's modes carry what its dynamics carries: an end connection's spring adds its +Hessian on the end tangent, a rigid end keeps only the magnitude of its tangent (the two +transverse components of its basis are held), and discrete attachments add their dry and added +masses. A line restrained in torsion carries the :ref:`nodal twist ` in its +dynamics, so its modes do too: the twist angle :math:`\varphi_k` of every node joins the +degrees of freedom, :math:`[\mathbf r, \mathbf m, \varphi]` per node (half-bandwidth 13), with +the lumped polar inertia :math:`I_k` as its mass and the second variation of the twist energy +:math:`E_t = \sum_e \tfrac12 (GJ_e/L_{0,e})\,\hat\tau_e^2` (and of the elastic end springs) as +its stiffness, at the static element torques :math:`M_e = (GJ_e/L_{0,e})\,\hat\tau_e`. With +element :math:`e` between nodes :math:`k` and :math:`k+1` and its full twist +:math:`\hat\tau_e = \varphi_{k+1} - \varphi_k + \rho_e(\mathbf q)`, +:math:`\rho_e = m_e + (K_e/GJ_e)(l_e - L_{0,e})`, + +.. math:: + + \frac{\partial^2 E_t}{\partial\mathbf q^2} = \sum_e \Big( M_e\,\frac{\partial^2 \rho_e}{\partial\mathbf q^2} + + \frac{GJ_e}{L_{0,e}}\,\mathbf g_e\mathbf g_e^{\mathsf T} \Big), \qquad + \frac{\partial^2 E_t}{\partial\varphi_{k+1}\,\partial\mathbf q}\Big|_e + = -\frac{\partial^2 E_t}{\partial\varphi_k\,\partial\mathbf q}\Big|_e = \frac{GJ_e}{L_{0,e}}\,\mathbf g_e, + \qquad \mathbf g_e = \frac{\partial\rho_e}{\partial\mathbf q} , + +the second term summed over the two elements that share a node; under torque–tension coupling +:math:`\partial^2\rho_e/\partial\mathbf q^2` holds :math:`(K_e/GJ_e)\,\partial^2 l_e/\partial\mathbf q^2`. + +The torque term lowers the bending frequencies of a twisted line, as on Greenhill's twisted +shaft; :math:`\mathbf g_e` couples the twist to the bending of a curved line and, under +torque–tension coupling, to the stretch. Eliminating the angles (no polar inertia) leaves the +condensed tangent of the statics, :math:`-M_t\,\partial^2\Theta/\partial\mathbf q^2 + +\nabla\Theta\,\nabla\Theta^{\mathsf T}/C`: the Schur complement of the angle block is the +rank-one term the statics carry in a bordered solve, which a band cannot hold. Damping (also +:math:`B_t`) is left out. The test suite checks the torsional modes of a clamped straight line +against :math:`\omega_n = (n\pi/L)\sqrt{GJ/I_{rn}}` and its lumped chain, elastic torsional +ends, the coupled axial–torsional modes of :math:`K`, the lateral modes of a taut line under a +torque against the clamped Greenhill-cable determinant, and the Schur complement against the +condensed static tangent (see :doc:`validation`). + Time integration ---------------- @@ -2869,7 +2946,8 @@ the end-position part, and a segment paid out at constant strain carries no damping force. The position Jacobian of the damping force gains :math:`-BA\, H'_a H'_b\, (\dot L_0/L_0^2)\, \mathbf{t}\mathbf{t}^\mathsf{T}` on -the end-position columns. +the end-position columns. On a cable restrained in torsion the torsion follows the lengths in the +same way (:ref:`theory-torsion`, Active line control). Tension and coupled loads ------------------------- diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index b9bb2e23..b69874b5 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -403,9 +403,6 @@ Torsion ``CableDyn_InitDeckRotating`` and pass the host's rotations, add a body (such a deck runs on the multibody route, which supports torsion), or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. - * - ``formal OpenFAST linearization of a line restrained in torsion is not supported`` - - linearise the model with ``TorsStiffness Free``; the twist and the torque carry no - linearisation state. * - ``torsion: the twist would move more than pi/2 from its committed value`` - the host turned a fairlead by more than 90° about the line's end direction without a step (an output probe or a non-stepping input update). Keep the platform turn per @@ -414,9 +411,8 @@ Torsion after 6 step halvings`` - the body turns faster than one step can follow the twist; reduce ``dtM``. * - ``torsion in a dynamic run needs the force-blended generalised-alpha (OPTION - alpha_force_blend True)`` / ``modal analysis (OPTION nModes) of a line with torsion is not - yet supported`` - - remove ``False alpha_force_blend`` or ``nModes`` from a deck with torsion. + alpha_force_blend True)`` + - remove ``False alpha_force_blend`` from a deck with torsion. * - ``OUTPUT "Torq...": line is not torsionally restrained at both ends ..., so it carries no torque`` - a ``Torq``/``Twist`` channel needs a line with a torsional restraint at both ends. diff --git a/examples/torsion_lazy_wave_hangoff_twist.dat b/examples/torsion_lazy_wave_hangoff_twist.dat index b2046ccf..0d505f71 100644 --- a/examples/torsion_lazy_wave_hangoff_twist.dat +++ b/examples/torsion_lazy_wave_hangoff_twist.dat @@ -7,8 +7,9 @@ Lozon Gulf of Mexico 80 m lazy-wave power cable twisted two turns at the hang-of -- carries no torque. The motionFile holds the hang-off in place and rolls its frame about the line from 0 -- to -720 deg over 60 s (roll column, smooth start), which imposes two turns of twist -- (Phi = Pretwist B - Pretwist A - roll = +720 deg); the cable then holds the twist for 30 s. --- Torsion is quasi-static (no torsional inertia): Torq1N1 follows the imposed twist, less the --- part the cable absorbs by writhing out of its plane (Twist1 = Phi - Theta). +-- The dynamics carry a twist angle at every node with the polar inertia Irn; the roll is slow +-- against the torsional modes, so Torq1N1 follows the imposed twist, less the part the cable +-- absorbs by writhing out of its plane (Twist1 = Phi - Theta). --------------------- LINE TYPES --------------------------------------------- TypeName Diam MassDenInAir EA BA EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t (-) (m) (kg/m) (N) (-) (N-m2) (N) (N-m2) (kg-m) (kg-m) (-) (-) (-) (-) diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 474539f4..631d1f33 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -4294,11 +4294,11 @@ def _check_torsion_lines( solved as without the columns. Restrained at both ends, torsion is solved: End B must be Fixed, every section type needs an explicit GJ > 0, no ATTACHMENTS, End A neither a rod end nor on a body other than Rigid6. A deck with torsion runs dynamics only with - the force-blended generalised-alpha (a coupled run is always dynamic) and takes no - modal analysis. A standalone mixed EI = 0 + finite-EI deck without bodies - (``aggregate_route``, run on the aggregate, which moves the line ends by translation - only) refuses any torsion column, one restrained end included; the coupled OpenFAST - and FAST.Farm routes turn the fairlead frame with the platform and accept it. + the force-blended generalised-alpha (a coupled run is always dynamic); its modal + analysis (nModes) carries the twist. A standalone mixed EI = 0 + finite-EI deck + without bodies (``aggregate_route``, run on the aggregate, which moves the line ends by + translation only) refuses any torsion column, one restrained end included; the coupled + OpenFAST and FAST.Farm routes turn the fairlead frame with the platform and accept it. """ # _check_attachments has already accepted every LineID as an integer torsion_lines: set[str] = set() @@ -4379,12 +4379,6 @@ def _check_torsion_lines( f"{self._label}: torsion in a dynamic run needs the force-blended " "generalised-alpha (OPTION alpha_force_blend True)" ) - modes_row = option_by_key.get("n_modes") - if modes_row is not None and round(_native_float(modes_row.values[0])) > 0: - raise DeckFormatError( - f"{self._label}: modal analysis (OPTION nModes) of a line with torsion is not " - "yet supported" - ) return torsion_lines def _line_type_fields(self, record: DeckRecord) -> tuple[str, ...]: diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 1d55158f..f481cd63 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -996,13 +996,13 @@ def test_torsion_line_rules_follow_the_native_checks(): one_end = _edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n")) _rejects(one_end, "is not torsionally restrained at both ends") DeckFile.from_text(_edit(one_end, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"))) - # the dynamic run needs the force blend; modal analysis refuses torsion + # the dynamic run needs the force blend; modal analysis carries the twist dynamic = _edit(_TORSION, ("0.0 TMax\n", "10.0 TMax\n")) DeckFile.from_text(dynamic) _rejects( _options(dynamic, "False alpha_force_blend"), "needs the force-blended generalised-alpha" ) - _rejects(_options(_TORSION, "3 nModes"), "modal analysis .* with torsion is not yet supported") + DeckFile.from_text(_options(_TORSION, "3 nModes")) # the coupled OpenFAST and FAST.Farm routes turn the fairlead frame with the platform and # accept torsion, one restrained end included; a coupled run is always dynamic, so it # needs the force blend whatever the deck's TMax diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index b922d085..57a4214e 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -113,7 +113,7 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension, & CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & - CD_HTORS_MAX_TWIST + CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID USE CableDyn_Vessel, ONLY: CD_VesselRAOType, CD_Vessel_Euler_DCM, CD_Vessel_Euler_Angular, & CD_Vessel_Point_Kinematics, CD_Vessel_RAO_Set, CD_Vessel_RAO_Eval, & @@ -143,7 +143,7 @@ MODULE CableDyn_DeckDriver CD_Froude_Krylov_Element_Force, CD_HYDRO_OK USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law, CD_Seabed_Normal_Contact, CD_Seabed_Contact_Gate, & CD_SEABED_CONTACT_BLEND - USE CableDyn_Modal, ONLY: CD_Modal_Bar_Band, CD_Modal_Hermite_Band, CD_Modal_Solve_Band, & + USE CableDyn_Modal, ONLY: CD_Modal_Bar_Band, CD_Modal_Hermite_Line, CD_Modal_Solve_Band, & CD_Modal_Write_Header, CD_Modal_Write_Line, CD_MODAL_OK USE CableDyn_StreamWave, ONLY: CD_StreamWaveType, CD_Stream_Solve, CD_Stream_Kinematics USE CableDyn_WaveSpectra, ONLY: CD_SeaType, CD_WaveTrainType, CD_TRAIN_JONSWAP, CD_SEA_OK, & @@ -303,10 +303,11 @@ MODULE CableDyn_DeckDriver INTEGER, PARAMETER :: WAVE_SEA = 4 ! WAVE_STREAM: regular nonlinear stream-function (Dean) wave of CableDyn_StreamWave INTEGER, PARAMETER :: WAVE_STREAM = 5 - ! One line's modal result (OPTION nModes) + ! One line's modal result (OPTION nModes); polar: each mode's polar share of its kinetic + ! energy, on a line with twist angles (dof_per_node 7) TYPE :: ModalLineResult INTEGER :: n_found = 0, dof_per_node = 3 - REAL(wp), ALLOCATABLE :: omega2(:), shapes(:, :), q(:) + REAL(wp), ALLOCATABLE :: omega2(:), shapes(:, :), q(:), polar(:) END TYPE ModalLineResult REAL(wp), PARAMETER :: TWO_PI = 8.0_wp*QUARTER_PI ! Deck and auxiliary-file record buffer length. next_record reports a record whose @@ -372,7 +373,8 @@ MODULE CableDyn_DeckDriver REAL(wp) :: ktt = CD_ZERO ! torsional damping Bt [N m^2 s] of the GJ column's third part (GJ|K|Bt), the torque Bt dtau/dt ! of the nodal twist; negative: -zeta, the fraction of an element's critical torsional - ! damping l0 sqrt(GJ Irn), resolved on the final mesh + ! damping l0 sqrt(GJ Irn), resolved on the final mesh (and again at the lengths active line + ! control sets) REAL(wp) :: bt = 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 @@ -3421,12 +3423,20 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) tors%irn = i_rn_in IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%irn, ld, lf) ! torsional damping (GJ|K|Bt): a negative value is -zeta of an element's critical torsional - ! damping l0 sqrt(GJ Irn), on the final mesh + ! damping l0 sqrt(GJ Irn), on the final mesh; the elements keep their zeta (bt_zeta), so a + ! length change by active line control re-resolves it IF (ANY(ABS(bt_in) > CD_ZERO)) THEN tors%bt = bt_in IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%bt, ld, lf) + IF (ANY(tors%bt < CD_ZERO)) THEN + ALLOCATE (tors%bt_zeta(SIZE(tors%bt))) + tors%bt_zeta = CD_ZERO + END IF DO k = 1, SIZE(tors%bt) - IF (tors%bt(k) < CD_ZERO) tors%bt(k) = -tors%bt(k)*lf(k)*SQRT(tors%gj(k)*tors%irn(k)) + IF (tors%bt(k) < CD_ZERO) THEN + tors%bt_zeta(k) = -tors%bt(k) + tors%bt(k) = CD_HermiteTorsion_Zeta_Damping(tors%bt_zeta(k), lf(k), tors%gj(k), tors%irn(k)) + END IF END DO END IF DO k = 1, 2 @@ -8080,10 +8090,6 @@ SUBROUTINE build_aggregate_control_table(ctrls, lines, points, rods, sections, t CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' has no finite-EI cable'); RETURN END IF ASSOCIATE (cab => agg%cables(obj)%line) - IF (cab%torsion%active) THEN - CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//': active line control of a finite-EI '// & - 'line restrained in torsion is not supported'); RETURN - END IF IF (cab%has_contact .AND. .NOT. cab%has_seabed_recompute) THEN CALL fail(ErrStat, ErrMsg, 'CONTROL line '//TRIM(lid)//' was built without the seabed '// & 'recompute inputs'); RETURN @@ -8558,9 +8564,6 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (opts%has_tmax .AND. opts%tmax > CD_ZERO .AND. .NOT. opts%alpha_force_blend) THEN CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF - IF (opts%n_modes > 0) THEN - CALL fail(ErrStat, ErrMsg, 'modal analysis (OPTION nModes) of a line with torsion is not yet supported'); RETURN - END IF END IF ! A FAILURE deck is inherently dynamic (the trigger fires at a committed march ! step) and runs on the point-system object graph -- the only path with the @@ -30881,7 +30884,10 @@ END SUBROUTINE write_deck_modes_ei0 SUBROUTINE write_deck_modes_hermite(out_root, lines, opts, cables, ErrStat, ErrMsg) !! .modes.out for finite-EI lines on the cubic-Hermite route, at the static - !! equilibrium the march starts from; the DOFs the march holds are held. + !! equilibrium the march starts from, on the DOFs the march solves (CD_Modal_Hermite_Line): + !! the DOFs the march holds are held, the end connections clamp or spring the end tangents, + !! and a line restrained in torsion carries the twist angle of every node. Positions and + !! translations are turned from the line's frame back to the deck's axes (its heading). CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckOptions), INTENT(IN) :: opts @@ -30889,55 +30895,38 @@ SUBROUTINE write_deck_modes_hermite(out_root, lines, opts, cables, ErrStat, ErrM INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(ModalLineResult), ALLOCATABLE :: res(:) - REAL(wp), ALLOCATABLE :: kmat(:, :), mmat(:, :), floor_z(:) - LOGICAL, ALLOCATABLE :: free(:) - INTEGER :: li, n, nm, es, kd + INTEGER :: li, nn, dpn, es, k, j, c, i0 + REAL(wp) :: v(3) CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK ErrMsg = '' ALLOCATE (res(SIZE(lines))) DO li = 1, SIZE(lines) - ASSOCIATE (c => cables(li)%line) - n = SIZE(c%q) - ALLOCATE (free(n), floor_z(c%nn)) - free = c%freemask - floor_z = c%seabed_z - IF (c%has_am .AND. c%has_contact) THEN - CALL CD_Modal_Hermite_Band(c%q, c%l0, c%EA, c%EI, c%rho_a, kd, kmat, mmat, es, em, & - axial_order=c%axial_quadrature_order, & - bending_order=c%bending_quadrature_order, am_rho=c%am_rho, & - am_waterline=c%am_wl, am_diam=c%am_diam, am_can=c%am_can, am_cat=c%am_cat, & - contact_kn=c%contact_kn, floor_z=floor_z) - ELSE IF (c%has_am) THEN - CALL CD_Modal_Hermite_Band(c%q, c%l0, c%EA, c%EI, c%rho_a, kd, kmat, mmat, es, em, & - axial_order=c%axial_quadrature_order, & - bending_order=c%bending_quadrature_order, am_rho=c%am_rho, & - am_waterline=c%am_wl, am_diam=c%am_diam, am_can=c%am_can, am_cat=c%am_cat) - ELSE IF (c%has_contact) THEN - CALL CD_Modal_Hermite_Band(c%q, c%l0, c%EA, c%EI, c%rho_a, kd, kmat, mmat, es, em, & - axial_order=c%axial_quadrature_order, & - bending_order=c%bending_quadrature_order, contact_kn=c%contact_kn, & - floor_z=floor_z) - ELSE - CALL CD_Modal_Hermite_Band(c%q, c%l0, c%EA, c%EI, c%rho_a, kd, kmat, mmat, es, em, & - axial_order=c%axial_quadrature_order, & - bending_order=c%bending_quadrature_order) - END IF - nm = MIN(opts%n_modes, COUNT(free)) - ALLOCATE (res(li)%omega2(MAX(nm, 1)), res(li)%shapes(n, MAX(nm, 1)), res(li)%q(n)) - res(li)%q = c%q - res(li)%dof_per_node = 6 - IF (es == CD_MODAL_OK .AND. nm > 0) & - CALL CD_Modal_Solve_Band(kmat, mmat, kd, free, nm, res(li)%omega2, res(li)%shapes, res(li)%n_found, & - es, em) - IF (ALLOCATED(kmat)) DEALLOCATE (kmat, mmat) - DEALLOCATE (free, floor_z) - END ASSOCIATE + CALL CD_Modal_Hermite_Line(cables(li)%line, opts%n_modes, res(li)%omega2, res(li)%shapes, res(li)%n_found, & + res(li)%dof_per_node, res(li)%polar, es, em) IF (es /= CD_MODAL_OK) THEN CALL fail(ErrStat, ErrMsg, 'line '//TRIM(int_to_str(lines(li)%id))//' modal analysis: '//TRIM(em)) RETURN END IF + dpn = res(li)%dof_per_node + nn = cables(li)%line%nn + ALLOCATE (res(li)%q(dpn*nn)) + res(li)%q = CD_ZERO + DO k = 1, nn + res(li)%q(dpn*(k - 1) + 1:dpn*(k - 1) + 6) = cables(li)%line%q(6*k - 5:6*k) + END DO + IF (cable_frame_is_identity(cables(li))) CYCLE + DO k = 1, nn + DO i0 = dpn*(k - 1), dpn*(k - 1) + 3, 3 + v = res(li)%q(i0 + 1:i0 + 3) + res(li)%q(i0 + 1:i0 + 3) = [(cable_global_component(cables(li), v, c), c=1, 3)] + DO j = 1, res(li)%n_found + v = res(li)%shapes(i0 + 1:i0 + 3, j) + res(li)%shapes(i0 + 1:i0 + 3, j) = [(cable_global_component(cables(li), v, c), c=1, 3)] + END DO + END DO + END DO END DO CALL write_modes_file(out_root, lines, res, ErrStat, ErrMsg) END SUBROUTINE write_deck_modes_hermite @@ -30945,15 +30934,19 @@ END SUBROUTINE write_deck_modes_hermite SUBROUTINE write_modes_file(out_root, lines, res, ErrStat, ErrMsg) !! .modes.out: a frequency table (LineID Mode Frequency Period Omega) and a !! mode-shape table (LineID Mode Node X Y Z dX dY dZ). The line models hold their nodes - !! End B first; the table numbers them End A first, like every other line output. + !! End B first; the table numbers them End A first, like every other line output. A file + !! with a line that carries twist angles adds the polar share of each mode (PolarShare) and + !! the nodal twist (dTwist, the section's rotation about the line's End A -> End B tangent, + !! so the model's angle about its own End B -> End A tangent changes sign). CHARACTER(*), INTENT(IN) :: out_root TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(ModalLineResult), INTENT(IN) :: res(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: unit, ios, li, part, nn, k, dpn, src, dst - REAL(wp), ALLOCATABLE :: q_a(:), shapes_a(:, :) + REAL(wp), ALLOCATABLE :: q_a(:), shapes_a(:, :), polar(:) CHARACTER(1) :: tb + LOGICAL :: twist ErrStat = CD_DECKDRV_OK ErrMsg = '' tb = char_tab() @@ -30962,11 +30955,24 @@ SUBROUTINE write_modes_file(out_root, lines, res, ErrStat, ErrMsg) CALL fail(ErrStat, ErrMsg, 'cannot open modal output file: '//TRIM(out_root)//'.modes.out'); RETURN END IF CALL CD_Modal_Write_Header(unit) + twist = ANY([(res(li)%dof_per_node == 7, li=1, SIZE(res))]) DO part = 1, 2 IF (part == 1) THEN WRITE (unit, '(A)') '# Natural frequencies' - WRITE (unit, '(A)') 'LineID'//tb//'Mode'//tb//'Frequency'//tb//'Period'//tb//'Omega' - WRITE (unit, '(A)') '(-)'//tb//'(-)'//tb//'(Hz)'//tb//'(s)'//tb//'(rad/s)' + IF (twist) THEN + WRITE (unit, '(A)') 'LineID'//tb//'Mode'//tb//'Frequency'//tb//'Period'//tb//'Omega'//tb//'PolarShare' + WRITE (unit, '(A)') '(-)'//tb//'(-)'//tb//'(Hz)'//tb//'(s)'//tb//'(rad/s)'//tb//'(-)' + ELSE + WRITE (unit, '(A)') 'LineID'//tb//'Mode'//tb//'Frequency'//tb//'Period'//tb//'Omega' + WRITE (unit, '(A)') '(-)'//tb//'(-)'//tb//'(Hz)'//tb//'(s)'//tb//'(rad/s)' + END IF + ELSE IF (twist) THEN + WRITE (unit, '(A)') '# Mode shapes (nodal translations and twist, unit largest nodal displacement; '// & + 'a torsional mode, PolarShare > 0.5, unit largest nodal twist)' + WRITE (unit, '(A)') 'LineID'//tb//'Mode'//tb//'Node'//tb//'X'//tb//'Y'//tb//'Z'//tb//'dX'//tb//'dY'//tb// & + 'dZ'//tb//'dTwist' + WRITE (unit, '(A)') '(-)'//tb//'(-)'//tb//'(-)'//tb//'(m)'//tb//'(m)'//tb//'(m)'//tb//'(-)'//tb//'(-)'// & + tb//'(-)'//tb//'(-)' ELSE WRITE (unit, '(A)') '# Mode shapes (nodal translations, unit largest nodal displacement)' WRITE (unit, '(A)') 'LineID'//tb//'Mode'//tb//'Node'//tb//'X'//tb//'Y'//tb//'Z'//tb//'dX'//tb//'dY'//tb//'dZ' @@ -30983,8 +30989,18 @@ SUBROUTINE write_modes_file(out_root, lines, res, ErrStat, ErrMsg) dst = dpn*(k - 1) q_a(dst + 1:dst + dpn) = res(li)%q(src + 1:src + dpn) shapes_a(dst + 1:dst + dpn, :) = res(li)%shapes(src + 1:src + dpn, :) + IF (dpn == 7) shapes_a(dst + 7, :) = CD_ZERO - shapes_a(dst + 7, :) END DO - CALL CD_Modal_Write_Line(unit, lines(li)%id, q_a, dpn, res(li)%omega2, shapes_a, res(li)%n_found, part) + IF (twist) THEN + IF (ALLOCATED(polar)) DEALLOCATE (polar) + ALLOCATE (polar(MAX(res(li)%n_found, 1))) + polar = CD_ZERO + IF (ALLOCATED(res(li)%polar)) polar(1:res(li)%n_found) = res(li)%polar(1:res(li)%n_found) + CALL CD_Modal_Write_Line(unit, lines(li)%id, q_a, dpn, res(li)%omega2, shapes_a, res(li)%n_found, part, & + polar=polar) + ELSE + CALL CD_Modal_Write_Line(unit, lines(li)%id, q_a, dpn, res(li)%omega2, shapes_a, res(li)%n_found, part) + END IF END DO END DO CLOSE (unit) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 03757502..a7ac4008 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -83,7 +83,7 @@ MODULE CableDyn_HermiteCableDynamic CD_HermiteTorsion_Element_Stretch, CD_HermiteTorsion_Element, & CD_HermiteTorsion_Stretch_Derivatives, CD_HermiteTwist_Reference, & CD_HermiteTwist_Carry, CD_HermiteTwist_Angle, CD_HermiteTwist_Omega, & - CD_HermiteTwist_Omega_Gradient, CD_HTORS_PI + CD_HermiteTwist_Omega_Gradient, CD_HTORS_PI, CD_HermiteTorsion_Zeta_Damping USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 !$ USE OMP_LIB, ONLY: omp_get_max_threads, omp_in_parallel IMPLICIT NONE @@ -100,7 +100,7 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Coupling_Tension PUBLIC :: CD_HermiteCable_Dyn_Element_Torque, CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist PUBLIC :: CD_HermiteCable_Dyn_Twist_Mirror_Size, CD_HermiteCable_Dyn_Twist_Pack, CD_HermiteCable_Dyn_Twist_Unpack - PUBLIC :: CD_HermiteCable_Dyn_Twist_Check + PUBLIC :: CD_HermiteCable_Dyn_Twist_Check, CD_HermiteCable_Dyn_Twist_Hessian PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion_Drive PUBLIC :: CD_HermiteCable_Dyn_Set_Torsion_Frames PUBLIC :: CD_HermiteCable_Dyn_EndConnection_Moment @@ -248,7 +248,11 @@ MODULE CableDyn_HermiteCableDynamic ! change; from then on l0_dot(ne) holds the unstretched-length rate of every element ! (zero outside the controlled span), which the axial damping subtracts from the strain ! rate. A model that is never controlled leaves has_ctrl false and l0_dot unallocated, so - ! every evaluation is unchanged. BA keeps its initial resolution. + ! every evaluation is unchanged. BA keeps its initial resolution. On a line restrained in + ! torsion every torsion term reads l0 when it is evaluated (the compliance sum l0/GJ, the + ! nodal twist's GJ/l0 and Bt/l0, the coupling term (K/GJ)(l - l0), the element shape), the + ! lumped polar inertia and a -zeta torsional damping are rebuilt with the other caches + ! (torsion_length_terms), and the torsional damping takes the rate of the twist per length. LOGICAL :: has_ctrl = .FALSE. REAL(wp), ALLOCATABLE :: l0_dot(:) ! The lengths and rates the committed state was reached with (allocated with l0_dot, set @@ -445,6 +449,9 @@ MODULE CableDyn_HermiteCableDynamic REAL(wp) :: tors_step_ends(3, 4) = CD_ZERO, tors_step_phi = CD_ZERO REAL(wp) :: tors_drive_ends(3, 4) = CD_ZERO, tors_drive_phi = CD_ZERO REAL(wp) :: snap_torsion_theta = CD_ZERO, snap_torsion_phi = CD_ZERO, snap_torsion_ends(3, 4) = CD_ZERO + ! the committed torque of the snapshot, kept as it was formed (under active line control the + ! committed state's compliance is that of the committed lengths, not of the present ones) + REAL(wp) :: snap_torsion_torque = CD_ZERO ! Torsion query cache (allocation-free read-only queries): Theta, dTheta/d[w_1, w_2] and ! dTheta/dr at both end nodes, evaluated at tors_c_q with the end frames tors_c_ends and ! unwrapped against tors_c_prev. A query uses it only when the model's q, end frames and @@ -1681,14 +1688,19 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_SegmentLength(model, elems, l0_new, l0_dot, E !! A call that changes no length and no rate (bit for bit, a rate of -0 counting as +0) !! returns at once, so a zero command of either sign on an uncontrolled model leaves it !! untouched. The update is atomic: every check and rebuild runs before the model is - !! written. A line restrained in torsion is refused (its condensed torsional compliance - !! has no length-control law here), as is a contact model without the seabed recompute - !! inputs and a model on the configuration-blended generalised-alpha (force blend off, - !! CD_HermiteCable_Dyn_Set_ForceBlend), whose blended state has no committed-length - !! treatment, so a ramp would lag by alpha_f times the length change. restored = .TRUE. (a checkpoint - !! restart re-applying the command the committed state was reached with) makes the - !! lengths and rates the committed ones at once; a committed force reloaded with the - !! state belongs to them and stays valid. + !! written. On a line restrained in torsion the torsion follows the lengths in the same way: + !! the terms read at evaluation (the condensed compliance sum l0/GJ, the nodal twist's element + !! stiffness GJ/l0 and damping Bt/l0, the coupling term (K/GJ)(l - l0)) take l0 there, the + !! lumped polar inertia Irn l0/2 and a torsional damping given as -zeta (zeta l0 sqrt(GJ Irn)) + !! are rebuilt with the caches, and the committed force keeps its torsion part at l0_c with + !! the rest. The rate enters the torsional damping as it enters the axial one: the damping + !! takes the rate of the twist per length (assemble_twist). A contact model without the seabed + !! recompute inputs is refused, as is a model on the configuration-blended generalised-alpha + !! (force blend off, CD_HermiteCable_Dyn_Set_ForceBlend), whose blended state has no + !! committed-length treatment, so a ramp would lag by alpha_f times the length change. + !! restored = .TRUE. (a checkpoint restart re-applying the command the committed state was + !! reached with) makes the lengths and rates the committed ones at once; a committed force + !! reloaded with the state belongs to them and stays valid. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model INTEGER, INTENT(IN) :: elems(:) REAL(wp), INTENT(IN) :: l0_new(:), l0_dot(:) @@ -1722,10 +1734,6 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_SegmentLength(model, elems, l0_new, l0_dot, E IF (ANY(l0_new <= CD_ZERO)) THEN CALL fail('l0 must be positive'); RETURN END IF - IF (model%torsion%active) THEN - CALL fail('a line restrained in torsion is not supported (the condensed torsional compliance '// & - 'has no length-control law)'); RETURN - END IF IF (model%has_contact .AND. .NOT. model%has_seabed_recompute) THEN CALL fail('a seabed-contact model needs the seabed recompute inputs '// & '(CD_HermiteCable_Dyn_Set_Control_Seabed)'); RETURN @@ -1923,8 +1931,9 @@ SUBROUTINE rebuild_length_caches(model, l0_new, ErrStat, ErrMsg) !! the constant mass Mgb (element by element, then the attachment masses), the nodal !! tributary lengths and, on a contact model, the nodal seabed coefficients !! (CD_Nodal_Seabed_Stiffness, as the deck builds them) with the friction spring - !! stiffness that follows them. Everything is built first; the model is written only - !! when every build succeeded. + !! stiffness that follows them, and on a line restrained in torsion the torsion terms built + !! from the lengths (torsion_length_terms). Everything is built first; the model is + !! written only when every build succeeded. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: l0_new(:) INTEGER, INTENT(OUT) :: ErrStat @@ -1982,15 +1991,38 @@ SUBROUTINE rebuild_length_caches(model, l0_new, ErrStat, ErrMsg) CALL MOVE_ALLOC(cn_new, model%contact_cn) IF (model%fr_active) model%fr_k = model%contact_kn END IF - ! the lumped polar inertia of the nodal twist follows the lengths - IF (model%tw_active) CALL tw_set_derived(model, model%torsion) + CALL torsion_length_terms(model) END SUBROUTINE rebuild_length_caches + SUBROUTINE torsion_length_terms(model) + !! The torsion terms built from the unstretched lengths, from model%l0 in the order + !! initialisation used (CD_HermiteCable_Dyn_Set_Torsion, the deck's torsion stage): the lumped + !! polar inertia of the nodal twist, half of each adjacent element's Irn l0 (tw_set_derived), + !! and the torsional damping of an element given as -zeta, Bt = zeta l0 sqrt(GJ Irn) + !! (CD_HermiteTorsion_Zeta_Damping), so the element keeps its fraction of critical damping. A + !! direct Bt is a section property and stays. The torsion query cache, keyed on the state and + !! not on the lengths, is dropped (Theta depends on l0 through the element shape and the + !! coupling term). Without torsion nothing is written. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model + INTEGER :: e + IF (.NOT. model%torsion%active) RETURN + model%tors_c_valid = .FALSE. + IF (.NOT. model%tw_active) RETURN + CALL tw_set_derived(model, model%torsion) + IF (.NOT. (ALLOCATED(model%torsion%bt_zeta) .AND. ALLOCATED(model%torsion%bt))) RETURN + DO e = 1, model%ne + IF (model%torsion%bt_zeta(e) > CD_ZERO) & + model%torsion%bt(e) = CD_HermiteTorsion_Zeta_Damping(model%torsion%bt_zeta(e), model%l0(e), & + model%torsion%gj(e), model%torsion%irn(e)) + END DO + END SUBROUTINE torsion_length_terms + SUBROUTINE enter_committed_lengths(model, aside, ErrStat, ErrMsg) !! Install the lengths and rates the committed state was reached with (l0_c, l0_dot_c) for !! one evaluation of the committed state, setting the present ones aside: after a length !! change the length-dependent caches are rebuilt from l0_c, and leave_committed_lengths - !! moves the present ones back bit for bit. A model that is not under active line control, + !! moves the present ones back bit for bit (the torsion terms, rebuilt from them). A model + !! that is not under active line control, !! or whose lengths and rates are the committed ones, is left as it is. On failure nothing !! is written. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model @@ -2037,6 +2069,8 @@ SUBROUTINE leave_committed_lengths(model, aside) CALL MOVE_ALLOC(aside%cn, model%contact_cn) IF (model%fr_active) CALL MOVE_ALLOC(aside%frk, model%fr_k) END IF + ! the torsion terms of the present lengths, rebuilt from them as they were built + CALL torsion_length_terms(model) END IF IF (aside%rates) model%l0_dot = aside%rate aside%lengths = .FALSE. @@ -5170,7 +5204,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat REAL(wp) :: tensile_force_save, tensile_threshold_save, tensile_xi_save, tensile_time_save ! The step-rotation diagnostic must not keep the turn of a step that is rewound. REAL(wp) :: rotation_save - REAL(wp) :: tors_theta0, tors_phi0, tors_phi1, tors_ends0(3, 4), tors_ends1(3, 4), tors_sub(3, 4) + REAL(wp) :: tors_theta0, tors_phi0, tors_phi1, tors_ends0(3, 4), tors_ends1(3, 4), tors_sub(3, 4), tors_torque0 CHARACTER(1024) :: em ! Tensile-qualification failure flag reported by each step (classified by flag, not by ! message text, so a short caller buffer cannot change the recovery decision). @@ -5271,6 +5305,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat tors_theta0 = model%torsion%theta tors_phi0 = model%torsion%phi tors_ends0 = model%torsion%ends + tors_torque0 = model%torsion%torque IF (model%tw_active) CALL tw_pack(model, model%ws_recovery_tw) tors_phi1 = tors_phi0 tors_ends1 = tors_ends0 @@ -5511,13 +5546,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat CONTAINS SUBROUTINE restore_torsion() - !! Interval-start torsion state (frames, Phi, Theta) after a rewind; no pending drive. + !! Interval-start torsion state (frames, Phi, Theta, torque) after a rewind; no pending drive. IF (.NOT. model%torsion%active) RETURN model%torsion%theta = tors_theta0 model%torsion%phi = tors_phi0 model%torsion%ends = tors_ends0 IF (model%tw_active) CALL tw_unpack(model, model%ws_recovery_tw) - model%torsion%torque = (tors_phi0 - tors_theta0)/CD_HermiteTorsion_Compliance(model%torsion, model%l0) + model%torsion%torque = tors_torque0 model%tors_drive_set = .FALSE. END SUBROUTINE restore_torsion END SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering @@ -6775,14 +6810,78 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Check(model, q_check, ends, ErrStat, ErrMsg END DO END SUBROUTINE CD_HermiteCable_Dyn_Twist_Check + SUBROUTINE CD_HermiteCable_Dyn_Twist_Hessian(model, eg, eh, ek, emt, lg, lh, lk, lmt, ErrStat, ErrMsg) + !! The second variation of the nodal-twist elastic energy at the committed state, for an + !! undamped modal analysis about it (CableDyn_Modal): the energy is + !! sum_e 1/2 (GJ/l0)_e tau_e**2 + sum_(elastic ends) 1/2 k tw**2, + !! tau_e = phi_{e+1} - phi_e + rho_e(q), tw = phi_1 - psi_1(q) (end 1), psi_2(q) + Phi - phi_N (end 2), + !! with the committed reference and end frames held. Per element: eg = d rho_e/dq and + !! eh = d2 rho_e/dq2 over its 12 DOFs, ek = GJ/l0 and emt = ek tau_e (the element torque + !! without damping), so d2E/dq2 = emt eh + ek eg eg^T, d2E/dphi_{e+1} dq = ek eg = -d2E/dphi_e dq + !! and d2E/dphi2 = ek [[1, -1], [-1, 1]]. Per end k (columns): lg = d psi/dm and lh = d2 psi/dm2 + !! in the end node's tangent handle m, lk the spring stiffness (0 at a rigid end, whose + !! angle is held) and lmt = lk tw, so d2E/dm2 = lk lg lg^T -+ lmt lh (- at end 1, + at end 2), + !! d2E/dphi dm = -lk lg and d2E/dphi2 = lk. Fails closed without the nodal twist. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(OUT) :: eg(:, :), eh(:, :, :), ek(:), emt(:), lg(3, 2), lh(3, 3, 2), lk(2), lmt(2) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: rho, beta, psi, tw + INTEGER :: e, iend + eg = CD_ZERO + eh = CD_ZERO + ek = CD_ZERO + emt = CD_ZERO + lg = CD_ZERO + lh = CD_ZERO + lk = CD_ZERO + lmt = CD_ZERO + ErrStat = CD_HCDYN_BADINPUT + IF (.NOT. model%tw_active) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Hessian: the model has no nodal twist'; RETURN + END IF + IF (SIZE(eg, 1) /= 12 .OR. SIZE(eg, 2) /= model%ne .OR. SIZE(eh, 1) /= 12 .OR. SIZE(eh, 2) /= 12 .OR. & + SIZE(eh, 3) /= model%ne .OR. SIZE(ek) /= model%ne .OR. SIZE(emt) /= model%ne) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Hessian: the element arrays must have ne columns'; RETURN + END IF + ErrStat = CD_HCDYN_OK + ErrMsg = '' + DO e = 1, model%ne + CALL twist_reference(model, e, model%q, model%torsion%ends, .TRUE., rho, beta, eg(:, e), eh(:, :, e), & + ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Hessian: '//TRIM(ErrMsg); RETURN + END IF + ek(e) = model%torsion%gj(e)/model%l0(e) + emt(e) = ek(e)*(model%tw_phi(e + 1) - model%tw_phi(e) + rho) + END DO + DO iend = 1, 2 + IF (model%tw_rigid(iend)) CYCLE + CALL twist_link(model, iend, model%q, model%torsion%ends, .TRUE., psi, lg(:, iend), lh(:, :, iend), & + ErrStat, ErrMsg) + IF (ErrStat /= CD_HCDYN_OK) THEN + ErrMsg = 'CD_HermiteCable_Dyn_Twist_Hessian: '//TRIM(ErrMsg); RETURN + END IF + lk(iend) = CD_ONE/model%torsion%end_compliance(iend) + IF (iend == 1) THEN + tw = model%tw_phi(1) - psi + ELSE + tw = psi + model%torsion%phi - model%tw_phi(model%nn) + END IF + lmt(iend) = lk(iend)*tw + END DO + END SUBROUTINE CD_HermiteCable_Dyn_Twist_Hessian + PURE INTEGER FUNCTION CD_HermiteCable_Dyn_Twist_Mirror_Size(model) RESULT(n) !! Reals of the nodal-twist checkpoint mirror (CD_HermiteCable_Dyn_Twist_Pack): the !! committed angles, rates and accelerations, directors, reference tangents, reference - !! twists, element torques, end-frame references and rates, and the force cache's angle - !! part; 0 without the nodal twist. + !! twists, element torques, end-frame references and rates, the force cache's angle part, + !! and the committed mean torque as it was formed (the summed twist over the compliance of + !! the lengths it was reached with, which a reload does not re-derive, as Restore does not); + !! 0 without the nodal twist. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model n = 0 - IF (model%tw_active) n = tw_pack_size(model) + model%nn + IF (model%tw_active) n = tw_pack_size(model) + model%nn + 1 END FUNCTION CD_HermiteCable_Dyn_Twist_Mirror_Size SUBROUTINE CD_HermiteCable_Dyn_Twist_Pack(model, buf) @@ -6794,13 +6893,14 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Pack(model, buf) n = tw_pack_size(model) CALL tw_pack(model, buf(1:n)) buf(n + 1:n + model%nn) = model%tw_fcR + buf(n + model%nn + 1) = model%torsion%torque END SUBROUTINE CD_HermiteCable_Dyn_Twist_Pack SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack(model, buf, ErrStat, ErrMsg, check_only) !! Reload the nodal twist from a mirror of CD_HermiteCable_Dyn_Twist_Pack written by a !! model built from the same input (the caller restores q, v, a and the force cache with - !! it). Fails closed on a size mismatch, a non-finite value or a non-unit director; with - !! check_only it only checks. + !! it), the committed torque included. Fails closed on a size mismatch, a non-finite value + !! or a non-unit director; with check_only it only checks. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: buf(:) INTEGER, INTENT(OUT) :: ErrStat @@ -6812,7 +6912,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack(model, buf, ErrStat, ErrMsg, check_o ErrMsg = 'CD_HermiteCable_Dyn_Twist_Unpack: the model has no nodal twist'; RETURN END IF n = tw_pack_size(model) - IF (SIZE(buf) /= n + model%nn) THEN + IF (SIZE(buf) /= n + model%nn + 1) THEN ErrMsg = 'CD_HermiteCable_Dyn_Twist_Unpack: the mirror does not match this line'; RETURN END IF IF (.NOT. CD_All_Finite(buf)) THEN @@ -6831,6 +6931,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack(model, buf, ErrStat, ErrMsg, check_o END IF CALL tw_unpack(model, buf(1:n)) model%tw_fcR = buf(n + 1:n + model%nn) + model%torsion%torque = buf(n + model%nn + 1) ErrStat = CD_HCDYN_OK ErrMsg = '' END SUBROUTINE CD_HermiteCable_Dyn_Twist_Unpack @@ -7444,6 +7545,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) TYPE(CD_HermiteTorsionType) :: saved REAL(wp) :: th, mt REAL(wp) :: saved_step_ends(3, 4), saved_step_phi, saved_snap_theta, saved_snap_phi, saved_snap_ends(3, 4) + REAL(wp) :: saved_snap_torque REAL(wp) :: saved_drive_ends(3, 4), saved_drive_phi LOGICAL :: saved_snap_valid, saved_drive_set, saved_tw_active REAL(wp), ALLOCATABLE :: saved_tw(:) @@ -7539,6 +7641,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) saved_snap_theta = model%snap_torsion_theta saved_snap_phi = model%snap_torsion_phi saved_snap_ends = model%snap_torsion_ends + saved_snap_torque = model%snap_torsion_torque saved_snap_valid = model%snap_valid model%tors_use_step = .FALSE. model%tors_drive_set = .FALSE. @@ -7547,6 +7650,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) model%snap_torsion_theta = model%torsion%theta model%snap_torsion_phi = model%torsion%phi model%snap_torsion_ends = model%torsion%ends + model%snap_torsion_torque = model%torsion%torque ! the snapshot predates the new load set (as for CD_HermiteCable_Dyn_Set_EndConnection) model%snap_valid = .FALSE. model%fc_valid = .FALSE. @@ -7565,6 +7669,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Torsion(model, torsion, ErrStat, ErrMsg) model%snap_torsion_theta = saved_snap_theta model%snap_torsion_phi = saved_snap_phi model%snap_torsion_ends = saved_snap_ends + model%snap_torsion_torque = saved_snap_torque model%snap_valid = saved_snap_valid ErrStat = es ErrMsg = 'CD_HermiteCable_Dyn_Set_Torsion: '//TRIM(em) @@ -7762,6 +7867,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Snapshot(model, ErrStat, ErrMsg) model%snap_torsion_theta = model%torsion%theta model%snap_torsion_phi = model%torsion%phi model%snap_torsion_ends = model%torsion%ends + model%snap_torsion_torque = model%torsion%torque IF (model%tw_active) THEN IF (.NOT. ALLOCATED(model%snap_tw)) ALLOCATE (model%snap_tw(tw_pack_size(model)), model%snap_tw_fcR(model%nn)) CALL tw_pack(model, model%snap_tw) @@ -7844,8 +7950,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Restore(model, ErrStat, ErrMsg) model%torsion%theta = model%snap_torsion_theta model%torsion%phi = model%snap_torsion_phi model%torsion%ends = model%snap_torsion_ends - IF (model%torsion%active) model%torsion%torque = (model%torsion%phi - model%torsion%theta)/ & - CD_HermiteTorsion_Compliance(model%torsion, model%l0) + IF (model%torsion%active) model%torsion%torque = model%snap_torsion_torque model%tors_drive_set = .FALSE. model%tors_use_step = .FALSE. IF (model%tw_active) CALL tw_unpack(model, model%snap_tw) @@ -7992,6 +8097,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) model%snap_torsion_theta = CD_ZERO model%snap_torsion_phi = CD_ZERO model%snap_torsion_ends = CD_ZERO + model%snap_torsion_torque = CD_ZERO CALL tw_release(model) model%tw_rigid = .FALSE. model%tw_psi = CD_ZERO @@ -8954,6 +9060,17 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K !! g (H q_dot)^T) and Kvb (Bt/l0) g g^T, and the coupling to the angles is kept per element !! for the solve (tw_eg, tw_ehv, tw_ek, tw_ed, tw_lg, tw_lk; want_tangent). tw_me holds the !! element torques and tw_tsum the summed twist. + !! + !! An element whose length changes at the rate l0_dot (active line control) damps the rate of + !! its twist per length, the quantity tau/l0 its elastic torque GJ tau/l0 reads, as the axial + !! damping takes the rate of the strain: M_e = (GJ/l0) tau + (Bt/l0) (d tau/dt - tau l0_dot/l0), + !! so a segment paid out at a constant twist per length carries no damping torque. At fixed q, + !! tau changes with l0 through the coupling term -(K/GJ) l0 and through the element's shape: + !! rho_e depends on the tangent handles m only through l0 m (the Hermite r' and r'') and m/|m|, + !! so l0 drho/dl0 = m_1 . drho/dm_1 + m_2 . drho/dm_2 - (K/GJ) l0 (an Euler identity of the + !! gradient g), and d tau/dt gains (l0_dot/l0)(m . g_m - (K/GJ) l0). The angle stiffness of the + !! element becomes GJ/l0 - (Bt/l0) l0_dot/l0 and its q-gradient gains (Bt/l0)(l0_dot/l0) + !! (g_m + H m), H the Hessian of rho_e. TYPE(CD_HermiteCableDynType), INTENT(INOUT), TARGET :: model REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) LOGICAL, INTENT(IN) :: want_residual, want_tangent @@ -8965,6 +9082,10 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K REAL(wp) :: om(3, 2), ew(3, 2) LOGICAL :: turning REAL(wp) :: tau, rate, mt, psi, gl(3), hl(3, 3), k, tw + ! length-rate share of the damping (active line control): l0_dot/l0, the element's tangent + ! handles (m in the 12-DOF layout, the r slots zero) and the angle stiffness it leaves + REAL(wp) :: rr, mv(12), gmv(12), kel_t, cpl + LOGICAL :: ctrl_rate INTEGER :: e, iend, node, b, i, j, es CHARACTER(1024) :: em @@ -9004,6 +9125,20 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K tau = phi(e + 1) - phi(e) + rho rate = w(e + 1) - w(e) + DOT_PRODUCT(g, ve) IF (turning .AND. kd > CD_ZERO) rate = rate + DOT_PRODUCT(ew(:, 1), om(:, 1)) + DOT_PRODUCT(ew(:, 2), om(:, 2)) + kel_t = kel + rr = CD_ZERO + IF (model%has_ctrl .AND. kd > CD_ZERO) rr = model%l0_dot(e)/model%l0(e) + ctrl_rate = ABS(rr) > CD_ZERO + mv = CD_ZERO + IF (ctrl_rate) THEN + ! the rate of the twist per length (see the header): (l0_dot/l0)(m . g_m - (K/GJ) l0 - tau) + mv(4:6) = q_cfg(6*e - 2:6*e) + mv(10:12) = q_cfg(6*e + 4:6*e + 6) + cpl = CD_ZERO + IF (ALLOCATED(model%torsion%couple)) cpl = model%torsion%couple(e) + rate = rate + rr*(DOT_PRODUCT(g, mv) - cpl*model%l0(e) - tau) + kel_t = kel - kd*rr + END IF mt = kel*tau + kd*rate model%tw_me(e) = mt model%tw_tsum = model%tw_tsum + tau @@ -9015,9 +9150,16 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K IF (want_tangent) THEN hv = CD_ZERO IF (kd > CD_ZERO) hv = MATMUL(h, ve) + ! the length-rate share: d(m . g_m)/dq = g_m + H m (H symmetric), and -tau rr in kel_t + IF (ctrl_rate) THEN + gmv = CD_ZERO + gmv(4:6) = g(4:6) + gmv(10:12) = g(10:12) + hv = MATMUL(h, ve + rr*mv) + rr*gmv + END IF DO j = 1, 12 DO i = 1, 12 - ke(i, j) = mt*h(i, j) + kel*g(i)*g(j) + kd*g(i)*hv(j) + ke(i, j) = mt*h(i, j) + kel_t*g(i)*g(j) + kd*g(i)*hv(j) END DO END DO CALL scatter12_band(Kb, ke, e) @@ -9031,7 +9173,7 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K END IF model%tw_eg(:, e) = g model%tw_ehv(:, e) = hv - model%tw_ek(e) = kel + model%tw_ek(e) = kel_t model%tw_ed(e) = kd END IF END DO diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index 75743309..d93094f6 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -49,6 +49,7 @@ MODULE CableDyn_HermiteTorsion PUBLIC :: CD_HermiteTorsionType PUBLIC :: CD_HermiteTorsion_Compliance PUBLIC :: CD_HermiteTorsion_Validate + PUBLIC :: CD_HermiteTorsion_Zeta_Damping PUBLIC :: CD_HermiteTorsion_Bordered_Solve PUBLIC :: CD_HermiteTorsion_Inertia PUBLIC :: CD_HermiteTorsion_Lowest_Mode @@ -120,6 +121,11 @@ MODULE CableDyn_HermiteTorsion !! (torque Bt d tau/dt). With irn unallocated the dynamics keeps the condensed, quasi-static !! torsion; the statics never read them. REAL(wp), ALLOCATABLE :: irn(:), bt(:) + !! The fraction zeta of an element's critical torsional damping l0 sqrt(GJ Irn) that a + !! negative deck Bt (-zeta) asked for, 0 on an element with a direct Bt; unallocated: every + !! Bt is direct. bt holds the resolved value zeta l0 sqrt(GJ Irn) (CD_HermiteTorsion_Zeta_Damping), + !! which active line control re-resolves when it changes l0, so the element keeps its zeta. + REAL(wp), ALLOCATABLE :: bt_zeta(:) 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). @@ -173,6 +179,14 @@ PURE REAL(wp) FUNCTION CD_HermiteTorsion_Compliance(tors, l0) RESULT(c) c = tors%end_compliance(1) + tors%end_compliance(2) + SUM(l0/tors%gj) END FUNCTION CD_HermiteTorsion_Compliance + ELEMENTAL REAL(wp) FUNCTION CD_HermiteTorsion_Zeta_Damping(zeta, l0, gj, irn) RESULT(bt) + !! The torsional damping Bt [N m^2 s] of an element of length l0 that a deck Bt of -zeta asks + !! for: zeta times the element's critical torsional damping l0 sqrt(GJ Irn) (the convention + !! of the axial BA, with GJ for EA and the polar inertia Irn for the mass per length). + REAL(wp), INTENT(IN) :: zeta, l0, gj, irn + bt = zeta*l0*SQRT(gj*irn) + END FUNCTION CD_HermiteTorsion_Zeta_Damping + PURE SUBROUTINE CD_HermiteTorsion_Validate(tors, l0, ErrStat, ErrMsg) !! Fail-closed check of an active torsion description against a mesh of SIZE(l0) elements. TYPE(CD_HermiteTorsionType), INTENT(IN) :: tors @@ -245,6 +259,25 @@ PURE SUBROUTINE CD_HermiteTorsion_Validate(tors, l0, ErrStat, ErrMsg) RETURN END IF END IF + IF (ALLOCATED(tors%bt_zeta)) THEN + IF (.NOT. ALLOCATED(tors%bt)) THEN + ErrMsg = 'torsion: a torsional damping ratio needs the torsional damping it resolves' + RETURN + END IF + IF (SIZE(tors%bt_zeta) /= SIZE(l0)) THEN + ErrMsg = 'torsion: the torsional damping ratio must have one entry per element' + RETURN + END IF + IF (.NOT. CD_All_Finite(tors%bt_zeta)) THEN + ErrStat = CD_HTORS_NONFINITE + ErrMsg = 'torsion: non-finite torsional damping ratio' + RETURN + END IF + IF (ANY(tors%bt_zeta < CD_ZERO)) THEN + ErrMsg = 'torsion: the torsional damping ratio must be non-negative' + RETURN + END IF + END IF IF (ANY(tors%end_compliance < CD_ZERO)) THEN ErrMsg = 'torsion: end compliances must be non-negative' RETURN diff --git a/src/CableDyn_Modal.f90 b/src/CableDyn_Modal.f90 index 2f1f0ac8..3c15668b 100644 --- a/src/CableDyn_Modal.f90 +++ b/src/CableDyn_Modal.f90 @@ -29,11 +29,29 @@ MODULE CableDyn_Modal !! and the consistent mass (m l0/6) [[2I, I], [I, 2I]]. !! Finite-EI lines (cubic-Hermite, position and tangent per node): the element Hessian of !! CD_HermiteCable_Element and the consistent mass of CD_HermiteCable_Mass. + !! + !! A line model of the cubic-Hermite dynamics (CD_Modal_Hermite_Line) adds what its dynamics + !! carries: the end connections (a finite spring's Hessian on the end tangent; a rigid end + !! keeps only the magnitude of its tangent, in the basis [d, b1, b2] of its direction d), the + !! discrete attachments' masses and, on a line restrained in torsion, its twist. The dynamics + !! of such a line carries a twist angle phi at every node (the nodal twist, with the polar + !! inertia Irn), so the modes do too: 7 DOFs per node [r, m, phi], the lumped polar inertia + !! (half of each adjacent element's Irn l0) as the mass of phi, and the second variation of the + !! twist energy sum_e 1/2 (GJ/l0)(phi_{e+1} - phi_e + rho_e(q))**2 (+ the elastic end springs) + !! as stiffness (CD_HermiteCable_Dyn_Twist_Hessian): with M_e the element torque, + !! d2E/dq2 = M_e d2rho/dq2 + (GJ/l0) g g^T, d2E/dphi dq = +-(GJ/l0) g, g = drho_e/dq, + !! which couples the twist to the bending and, under torque-tension coupling (rho_e then holds + !! (K/GJ)(l - l0)), to the stretch. Eliminating the angles (no polar inertia) leaves the + !! condensed static tangent of the statics, M_t d2(-Theta)/dq2 + (1/C) g_T g_T^T, + !! g_T = dTheta/dq: the Schur complement of the angle block is that rank-one term. USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_All_Finite USE CableDyn_SeabedContact, ONLY: CD_Seabed_Normal_Law USE CableDyn_Hydro, ONLY: CD_Cable_Added_Mass_Matrix USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Element, CD_HermiteCable_Mass - USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_AddedMass_Element + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_AddedMass_Element, CD_HermiteCableDynType, & + CD_HermiteCable_Dyn_Twist_Hessian, CD_HCDYN_OK + USE CableDyn_EndConnection, ONLY: CD_EndConn_Spring, CD_EndConn_Basis, CD_ENDCONN_OK, CD_ENDCONN_FINITE, & + CD_ENDCONN_RIGID USE CableDyn_Linalg, ONLY: CD_Factor_Banded, CD_Solve_Factored_Banded, CD_Blas_Runtime_Check, CD_LINALG_OK, & CD_BLAS_UNAVAILABLE_INFO IMPLICIT NONE @@ -48,6 +66,7 @@ MODULE CableDyn_Modal REAL(wp), PARAMETER :: TWO_PI = 6.283185307179586476925286766559005768394_wp PUBLIC :: CD_Modal_Bar_Band, CD_Modal_Hermite_Band, CD_Modal_Solve_Band + PUBLIC :: CD_Modal_Hermite_Line, CD_Modal_Hermite_Line_Band PUBLIC :: CD_Modal_Bar_Matrices, CD_Modal_Hermite_Matrices, CD_Modal_Solve PUBLIC :: CD_Modal_Write_Header, CD_Modal_Write_Line @@ -361,6 +380,288 @@ SUBROUTINE CD_Modal_Hermite_Band(q, l0, ea, ei, rho_a, kd, K, M, ErrStat, ErrMsg END IF END SUBROUTINE CD_Modal_Hermite_Band + SUBROUTINE CD_Modal_Hermite_Line(model, n_modes, omega2, shapes, n_found, dof_per_node, polar, ErrStat, ErrMsg) + !! The n_modes lowest modes of a cubic-Hermite line model about its committed state (the + !! static equilibrium a deck starts its march from), on the DOFs its dynamics solves + !! (CD_Modal_Hermite_Line_Band). dof_per_node is 6 ([r, m] per node) or 7 ([r, m, phi]); + !! shapes(:, j) is the full-length mode vector in the model's axes and node order (zero on + !! the held DOFs), M-orthonormal; polar(j) its polar share of the modal kinetic energy, + !! sum_k I_k phi_k**2 (0 without twist, 1 for a pure torsional mode). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: n_modes + REAL(wp), ALLOCATABLE, INTENT(OUT) :: omega2(:), shapes(:, :), polar(:) + INTEGER, INTENT(OUT) :: n_found, dof_per_node, ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: kb(:, :), mb(:, :) + REAL(wp) :: basis(3, 3), f3(3) + LOGICAL, ALLOCATABLE :: free(:) + INTEGER :: n, kd, iend, j, k, nm + CHARACTER(1024) :: em + + n_found = 0 + CALL CD_Modal_Hermite_Line_Band(model, kd, kb, mb, free, dof_per_node, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODAL_OK) RETURN + n = SIZE(free) + nm = MIN(n_modes, COUNT(free)) + ALLOCATE (omega2(MAX(nm, 1)), shapes(n, MAX(nm, 1)), polar(MAX(nm, 1))) + omega2 = CD_ZERO + shapes = CD_ZERO + polar = CD_ZERO + IF (nm < 1) THEN + CALL fail(ErrStat, ErrMsg, 'the line has no free degree of freedom') + RETURN + END IF + CALL CD_Modal_Solve_Band(kb, mb, kd, free, nm, omega2, shapes, n_found, ErrStat, ErrMsg) + IF (ErrStat /= CD_MODAL_OK) RETURN + ! back to the model's axes: m = B [s, 0, 0] at a rigid end + IF (model%has_endconn) THEN + DO iend = 1, 2 + IF (model%endconn_mode(iend) /= CD_ENDCONN_RIGID) CYCLE + CALL CD_EndConn_Basis(model%endconn_d0(:, iend), basis, ErrStat, em) + IF (ErrStat /= CD_ENDCONN_OK) THEN + n_found = 0 + CALL fail(ErrStat, ErrMsg, 'end connection: '//TRIM(em)) + RETURN + END IF + j = dof_per_node*(MERGE(1, model%nn, iend == 1) - 1) + 3 + DO k = 1, n_found + f3 = shapes(j + 1:j + 3, k) + shapes(j + 1:j + 3, k) = MATMUL(basis, f3) + END DO + END DO + END IF + IF (dof_per_node == 7) THEN + DO k = 1, n_found + polar(k) = SUM(model%tw_mass*shapes(7:n:7, k)**2) + END DO + END IF + END SUBROUTINE CD_Modal_Hermite_Line + + SUBROUTINE CD_Modal_Hermite_Line_Band(model, kd, K, M, free, dof_per_node, ErrStat, ErrMsg) + !! Stiffness and mass of a cubic-Hermite line model at its committed state, as their + !! symmetric parts in upper band storage of half-bandwidth kd, with the free-DOF mask, on + !! the DOFs its dynamics solves: the element stiffness and mass with the Morison added mass + !! and the seabed normal contact of CD_Modal_Hermite_Band, the attachments' masses, the end + !! connections and, with the nodal twist, the twist angles (see the module note; 7 DOFs per + !! node, kd = 13, else 6 and kd = 11). The tangent handle of a rigid end is in the basis + !! [d, b1, b2] of its direction (CD_EndConn_Basis), b1 and b2 held. A line with the + !! condensed torsion of the quasi-static dynamics (no polar inertia) is refused. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(OUT) :: kd, dof_per_node, ErrStat + REAL(wp), ALLOCATABLE, INTENT(OUT) :: K(:, :), M(:, :) + LOGICAL, ALLOCATABLE, INTENT(OUT) :: free(:) + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: k6(:, :), m6(:, :), floor_z(:), eg(:, :), eh(:, :, :), ek(:), emt(:) + REAL(wp) :: lg(3, 2), lh(3, 3, 2), lk(2), lmt(2), f3(3), k3(3, 3), ke(14, 14), kl(4, 4), basis(3, 3, 2) + LOGICAL :: twist, rigid(2) + INTEGER :: nn, ne, n6, n, kd6, i, j, i6, j6, e, a, b, ia, ib, iend, node, p + INTEGER :: gd(14), gl4(4) + CHARACTER(1024) :: em + + ErrStat = CD_MODAL_OK + ErrMsg = '' + kd = 0 + dof_per_node = 6 + nn = model%nn + ne = model%ne + n6 = model%ndof + twist = model%tw_active + IF (model%torsion%active .AND. .NOT. twist) THEN + CALL fail(ErrStat, ErrMsg, 'a line with condensed torsion (no polar inertia Irn) has no torsional '// & + 'modes; give its torsion the polar inertia') + RETURN + END IF + ALLOCATE (floor_z(nn)) + floor_z = model%seabed_z + IF (model%has_am .AND. model%has_contact) THEN + CALL CD_Modal_Hermite_Band(model%q, model%l0, model%EA, model%EI, model%rho_a, kd6, k6, m6, ErrStat, em, & + axial_order=model%axial_quadrature_order, & + bending_order=model%bending_quadrature_order, am_rho=model%am_rho, & + am_waterline=model%am_wl, am_diam=model%am_diam, am_can=model%am_can, & + am_cat=model%am_cat, contact_kn=model%contact_kn, floor_z=floor_z) + ELSE IF (model%has_am) THEN + CALL CD_Modal_Hermite_Band(model%q, model%l0, model%EA, model%EI, model%rho_a, kd6, k6, m6, ErrStat, em, & + axial_order=model%axial_quadrature_order, & + bending_order=model%bending_quadrature_order, am_rho=model%am_rho, & + am_waterline=model%am_wl, am_diam=model%am_diam, am_can=model%am_can, & + am_cat=model%am_cat) + ELSE IF (model%has_contact) THEN + CALL CD_Modal_Hermite_Band(model%q, model%l0, model%EA, model%EI, model%rho_a, kd6, k6, m6, ErrStat, em, & + axial_order=model%axial_quadrature_order, & + bending_order=model%bending_quadrature_order, contact_kn=model%contact_kn, & + floor_z=floor_z) + ELSE + CALL CD_Modal_Hermite_Band(model%q, model%l0, model%EA, model%EI, model%rho_a, kd6, k6, m6, ErrStat, em, & + axial_order=model%axial_quadrature_order, & + bending_order=model%bending_quadrature_order) + END IF + IF (ErrStat /= CD_MODAL_OK) THEN + ErrMsg = em + RETURN + END IF + ! discrete attachments: dry mass m and added mass Ca rho V on the node's translations + IF (model%has_attach) THEN + DO p = 1, SIZE(model%att_node) + DO i = 1, 3 + j = 6*(model%att_node(p) - 1) + i + CALL add_entry(m6, kd6, j, j, model%att_mass(p) + model%att_madd(p)) + END DO + END DO + END IF + ! end connections: a finite spring adds d2U/dm2 on its end tangent; a rigid end is + ! rotated into its basis below + rigid = .FALSE. + IF (model%has_endconn) THEN + DO iend = 1, 2 + node = MERGE(1, nn, iend == 1) + j = 6*(node - 1) + 3 + IF (model%endconn_mode(iend) == CD_ENDCONN_FINITE) THEN + CALL CD_EndConn_Spring(model%q(j + 1:j + 3), model%endconn_d0(:, iend), model%endconn_k(iend), f3, k3, & + ErrStat, em) + IF (ErrStat /= CD_ENDCONN_OK) THEN + CALL fail(ErrStat, ErrMsg, 'end connection: '//TRIM(em)) + RETURN + END IF + CALL add_block(k6, kd6, [j + 1, j + 2, j + 3], k3) + ELSE IF (model%endconn_mode(iend) == CD_ENDCONN_RIGID) THEN + rigid(iend) = .TRUE. + CALL CD_EndConn_Basis(model%endconn_d0(:, iend), basis(:, :, iend), ErrStat, em) + IF (ErrStat /= CD_ENDCONN_OK) THEN + CALL fail(ErrStat, ErrMsg, 'end connection: '//TRIM(em)) + RETURN + END IF + END IF + END DO + END IF + + IF (.NOT. twist) THEN + n = n6 + kd = kd6 + CALL MOVE_ALLOC(k6, K) + CALL MOVE_ALLOC(m6, M) + ALLOCATE (free(n)) + free = model%freemask + ELSE + ! [r, m] of node p at 7(p - 1) + 1..6, its angle at 7 p: DOF i6 of the cable is + ! i6 + (i6 - 1)/6; one element spans 14 DOFs (half-bandwidth 13) + dof_per_node = 7 + n = 7*nn + kd = 13 + ALLOCATE (K(kd + 1, n), M(kd + 1, n), free(n)) + K = CD_ZERO + M = CD_ZERO + DO j6 = 1, n6 + DO i6 = MAX(1, j6 - kd6), j6 + K(kd + 1 + (i6 + (i6 - 1)/6) - (j6 + (j6 - 1)/6), j6 + (j6 - 1)/6) = k6(kd6 + 1 + i6 - j6, j6) + M(kd + 1 + (i6 + (i6 - 1)/6) - (j6 + (j6 - 1)/6), j6 + (j6 - 1)/6) = m6(kd6 + 1 + i6 - j6, j6) + END DO + free(j6 + (j6 - 1)/6) = model%freemask(j6) + END DO + DEALLOCATE (k6, m6) + ALLOCATE (eg(12, ne), eh(12, 12, ne), ek(ne), emt(ne)) + CALL CD_HermiteCable_Dyn_Twist_Hessian(model, eg, eh, ek, emt, lg, lh, lk, lmt, ErrStat, em) + IF (ErrStat /= CD_HCDYN_OK) THEN + CALL fail(ErrStat, ErrMsg, TRIM(em)) + RETURN + END IF + DO e = 1, ne + ! element DOFs [r_e, m_e, phi_e, r_e+1, m_e+1, phi_e+1]; the cable's 12 at 1..6, 8..13 + DO i = 1, 14 + gd(i) = 7*(e - 1) + i + END DO + ke = CD_ZERO + DO b = 1, 12 + ib = b + (b - 1)/6 + DO a = 1, 12 + ia = a + (a - 1)/6 + ke(ia, ib) = emt(e)*eh(a, b, e) + ek(e)*eg(a, e)*eg(b, e) + END DO + ke(ib, 14) = ek(e)*eg(b, e) + ke(14, ib) = ke(ib, 14) + ke(ib, 7) = -ek(e)*eg(b, e) + ke(7, ib) = ke(ib, 7) + END DO + ke(7, 7) = ek(e) + ke(14, 14) = ek(e) + ke(7, 14) = -ek(e) + ke(14, 7) = -ek(e) + CALL add_block(K, kd, gd, ke) + END DO + DO iend = 1, 2 + IF (.NOT. lk(iend) > CD_ZERO) CYCLE + ! the elastic end's spring on [m, phi] of its node, d2psi/dm2 signed by its torque + node = MERGE(1, nn, iend == 1) + gl4 = [7*(node - 1) + 4, 7*(node - 1) + 5, 7*(node - 1) + 6, 7*node] + DO b = 1, 3 + DO a = 1, 3 + kl(a, b) = lk(iend)*lg(a, iend)*lg(b, iend) + MERGE(-lmt(iend), lmt(iend), iend == 1)*lh(a, b, iend) + END DO + kl(b, 4) = -lk(iend)*lg(b, iend) + kl(4, b) = kl(b, 4) + END DO + kl(4, 4) = lk(iend) + CALL add_block(K, kd, gl4, kl) + END DO + DO p = 1, nn + CALL add_entry(M, kd, 7*p, 7*p, model%tw_mass(p)) + free(7*p) = model%tw_free(p) + END DO + END IF + ! a rigid end: its tangent handle in the basis [d, b1, b2], b1 and b2 held + DO iend = 1, 2 + IF (.NOT. rigid(iend)) CYCLE + node = MERGE(1, nn, iend == 1) + j = dof_per_node*(node - 1) + 3 + CALL rotate_band_block(K, kd, j, basis(:, :, iend), ErrStat, em) + IF (ErrStat == CD_MODAL_OK) CALL rotate_band_block(M, kd, j, basis(:, :, iend), ErrStat, em) + IF (ErrStat /= CD_MODAL_OK) THEN + ErrMsg = em + RETURN + END IF + free(j + 2:j + 3) = .FALSE. + END DO + END SUBROUTINE CD_Modal_Hermite_Line_Band + + SUBROUTINE rotate_band_block(ab, kd, j0, b, ErrStat, ErrMsg) + !! A <- T^T A T for a symmetric A in upper band storage, T the identity but for the block b + !! on the DOFs j0 + 1..j0 + 3 (the tangent handle of a node in a rigid end's basis). The + !! block's couplings reach only the DOFs of its node's two elements, all within kd of every + !! DOF of the block, so the band does not widen; an entry that would fails closed. + REAL(wp), INTENT(INOUT) :: ab(:, :) + INTEGER, INTENT(IN) :: kd, j0 + REAL(wp), INTENT(IN) :: b(3, 3) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), ALLOCATABLE :: w(:, :) + INTEGER :: n, lo, hi, i, j + ErrStat = CD_MODAL_OK + ErrMsg = '' + n = SIZE(ab, 2) + lo = MAX(1, j0 + 1 - kd) + hi = MIN(n, j0 + 3 + kd) + ALLOCATE (w(lo:hi, lo:hi)) + w = CD_ZERO + DO j = lo, hi + DO i = MAX(lo, j - kd), j + w(i, j) = ab(kd + 1 + i - j, j) + w(j, i) = w(i, j) + END DO + END DO + w(j0 + 1:j0 + 3, :) = MATMUL(TRANSPOSE(b), w(j0 + 1:j0 + 3, :)) + w(:, j0 + 1:j0 + 3) = MATMUL(w(:, j0 + 1:j0 + 3), b) + DO j = lo, hi + DO i = lo, j + IF (.NOT. ((i > j0 .AND. i <= j0 + 3) .OR. (j > j0 .AND. j <= j0 + 3))) CYCLE + IF (j - i <= kd) THEN + ab(kd + 1 + i - j, j) = w(i, j) + ELSE IF (ABS(w(i, j)) > CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'a rigid end basis would widen the band') + RETURN + END IF + END DO + END DO + END SUBROUTINE rotate_band_block + SUBROUTINE CD_Modal_Bar_Matrices(q, elem_conn, l0, ea, rho_a, tension_only, K, M, ErrStat, ErrMsg, & am_rho, am_waterline, am_diam, am_can, am_cat, seabed_kn, floor_z) !! Dense form of CD_Modal_Bar_Band (the symmetric parts), for the dense reference solver. @@ -742,15 +1043,20 @@ SUBROUTINE CD_Modal_Write_Header(unit) '(static tangent, structural + added mass, fixed and prescribed ends held)' END SUBROUTINE CD_Modal_Write_Header - SUBROUTINE CD_Modal_Write_Line(unit, line_id, q, dof_per_node, omega2, shapes, n_found, part) + SUBROUTINE CD_Modal_Write_Line(unit, line_id, q, dof_per_node, omega2, shapes, n_found, part, polar) !! part = 1: the frequency rows "LineID Mode Frequency Period Omega"; part = 2: the !! shape rows "LineID Mode Node X Y Z dX dY dZ", the nodal translations of each mode !! scaled to a unit largest nodal displacement (the static position X Y Z beside it). - !! A negative omega^2 is written with a negative frequency and period 0. + !! A negative omega^2 is written with a negative frequency and period 0. With polar (the + !! twist columns of a file holding a line with twist): the frequency rows add the polar + !! share of each mode, the shape rows the nodal twist dTwist (the 7th DOF of a node when + !! dof_per_node = 7, else 0) on the same scale; a mode whose kinetic energy is mostly polar + !! (share above 1/2, a torsional mode) is scaled to a unit largest nodal twist instead. INTEGER, INTENT(IN) :: unit, line_id, dof_per_node, n_found, part REAL(wp), INTENT(IN) :: q(:), omega2(:), shapes(:, :) + REAL(wp), INTENT(IN), OPTIONAL :: polar(:) INTEGER :: j, i, nn, i0 - REAL(wp) :: om, fr, per, scl, dmax + REAL(wp) :: om, fr, per, scl, dmax, tw CHARACTER(1), PARAMETER :: TB = ACHAR(9) nn = SIZE(q)/dof_per_node DO j = 1, n_found @@ -759,19 +1065,35 @@ SUBROUTINE CD_Modal_Write_Line(unit, line_id, q, dof_per_node, omega2, shapes, n fr = om/TWO_PI per = CD_ZERO IF (om > CD_ZERO) per = CD_ONE/fr - WRITE (unit, '(I0,A,I0,3(A,ES16.8E3))') line_id, TB, j, TB, fr, TB, per, TB, om + IF (PRESENT(polar)) THEN + WRITE (unit, '(I0,A,I0,4(A,ES16.8E3))') line_id, TB, j, TB, fr, TB, per, TB, om, TB, polar(j) + ELSE + WRITE (unit, '(I0,A,I0,3(A,ES16.8E3))') line_id, TB, j, TB, fr, TB, per, TB, om + END IF ELSE dmax = CD_ZERO - DO i = 1, nn - i0 = dof_per_node*(i - 1) - dmax = MAX(dmax, SQRT(SUM(shapes(i0 + 1:i0 + 3, j)**2))) - END DO + IF (PRESENT(polar) .AND. dof_per_node == 7) THEN + IF (polar(j) > 0.5_wp) dmax = MAXVAL(ABS(shapes(7:7*nn:7, j))) + END IF + IF (.NOT. dmax > CD_ZERO) THEN + DO i = 1, nn + i0 = dof_per_node*(i - 1) + dmax = MAX(dmax, SQRT(SUM(shapes(i0 + 1:i0 + 3, j)**2))) + END DO + END IF scl = CD_ONE IF (dmax > CD_ZERO) scl = CD_ONE/dmax DO i = 1, nn i0 = dof_per_node*(i - 1) - WRITE (unit, '(I0,A,I0,A,I0,6(A,ES16.8E3))') line_id, TB, j, TB, i, TB, q(i0 + 1), TB, q(i0 + 2), TB, & - q(i0 + 3), TB, scl*shapes(i0 + 1, j), TB, scl*shapes(i0 + 2, j), TB, scl*shapes(i0 + 3, j) + IF (PRESENT(polar)) THEN + tw = CD_ZERO + IF (dof_per_node == 7) tw = scl*shapes(i0 + 7, j) + WRITE (unit, '(I0,A,I0,A,I0,7(A,ES16.8E3))') line_id, TB, j, TB, i, TB, q(i0 + 1), TB, q(i0 + 2), & + TB, q(i0 + 3), TB, scl*shapes(i0 + 1, j), TB, scl*shapes(i0 + 2, j), TB, scl*shapes(i0 + 3, j), TB, tw + ELSE + WRITE (unit, '(I0,A,I0,A,I0,6(A,ES16.8E3))') line_id, TB, j, TB, i, TB, q(i0 + 1), TB, q(i0 + 2), & + TB, q(i0 + 3), TB, scl*shapes(i0 + 1, j), TB, scl*shapes(i0 + 2, j), TB, scl*shapes(i0 + 3, j) + END IF END DO END IF END DO diff --git a/src/CableDyn_OpenFAST_HermiteFMF.f90 b/src/CableDyn_OpenFAST_HermiteFMF.f90 index 55be3705..52e57366 100644 --- a/src/CableDyn_OpenFAST_HermiteFMF.f90 +++ b/src/CableDyn_OpenFAST_HermiteFMF.f90 @@ -74,6 +74,7 @@ MODULE CableDyn_OpenFAST_HermiteFMF PUBLIC :: CD_HFMF_Set_EndConnection PUBLIC :: CD_HFMF_Set_Torsion PUBLIC :: CD_HFMF_Refresh_Acceleration + PUBLIC :: CD_HFMF_Twist_Lin_Count, CD_HFMF_Twist_Lin_Slots, CD_HFMF_Set_Twist_Frame_Rates PUBLIC :: CD_HFMF_NNodes PUBLIC :: CD_HFMF_GetNodePositions PUBLIC :: CD_HFMF_UpdateStates @@ -1274,6 +1275,77 @@ SUBROUTINE CD_HFMF_Refresh_Acceleration(self, ErrStat, ErrMsg) END IF END SUBROUTINE CD_HFMF_Refresh_Acceleration + INTEGER FUNCTION CD_HFMF_Twist_Lin_Count(self) RESULT(n) + !! Number of the cable's nodal-twist linearisation states of one kind: the free twist angles, + !! at every node but a torsionally rigid end (whose angle is held). Zero without torsion and + !! for the condensed torsion, whose torque M = (Phi - Theta(q))/C is an algebraic function of + !! the configuration and the end frames with no state of its own. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + n = 0 + IF (.NOT. self%initialized) RETURN + IF (.NOT. self%line%tw_active) RETURN + n = COUNT(self%line%tw_free) + END FUNCTION CD_HFMF_Twist_Lin_Count + + SUBROUTINE CD_HFMF_Twist_Lin_Slots(self, phi_slot, rate_slot, acc_slot, node, ErrStat, ErrMsg) + !! The slots, 1-based in this cable's CD_HFMF_PackMirror buffer, of the free twist angles phi, + !! their rates and their accelerations, with their model nodes (End B = node 1), in node order; + !! each array is sized CD_HFMF_Twist_Lin_Count. Angles, rates and accelerations are the first + !! three nn-blocks of the nodal-twist tail that closes the torsion block + !! (CD_HermiteCable_Dyn_Twist_Pack), so the slots of the free nodes are consecutive. + TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self + INTEGER, INTENT(OUT) :: phi_slot(:), rate_slot(:), acc_slot(:), node(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: k0, i, k, n + ErrStat = CD_HFMF_OK + ErrMsg = '' + phi_slot = 0 + rate_slot = 0 + acc_slot = 0 + node = 0 + n = CD_HFMF_Twist_Lin_Count(self) + IF (SIZE(phi_slot) /= n .OR. SIZE(rate_slot) /= n .OR. SIZE(acc_slot) /= n .OR. SIZE(node) /= n) THEN + ErrStat = CD_HFMF_BADINPUT + ErrMsg = 'CD_HFMF_Twist_Lin_Slots: the slot arrays must be sized CD_HFMF_Twist_Lin_Count' + RETURN + END IF + IF (n == 0) RETURN + k0 = CD_HFMF_MirrorSize(self) - CD_HermiteCable_Dyn_Twist_Mirror_Size(self%line) + k = 0 + DO i = 1, self%line%nn + IF (.NOT. self%line%tw_free(i)) CYCLE + k = k + 1 + phi_slot(k) = k0 + i + rate_slot(k) = k0 + self%line%nn + i + acc_slot(k) = k0 + 2*self%line%nn + i + node(k) = i + END DO + END SUBROUTINE CD_HFMF_Twist_Lin_Slots + + SUBROUTINE CD_HFMF_Set_Twist_Frame_Rates(self, ErrStat, ErrMsg) + !! Linearisation of the nodal twist: give the parent-attached end frame the angular velocity + !! and acceleration of the parent last written (CD_HFMF_SetCoupledKinematics), the rates a + !! time step takes from the frame's turn over the step (tw_om, tw_oal of the committed step). + !! The frame turns rigidly with the parent, so its rates are the parent's, here in the solve + !! frame. With them the torsional damping of the element at a rigid end takes the frame's + !! turning rate, (Bt/l0) drho/dw . omega, and the reaction moment the polar inertia of the held + !! end section, as in the march; without them a linearisation would hold both at the committed + !! rates. A no-op without the nodal twist or a parent-attached frame. The caller restores the + !! committed rates with the mirror (CD_HFMF_UnpackMirror). + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_HFMF_OK + ErrMsg = '' + IF (.NOT. self%initialized) THEN + ErrStat = CD_HFMF_BADINPUT; ErrMsg = 'CD_HFMF_Set_Twist_Frame_Rates: module not initialised'; RETURN + END IF + IF (.NOT. (self%tors_parent .AND. self%line%tw_active)) RETURN + self%line%tw_om(:, self%tors_index) = frame_to_local(self, self%parent_omega) + self%line%tw_oal(:, self%tors_index) = frame_to_local(self, self%parent_alpha) + END SUBROUTINE CD_HFMF_Set_Twist_Frame_Rates + INTEGER FUNCTION CD_HFMF_NNodes(self) RESULT(n) !! Node count of the owned cable (the held-fluid sampling surface). Zero if !! uninitialised. @@ -1679,8 +1751,10 @@ END FUNCTION CD_HFMF_BoundaryMirrorSize INTEGER FUNCTION CD_HFMF_TorsionMirrorSize(self) RESULT(n) !! Mirror slots of the torsion, last: the accepted (unwrapped) Theta, Phi and the four - !! end-frame vectors (14 values), then the nodal twist's state - !! (CD_HermiteCable_Dyn_Twist_Mirror_Size); zero without torsion. + !! end-frame vectors (14 values), then the nodal twist's state with its committed torque + !! (CD_HermiteCable_Dyn_Twist_Mirror_Size); zero without torsion. The condensed torque is + !! re-derived on a reload, (Phi - Theta)/C at the re-applied (committed) lengths, which is + !! how every step and frame write forms it. TYPE(CD_HFMF_ModuleType), INTENT(IN) :: self n = 0 IF (.NOT. self%initialized) RETURN @@ -1935,7 +2009,8 @@ SUBROUTINE CD_HFMF_UnpackMirror(self, buf, t, ErrStat, ErrMsg) self%line%torsion%torque = (self%line%torsion%phi - self%line%torsion%theta)/ & CD_HermiteTorsion_Compliance(self%line%torsion, self%line%l0) self%line%tors_drive_set = .FALSE. - ! the nodal twist, checked above (its force-cache part rides with the cable's) + ! the nodal twist, checked above (its force-cache part rides with the cable's); it brings + ! back the committed torque as it was formed (a summed twist over the compliance) IF (self%line%tw_active) CALL CD_HermiteCable_Dyn_Twist_Unpack(self%line, buf(k + 15:SIZE(buf)), es, em) ! (a parent-attached torsion frame turns with the parent orientation, which the boundary ! block restored as committed, so a later step without u_orientation holds it) diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 01d7957a..55864a9f 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -55,10 +55,12 @@ MODULE CableDyn !! deck + state mirror, accepted on committed mooring-interval boundaries), !! linearization with the line dynamics (as MoorDyn-F: the continuous states are the !! EI=0 lines' interior-node positions and the finite-EI cables' free DOFs, positions - !! and tangents, then their velocities, and the rope models' constitutive states; A, B, C - !! and D by central differences of lin_eval, the accelerations and state rates evaluated - !! at the perturbed state; Free/Connect points, VIV lines, bodies, rods, Point3 buoys, - !! torsion, CONTROL and rigid cable ends fail closed), and + !! and tangents, and the free twist angles of a cable restrained in torsion, then their + !! velocities, and the rope models' constitutive states; A, B, C and D by central + !! differences of lin_eval, the accelerations and state rates evaluated at the perturbed + !! state; the coupled-point orientation turns a torsion end frame and the fairlead moment + !! carries the torque; Free/Connect points, VIV lines, bodies, rods, Point3 buoys, CONTROL + !! and rigid cable ends fail closed), and !! FAST.Farm farm-level moorings (FarmSize > 0: Turbine decks, !! per-turbine coupled meshes, shared lines; still-water hydro; farm restart and !! farm linearization fail closed with named messages). Checkpoint restart re-parses a @@ -99,7 +101,9 @@ MODULE CableDyn USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & CD_HFMF_FrictionMirrorSize, CD_HFMF_BoundaryMirrorSize, & CD_HFMF_ForceMirrorSize, CD_HFMF_TorsionMirrorSize, CD_HFMF_VIVMirrorSize, & - CD_HFMF_Refresh_Acceleration, CD_HFMF_OK + CD_HFMF_Refresh_Acceleration, CD_HFMF_OK, & + CD_HFMF_Twist_Lin_Count, CD_HFMF_Twist_Lin_Slots, & + CD_HFMF_Set_Twist_Frame_Rates USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Reset_Profile, & CD_HermiteCable_Dyn_Disable_Profile, & CD_HermiteCable_Dyn_Get_Profile, & @@ -853,16 +857,9 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ErrStat, ErrMsg, RoutineName ) RETURN END IF - ! a line restrained in torsion returns a torque moment that turns with the platform - ! even at a bending-pinned end: its rotational stiffness a a^T / C has no column in - ! the translation-only reduction either - IF (Inst(id)%agg%cables(ic)%line%torsion%active) THEN - CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: formal OpenFAST linearization '// & - 'of a line restrained in torsion is not supported: its condensed torque '// & - 'carries no state of its own (set TorsStiffness Free to linearize).', & - ErrStat, ErrMsg, RoutineName ) - RETURN - END IF + ! (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) END DO END IF CALL CD_AGG_GetInitMetadata( Inst(id)%agg, nreportlines, npoints, nsections, nei0, nfinite, es, em ) @@ -2713,16 +2710,17 @@ END SUBROUTINE CD_CalcContStateDeriv !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE lin_state_map( inst_e, m, ErrStat, ErrMsg ) !! The x%states mirror slots of the linearization states (CD_InitVars under Linearize): for - !! every interior DOF of an EI = 0 line and every free DOF of a finite-EI cable, the slot of - !! its position, of its velocity and of its acceleration (lin_pos, lin_vel, lin_acc), and the - !! mirror buffers of lin_eval. + !! every interior DOF of an EI = 0 line, every free DOF of a finite-EI cable and every free + !! twist angle of a cable restrained in torsion, the slot of its position, of its velocity + !! and of its acceleration (lin_pos, lin_vel, lin_acc), and the mirror buffers of lin_eval. TYPE(CD_OF_Instance), INTENT(INOUT) :: inst_e TYPE(CD_MiscVarType), INTENT(IN) :: m INTEGER(IntKi), INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER(IntKi) :: il, ic, ndofl, nin, nf, csz, koff, n, k, j, es, n1, k1, kind + INTEGER(IntKi) :: il, ic, ndofl, nin, nf, csz, koff, n, k, j, es, n1, k1, kind, ntw CHARACTER(ErrMsgLen) :: em LOGICAL, ALLOCATABLE :: mask(:) + INTEGER, ALLOCATABLE :: tw_p(:), tw_r(:), tw_a(:), tw_n(:) ErrStat = ErrID_None ErrMsg = '' @@ -2736,7 +2734,7 @@ SUBROUTINE lin_state_map( inst_e, m, ErrStat, ErrMsg ) END DO DO ic = 1, inst_e%agg%ncable IF (CD_HFMF_MirrorSize( inst_e%agg%cables(ic) ) <= 0) CYCLE - n = n + COUNT(inst_e%agg%cables(ic)%line%freemask) + n = n + COUNT(inst_e%agg%cables(ic)%line%freemask) + CD_HFMF_Twist_Lin_Count( inst_e%agg%cables(ic) ) END DO ! the constitutive states: every viscoelastic and Syrope element, the per-element tail ! after the line's interior block (as pack_state_mirror) @@ -2801,6 +2799,31 @@ SUBROUTINE lin_state_map( inst_e, m, ErrStat, ErrMsg ) END DO koff = koff + csz END DO + ! the nodal twist of a cable restrained in torsion: each free node's angle phi, its rate and + ! its acceleration, in the cable's torsion tail (CD_HFMF_Twist_Lin_Slots) + koff = 0 + IF (inst_e%nlines > 0) koff = m%LineStateIsN(inst_e%nlines) + DO ic = 1, inst_e%agg%ncable + csz = CD_HFMF_MirrorSize( inst_e%agg%cables(ic) ) + IF (csz <= 0) CYCLE + ntw = CD_HFMF_Twist_Lin_Count( inst_e%agg%cables(ic) ) + IF (ntw > 0) THEN + ALLOCATE (tw_p(ntw), tw_r(ntw), tw_a(ntw), tw_n(ntw)) + CALL CD_HFMF_Twist_Lin_Slots( inst_e%agg%cables(ic), tw_p, tw_r, tw_a, tw_n, es, em ) + IF (es /= CD_HFMF_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))//': '// & + TRIM(em), ErrStat, ErrMsg, 'lin_state_map' ); RETURN + END IF + DO j = 1, ntw + k = k + 1 + inst_e%lin_pos(k) = koff + tw_p(j) + inst_e%lin_vel(k) = koff + tw_r(j) + inst_e%lin_acc(k) = koff + tw_a(j) + END DO + DEALLOCATE (tw_p, tw_r, tw_a, tw_n) + END IF + koff = koff + csz + END DO inst_e%lin_states = .TRUE. CONTAINS @@ -2907,7 +2930,11 @@ SUBROUTINE lin_eval( id, p, m, u, x_in, ErrStat, ErrMsg, dxdt, y_out ) CALL restore; RETURN END IF ! the input: the coupled points move to u, and the accelerations follow (the EI = 0 lines - ! in the non-probe update, the cables by their refresh) + ! in the non-probe update, the cables by their refresh). The orientation of a cable's + ! coupled point turns its parent-attached torsion end frame (CD_HFMF_SetCoupledKinematics): + ! the condensed torque (Phi - Theta)/C and a nodal twist's end element are then evaluated + ! with the turned frame, and the frame takes the point's angular velocity and acceleration + ! (CD_HFMF_Set_Twist_Frame_Rates: the torsional damping and the held section's inertia) CALL mesh_to_arrays( u%CoupledKinematics(1), Inst(id)%ncp, Inst(id)%ws_pos, Inst(id)%ws_vel, & Inst(id)%ws_acc, Inst(id)%ws_orient, Inst(id)%ws_omega, Inst(id)%ws_alpha, & ErrStat2, ErrMsg2 ) @@ -2922,7 +2949,17 @@ SUBROUTINE lin_eval( id, p, m, u, x_in, ErrStat, ErrMsg, dxdt, y_out ) CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) CALL restore; RETURN END IF + ! (The operating-point outputs of the .lin file come from CD_CalcOutput, which keeps the + ! committed state's accelerations and the end-frame rates of its last step's turn; at a + ! settled operating point, such as the still-water start the documentation prescribes, + ! they are those of this surface, and the matrices are differences of this surface alone.) DO ic = 1, Inst(id)%agg%ncable + CALL CD_HFMF_Set_Twist_Frame_Rates( Inst(id)%agg%cables(ic), es, em ) + IF (es /= CD_HFMF_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & + ' torsion end-frame rates: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) + CALL restore; RETURN + END IF CALL CD_HFMF_Refresh_Acceleration( Inst(id)%agg%cables(ic), es, em ) IF (es /= CD_HFMF_OK) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & @@ -3504,17 +3541,36 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) ! the constitutive states: a viscoelastic slow-branch stretch (m) takes the position step, ! a Syrope slow strain the strain of a micrometre over a metre REAL(R8Ki), PARAMETER :: LIN_DSLOW = 1.0E-6_R8Ki + ! the nodal twist: at a fixed configuration the element twist phi_{e+1} - phi_e + rho_e(q) + ! (with GJ|K, + (K/GJ)(l_e - l0), which the angles do not change) and so the torques and + ! their forces M_e drho_e/dq on the cable are affine in the angles; the coupling of the + ! angles to the configuration (rho_e, the stretch) is not, and the angle takes the + ! position step's 1e-6 rad, as the r and m it is differenced with. A rate enters only the + ! linear torsional damping, so any rate step is exact up to round-off: 0.01 rad/s + REAL(R8Ki), PARAMETER :: LIN_DPHI = 1.0E-6_R8Ki, LIN_DW = 1.0E-2_R8Ki + ! the coupled-point rotation step of a linearization run: a rotation moves no node, so + ! neither contact nor slack constrains it, and the turn of a torsion end frame about axes + ! across its director (a solid angle) or of an end connection's direction is nonlinear: + ! 1e-4 rad keeps the central difference's O(h^2) error near 1e-9 and the difference of the + ! moments and accelerations some eight digits above round-off. In a Linearize run every + ! input Jacobian goes through lin_eval with this step, the glue's time-domain + ! input-output solves before the linearization times included; a run without + ! Linearize keeps 0.1 rad + REAL(R8Ki), PARAMETER :: LIN_DROT = 1.0E-4_R8Ki LOGICAL, ALLOCATABLE :: lin1m(:) - INTEGER(IntKi) :: kind1 + INTEGER(IntKi) :: kind1, ntw + INTEGER, ALLOCATABLE :: tw_p(:), tw_r(:), tw_a(:), tw_n(:) INTEGER(IntKi) :: ipass, nnc, inode, ikind, i0, nrun, icomp, k ! the position step of the line states and the coupled-point displacement step of the ! inputs under linearization (lin_disp_step), and a cable's tangent-rate step - REAL(R8Ki) :: dx_pos, dx_u, dtr + REAL(R8Ki) :: dx_pos, dx_u, dtr, dx_rot ErrStat = ErrID_None ErrMsg = '' dx_u = 0.05_R8Ki + dx_rot = 0.1_R8Ki IF (Linearize) THEN + dx_rot = LIN_DROT dx_u = LIN_DX CALL lin_disp_step( inst_, dx_u, ErrStat2, ErrMsg2 ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) @@ -3525,8 +3581,9 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) IF (Linearize) THEN ! Linearization with the line dynamics, as MoorDyn-F: the continuous states are the ! positions of every EI = 0 line's interior nodes and of every finite-EI cable's free - ! DOFs (node positions r and tangents m = dr/ds), then their velocities, held in the - ! x%states mirror slots (lin_state_map), and the per-element constitutive states of the + ! DOFs (node positions r and tangents m = dr/ds) and the free twist angles phi of a + ! cable restrained in torsion, then their velocities, held in the x%states mirror slots + ! (lin_state_map), and the per-element constitutive states of the ! viscoelastic and Syrope ropes as first-order states. The acceleration and the other ! mirror blocks are not registered: the glue would take every registered x as a state. ALLOCATE (Vars%x(0), STAT=ErrStat2) @@ -3624,6 +3681,56 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) END DO koff = koff + csz END DO + ! the nodal twist of every cable restrained in torsion, after the cables' r and m: + ! the angles phi of its free nodes (every node but a torsionally rigid end), then in + ! the second pass their rates, one consecutive run per cable (CD_HFMF_Twist_Lin_Slots) + koff = 0 + IF (inst_%nlines > 0) koff = m%LineStateIsN(inst_%nlines) + DO ic = 1, inst_%agg%ncable + csz = CD_HFMF_MirrorSize( inst_%agg%cables(ic) ) + IF (csz <= 0) CYCLE + ntw = CD_HFMF_Twist_Lin_Count( inst_%agg%cables(ic) ) + IF (ntw > 0) THEN + nnc = inst_%agg%cables(ic)%line%nn + ALLOCATE (tw_p(ntw), tw_r(ntw), tw_a(ntw), tw_n(ntw), CblLinPos(ntw), STAT=ErrStat2) + IF (ErrStat2 /= 0) THEN + CALL SetErrStat( ErrID_Fatal, 'Could not allocate cable twist lin-name work arrays.', & + ErrStat, ErrMsg, RoutineName ); RETURN + END IF + CALL CD_HFMF_Twist_Lin_Slots( inst_%agg%cables(ic), tw_p, tw_r, tw_a, tw_n, es, em ) + IF (es /= CD_HFMF_OK) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & + ': '//TRIM(em), ErrStat, ErrMsg, RoutineName ); RETURN + END IF + ! one variable per cable and kind needs one consecutive run of mirror slots + IF (tw_p(ntw) - tw_p(1) /= ntw - 1 .OR. tw_r(ntw) - tw_r(1) /= ntw - 1) THEN + CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: cable '//TRIM(Num2LStr(ic))// & + ': the free twist angles are not consecutive in the state mirror.', & + ErrStat, ErrMsg, RoutineName ); RETURN + END IF + ! the node named End A first, as the channels and the cable's r and m states + DO j = 1, ntw + LinStr = 'Cable '//TRIM(Num2LStr(ic))//' node '//TRIM(Num2LStr(nnc + 1 - tw_n(j))) + IF (ipass == 1) THEN + CblLinPos(j) = TRIM(LinStr)//' twist, rad' + ELSE + CblLinPos(j) = TRIM(LinStr)//' twist rate, rad/s' + END IF + END DO + LinStr = 'Cable '//TRIM(Num2LStr(ic))//' twist' + IF (ipass == 1) THEN + CALL MV_AddVar( Vars%x, LinStr, FieldScalar, DatLoc(CD_x_states), & + iAry=koff + tw_p(1), Num=ntw, Flags=VF_DerivOrder2, DerivOrder=0, & + Perturb=LIN_DPHI, LinNames=CblLinPos ) + ELSE + CALL MV_AddVar( Vars%x, TRIM(LinStr)//' rate', FieldScalar, DatLoc(CD_x_states), & + iAry=koff + tw_r(1), Num=ntw, Flags=VF_DerivOrder2, DerivOrder=1, & + Perturb=LIN_DW, LinNames=CblLinPos ) + END IF + DEALLOCATE (tw_p, tw_r, tw_a, tw_n, CblLinPos) + END IF + koff = koff + csz + END DO END DO ! the per-element constitutive states of the EI = 0 lines, first-order states: the ! viscoelastic slow-branch stretch dl_1 and the Syrope slow strain (the Syrope running @@ -4029,7 +4136,7 @@ SUBROUTINE CD_InitVars(Vars, u, p, x, y, m, inst_, Linearize, ErrStat, ErrMsg) DatLoc(CD_u_CoupledKinematics, ivT), & Mesh=u%CoupledKinematics(ivT), & Perturbs=[dx_u, & ! FieldTransDisp - 0.1_R8Ki, & ! FieldOrientation + dx_rot, & ! FieldOrientation 0.1_R8Ki, & ! FieldTransVel 0.1_R8Ki, & ! FieldAngularVel 0.1_R8Ki, & ! FieldTransAcc diff --git a/tests/data/torsion_lazy_wave_modes.dat b/tests/data/torsion_lazy_wave_modes.dat new file mode 100644 index 00000000..f525bc61 --- /dev/null +++ b/tests/data/torsion_lazy_wave_modes.dat @@ -0,0 +1,46 @@ +--------------------- CableDyn Input File ------------------------------------ +Modal analysis (nModes) of the Gulf of Mexico 80 m lazy-wave cable twisted two turns +-- Driver regression: the cable, clamped and restrained in torsion at both ends, of +-- examples/torsion_lazy_wave_hangoff_twist.dat (illustrative GJ = 50 kN.m^2), with the two turns +-- imposed as the End B pretwist instead of the hang-off roll. The static solve twists the cable +-- by +720 deg; the modes about that twisted equilibrium carry the twist angle of every node +-- (the polar inertia Irn of LINE TYPES), so the table adds PolarShare and dTwist. One 0.1 s step. +--------------------- LINE TYPES --------------------------------------------- +TypeName Diam MassDenInAir EA BA EI GAs GJ Irt Irn Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (N-m2) (N) (N-m2) (kg-m) (kg-m) (-) (-) (-) (-) +bare 0.160 36.70 4.69e8 0.0 1.99e4 9.02e7 5.0e4 0.0587 0.1174 1.2 0.1 1.0 0.0 +buoy 0.290 59.53 4.69e8 0.0 1.99e4 9.02e7 5.0e4 0.3129 0.6258 1.2 0.1 1.0 0.0 +--------------------- POINTS ------------------------------------------------ +ID Type X Y Z +(-) (-) (m) (m) (m) +1 Coupled 5.0 0.0 -14.0 +2 Fixed 125.0 0.0 -80.0 +--------------------- LINES ------------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +--------------------- SECTIONS ---------------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 bare 68.114 56 +1 buoy 50.000 40 +1 bare 52.101 32 +--------------------- END CONNECTIONS --------------------------------------- +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg) +1 A Rigid 0.14641 0.0 -0.98922 Rigid 0.0 1.0 0.0 0.0 +1 B Rigid 0.99999 0.0 0.00503 Rigid 0.0 1.0 0.0 720.0 +--------------------- OPTIONS ----------------------------------------------- +9.80665 g - Gravitational acceleration (m/s^2) +1025.0 rhoW - Water density (kg/m^3) +80.0 WtrDpth - Water depth for the flat seabed (m) +1.0e5 kBot - Seabed penalty stiffness base (Pa/m) +1.0e4 cBot - Seabed normal damping base (Pa-s/m) +0.1 dtM - CableDyn internal time step (s) +0.1 TMax - Standalone simulation duration (s) +12 nModes - Modal analysis: number of lowest natural modes per line +--------------------- OUTPUTS ----------------------------------------------- +"FairTen1" +"Torq1N1" +"Twist1" +--------------------- need this line ---------------------------------------- diff --git a/tests/test_control_torsion.f90 b/tests/test_control_torsion.f90 new file mode 100644 index 00000000..e63a3ec6 --- /dev/null +++ b/tests/test_control_torsion.f90 @@ -0,0 +1,1048 @@ +! File: tests/test_control_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_control_torsion + !! Active line control (CD_HermiteCable_Dyn_Set_SegmentLength, deck CONTROL) of a finite-EI line + !! restrained in torsion. Unless named otherwise the line is straight along +x, 10 elements of + !! 1 m unstretched held between rigid torsional ends H = 10.1 m apart (1 % strain), with the + !! imposed twist Phi; its fairlead-side span (the last two elements, S = 2 m) is controlled. + !! Q quasi-static: the span paid out and hauled in, DeltaL = 0.05 sin(2 pi t/10 s), carries the + !! torque GJ Phi/L(t) + K (H - L)/L and the tension EA (H - L)/L + K Phi/L (L = 10 m + DeltaL, + !! with the axial damping's BA d(eps)/dt): + !! condensed torsion without and with torque-tension coupling K, and the nodal twist with a + !! negligible Irn (1e-9) and K (every node torque); + !! D torsional damping with the length rate: a constant pay-out Ldot of the span under GJ|K|Bt + !! (Irn 1e-9) keeps the twist per length uniform, so the torque is the Kelvin-Voigt + !! GJ chi + Bt chi_dot with chi = (Phi + (K/GJ) H)/L - K/GJ; without the rate it is not; + !! F the length-rate share of the torsional damping on a bowed line equals Bt l0_dot + !! d(tau/l0)/dl0 by central differences of the element twist at fixed q (the Euler identity + !! l0 drho/dl0 = m . drho/dm of the element shape), on interior elements, at both rigid + !! torsional ends (End A the fairlead) and with coupling, and the torque tangent the step + !! assembles matches central differences of the torque; + !! Z the torsion terms a length change rebuilds equal those of a model built with the new + !! lengths bit for bit (the lumped polar inertia Irn l0/2, a -zeta torsional damping + !! re-resolved as zeta l0 sqrt(GJ Irn), a direct Bt kept); a committed-state evaluation + !! between the command and the step takes the committed lengths and leaves the present ones, + !! and a saved control state and a snapshot take a command back bit for bit; + !! E energy with a real Irn: with the centreline held, a span paid out under a ringing twist + !! changes the twist and polar kinetic energy by the work of the length change, + !! integral of sum (dE/dl0) l0_dot + 1/2 I_dot w^2 (the mass of the new lengths, without the + !! rate term, as for the translational mass); + !! L a slow pay-out under a twist with a real Irn: the torque follows GJ Phi/L(t), the run at + !! rho_inf = 0.4 (alpha_f = 2/7) follows the one at rho_inf = 0 within a few per cent of the + !! per-step torque change, also with the committed force evaluated afresh each step rather + !! than reused (it keeps its torsion at the committed lengths; taking it at the new ones + !! lags by alpha_f of it), and no step jumps; + !! R restart mid-ramp: a rolling, twisting, torsionally damped coupled cable under a pay-out + !! ramp continues bit-identically from a snapshot and from a module rebuilt from the + !! checkpoint mirror with the command re-applied; after a non-stepping frame write (whose + !! torque is the summed twist over the compliance) both bring back that committed torque + !! bit for bit, which re-deriving it as (Phi - Theta)/C would not (where a build makes the + !! two equal, the torque is set one ulp off the re-derived value so the check resolves); + !! S deck: a straight torsion line with a pretwist and a CONTROL row on the coupled aggregate + !! (the CompMooring = 5 route; the standalone driver takes no CONTROL) initialises, its + !! Torq1N1 follows GJ Twist1/L(t) through a haul-in ramp, and the shell's checkpoint recipe + !! continues bit-identically. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & + CD_HermiteTorsion_Zeta_Damping, CD_HermiteTorsion_Element_Stretch, & + CD_HermiteTorsion_Compliance, CD_HTORS_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Reaction, & + CD_HermiteCable_Dyn_Set_SegmentLength, & + CD_HermiteCable_Dyn_Set_Axial_Damping, & + CD_HermiteCable_Dyn_Set_Torsion, CD_HermiteCable_Dyn_Set_Torsion_Drive, & + CD_HermiteCable_Dyn_Torsion_State, CD_HermiteCable_Dyn_Node_Torque, & + CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Element_Torque, & + CD_HermiteCable_Dyn_Recompute_Acceleration, CD_HermiteCable_Dyn_Snapshot, & + CD_HermiteCable_Dyn_Restore, CD_HermiteCableControlSaveType, & + CD_HermiteCable_Dyn_Save_Control, CD_HermiteCable_Dyn_Restore_Control, & + CD_HermiteCable_Dyn_Set_ForceBlend, CD_HermiteCable_Dyn_End, CD_HCDYN_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_ModuleType, CD_HFMF_Init, CD_HFMF_Set_EndConnection, & + CD_HFMF_Set_Torsion, CD_HFMF_UpdateStates, CD_HFMF_Set_SegmentLength, & + CD_HFMF_SetCoupledKinematics, & + CD_HFMF_Snapshot, CD_HFMF_Restore, CD_HFMF_MirrorSize, & + CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, CD_HFMF_End, CD_HFMF_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_UpdateStates_Moving, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & + CD_AGG_Apply_LineControl, CD_AGG_EvalChannel, CD_AGG_End, CD_AGG_OK + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + ! the straight line of Q, D, Z, E, L + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, NDOF = 6*NN + REAL(wp), PARAMETER :: LS = 10.0_wp, HH = 10.1_wp, EA = 1.0e5_wp, EI = 100.0_wp, GJ = 80.0_wp + REAL(wp), PARAMETER :: PHI0 = 0.5_wp*PI, KTT = 500.0_wp + INTEGER, PARAMETER :: SPAN(2) = [NE - 1, NE] + INTEGER :: nfail = 0 + + CALL check_quasi_static('condensed', 0.0_wp, 0.0_wp) + CALL check_quasi_static('condensed, coupled', KTT, 0.0_wp) + CALL check_quasi_static('nodal twist, coupled', KTT, 1.0e-9_wp) + CALL check_damping_rate() + CALL check_rate_identity('interior', [5, 6], 0.0_wp) + CALL check_rate_identity('End B rigid', [1, 2], 0.0_wp) + CALL check_rate_identity('fairlead, End A rigid', [NE - 1, NE], 0.0_wp) + CALL check_rate_identity('interior, coupled', [5, 6], 0.5_wp) + CALL check_rate_identity('fairlead, coupled', [NE - 1, NE], 0.5_wp) + CALL check_rebuild() + CALL check_energy() + CALL check_lag() + CALL check_restart() + CALL check_deck() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: active line control of lines restrained in torsion' + +CONTAINS + + 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 + + LOGICAL FUNCTION same_bits(x, y) RESULT(same) + REAL(wp), INTENT(IN) :: x(:), y(:) + same = SIZE(x) == SIZE(y) + IF (same) same = ALL(TRANSFER(x, 0_INT64, SIZE(x)) == TRANSFER(y, 0_INT64, SIZE(y))) + END FUNCTION same_bits + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE build_line(m, l0, rho_inf, rhoa, ktt_in, irn, ba, hold_all, es, em, bt, zeta, phi) + !! The straight line: nodes at x = s H/L with m = (H/L, 0, 0) (uniform strain, at rest in + !! equilibrium without weight), every transverse DOF held (an axial and torsional problem), + !! the end translations held (hold_all: every DOF, the twist alone moves). The kernel takes + !! EA - K^2/GJ, as the deck gives it under coupling. Torsion: both ends along +x with the + !! reference normal +z, rigid, imposed twist phi (default Phi0), GJ, coupling ktt_in, the + !! polar inertia irn (> 0: nodal twist), a direct Bt (bt) or a -zeta damping (zeta, resolved + !! as the deck does). ba > 0 adds axial damping. + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: m + REAL(wp), INTENT(IN) :: l0(NE), rho_inf, rhoa, ktt_in, irn, ba + LOGICAL, INTENT(IN) :: hold_all + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + REAL(wp), INTENT(IN), OPTIONAL :: bt(NE), zeta(NE), phi + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), s, g(NDOF), raw, lt + INTEGER, ALLOCATABLE :: fixed(:) + INTEGER :: i, k + lt = SUM(l0) + q = 0.0_wp + fixed = [INTEGER ::] + DO i = 1, NN + s = SUM(l0(1:i - 1)) + q(6*i - 5) = s*HH/lt + q(6*i - 2) = HH/lt + fixed = [fixed, 6*i - 4, 6*i - 3, 6*i - 1, 6*i] + IF (hold_all .OR. i == 1 .OR. i == NN) fixed = [fixed, 6*i - 5] + IF (hold_all) fixed = [fixed, 6*i - 2] + END DO + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA - ktt_in**2/GJ, k=1, NE)], [(EI, k=1, NE)], [(rhoa, k=1, NE)], & + [(0.0_wp, k=1, NE)], q, fixed, -1.0e3_wp, 0.0_wp, rho_inf, es, em) + IF (es /= CD_HCDYN_OK) RETURN + IF (ba > 0.0_wp) THEN + CALL CD_HermiteCable_Dyn_Set_Axial_Damping(m, [(ba, k=1, NE)], es, em) + IF (es /= CD_HCDYN_OK) RETURN + END IF + tors%active = .TRUE. + tors%phi = PHI0 + IF (PRESENT(phi)) tors%phi = phi + tors%ends = RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp], [3, 4]) + tors%end_compliance = 0.0_wp + ALLOCATE (tors%gj(NE)) + tors%gj = GJ + IF (ktt_in > 0.0_wp) tors%couple = [(ktt_in/GJ, k=1, NE)] + IF (irn > 0.0_wp) tors%irn = [(irn, k=1, NE)] + IF (PRESENT(bt)) tors%bt = bt + IF (PRESENT(zeta)) THEN + IF (.NOT. ALLOCATED(tors%bt)) tors%bt = [(0.0_wp, k=1, NE)] + tors%bt_zeta = zeta + DO k = 1, NE + IF (zeta(k) > 0.0_wp) tors%bt(k) = CD_HermiteTorsion_Zeta_Damping(zeta(k), l0(k), GJ, irn) + END DO + END IF + CALL CD_HermiteTorsion_Line(q, l0, tors%ends, raw, g, es, em, couple=tors%couple) + IF (es /= CD_HTORS_OK) RETURN + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + END SUBROUTINE build_line + + SUBROUTINE command(m, dl, dldot, es, em, restored) + !! The span from its base S = 2 m to S + dl, each element scaled by (S + dl)/S, rate dldot l/S. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp), INTENT(IN) :: dl, dldot + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + LOGICAL, INTENT(IN), OPTIONAL :: restored + REAL(wp), PARAMETER :: S = 2.0_wp + CALL CD_HermiteCable_Dyn_Set_SegmentLength(m, SPAN, [1.0_wp, 1.0_wp]*((S + dl)/S), [1.0_wp, 1.0_wp]*(dldot/S), & + es, em, restored=restored) + END SUBROUTINE command + + REAL(wp) FUNCTION end_tension(m) RESULT(t) + !! Axial pull of the line on its held fairlead node (the last node). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp) :: f(3) + INTEGER :: es + CHARACTER(200) :: em + CALL CD_HermiteCable_Dyn_Reaction(m, NN, f, es, em) + t = -f(1) + IF (es /= CD_HCDYN_OK) t = HUGE(1.0_wp) + END FUNCTION end_tension + + REAL(wp) FUNCTION line_torque(m) RESULT(tq) + !! The torque of the line: the condensed torque, or the node torque of the nodal twist furthest + !! from the mean (so a non-uniform torque shows). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + REAL(wp) :: th, ntq(NN) + INTEGER :: es + CHARACTER(300) :: em + IF (m%tw_active) THEN + CALL CD_HermiteCable_Dyn_Node_Torque(m, ntq, es, em) + tq = ntq(MAXLOC(ABS(ntq - SUM(ntq)/REAL(NN, wp)), 1)) + ELSE + CALL CD_HermiteCable_Dyn_Torsion_State(m, th, tq, es, em) + END IF + IF (es /= CD_HCDYN_OK) tq = HUGE(1.0_wp) + END FUNCTION line_torque + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_quasi_static(label, kc, irn) + !! Q: rho_inf = 0, a light line (0.01 kg/m) with axial damping, 1000 steps of 0.01 s. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: kc, irn + REAL(wp), PARAMETER :: DT = 0.01_wp, AMP = 0.05_wp, PER = 10.0_wp, BA = 100.0_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: l0(NE), t, dl, dldot, lt, mexp, texp, err_m, err_t, frozen + INTEGER :: k, es + CHARACTER(300) :: em + l0 = 1.0_wp + CALL build_line(m, l0, 0.0_wp, 0.01_wp, kc, irn, BA, .FALSE., es, em) + CALL require(es == CD_HCDYN_OK, 'Q '//label//': build: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + CALL require(m%tw_active .EQV. irn > 0.0_wp, 'Q '//label//': the twist model') + err_m = 0.0_wp + err_t = 0.0_wp + frozen = 0.0_wp + DO k = 1, NINT(PER/DT) + t = REAL(k, wp)*DT + dl = AMP*(SIN(2.0_wp*PI*t/PER) - 0.5_wp*SIN(4.0_wp*PI*t/PER)) + dldot = AMP*(2.0_wp*PI/PER)*(COS(2.0_wp*PI*t/PER) - COS(4.0_wp*PI*t/PER)) + CALL command(m, dl, dldot, es, em) + CALL require(es == CD_HCDYN_OK, 'Q '//label//': command: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) EXIT + CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'Q '//label//': step: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) EXIT + lt = LS + dl + mexp = GJ*PHI0/lt + kc*(HH - lt)/lt + ! the axial Kelvin-Voigt share BA d(eps)/dt of the uniform strain eps = H/L - 1 + texp = EA*(HH - lt)/lt - BA*HH*dldot/lt**2 + kc*PHI0/lt + err_m = MAX(err_m, ABS(line_torque(m) - mexp)/mexp) + err_t = MAX(err_t, ABS(end_tension(m) - texp)/texp) + frozen = MAX(frozen, ABS(GJ*PHI0/LS + kc*(HH - LS)/LS - mexp)/mexp) + END DO + WRITE (*, '(A,A,A,3ES10.2)') 'Q quasi-static (', label, '): torque, tension rel. error; a frozen '// & + 'compliance would miss by ', err_m, err_t, frozen + CALL require(err_m <= 1.0e-7_wp, 'Q '//label//': the torque is GJ Phi/L(t) + K (H - L)/L') + CALL require(err_t <= 1.0e-5_wp, 'Q '//label//': the tension is EA (H - L)/L + K Phi/L') + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_quasi_static + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_damping_rate() + !! D: the span paid out at Ldot = 0.01 m/s from t = 0 over 4 s, Bt = 100 N m2 s, K as in Q. + !! Every element obeys GJ chi_e + Bt chi_e_dot = M with one M (the angles carry no inertia) and + !! starts from one chi, so chi stays uniform, and the end constraint gives sum chi_e l_e = + !! Phi + (K/GJ)(H - L): M = GJ chi + Bt chi_dot, chi_dot = -(Phi + (K/GJ) H) Ldot/L^2. + REAL(wp), PARAMETER :: DT = 0.01_wp, LDOT = 0.01_wp, TEND = 4.0_wp, BT = 100.0_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: l0(NE), t, lt, chi, chid, mexp, err(2), lag, c + INTEGER :: k, es, pass + CHARACTER(300) :: em + c = KTT/GJ + l0 = 1.0_wp + lag = BT*(PHI0 + c*HH)*LDOT/(LS + LDOT*TEND)**2 + DO pass = 1, 2 + CALL build_line(m, l0, 0.0_wp, 0.01_wp, KTT, 1.0e-9_wp, 100.0_wp, .FALSE., es, em, bt=[(BT, k=1, NE)]) + CALL require(es == CD_HCDYN_OK, 'D: build: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + err(pass) = 0.0_wp + DO k = 1, NINT(TEND/DT) + t = REAL(k, wp)*DT + CALL command(m, LDOT*t, MERGE(LDOT, 0.0_wp, pass == 1), es, em) + IF (es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'D: march: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) EXIT + IF (t < 1.0_wp) CYCLE + lt = LS + LDOT*t + chi = (PHI0 + c*HH)/lt - c + chid = -(PHI0 + c*HH)*LDOT/lt**2 + mexp = GJ*chi + BT*chid + err(pass) = MAX(err(pass), ABS(line_torque(m) - mexp)) + END DO + CALL CD_HermiteCable_Dyn_End(m) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A)') 'D torsional damping lag ', lag, ' N m; max torque error with '// & + 'the length rate ', err(1), ', without ', err(2), ' N m' + CALL require(err(1) <= 1.0e-2_wp*lag, 'D: the torque is GJ chi + Bt chi_dot (the twist per length damped)') + CALL require(err(2) > 0.2_wp*lag, 'D: without the length rate the damping torque is wrong') + END SUBROUTINE check_damping_rate + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_rate_identity(label, el, kc) + !! F: a bowed line at rest whose tangent DOFs are neither unit nor along the chord (transverse + !! DOFs free, node 1 and the last node held, nodal twist Irn 0.05 kg m, Bt = 30 N m2 s, rigid + !! torsional ends, coupling K/GJ = kc), the elements el at the rate l0_dot = 0.02 m/s: + !! - the change of their committed torque is Bt l0_dot d(tau/l0)/dl0 at fixed q, against + !! central differences of the element twist (with the coupling term (K/GJ)(l - l0)) over + !! l0 (+- 1e-5 m), and against the straight-line value -Bt l0_dot tau/l0^2; + !! - the element torque's tangent in its 12 DOFs and in its End-2 angle as a step assembles + !! it (the last assembly of a two-iteration step, at the accepted trial iterate, whose q, v, + !! angles and rates the test reads back and checks against the torque the assembly kept), + !! against central differences of the torque at that state (+- 1e-6), and the same + !! differences without the rate, which the check must resolve. + CHARACTER(*), INTENT(IN) :: label + INTEGER, INTENT(IN) :: el(2) + REAL(wp), INTENT(IN) :: kc + REAL(wp), PARAMETER :: BT = 30.0_wp, RATE = 0.02_wp, DELTA = 1.0e-5_wp, HQ = 1.0e-6_wp + TYPE(CD_HermiteCableDynType) :: m, base, pert, at, at0 + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: l0(NE), q(NDOF), s, g(NDOF), raw, tw0(NE), twp(NE), twm(NE), mt0(NE), mt1(NE) + REAL(wp) :: fd(2), share(2), shape(2), err, dq(13), dfd(13), dfd0(13), terr, tres, mp, mm, mt_at, state_err + INTEGER :: i, k, j, es + CHARACTER(300) :: em + l0 = 1.0_wp + q = 0.0_wp + DO i = 1, NN + s = REAL(i - 1, wp) + q(6*i - 5) = s + q(6*i - 4) = 0.8_wp*SIN(PI*s/LS)**2 + q(6*i - 3) = 0.4_wp*SIN(2.0_wp*PI*s/LS)**2 + q(6*i - 2) = 1.0_wp + 0.05_wp*s + q(6*i - 1) = 0.8_wp*(PI/LS)*SIN(2.0_wp*PI*s/LS) + 0.1_wp + q(6*i) = 0.4_wp*(2.0_wp*PI/LS)*SIN(4.0_wp*PI*s/LS) - 0.07_wp + END DO + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(1.0_wp, k=1, NE)], [(0.0_wp, k=1, NE)], & + q, [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], -1.0e3_wp, 0.0_wp, 0.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'F '//label//': init: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + tors%active = .TRUE. + tors%phi = 1.0_wp + tors%ends = RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp], [3, 4]) + tors%end_compliance = 0.0_wp + tors%gj = [(GJ, k=1, NE)] + IF (kc > 0.0_wp) tors%couple = [(kc, k=1, NE)] + tors%irn = [(0.05_wp, k=1, NE)] + tors%bt = [(BT, k=1, NE)] + CALL CD_HermiteTorsion_Line(q, l0, tors%ends, raw, g, es, em, couple=tors%couple) + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + CALL require(es == CD_HCDYN_OK .AND. m%tw_active, 'F '//label//': nodal twist on the bowed line: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + CALL coupled_twist(m, kc, tw0) + CALL CD_HermiteCable_Dyn_Element_Torque(m, mt0, es, em) + ! the element twist at l0 +- DELTA (the committed angles and q kept) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(m, el, l0(el) + DELTA, [0.0_wp, 0.0_wp], es, em) + CALL coupled_twist(m, kc, twp) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(m, el, l0(el) - DELTA, [0.0_wp, 0.0_wp], es, em) + CALL coupled_twist(m, kc, twm) + ! the rate at the base lengths, committed, and the torque of that committed state + CALL CD_HermiteCable_Dyn_Set_SegmentLength(m, el, l0(el), [RATE, RATE], es, em, restored=.TRUE.) + CALL require(es == CD_HCDYN_OK, 'F '//label//': the committed rate: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(m, es, em) + CALL require(es == CD_HCDYN_OK, 'F '//label//': the committed state with the rate: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Element_Torque(m, mt1, es, em) + err = 0.0_wp + DO k = 1, 2 + i = el(k) + fd(k) = BT*RATE*(twp(i)/(l0(i) + DELTA) - twm(i)/(l0(i) - DELTA))/(2.0_wp*DELTA) + shape(k) = -BT*RATE*tw0(i)/l0(i)**2 + share(k) = mt1(i) - mt0(i) + err = MAX(err, ABS(share(k) - fd(k))/ABS(fd(k))) + END DO + ! the tangent of the last assembly of a step (full Newton: the accepted trial of its first + ! iteration) at the state of that assembly, read back from the step's staged iterate + base = m + CALL CD_HermiteCable_Dyn_Step(m, 1.0e-4_wp, 2, 1.0e-14_wp, es, em) + at = base + at%q = m%ws_qa + at%v = m%ws_va + at%tw_phi = m%tw_pe + at%tw_w = m%tw_we + at0 = at + at0%l0_dot = 0.0_wp + at0%l0_dot_c = 0.0_wp + terr = 0.0_wp + tres = 0.0_wp + state_err = 0.0_wp + DO k = 1, 2 + i = el(k) + dq(1:12) = m%tw_ek(i)*m%tw_eg(:, i) + m%tw_ed(i)*m%tw_ehv(:, i) + dq(13) = m%tw_ek(i) + pert = at + CALL perturbed_torque(pert, i, 1, 0.0_wp, mt_at) + state_err = MAX(state_err, ABS(mt_at - m%tw_me(i))/ABS(m%tw_me(i))) + DO j = 1, 13 + pert = at + CALL perturbed_torque(pert, i, j, HQ, mp) + pert = at + CALL perturbed_torque(pert, i, j, -HQ, mm) + dfd(j) = (mp - mm)/(2.0_wp*HQ) + pert = at0 + CALL perturbed_torque(pert, i, j, HQ, mp) + pert = at0 + CALL perturbed_torque(pert, i, j, -HQ, mm) + dfd0(j) = (mp - mm)/(2.0_wp*HQ) + END DO + terr = MAX(terr, MAXVAL(ABS(dq - dfd))/MAXVAL(ABS(dfd))) + tres = MAX(tres, MAXVAL(ABS(dfd - dfd0))/MAXVAL(ABS(dfd))) + END DO + WRITE (*, '(A,A,A,2ES13.5,A,2ES13.5,A,2ES13.5,A,ES9.2,A,ES9.2,A,ES9.2,A,ES9.2)') 'F length-rate damping (', & + label, '): torque ', share, '; by differences ', fd, '; straight-line value ', shape, '; rel. error ', err, & + '; tangent against differences ', terr, ', its length-rate share ', tres, ' (state read back to ', & + state_err, ')' + CALL require(err <= 1.0e-6_wp, 'F '//label//': the length-rate damping is Bt l0_dot d(tau/l0)/dl0 at fixed q') + CALL require(MAXVAL(ABS(shape - fd)) > 1.0e3_wp*err*MAXVAL(ABS(fd)), & + 'F '//label//': the element shape''s dependence on l0 is resolved by the check') + CALL require(state_err <= 1.0e-12_wp, 'F '//label//': the state of the step''s last assembly is read back') + CALL require(terr <= 1.0e-6_wp, 'F '//label//': the assembled torque tangent matches central differences') + CALL require(tres > 1.0e2_wp*terr, 'F '//label//': the tangent check resolves the length-rate share') + DO k = 1, NE + IF (ANY(el == k)) CYCLE + CALL require(same_bits(mt1(k:k), mt0(k:k)), 'F '//label//': elements without a rate keep their torque') + END DO + CALL CD_HermiteCable_Dyn_End(m) + CALL CD_HermiteCable_Dyn_End(base) + CALL CD_HermiteCable_Dyn_End(pert) + CALL CD_HermiteCable_Dyn_End(at) + CALL CD_HermiteCable_Dyn_End(at0) + END SUBROUTINE check_rate_identity + + SUBROUTINE coupled_twist(m, kc, tw) + !! The element twists tau_e of the nodal twist: the material twist (the query) plus the + !! coupling term (K/GJ)(l_e - l0_e) of the stretched element length. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: m + REAL(wp), INTENT(IN) :: kc + REAL(wp), INTENT(OUT) :: tw(NE) + INTEGER :: e, es + CHARACTER(300) :: em + CALL CD_HermiteCable_Dyn_Element_Twist(m, tw, es, em) + IF (.NOT. kc > 0.0_wp) RETURN + DO e = 1, NE + tw(e) = tw(e) + kc*(CD_HermiteTorsion_Element_Stretch(m%q(6*e - 5:6*e + 6), m%l0(e), 4) - m%l0(e)) + END DO + END SUBROUTINE coupled_twist + + SUBROUTINE perturbed_torque(m, e, j, h, mt) + !! The committed torque of element e with its DOF j (1-12: [r1, m1, r2, m2]; 13: the End-2 + !! angle) moved by h, from a re-derived committed state. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: e, j + REAL(wp), INTENT(IN) :: h + REAL(wp), INTENT(OUT) :: mt + REAL(wp) :: tq(NE) + INTEGER :: es + CHARACTER(300) :: em + IF (j <= 12) THEN + m%q(6*e - 6 + j) = m%q(6*e - 6 + j) + h + ELSE + m%tw_phi(e + 1) = m%tw_phi(e + 1) + h + END IF + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(m, es, em) + CALL CD_HermiteCable_Dyn_Element_Torque(m, tq, es, em) + mt = tq(e) + IF (es /= CD_HCDYN_OK) mt = HUGE(1.0_wp) + END SUBROUTINE perturbed_torque + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_rebuild() + !! Z: Irn 0.5 kg m, K, a -zeta damping (zeta 0.1) on every element but element 3, which takes + !! a direct Bt of 7 N m2 s; the span lengthened by 30 % at 0.05 m/s. + REAL(wp), PARAMETER :: LAM = 1.3_wp, IRN = 0.5_wp, ZETA = 0.1_wp, DT = 0.01_wp + TYPE(CD_HermiteCableDynType) :: a, b, ref, twin + TYPE(CD_HermiteCableControlSaveType) :: saved + REAL(wp) :: l0(NE), l0b(NE), zt(NE), btd(NE), bt_keep(NE), mass_keep(NN), torque_keep + INTEGER :: k, es + CHARACTER(300) :: em + l0 = 1.0_wp + zt = ZETA + zt(3) = 0.0_wp + btd = 0.0_wp + btd(3) = 7.0_wp + CALL build_line(a, l0, 0.0_wp, 0.01_wp, KTT, IRN, 100.0_wp, .FALSE., es, em, bt=btd, zeta=zt) + CALL require(es == CD_HCDYN_OK .AND. a%tw_active, 'Z: build: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + ref = a + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, LAM*l0(SPAN), [0.05_wp, 0.05_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. a%has_ctrl, 'Z: a line restrained in torsion takes a length command: '// & + TRIM(em)) + l0b = l0 + l0b(SPAN) = LAM*l0(SPAN) + CALL build_line(b, l0b, 0.0_wp, 0.01_wp, KTT, IRN, 100.0_wp, .FALSE., es, em, bt=btd, zeta=zt) + CALL require(es == CD_HCDYN_OK, 'Z: fresh build at the new lengths: '//TRIM(em)) + CALL require(same_bits(a%tw_mass, b%tw_mass), 'Z: the lumped polar inertia equals a fresh build bit for bit') + CALL require(same_bits(a%torsion%bt, b%torsion%bt), 'Z: the torsional damping equals a fresh build bit for bit') + CALL require(ALL(a%torsion%bt(SPAN) == CD_HermiteTorsion_Zeta_Damping(ZETA, LAM, GJ, IRN)) .AND. & + ALL(a%torsion%bt(SPAN) > ref%torsion%bt(SPAN)), & + 'Z: a -zeta damping is re-resolved as zeta l0 sqrt(GJ Irn) at the new lengths') + CALL require(a%torsion%bt(3) == 7.0_wp .AND. same_bits(a%torsion%bt(1:NE - 2), ref%torsion%bt(1:NE - 2)), & + 'Z: a direct Bt and the elements outside the span keep their damping') + ! a committed-state evaluation between the command and the step takes the committed lengths + ! (the acceleration of a never-commanded twin) and leaves the present torsion terms + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(ref, es, em) + CALL CD_HermiteCable_Dyn_Recompute_Acceleration(a, es, em) + CALL require(es == CD_HCDYN_OK .AND. same_bits(a%a, ref%a) .AND. same_bits(a%tw_al, ref%tw_al) .AND. & + same_bits(a%tw_mt, ref%tw_mt), 'Z: the committed state is evaluated at the committed lengths') + CALL require(same_bits(a%tw_mass, b%tw_mass) .AND. same_bits(a%torsion%bt, b%torsion%bt) .AND. & + same_bits(a%l0, l0b), 'Z: the committed-state evaluation leaves the present torsion terms') + ! a saved control state takes a command back + bt_keep = a%torsion%bt + mass_keep = a%tw_mass + CALL CD_HermiteCable_Dyn_Save_Control(a, saved) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, 0.6_wp*l0(SPAN), [-0.2_wp, -0.2_wp], es, em) + CALL require(es == CD_HCDYN_OK .AND. .NOT. same_bits(a%tw_mass, mass_keep), 'Z: a command to take back') + CALL CD_HermiteCable_Dyn_Restore_Control(a, saved, es, em) + CALL require(es == CD_HCDYN_OK .AND. same_bits(a%tw_mass, mass_keep) .AND. same_bits(a%torsion%bt, bt_keep), & + 'Z: the saved control state takes the torsion terms back bit for bit') + ! snapshot, command, step, restore: lengths, torsion terms and committed torque come back + DO k = 1, 3 + CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'Z: step: '//TRIM(em)) + END DO + ! the snapshot falls between a command and its step: the committed torque belongs to the + ! committed lengths, not to the commanded ones + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, 0.9_wp*l0(SPAN), [-0.1_wp, -0.1_wp], es, em) + twin = a + torque_keep = a%torsion%torque + CALL CD_HermiteCable_Dyn_Snapshot(a, es, em) + CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, 0.8_wp*l0(SPAN), [-0.1_wp, -0.1_wp], es, em) + CALL CD_HermiteCable_Dyn_Step(a, DT, 50, 1.0e-10_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'Z: step after the command: '//TRIM(em)) + CALL CD_HermiteCable_Dyn_Restore(a, es, em) + CALL require(es == CD_HCDYN_OK .AND. same_bits(a%l0, twin%l0) .AND. same_bits(a%tw_mass, twin%tw_mass) .AND. & + same_bits(a%torsion%bt, twin%torsion%bt) .AND. same_bits(a%tw_phi, twin%tw_phi) .AND. & + same_bits([a%torsion%torque], [torque_keep]), & + 'Z: restore brings back the lengths, the torsion terms, the twist and the torque bit for bit') + CALL CD_HermiteCable_Dyn_End(a) + CALL CD_HermiteCable_Dyn_End(b) + CALL CD_HermiteCable_Dyn_End(ref) + CALL CD_HermiteCable_Dyn_End(twin) + END SUBROUTINE check_rebuild + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE energy_of(m, e) + !! Twist and polar kinetic energy of the held straight line, from the element twists and the + !! lengths (sum GJ tau^2/(2 l0) + 1/2 sum I w^2, I the lumped Irn l0/2 of the lengths). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: m + REAL(wp), INTENT(OUT) :: e + REAL(wp), PARAMETER :: IRN = 0.5_wp + REAL(wp) :: tw(NE), inertia(NN) + INTEGER :: es, k + CHARACTER(300) :: em + CALL CD_HermiteCable_Dyn_Element_Twist(m, tw, es, em) + inertia = 0.0_wp + DO k = 1, NE + inertia(k) = inertia(k) + 0.5_wp*IRN*m%l0(k) + inertia(k + 1) = inertia(k + 1) + 0.5_wp*IRN*m%l0(k) + END DO + e = SUM(0.5_wp*GJ*tw**2/m%l0) + 0.5_wp*SUM(inertia*m%tw_w**2) + IF (es /= CD_HCDYN_OK) e = HUGE(1.0_wp) + END SUBROUTINE energy_of + + FUNCTION control_power(m) RESULT(p) + !! The work rate of the length change at the state of m: p(1) the elastic share, the sum over + !! the elements of dE/dl0 l0_dot = -GJ tau^2 l0_dot/(2 l0^2), and p(2) the inertial one, + !! 1/2 I_dot w^2 at the nodes. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: m + REAL(wp) :: p(2) + REAL(wp), PARAMETER :: IRN = 0.5_wp + REAL(wp) :: tw(NE), idot(NN) + INTEGER :: es, k + CHARACTER(300) :: em + p = 0.0_wp + IF (.NOT. m%has_ctrl) RETURN + CALL CD_HermiteCable_Dyn_Element_Twist(m, tw, es, em) + idot = 0.0_wp + DO k = 1, NE + idot(k) = idot(k) + 0.5_wp*IRN*m%l0_dot(k) + idot(k + 1) = idot(k + 1) + 0.5_wp*IRN*m%l0_dot(k) + END DO + p(1) = SUM(-0.5_wp*GJ*tw**2*m%l0_dot/m%l0**2) + p(2) = 0.5_wp*SUM(idot*m%tw_w**2) + IF (es /= CD_HCDYN_OK) p = HUGE(1.0_wp) + END FUNCTION control_power + + SUBROUTINE check_energy() + !! E: Irn 0.5 kg m, no damping, rho_inf = 1, every cable DOF held. Over the first 0.5 s the + !! imposed twist is driven from 1 to 1.3 rad (with zero rate at both ends), which then holds + !! and rings (the first mode at 4 rad/s); from t = 0.5 s the span is paid out by 0.5 m on a + !! smoothstep over 10 s, then held to 15 s. The energy change since the end of the drive is + !! compared with the trapezoidal integral of control_power over the steps. + REAL(wp), PARAMETER :: DT = 0.005_wp, T0 = 0.5_wp, TR = 10.0_wp, TEND = 15.0_wp, AMP = 0.5_wp + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: l0(NE), t, u, dl, dldot, e0, e1, w(2), p0(2), p1(2), err, wmax + INTEGER :: k, es + CHARACTER(300) :: em + l0 = 1.0_wp + CALL build_line(m, l0, 1.0_wp, 1.0_wp, 0.0_wp, 0.5_wp, 0.0_wp, .TRUE., es, em, phi=1.0_wp) + CALL require(es == CD_HCDYN_OK .AND. m%tw_active, 'E: build: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + DO k = 1, NINT(T0/DT) + t = REAL(k, wp)*DT + CALL CD_HermiteCable_Dyn_Set_Torsion_Drive(m, m%torsion%ends, & + 1.0_wp + 0.3_wp*(t/T0 - SIN(2.0_wp*PI*t/T0)/(2.0_wp*PI)), es, em) + IF (es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-11_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'E: the driven steps: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + END DO + CALL energy_of(m, e0) + p0 = control_power(m) + w = 0.0_wp + err = 0.0_wp + wmax = 0.0_wp + DO k = NINT(T0/DT) + 1, NINT(TEND/DT) + t = REAL(k, wp)*DT + u = MIN(MAX((t - T0)/TR, 0.0_wp), 1.0_wp) + dl = AMP*u**3*(10.0_wp - 15.0_wp*u + 6.0_wp*u**2) + dldot = AMP*30.0_wp*u**2*(1.0_wp - u)**2/TR + CALL command(m, dl, dldot, es, em) + IF (es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-11_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'E: march: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) EXIT + CALL energy_of(m, e1) + p1 = control_power(m) + ! trapezoidal work of the step: the power at t_{k-1} (its lengths and the rate commanded + ! then) and at t_k + w = w + 0.5_wp*DT*(p0 + p1) + p0 = p1 + err = MAX(err, ABS(e1 - e0 - SUM(w))) + wmax = MAX(wmax, ABS(SUM(w))) + END DO + WRITE (*, '(A,2ES12.4,A,ES12.5,A,ES10.3)') 'E energy: work of the length change (elastic, inertial) ', w, & + ' J of ', e1, ' J; max balance error ', err/wmax + CALL require(wmax > 1.0e-2_wp*e0, 'E: the length change does measurable work') + CALL require(err <= 2.0e-3_wp*wmax, 'E: the twist energy changes by the work of the length change') + CALL require(ABS(w(2)) > 10.0_wp*err, 'E: the balance resolves the inertial share (the lumped Irn l0/2 follows)') + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_energy + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_lag() + !! L: Irn 0.5 kg m, -zeta 0.2 damping, every cable DOF held, Phi = 1 rad; the span paid out by + !! 0.5 m on a smoothstep over 20 s, dt 0.01 s, at rho_inf = 0 and 0.4, and at 0.4 with the + !! committed force dropped before every step (re-selecting the force blend does), so each + !! step evaluates it at the committed lengths instead of reusing the converged one. + REAL(wp), PARAMETER :: DT = 0.01_wp, TR = 20.0_wp, AMP = 0.5_wp + INTEGER, PARAMETER :: NSTEP = NINT(TR/DT) + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: l0(NE), t, u, dl, dldot, hist(NSTEP, 3), ntq(NN), err_qs, d_step, diff, diff_fresh, jump, prev, mqs + INTEGER :: k, es, pass + CHARACTER(300) :: em + l0 = 1.0_wp + err_qs = 0.0_wp + jump = 0.0_wp + DO pass = 1, 3 + CALL build_line(m, l0, MERGE(0.0_wp, 0.4_wp, pass == 1), 1.0_wp, 0.0_wp, 0.5_wp, 0.0_wp, .TRUE., es, em, & + zeta=[(0.2_wp, k=1, NE)], phi=1.0_wp) + CALL require(es == CD_HCDYN_OK, 'L: build: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) RETURN + prev = GJ*1.0_wp/LS + DO k = 1, NSTEP + t = REAL(k, wp)*DT + u = MIN(t/TR, 1.0_wp) + dl = AMP*u**3*(10.0_wp - 15.0_wp*u + 6.0_wp*u**2) + dldot = AMP*30.0_wp*u**2*(1.0_wp - u)**2/TR + CALL command(m, dl, dldot, es, em) + IF (pass == 3 .AND. es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Set_ForceBlend(m, .TRUE., es, em) + IF (es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Step(m, DT, 50, 1.0e-11_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'L: march: '//TRIM(em)) + IF (es /= CD_HCDYN_OK) EXIT + CALL CD_HermiteCable_Dyn_Node_Torque(m, ntq, es, em) + hist(k, pass) = ntq(1) + mqs = GJ*1.0_wp/(LS + dl) + err_qs = MAX(err_qs, ABS(ntq(1) - mqs)/mqs) + jump = MAX(jump, ABS(ntq(1) - prev)) + prev = ntq(1) + END DO + CALL CD_HermiteCable_Dyn_End(m) + END DO + ! the largest per-step change of the quasi-static torque GJ Phi/L(t): at the peak rate, + ! 15/8 AMP/TR, at the mid-ramp length + d_step = GJ*1.0_wp*(15.0_wp/8.0_wp)*AMP/TR*DT/(LS + 0.5_wp*AMP)**2 + diff = MAXVAL(ABS(hist(:, 2) - hist(:, 1))) + diff_fresh = MAXVAL(ABS(hist(:, 3) - hist(:, 1))) + WRITE (*, '(A,ES10.3,A,ES10.3,A,2ES10.3,A,ES10.3)') 'L slow pay-out: torque vs GJ Phi/L(t) ', err_qs, & + '; per-step change ', d_step, ' N m; rho_inf 0.4 vs 0 (reused, fresh committed force) ', diff, diff_fresh, & + '; largest step ', jump + CALL require(err_qs <= 1.0e-3_wp, 'L: the torque follows GJ Phi/L(t)') + CALL require(diff <= 5.0e-2_wp*d_step, 'L: the alpha_f > 0 run follows the alpha_f = 0 one (no lag)') + CALL require(diff_fresh <= 5.0e-2_wp*d_step, & + 'L: a committed force evaluated afresh is taken at the committed lengths (no lag)') + CALL require(jump <= 1.5_wp*d_step, 'L: no step changes the torque by more than the quasi-static change') + END SUBROUTINE check_lag + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE build_coupled(cab, es, em) + !! The bowed 10 m HFMF cable of the nodal-twist gates (20 elements): node 21 coupled, node 1 + !! held, Rigid bending ends along +x, the coupled torsion frame on the parent, Irn 0.05, + !! K 200 N m, -zeta 0.1 torsional damping, Phi 1 rad. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + INTEGER, PARAMETER :: NE2 = 20, NN2 = NE2 + 1, ND2 = 6*NN2 + REAL(wp), PARAMETER :: KC = 200.0_wp + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(ND2), l0(NE2), eye(3, 3), frame(3, 2), s, g(ND2), raw + INTEGER :: k + l0 = LS/REAL(NE2, wp) + q = 0.0_wp + DO k = 1, NN2 + s = LS*REAL(k - 1, wp)/REAL(NE2, wp) + q(6*k - 5) = s + q(6*k - 4) = 0.3_wp*SIN(PI*s/LS)**2 + q(6*k - 3) = 0.1_wp*SIN(2.0_wp*PI*s/LS)**2 + q(6*k - 2) = 1.0_wp + q(6*k - 1) = 0.3_wp*(PI/LS)*SIN(2.0_wp*PI*s/LS) + q(6*k) = 0.1_wp*(2.0_wp*PI/LS)*SIN(4.0_wp*PI*s/LS) + END DO + eye = 0.0_wp + DO k = 1, 3 + eye(k, k) = 1.0_wp + END DO + CALL CD_HFMF_Init(cab, l0, [(EA - KC**2/GJ, k=1, NE2)], [(EI, k=1, NE2)], [(1.0_wp, k=1, NE2)], & + [(0.0_wp, k=1, NE2)], q, [1, 2, 3, ND2 - 5, ND2 - 4, ND2 - 3], 0.0_wp, 0.0_wp, 0.8_wp, 0.01_wp, & + NN2, es, em, max_iter=60, tol=1.0e-10_wp) + IF (es /= CD_HFMF_OK) RETURN + CALL CD_HFMF_Set_EndConnection(cab, [0.0_wp, 0.0_wp], RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], & + [3, 2]), es, em, & + coupled_d0_parent=[1.0_wp, 0.0_wp, 0.0_wp], parent_orientation=eye, & + connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + IF (es /= CD_HFMF_OK) RETURN + tors%active = .TRUE. + tors%phi = 1.0_wp + tors%ends = RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp], [3, 4]) + tors%end_compliance = 0.0_wp + tors%gj = [(GJ, k=1, NE2)] + tors%couple = [(KC/GJ, k=1, NE2)] + tors%irn = [(0.05_wp, k=1, NE2)] + tors%bt_zeta = [(0.1_wp, k=1, NE2)] + tors%bt = CD_HermiteTorsion_Zeta_Damping(tors%bt_zeta, l0, GJ, 0.05_wp) + CALL CD_HermiteTorsion_Line(q, l0, tors%ends, raw, g, es, em, couple=tors%couple) + IF (es /= CD_HTORS_OK) RETURN + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + frame(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] + frame(:, 2) = [0.0_wp, 0.0_wp, 1.0_wp] + CALL CD_HFMF_Set_Torsion(cab, tors, es, em, coupled_frame_parent=frame, parent_orientation=eye) + END SUBROUTINE build_coupled + + SUBROUTINE coupled_command(cab, k, es, em, restored) + !! The command of step k: the two elements at the coupled end (base 0.5 m each) paid out by + !! 0.15 m on a half cosine over 3 s, then held. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + INTEGER, INTENT(IN) :: k + INTEGER, INTENT(OUT) :: es + CHARACTER(*), INTENT(OUT) :: em + LOGICAL, INTENT(IN), OPTIONAL :: restored + REAL(wp), PARAMETER :: TR = 3.0_wp, AMP = 0.15_wp, S = 1.0_wp + REAL(wp) :: t, dl, dldot + t = 0.01_wp*REAL(k, wp) + IF (t < TR) THEN + dl = AMP*0.5_wp*(1.0_wp - COS(PI*t/TR)) + dldot = AMP*0.5_wp*(PI/TR)*SIN(PI*t/TR) + ELSE + dl = AMP + dldot = 0.0_wp + END IF + CALL CD_HFMF_Set_SegmentLength(cab, [19, 20], [0.5_wp, 0.5_wp]*((S + dl)/S), [0.5_wp, 0.5_wp]*(dldot/S), & + es, em, restored=restored) + END SUBROUTINE coupled_command + + SUBROUTINE coupled_march(cab, k0, k1, ok) + !! Steps k0 + 1 .. k1: the command, then a lateral sway of the coupled end with a parent roll + !! about the line (2 rad/s) and an imposed twist following it. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cab + INTEGER, INTENT(IN) :: k0, k1 + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: t, x(3), v(3), a(3), dcm(3, 3), w(3), al(3), phi + INTEGER :: k, es + CHARACTER(300) :: em + ok = .TRUE. + DO k = k0 + 1, k1 + t = 0.01_wp*REAL(k, wp) + x = [LS, 0.05_wp*SIN(2.0_wp*t), 0.0_wp] + v = [0.0_wp, 0.1_wp*COS(2.0_wp*t), 0.0_wp] + a = [0.0_wp, -0.2_wp*SIN(2.0_wp*t), 0.0_wp] + dcm = 0.0_wp + dcm(1, 1) = 1.0_wp + dcm(2, 2) = COS(2.0_wp*t) + dcm(3, 3) = COS(2.0_wp*t) + dcm(2, 3) = SIN(2.0_wp*t) + dcm(3, 2) = -SIN(2.0_wp*t) + w = [2.0_wp, 0.0_wp, 0.0_wp] + al = 0.0_wp + phi = 1.0_wp - 2.0_wp*t + 0.3_wp*SIN(2.0_wp*t) + CALL coupled_command(cab, k, es, em) + IF (es == CD_HFMF_OK) CALL CD_HFMF_UpdateStates(cab, x, v, a, es, em, u_orientation=dcm, u_angular_velocity=w, & + u_angular_acceleration=al, u_twist=phi) + IF (es /= CD_HFMF_OK) THEN + WRITE (*, '(A,I0,A)') ' coupled step ', k, ': '//TRIM(em) + ok = .FALSE. + RETURN + END IF + END DO + END SUBROUTINE coupled_march + + SUBROUTINE check_restart() + !! R: 150 steps (mid-ramp), snapshot and mirror, 100 more; restore and redo the 100. A fresh + !! module given the command of step 150 as committed and then the mirror redoes them too. + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab, cab2 + REAL(wp), ALLOCATABLE :: mirror(:), qref(:), pref(:), mref(:) + INTEGER :: es + LOGICAL :: ok + CHARACTER(300) :: em + ALLOCATE (cab, cab2) + CALL build_coupled(cab, es, em) + CALL require(es == CD_HFMF_OK .AND. cab%line%tw_active, 'R: build: '//TRIM(em)) + IF (es /= CD_HFMF_OK) RETURN + CALL coupled_march(cab, 0, 150, ok) + CALL require(ok .AND. cab%line%has_ctrl, 'R: first leg under the pay-out ramp') + IF (.NOT. ok) RETURN + CALL CD_HFMF_Snapshot(cab, es, em) + CALL require(es == CD_HFMF_OK, 'R: snapshot: '//TRIM(em)) + ALLOCATE (mirror(CD_HFMF_MirrorSize(cab))) + CALL CD_HFMF_PackMirror(cab, mirror, es, em) + CALL require(es == CD_HFMF_OK, 'R: mirror pack: '//TRIM(em)) + CALL coupled_march(cab, 150, 250, ok) + CALL require(ok, 'R: second leg') + qref = cab%line%q + pref = cab%line%tw_phi + mref = cab%line%tw_mt + CALL CD_HFMF_Restore(cab, es, em) + CALL require(es == CD_HFMF_OK, 'R: restore: '//TRIM(em)) + CALL coupled_march(cab, 150, 250, ok) + CALL require(ok .AND. same_bits(cab%line%q, qref) .AND. same_bits(cab%line%tw_phi, pref) .AND. & + same_bits(cab%line%tw_mt, mref), 'R: the run restored from the snapshot continues bit-identically') + CALL build_coupled(cab2, es, em) + CALL require(es == CD_HFMF_OK, 'R: rebuild: '//TRIM(em)) + CALL coupled_command(cab2, 150, es, em, restored=.TRUE.) + CALL require(es == CD_HFMF_OK, 'R: the checkpointed command re-applied: '//TRIM(em)) + CALL CD_HFMF_UnpackMirror(cab2, mirror, 1.5_wp, es, em) + CALL require(es == CD_HFMF_OK, 'R: mirror reload: '//TRIM(em)) + CALL coupled_march(cab2, 150, 250, ok) + CALL require(ok .AND. same_bits(cab2%line%q, qref) .AND. same_bits(cab2%line%tw_phi, pref) .AND. & + same_bits(cab2%line%tw_mt, mref), 'R: the run rebuilt from the mirror continues bit-identically') + WRITE (*, '(A,F9.5,A,F9.5,A)') 'R restart mid-ramp: span ', SUM(cab%line%l0(19:20)), ' m, end twist angle ', & + pref(SIZE(pref)), ' rad; snapshot and mirror runs identical' + ! a non-stepping write of the coupled end at step 250 turned 0.05 rad further: the committed + ! torque is then the summed twist over the compliance, which the snapshot and the mirror + ! must bring back as it is + BLOCK + TYPE(CD_HFMF_ModuleType), ALLOCATABLE :: cab3 + REAL(wp) :: t, x(3), v(3), a(3), dcm(3, 3), tq_keep, tq_formula + LOGICAL :: ok2 + ALLOCATE (cab3) + t = 2.5_wp + x = [LS, 0.05_wp*SIN(2.0_wp*t), 0.0_wp] + v = [0.0_wp, 0.1_wp*COS(2.0_wp*t), 0.0_wp] + a = [0.0_wp, -0.2_wp*SIN(2.0_wp*t), 0.0_wp] + dcm = 0.0_wp + dcm(1, 1) = 1.0_wp + dcm(2, 2) = COS(2.0_wp*t + 0.05_wp) + dcm(3, 3) = COS(2.0_wp*t + 0.05_wp) + dcm(2, 3) = SIN(2.0_wp*t + 0.05_wp) + dcm(3, 2) = -SIN(2.0_wp*t + 0.05_wp) + CALL CD_HFMF_SetCoupledKinematics(cab, x, v, a, es, em, u_orientation=dcm, & + u_angular_velocity=[2.0_wp, 0.0_wp, 0.0_wp], & + u_angular_acceleration=[0.0_wp, 0.0_wp, 0.0_wp]) + CALL require(es == CD_HFMF_OK, 'R: the non-stepping frame write: '//TRIM(em)) + tq_keep = cab%line%torsion%torque + tq_formula = (cab%line%torsion%phi - cab%line%torsion%theta)/ & + CD_HermiteTorsion_Compliance(cab%line%torsion, cab%line%l0) + WRITE (*, '(A,ES24.16,A,ES10.3)') 'R committed torque after a frame write ', tq_keep, & + ' N m; re-derived as (Phi - Theta)/C it would differ by ', tq_formula - tq_keep + ! the two differ only by the round-off of Phi - (Phi - summed twist), which some builds + ! happen to make exact: one ulp off the re-derived value keeps the check resolving + IF (same_bits([tq_formula], [tq_keep])) THEN + tq_keep = NEAREST(tq_formula, 1.0_wp) + cab%line%torsion%torque = tq_keep + END IF + CALL CD_HFMF_PackMirror(cab, mirror, es, em) + CALL CD_HFMF_Snapshot(cab, es, em) + CALL coupled_march(cab, 250, 251, ok2) + CALL CD_HFMF_Restore(cab, es, em) + CALL require(es == CD_HFMF_OK .AND. ok2 .AND. same_bits([cab%line%torsion%torque], [tq_keep]), & + 'R: the snapshot brings back the committed torque of a frame write as it was formed') + CALL build_coupled(cab3, es, em) + CALL coupled_command(cab3, 250, es, em, restored=.TRUE.) + CALL CD_HFMF_UnpackMirror(cab3, mirror, t, es, em) + CALL require(es == CD_HFMF_OK .AND. same_bits([cab3%line%torsion%torque], [tq_keep]), & + 'R: the mirror brings back the committed torque of a frame write as it was formed') + CALL CD_HFMF_End(cab3) + END BLOCK + CALL CD_HFMF_End(cab) + CALL CD_HFMF_End(cab2) + END SUBROUTINE check_restart + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_deck(path) + !! The straight neutral 100 m torsion line of test_coupled_torsion (40 segments, GJ 5e4, + !! Irn 1e-9, torsional damping -zeta = -0.1), End A Coupled at (0, 0, -50) with a 30 deg + !! pretwist, End B Fixed, controlled on channel 1; outputs Torq1N1 and Twist1. + CHARACTER(*), INTENT(IN) :: path + INTEGER :: u + CHARACTER(160) :: neutral_type + WRITE (neutral_type, '(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|0|-0.1 1.0 1.0e-9 0.0 0.0 0.0 0.0' + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'controlled torsion line' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(neutral_type) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + 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 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 30' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Line(s)' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') '1 1' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE deck_command(step, dl, dldot) + !! A haul-in of 0.1 m on a half cosine over 1 s (20 steps of 0.05 s), then held. + INTEGER, INTENT(IN) :: step + REAL(wp), INTENT(OUT) :: dl, dldot + REAL(wp) :: t + t = 0.05_wp*REAL(step, wp) + IF (t < 1.0_wp) THEN + dl = -0.1_wp*0.5_wp*(1.0_wp - COS(PI*t)) + dldot = -0.1_wp*0.5_wp*PI*SIN(PI*t) + ELSE + dl = -0.1_wp + dldot = 0.0_wp + END IF + END SUBROUTINE deck_command + + SUBROUTINE check_deck() + !! S: reference A marches 30 steps (the ramp and a hold), Torq1N1 against GJ Twist1/L(t). + !! B is rebuilt at step 12 (mid-ramp) with the shell's recipe (torsion mirror, coupled + !! kinematics, the command re-applied as committed, full mirror) and both march 12 more. + REAL(wp), PARAMETER :: DT = 0.05_wp, GJD = 5.0e4_wp, DEG = PI/180.0_wp + TYPE(CD_AGG_ModuleType) :: a, b + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1), omega(3, 1), alpha(3, 1) + REAL(wp) :: dl, dldot, tq, tw, tqb, twb, err, lt, t + REAL(wp), ALLOCATABLE :: mirror(:) + INTEGER :: es, ni, k + LOGICAL :: cv, st, same + CHARACTER(512) :: em + CALL write_deck('ctl_torsion_deck.dat') + CALL CD_AGG_Init_From_Deck(a, 'ctl_torsion_deck.dat', DT, es, em, host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'S: a deck with CONTROL on a line restrained in torsion initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(a%ctrl_is_cable(1) .AND. a%cables(1)%line%tw_active .AND. & + a%ctrl_elem(1) + a%ctrl_nelem(1) - 1 == a%cables(1)%line%ne, & + 'S: the row controls the fairlead segment of the nodal-twist cable') + CALL require(ALLOCATED(a%cables(1)%line%torsion%bt_zeta), 'S: the deck keeps the -zeta of its torsional damping') + IF (.NOT. ALLOCATED(a%cables(1)%line%torsion%bt_zeta)) RETURN + CALL require(ALL(a%cables(1)%line%torsion%bt_zeta == 0.1_wp), 'S: zeta = 0.1 on every element') + CALL CD_AGG_GetMovingPointMesh(a, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + err = 0.0_wp + same = .TRUE. + DO k = 1, 30 + CALL deck_command(k, dl, dldot) + CALL CD_AGG_Apply_LineControl(a, [dl], [dldot], es, em) + CALL require(es == CD_AGG_OK, 'S: command: '//TRIM(em)) + CALL CD_AGG_Step_Moving(a, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'S: step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_CalcOutput(a, es, em) + CALL CD_AGG_EvalChannel(a, 1, tq, es, em) + CALL CD_AGG_EvalChannel(a, 2, tw, es, em) + IF (k == 10) THEN + ASSOCIATE (cl => a%cables(1)%line, e1 => a%ctrl_elem(1)) + CALL require(ALL(cl%torsion%bt(e1:cl%ne) == CD_HermiteTorsion_Zeta_Damping(0.1_wp, cl%l0(e1:cl%ne), GJD, & + 1.0e-9_wp)), & + 'S: the commanded elements re-resolve the deck''s -zeta at their new lengths') + END ASSOCIATE + END IF + lt = 100.0_wp + dl + err = MAX(err, ABS(tq - GJD*tw*DEG/lt)/ABS(GJD*tw*DEG/lt)) + IF (k == 12) THEN + t = DT*REAL(k, wp) + ALLOCATE (mirror(CD_HFMF_MirrorSize(a%cables(1)))) + CALL CD_HFMF_PackMirror(a%cables(1), mirror, es, em) + CALL CD_AGG_Init_From_Deck(b, 'ctl_torsion_deck.dat', DT, es, em, host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'S: rebuild: '//TRIM(em)) + CALL CD_HFMF_UnpackMirror(b%cables(1), mirror, t, es, em) + CALL require(es == CD_HFMF_OK, 'S: torsion mirror first: '//TRIM(em)) + CALL CD_AGG_UpdateStates_Moving(b, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + CALL require(es == CD_AGG_OK, 'S: coupled kinematics: '//TRIM(em)) + CALL CD_AGG_Apply_LineControl(b, [dl], [dldot], es, em, restored=.TRUE.) + CALL require(es == CD_AGG_OK, 'S: the checkpointed command re-applied: '//TRIM(em)) + CALL CD_HFMF_UnpackMirror(b%cables(1), mirror, t, es, em) + CALL require(es == CD_HFMF_OK, 'S: full mirror: '//TRIM(em)) + ELSE IF (k > 12 .AND. k <= 24) THEN + CALL CD_AGG_Apply_LineControl(b, [dl], [dldot], es, em) + CALL CD_AGG_Step_Moving(b, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'S: restarted step: '//TRIM(em)) + CALL CD_AGG_CalcOutput(b, es, em) + CALL CD_AGG_EvalChannel(b, 1, tqb, es, em) + CALL CD_AGG_EvalChannel(b, 2, twb, es, em) + same = same .AND. same_bits(a%cables(1)%line%q, b%cables(1)%line%q) .AND. & + same_bits(a%cables(1)%line%tw_phi, b%cables(1)%line%tw_phi) .AND. same_bits([tq, tw], [tqb, twb]) + END IF + END DO + WRITE (*, '(A,F9.4,A,ES15.7,A,ES10.3)') 'S deck: Twist1 ', tw, ' deg, Torq1N1 ', tq, & + '; max rel. error against GJ Twist1/L(t) ', err + CALL require(ABS(ABS(tw) - 30.0_wp) <= 1.0e-6_wp, 'S: the line keeps its 30 deg twist') + CALL require(err <= 1.0e-6_wp, 'S: Torq1N1 follows GJ Twist1/L(t) through the haul-in') + CALL require(same, 'S: the checkpoint restart mid-ramp continues bit-identically') + CALL CD_AGG_End(a, es, em) + CALL CD_AGG_End(b, es, em) + END SUBROUTINE check_deck + +END PROGRAM test_control_torsion diff --git a/tests/test_hermite_cable_control.f90 b/tests/test_hermite_cable_control.f90 index 590a74f0..edb04a18 100644 --- a/tests/test_hermite_cable_control.f90 +++ b/tests/test_hermite_cable_control.f90 @@ -7,9 +7,9 @@ PROGRAM test_hermite_cable_control !! A the update is inert when nothing changes (a rate of -0 included), rebuilds every !! length-dependent cache to what a model built with the new lengths carries (bit for !! bit), leaves the committed lengths to a re-derived acceleration, is atomic on - !! failure, refuses a torsion line, a contact line without the seabed recompute inputs - !! and the configuration blend, is taken back exactly by a saved control state, and - !! joins the snapshot/restore contract exactly; + !! failure, refuses a contact line without the seabed recompute inputs and the + !! configuration blend, is taken back exactly by a saved control state, and joins the + !! snapshot/restore contract exactly (a line restrained in torsion: test_control_torsion); !! B a hanging vertical cable whose top span is paid out settles to the top reaction !! w (L + DeltaL) and the stretched length L' + w L'**2/(2 EA); !! C a taut vertical cable whose top span is hauled in settles to the top tension @@ -209,10 +209,6 @@ SUBROUTINE check_model_contract() CALL CD_HermiteCable_Dyn_Set_SegmentLength(a, SPAN, [1.0_wp, -1.0_wp], [0.0_wp, 0.0_wp], es, em) CALL require(es /= CD_HCDYN_OK .AND. unchanged(a, ref), 'A: a non-positive length fails and writes nothing') twin = a - twin%torsion%active = .TRUE. - CALL CD_HermiteCable_Dyn_Set_SegmentLength(twin, SPAN, [1.0_wp, 1.0_wp], [0.0_wp, 0.0_wp], es, em) - CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'torsion') > 0, 'A: a line restrained in torsion fails closed') - twin%torsion%active = .FALSE. twin%has_seabed_recompute = .FALSE. CALL CD_HermiteCable_Dyn_Set_SegmentLength(twin, SPAN, [1.0_wp, 1.0_wp], [0.0_wp, 0.0_wp], es, em) CALL require(es /= CD_HCDYN_OK .AND. INDEX(em, 'seabed recompute') > 0, & diff --git a/tests/test_lin_torsion.f90 b/tests/test_lin_torsion.f90 new file mode 100644 index 00000000..efd33dd4 --- /dev/null +++ b/tests/test_lin_torsion.f90 @@ -0,0 +1,586 @@ +! File: tests/test_lin_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_lin_torsion + !! OpenFAST linearisation of a cable restrained in torsion, on the aggregate surface the OpenFAST + !! shell drives: the shell's lin_eval recipe (the mirror loaded with a perturbed state, the + !! coupled point moved to a perturbed input, the parent's rates given to the torsion end frame + !! (CD_HFMF_Set_Twist_Frame_Rates), the accelerations solved without a time step, the mirror + !! restored), the linearisation states of the nodal twist from CD_HFMF_Twist_Lin_Slots, and A, B, + !! C and D by central differences as CD_JacobianPContState and CD_JacobianPInput form them. The + !! line is a straight, neutrally buoyant 100 m cable held taut at 0.5 % strain between a coupled + !! fairlead (0, 0, -20) and a fixed anchor below it, pinned in bending and rigid in torsion at + !! both ends, GJ = 5e4 N m^2, 50 elements. + !! F torsional modes: with Irn = 2 kg m the twist block of A is decoupled from the line's + !! position and tangent states (its coupling entries vanish to the differences' round-off), + !! so its eigenvalues are eigenvalues of A: the frequencies of the first three twist modes + !! are n pi/L sqrt(GJ/Irn) of the continuum, within the lumped-inertia discretisation + !! error, and the lumped chain's own 2 sqrt(GJ/Irn)/h sin(n pi/(2N)) to 1e-6; + !! K roll stiffness: the zero-frequency reduction -(D - C A^-1 B) of the fairlead moment about + !! the line axis per unit platform rotation about it is GJ/L (to 1e-6), with the twist + !! angles as states; the feedthrough D alone (the interior twist held, as a linearisation + !! without twist states would give it) is the end element's GJ/l_e, N times too stiff; + !! C condensed torsion (the same line without Irn, its torque algebraic in q and the end + !! frames, no states of its own): the reduction gives GJ/L as well; + !! E an elastic torsional end (spring kt at End B): its end angle is a state too, and the + !! reduction gives the series stiffness 1/(L/GJ + 1/kt); + !! R frame rates: with the torsional damping Bt (GJ|0|Bt) the reduced moment per unit angular + !! velocity of the platform about the line axis is Bt/L, the steady-roll torque of the + !! march (test_nodal_twist_dynamic D), and it vanishes without the frame rates; the moment + !! per unit angular acceleration is the held end section's polar inertia Irn l_e/2. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_CalcOutput, CD_AGG_End, CD_AGG_OK + USE CableDyn_OpenFAST_HermiteFMF, ONLY: CD_HFMF_MirrorSize, CD_HFMF_PackMirror, CD_HFMF_UnpackMirror, & + CD_HFMF_Refresh_Acceleration, CD_HFMF_Set_Torsion, & + CD_HFMF_Twist_Lin_Count, CD_HFMF_Twist_Lin_Slots, & + CD_HFMF_Set_Twist_Frame_Rates, CD_HFMF_OK + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp, DT = 0.05_wp + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp, IRN = 2.0_wp, BT = 1.0e3_wp + INTEGER, PARAMETER :: NE = 50 + ! the linearisation steps of the OpenFAST shell (CD_InitVars): positions, tangents and twist + ! angles 1e-6, velocities 0.1 m/s (tangent rates 0.1 m/s over the element length), twist rates + ! 0.01 rad/s, rotations 1e-4 rad, angular velocities and accelerations 0.1 + REAL(wp), PARAMETER :: HX = 1.0e-6_wp, HV = 0.1_wp, HW = 1.0e-2_wp, HROT = 1.0e-4_wp, HOM = 0.1_wp + INTEGER :: nfail = 0 + + ! the shell's state of one cable: [r, m free; phi free; their rates], mirror slots and buffers + TYPE(CD_AGG_ModuleType) :: agg + INTEGER :: nf, ntw, nx2, msz + INTEGER, ALLOCATABLE :: q_slot(:), v_slot(:), a_slot(:), tp(:), tr(:), ta(:), tn(:) + REAL(wp), ALLOCATABLE :: buf0(:), wbuf(:) + REAL(wp) :: pos0(3, 1), vel0(3, 1), acc0(3, 1), t0 + + CALL check_modes_and_stiffness() + CALL check_condensed() + CALL check_elastic_end() + CALL check_frame_rates() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: linearisation of a line restrained in torsion (modes, roll stiffness, condensed, '// & + 'elastic end, frame rates)' + +CONTAINS + + 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, irn_v, bt_v, tors_b) + !! The straight vertical line, neutrally buoyant (mass rhoW pi d^2/4) and without drag or + !! added mass, so the 0.5 % strain is uniform; Irn irn_v, torsional damping bt_v, and the + !! torsional restraint of End B tors_b (default Rigid). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: irn_v, bt_v + CHARACTER(*), INTENT(IN), OPTIONAL :: tors_b + INTEGER :: u + CHARACTER(240) :: ltype + CHARACTER(40) :: gj_col + gj_col = '5.0e4' + IF (bt_v > 0.0_wp) WRITE (gj_col, '(A,ES10.4)') '5.0e4|0|', bt_v + WRITE (ltype, '(A,ES24.16,A,A,A,ES12.5,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 ', TRIM(gj_col), ' 1.0 ', irn_v, ' 0.0 0.0 0.0 0.0' + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'linearisation of a line restrained in torsion' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(ltype) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 0.0 0.0 -120.5 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,I0)') '1 cab 100.0 ', NE + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Pinned 0 0 -1 Rigid 1 0 0 0' + IF (PRESENT(tors_b)) THEN + WRITE (u, '(A)') '1 B Pinned 0 0 -1 '//tors_b//' 1 0 0 0' + ELSE + WRITE (u, '(A)') '1 B Pinned 0 0 -1 Rigid 1 0 0 0' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE setup(path, ok) + !! Build the aggregate (host orientation, as the shell) and the shell's state map of its cable. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(OUT) :: ok + INTEGER :: es, i, k + CHARACTER(512) :: em + REAL(wp) :: ld(3, 1) + CALL CD_AGG_Init_From_Deck(agg, path, DT, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'the torsion line builds on the aggregate: '//TRIM(em)) + IF (.NOT. ok) RETURN + k = CD_AGG_NMovingPoints(agg, es, em) + ok = agg%ncable == 1 .AND. k == 1 + CALL require(ok, 'the deck is one coupled cable') + IF (.NOT. ok) RETURN + CALL map_states() + CALL CD_AGG_GetMovingPointMesh(agg, pos0, vel0, acc0, ld, es, em) + t0 = agg%cables(1)%line%t + ! the cable's r, m slots in its mirror [v_free; q_free; a_free] + IF (ALLOCATED(q_slot)) DEALLOCATE (q_slot, v_slot, a_slot) + ALLOCATE (q_slot(nf), v_slot(nf), a_slot(nf)) + k = 0 + DO i = 1, nf + k = k + 1 + v_slot(k) = i + q_slot(k) = nf + i + a_slot(k) = 2*nf + i + END DO + END SUBROUTINE setup + + SUBROUTINE map_states() + !! The state counts and the twist slots of the cable (re-read after a torsion change). + INTEGER :: es + CHARACTER(512) :: em + nf = COUNT(agg%cables(1)%line%freemask) + ntw = CD_HFMF_Twist_Lin_Count(agg%cables(1)) + nx2 = nf + ntw + msz = CD_HFMF_MirrorSize(agg%cables(1)) + IF (ALLOCATED(tp)) DEALLOCATE (tp, tr, ta, tn) + ALLOCATE (tp(ntw), tr(ntw), ta(ntw), tn(ntw)) + CALL CD_HFMF_Twist_Lin_Slots(agg%cables(1), tp, tr, ta, tn, es, em) + CALL require(es == CD_HFMF_OK, 'the twist slots: '//TRIM(em)) + IF (ALLOCATED(buf0)) DEALLOCATE (buf0, wbuf) + ALLOCATE (buf0(msz), wbuf(msz)) + CALL CD_HFMF_PackMirror(agg%cables(1), buf0, es, em) + CALL require(es == CD_HFMF_OK, 'the committed mirror packs: '//TRIM(em)) + END SUBROUTINE map_states + + FUNCTION rot_dcm(axis, ang) RESULT(r) + !! OpenFAST mesh orientation (global to local) of a turn ang about the global axis. + INTEGER, INTENT(IN) :: axis + REAL(wp), INTENT(IN) :: ang + REAL(wp) :: r(3, 3), c, s + INTEGER :: i, j + c = COS(ang) + s = SIN(ang) + r = 0.0_wp + r(axis, axis) = 1.0_wp + i = MOD(axis, 3) + 1 + j = MOD(axis + 1, 3) + 1 + r(i, i) = c + r(j, j) = c + r(i, j) = s + r(j, i) = -s + END FUNCTION rot_dcm + + SUBROUTINE state_of(x) + !! The linearisation state of the committed mirror: [q_free; phi_free; v_free; w_free]. + REAL(wp), INTENT(OUT) :: x(:) + x(1:nf) = buf0(q_slot) + x(nf + 1:nx2) = buf0(tp) + x(nx2 + 1:nx2 + nf) = buf0(v_slot) + x(nx2 + nf + 1:2*nx2) = buf0(tr) + END SUBROUTINE state_of + + SUBROUTINE lin_eval(x, axis, ang, om, al, xdot, mom, rates) + !! The shell's lin_eval on the cable: state x, the coupled point turned by ang about the global + !! axis (0: not turned) with angular velocity om and acceleration al; xdot = dx/dt and the + !! fairlead moment mom. rates = .FALSE. leaves out CD_HFMF_Set_Twist_Frame_Rates. + REAL(wp), INTENT(IN) :: x(:), ang, om(3), al(3) + INTEGER, INTENT(IN) :: axis + REAL(wp), INTENT(OUT) :: xdot(:), mom(3) + LOGICAL, INTENT(IN), OPTIONAL :: rates + REAL(wp) :: orient(3, 3, 1), omg(3, 1), alp(3, 1), p(3, 1), v(3, 1), a(3, 1), ld(3, 1), mm(3, 1) + INTEGER :: es + LOGICAL :: with_rates + CHARACTER(512) :: em + with_rates = .TRUE. + IF (PRESENT(rates)) with_rates = rates + wbuf = buf0 + wbuf(q_slot) = x(1:nf) + wbuf(tp) = x(nf + 1:nx2) + wbuf(v_slot) = x(nx2 + 1:nx2 + nf) + wbuf(tr) = x(nx2 + nf + 1:2*nx2) + CALL CD_HFMF_UnpackMirror(agg%cables(1), wbuf, t0, es, em) + CALL require(es == CD_HFMF_OK, 'lin_eval: the state loads: '//TRIM(em)) + orient(:, :, 1) = rot_dcm(MAX(axis, 1), MERGE(ang, 0.0_wp, axis > 0)) + omg(:, 1) = om + alp(:, 1) = al + CALL CD_AGG_UpdateStates_Moving(agg, pos0, vel0, acc0, es, em, output_probe=.FALSE., orientation=orient, & + angular_velocity=omg, angular_acceleration=alp) + CALL require(es == CD_AGG_OK, 'lin_eval: the input loads: '//TRIM(em)) + IF (with_rates) CALL CD_HFMF_Set_Twist_Frame_Rates(agg%cables(1), es, em) + CALL CD_HFMF_Refresh_Acceleration(agg%cables(1), es, em) + CALL require(es == CD_HFMF_OK, 'lin_eval: the accelerations: '//TRIM(em)) + CALL CD_HFMF_PackMirror(agg%cables(1), wbuf, es, em) + xdot(1:nf) = wbuf(v_slot) + xdot(nf + 1:nx2) = wbuf(tr) + xdot(nx2 + 1:nx2 + nf) = wbuf(a_slot) + xdot(nx2 + nf + 1:2*nx2) = wbuf(ta) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, p, v, a, ld, es, em, moment=mm) + CALL require(es == CD_AGG_OK, 'lin_eval: the outputs: '//TRIM(em)) + mom = mm(:, 1) + ! the committed state back + orient(:, :, 1) = rot_dcm(1, 0.0_wp) + omg = 0.0_wp + alp = 0.0_wp + CALL CD_AGG_UpdateStates_Moving(agg, pos0, vel0, acc0, es, em, output_probe=.TRUE., orientation=orient, & + angular_velocity=omg, angular_acceleration=alp) + CALL CD_HFMF_UnpackMirror(agg%cables(1), buf0, t0, es, em) + CALL require(es == CD_HFMF_OK, 'lin_eval: the committed state restores: '//TRIM(em)) + END SUBROUTINE lin_eval + + SUBROUTINE state_matrix(amat, cmom) + !! A = d xdot/dx and C = d M/dx (the fairlead moment) by central differences over the states. + REAL(wp), INTENT(OUT) :: amat(:, :), cmom(:, :) + REAL(wp) :: x0(2*nx2), x(2*nx2), fp(2*nx2), fm(2*nx2), mp(3), mn(3), h, z3(3) + INTEGER :: j + z3 = 0.0_wp + CALL state_of(x0) + DO j = 1, 2*nx2 + h = state_step(j) + x = x0 + x(j) = x0(j) + h + CALL lin_eval(x, 0, 0.0_wp, z3, z3, fp, mp) + x(j) = x0(j) - h + CALL lin_eval(x, 0, 0.0_wp, z3, z3, fm, mn) + amat(:, j) = (fp - fm)/(2.0_wp*h) + cmom(:, j) = (mp - mn)/(2.0_wp*h) + END DO + END SUBROUTINE state_matrix + + REAL(wp) FUNCTION state_step(j) RESULT(h) + !! The shell's step of state j: positions, tangents and angles HX; velocities HV, tangent + !! rates HV over the mean element length, twist rates HW. + INTEGER, INTENT(IN) :: j + INTEGER :: dof + IF (j <= nx2) THEN + h = HX + ELSE IF (j <= nx2 + nf) THEN + dof = 0 + h = HV + ! a tangent DOF (4-6 of its node) takes the tangent-rate step + dof = free_dof(j - nx2) + IF (MOD(dof - 1, 6) >= 3) h = HV*REAL(NE, wp)/SUM(agg%cables(1)%line%l0) + ELSE + h = HW + END IF + END FUNCTION state_step + + INTEGER FUNCTION free_dof(k) RESULT(dof) + !! The cable DOF of the k-th free DOF. + INTEGER, INTENT(IN) :: k + INTEGER :: i, c + c = 0 + dof = 0 + DO i = 1, SIZE(agg%cables(1)%line%freemask) + IF (.NOT. agg%cables(1)%line%freemask(i)) CYCLE + c = c + 1 + IF (c == k) THEN + dof = i + RETURN + END IF + END DO + END FUNCTION free_dof + + SUBROUTINE input_columns(axis, kind, b, dmom, rates) + !! B = d xdot/du and D = d M/du for one input of the coupled point: kind 1 the rotation about + !! the global axis, 2 its angular velocity, 3 its angular acceleration. + INTEGER, INTENT(IN) :: axis, kind + REAL(wp), INTENT(OUT) :: b(:), dmom(3) + LOGICAL, INTENT(IN), OPTIONAL :: rates + REAL(wp) :: x0(2*nx2), fp(2*nx2), fm(2*nx2), mp(3), mn(3), w(3), z3(3), h + z3 = 0.0_wp + CALL state_of(x0) + SELECT CASE (kind) + CASE (1) + h = HROT + CALL lin_eval(x0, axis, h, z3, z3, fp, mp, rates) + CALL lin_eval(x0, axis, -h, z3, z3, fm, mn, rates) + CASE (2) + h = HOM + w = 0.0_wp + w(axis) = h + CALL lin_eval(x0, 0, 0.0_wp, w, z3, fp, mp, rates) + CALL lin_eval(x0, 0, 0.0_wp, -w, z3, fm, mn, rates) + CASE DEFAULT + h = HOM + w = 0.0_wp + w(axis) = h + CALL lin_eval(x0, 0, 0.0_wp, z3, w, fp, mp, rates) + CALL lin_eval(x0, 0, 0.0_wp, z3, -w, fm, mn, rates) + END SELECT + b = (fp - fm)/(2.0_wp*h) + dmom = (mp - mn)/(2.0_wp*h) + END SUBROUTINE input_columns + + REAL(wp) FUNCTION reduced(amat, cmom, b, dmom, row) RESULT(k) + !! -(D - C A^-1 B) of the moment component row for one input column: A = [0 I; Kx Cx] and the + !! top rows of B vanish, so A^-1 B = [Kx^-1 b_acc; 0] and C A^-1 B = C_x Kx^-1 b_acc. + REAL(wp), INTENT(IN) :: amat(:, :), cmom(:, :), b(:), dmom(3) + INTEGER, INTENT(IN) :: row + REAL(wp), ALLOCATABLE :: kx(:, :), z(:, :) + INTEGER, ALLOCATABLE :: ipiv(:) + INTEGER :: info + EXTERNAL :: DGESV + ALLOCATE (kx(nx2, nx2), z(nx2, 1), ipiv(nx2)) + kx = amat(nx2 + 1:2*nx2, 1:nx2) + z(:, 1) = b(nx2 + 1:2*nx2) + CALL DGESV(nx2, 1, kx, nx2, ipiv, z, nx2, info) + CALL require(info == 0, 'the position block of A is regular') + k = -(dmom(row) - DOT_PRODUCT(cmom(row, 1:nx2), z(:, 1))) + END FUNCTION reduced + + SUBROUTINE twist_eigen(amat, omega, coupling) + !! The twist block of A, d a_phi/d phi = -M^-1 K with the lumped polar inertia M: omega^2 are + !! the eigenvalues of M^(1/2) (-A_pp) M^(-1/2) (symmetric; cyclic Jacobi), ascending. coupling + !! is the largest entry coupling the twist states to the r, m states, relative to the block. + REAL(wp), INTENT(IN) :: amat(:, :) + REAL(wp), INTENT(OUT) :: omega(:), coupling + REAL(wp) :: s(ntw, ntw), mass(ntw), big + INTEGER :: i, j + DO i = 1, ntw + mass(i) = agg%cables(1)%line%tw_mass(tn(i)) + END DO + DO j = 1, ntw + DO i = 1, ntw + s(i, j) = -amat(nx2 + nf + i, nf + j)*SQRT(mass(i)/mass(j)) + END DO + END DO + big = MAXVAL(ABS(s)) + s = 0.5_wp*(s + TRANSPOSE(s)) + CALL jacobi(s, omega) + omega = SQRT(MAX(omega, 0.0_wp)) + ! the twist rows against the r, m columns (positions and rates) and the r, m rows against the + ! twist columns, each scaled by its row block + ASSOCIATE (tw_rows => amat(nx2 + nf + 1:2*nx2, :), line_rows => amat(nx2 + 1:nx2 + nf, :)) + coupling = MAX(MAXVAL(ABS(tw_rows(:, 1:nf))), MAXVAL(ABS(tw_rows(:, nx2 + 1:nx2 + nf))))/ & + MAXVAL(ABS(tw_rows(:, nf + 1:nx2))) + coupling = MAX(coupling, MAX(MAXVAL(ABS(line_rows(:, nf + 1:nx2))), & + MAXVAL(ABS(line_rows(:, nx2 + nf + 1:2*nx2))))/MAXVAL(ABS(line_rows(:, 1:nf)))) + END ASSOCIATE + END SUBROUTINE twist_eigen + + SUBROUTINE jacobi(s, ev) + !! Eigenvalues of the symmetric matrix s by cyclic Jacobi rotations, ascending. + REAL(wp), INTENT(INOUT) :: s(:, :) + REAL(wp), INTENT(OUT) :: ev(:) + INTEGER :: n, p, q, k, sweep + REAL(wp) :: theta, t, c, sn, tau, off, apq, app, aqq, tmp + n = SIZE(s, 1) + DO sweep = 1, 100 + off = 0.0_wp + DO q = 2, n + DO p = 1, q - 1 + off = off + s(p, q)**2 + END DO + END DO + IF (off <= 1.0e-30_wp*SUM([(s(k, k)**2, k=1, n)])) EXIT + DO q = 2, n + DO p = 1, q - 1 + apq = s(p, q) + IF (ABS(apq) <= TINY(1.0_wp)) CYCLE + app = s(p, p) + aqq = s(q, q) + theta = (aqq - app)/(2.0_wp*apq) + t = SIGN(1.0_wp, theta)/(ABS(theta) + SQRT(theta**2 + 1.0_wp)) + c = 1.0_wp/SQRT(t**2 + 1.0_wp) + sn = t*c + tau = sn/(1.0_wp + c) + DO k = 1, n + IF (k == p .OR. k == q) CYCLE + tmp = s(k, p) + s(k, p) = tmp - sn*(s(k, q) + tau*tmp) + s(k, q) = s(k, q) + sn*(tmp - tau*s(k, q)) + s(p, k) = s(k, p) + s(q, k) = s(k, q) + END DO + s(p, p) = app - t*apq + s(q, q) = aqq + t*apq + s(p, q) = 0.0_wp + s(q, p) = 0.0_wp + END DO + END DO + END DO + DO k = 1, n + ev(k) = s(k, k) + END DO + DO p = 1, n - 1 + DO q = p + 1, n + IF (ev(q) < ev(p)) THEN + tmp = ev(p) + ev(p) = ev(q) + ev(q) = tmp + END IF + END DO + END DO + END SUBROUTINE jacobi + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_modes_and_stiffness() + REAL(wp), ALLOCATABLE :: amat(:, :), cmom(:, :), b(:), omega(:) + REAL(wp) :: dmom(3), coupling, w_cont, w_disc, e_cont, e_disc, k_red, k_ft, k_ref, h, kxx + INTEGER :: n, es, j + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('lin_torsion_modes.dat', IRN, 0.0_wp) + CALL setup('lin_torsion_modes.dat', ok) + IF (.NOT. ok) RETURN + ! rigid in torsion at both ends: the two end angles are held, the 49 interior ones are states + CALL require(ntw == NE - 1, 'F: the free twist angles are the interior nodes''') + ok = .TRUE. + DO j = 2, ntw + ok = ok .AND. tp(j) == tp(1) + j - 1 .AND. tr(j) == tr(1) + j - 1 .AND. ta(j) == ta(1) + j - 1 + END DO + CALL require(ok, 'F: the twist slots are consecutive') + CALL require(.NOT. (ANY(ABS(agg%cables(1)%line%tw_phi(tn) - buf0(tp)) > 0.0_wp) .OR. & + ANY(ABS(agg%cables(1)%line%tw_w(tn) - buf0(tr)) > 0.0_wp)), & + 'F: the slots hold the committed angles and rates') + ALLOCATE (amat(2*nx2, 2*nx2), cmom(3, 2*nx2), b(2*nx2), omega(ntw)) + CALL state_matrix(amat, cmom) + CALL twist_eigen(amat, omega, coupling) + h = L/REAL(NE, wp) + WRITE (*, '(A,I0,A,I0,A,ES10.3)') 'F: ', 2*nx2, ' states (', 2*ntw, ' twist); twist-line coupling / block ', & + coupling + CALL require(coupling <= 1.0e-8_wp, 'F: the twist block is decoupled from the line states') + DO n = 1, 3 + w_cont = REAL(n, wp)*PI/L*SQRT(GJ/IRN) + w_disc = 2.0_wp/h*SQRT(GJ/IRN)*SIN(REAL(n, wp)*PI/(2.0_wp*REAL(NE, wp))) + e_cont = omega(n)/w_cont - 1.0_wp + e_disc = omega(n)/w_disc - 1.0_wp + WRITE (*, '(A,I0,A,F12.8,A,F12.8,A,ES10.3,A,F12.8,A,ES10.3)') 'F: mode ', n, ' omega ', omega(n), & + ' rad/s; continuum ', w_cont, ' (', e_cont, '); lumped chain ', w_disc, ' (', e_disc, ')' + CALL require(ABS(e_disc) <= 1.0e-6_wp, 'F: the twist mode matches the lumped chain') + ! the lumped-inertia chain lies (n pi/N)^2/24 below the continuum + CALL require(ABS(e_cont) <= 1.2_wp*(REAL(n, wp)*PI/REAL(NE, wp))**2/24.0_wp + 1.0e-6_wp, & + 'F: the twist mode matches n pi/L sqrt(GJ/Irn) within the discretisation error') + END DO + ! K: the roll stiffness about the line axis (global z) + CALL input_columns(3, 1, b, dmom) + k_red = reduced(amat, cmom, b, dmom, 3) + k_ft = -dmom(3) + k_ref = GJ/L + WRITE (*, '(A,ES16.9,A,ES16.9,A,ES10.3,A,ES16.9,A,ES16.9)') 'K: -(D - C A^-1 B) ', k_red, ' N m/rad; GJ/L ', & + k_ref, ' (', k_red/k_ref - 1.0_wp, '); feedthrough D alone ', k_ft, '; GJ/l_e ', GJ/h + CALL require(ABS(k_red/k_ref - 1.0_wp) <= 1.0e-6_wp, 'K: the reduced roll stiffness is GJ/L') + CALL require(ABS(k_ft/(GJ/h) - 1.0_wp) <= 1.0e-6_wp, 'K: the feedthrough alone is the end element''s GJ/l_e') + ! a turn about an axis across the line does not load the straight pinned line + CALL input_columns(1, 1, b, dmom) + kxx = reduced(amat, cmom, b, dmom, 1) + WRITE (*, '(A,ES10.3,A)') 'K: about x: ', kxx, ' N m/rad' + CALL require(ABS(kxx) <= 1.0e-6_wp*k_ref, 'K: no roll stiffness across the straight pinned line') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_modes_and_stiffness + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_condensed() + !! The line of F and K with its torsion installed again without the polar inertia: the + !! condensed torsion, whose uniform torque has no state of its own. + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp), ALLOCATABLE :: amat(:, :), cmom(:, :), b(:) + REAL(wp) :: dmom(3), k_red, k_ref, frame(3, 2), dcm(3, 3) + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('lin_torsion_condensed.dat', IRN, 0.0_wp) + CALL setup('lin_torsion_condensed.dat', ok) + IF (.NOT. ok) RETURN + tors = agg%cables(1)%line%torsion + IF (ALLOCATED(tors%irn)) DEALLOCATE (tors%irn) + frame = agg%cables(1)%tors_frame_parent + dcm = agg%cables(1)%parent_dcm + CALL CD_HFMF_Set_Torsion(agg%cables(1), tors, es, em, coupled_frame_parent=frame, parent_orientation=dcm) + CALL require(es == CD_HFMF_OK, 'C: the condensed torsion installs: '//TRIM(em)) + IF (es /= CD_HFMF_OK) RETURN + CALL map_states() + CALL require(ntw == 0 .AND. .NOT. agg%cables(1)%line%tw_active, 'C: the condensed torsion has no twist states') + ALLOCATE (amat(2*nx2, 2*nx2), cmom(3, 2*nx2), b(2*nx2)) + CALL state_matrix(amat, cmom) + CALL input_columns(3, 1, b, dmom) + k_red = reduced(amat, cmom, b, dmom, 3) + k_ref = GJ/L + WRITE (*, '(A,ES16.9,A,ES16.9,A,ES10.3,A,ES16.9)') 'C: -(D - C A^-1 B) ', k_red, ' N m/rad; GJ/L ', k_ref, & + ' (', k_red/k_ref - 1.0_wp, '); D alone ', -dmom(3) + CALL require(ABS(k_red/k_ref - 1.0_wp) <= 1.0e-6_wp, 'C: the condensed roll stiffness is GJ/L') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_condensed + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_elastic_end() + !! The line of K with an elastic torsional spring kt at End B: its end angle is a state too, + !! and the reduced roll stiffness is that of the series compliance, 1/(L/GJ + 1/kt). + REAL(wp), PARAMETER :: KT = 2.0e3_wp + REAL(wp), ALLOCATABLE :: amat(:, :), cmom(:, :), b(:) + REAL(wp) :: dmom(3), k_red, k_ref + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('lin_torsion_elastic.dat', IRN, 0.0_wp, tors_b='2.0e3') + CALL setup('lin_torsion_elastic.dat', ok) + IF (.NOT. ok) RETURN + CALL require(ntw == NE, 'E: the elastic end''s angle is a state') + ALLOCATE (amat(2*nx2, 2*nx2), cmom(3, 2*nx2), b(2*nx2)) + CALL state_matrix(amat, cmom) + CALL input_columns(3, 1, b, dmom) + k_red = reduced(amat, cmom, b, dmom, 3) + k_ref = 1.0_wp/(L/GJ + 1.0_wp/KT) + WRITE (*, '(A,ES16.9,A,ES16.9,A,ES10.3,A)') 'E: -(D - C A^-1 B) ', k_red, ' N m/rad; 1/(L/GJ + 1/kt) ', & + k_ref, ' (', k_red/k_ref - 1.0_wp, ')' + CALL require(ABS(k_red/k_ref - 1.0_wp) <= 1.0e-6_wp, 'E: the roll stiffness of the elastic end in series') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_elastic_end + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_frame_rates() + REAL(wp), ALLOCATABLE :: amat(:, :), cmom(:, :), b(:) + REAL(wp) :: dmom(3), k_om, k_om0, k_al, i_held, h + INTEGER :: es + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('lin_torsion_rates.dat', IRN, BT) + CALL setup('lin_torsion_rates.dat', ok) + IF (.NOT. ok) RETURN + ALLOCATE (amat(2*nx2, 2*nx2), cmom(3, 2*nx2), b(2*nx2)) + CALL state_matrix(amat, cmom) + CALL input_columns(3, 2, b, dmom) + k_om = reduced(amat, cmom, b, dmom, 3) + CALL input_columns(3, 2, b, dmom, rates=.FALSE.) + k_om0 = reduced(amat, cmom, b, dmom, 3) + WRITE (*, '(A,ES16.9,A,ES16.9,A,ES10.3,A,ES10.3)') 'R: moment per unit angular velocity ', k_om, & + ' N m s/rad; Bt/L ', BT/L, ' (', k_om/(BT/L) - 1.0_wp, '); without the frame rates ', k_om0 + CALL require(ABS(k_om/(BT/L) - 1.0_wp) <= 1.0e-6_wp, 'R: the steady-roll damping torque Bt/L') + CALL require(ABS(k_om0) <= 1.0e-9_wp*BT/L, 'R: without the frame rates the damping column vanishes') + CALL input_columns(3, 3, b, dmom) + k_al = -dmom(3) + h = L/REAL(NE, wp) + i_held = 0.5_wp*IRN*h + WRITE (*, '(A,ES16.9,A,ES16.9,A,ES10.3)') 'R: moment per unit angular acceleration ', k_al, & + ' kg m^2; Irn l_e/2 ', i_held, ' (', k_al/i_held - 1.0_wp, ')' + CALL require(ABS(k_al/i_held - 1.0_wp) <= 1.0e-6_wp, 'R: the held end section''s polar inertia') + CALL require(.NOT. MAXVAL(ABS(b)) > 0.0_wp, 'R: the angular acceleration does not drive the line states') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_frame_rates +END PROGRAM test_lin_torsion diff --git a/tests/test_modal_torsion.f90 b/tests/test_modal_torsion.f90 new file mode 100644 index 00000000..b1e6f94e --- /dev/null +++ b/tests/test_modal_torsion.f90 @@ -0,0 +1,804 @@ +! File: tests/test_modal_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_modal_torsion + !! Modal analysis of a cubic-Hermite line restrained in torsion (CD_Modal_Hermite_Line: the + !! twist angle of every node joins the modes, with the lumped polar inertia Irn l0 as its mass + !! and the second variation of the twist energy as its stiffness), on a 10 m line along +x: + !! T torsional modes of a straight taut line clamped at both ends (bending Rigid): + !! T1 rigid torsional ends: omega_n = n pi/L0 sqrt(GJ/Irn) (continuum; the lumped chain's + !! error 1 - sin(x)/x, x = n pi/(2 NE), bounds it) and the chain's own + !! 2 sqrt(GJ/Irn)/l0 sin(n pi/(2 NE)) to 1e-9; every other mode (bending, axial) equal to + !! the same line without torsion to 1e-9 and free of twist; + !! T2 elastic torsional ends k: the continuum's ((GJ b)^2 - k^2) sin(b L0) = 2 k GJ b cos(b L0), + !! omega = b sqrt(GJ/Irn), and the lumped chain with the end springs (dense solve); + !! T3 torque-tension coupling K (energy 1/2 EA e^2 + K e tau + 1/2 GJ tau^2): the coupled + !! axial-torsional modes omega^2 = (n pi/L0)^2 eig([[EA, K], [K, GJ]], diag(m, Irn)); + !! C the condensed limit (negligible Irn) of a line under a torque M: + !! C1 the lateral modes of the straight taut clamped line under the torque M. Linearised + !! about the straight state, u = y + i z (s0 the unstretched arc length, stretch lambda), + !! (EI/lambda^4) u'''' - i (M/lambda^2) u''' - (T/lambda) u'' = m omega^2 u + !! (the shaft under torque of Greenhill, Proc. Inst. Mech. Eng., 1883, and Ziegler, + !! Principles of Structural Stability, 1968, with the tension of a taut cable; the twist + !! energy -M Theta, Theta = 1/2 int (y'z'' - z'y'')/lambda^2 the parallel-transport + !! holonomy of the centreline). u = sum c_j + !! exp(i k_j s0) with EIe k^4 - Me k^3 + Te k^2 = m omega^2, clamped (u = u' = 0) at both + !! ends: the 4 x 4 determinant, times exp(-i L0 sum k_j/2) purely imaginary, vanishes + !! at the frequencies (each a pair of real modes, a helix and its mirror). With + !! 9 Me^2 < 32 EIe Te the quartic has no double root at omega > 0. The torque lowers + !! every lateral frequency (M = 4 EI/L0: -5.5 % on the first); + !! C2 the Schur complement of the twist angles in the modal stiffness, K_qq - + !! K_qphi K_phiphi^-1 K_phiq, is the condensed static tangent of the statics at the same + !! state, the element Hessians + M_t d2(-Theta)/dq2 + (1/C) g g^T (CD_HermiteTorsion_Line, + !! M_t = (Phi - Theta)/C), and the central difference of the condensed static residual + !! sum f_int - M_t dTheta/dq: on a bowed, twisted line with bending-pinned ends (rigid + !! and elastic torsional ends), clamped ends, and torque-tension coupling. + !! E the end connections the modes take from the model: a finite bending spring k at both + !! ends of the straight taut line (no torsion) puts its first lateral frequency between the + !! pinned (k = 0) and the clamped (Rigid) line's, rising with k and within 1e-4 of the + !! clamped one at k = 1e5 EI/L0. + !! The modal analysis without the twist (the old route: CD_Modal_Hermite_Band, no twist + !! DOFs, the end connections ignored) is reported beside each gate for comparison. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_Modal, ONLY: CD_Modal_Hermite_Line, CD_Modal_Hermite_Line_Band, CD_Modal_Hermite_Band, & + CD_Modal_Solve_Band, CD_Modal_Solve, CD_MODAL_OK + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID, CD_ENDCONN_FINITE, CD_EndConn_Basis + USE CableDyn_HermiteCable, ONLY: CD_HermiteCable_Element + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & + CD_HermiteTorsion_Compliance, CD_HTORS_OK, CD_HTORS_KBAND + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Set_EndConnection, CD_HermiteCable_Dyn_Set_Torsion, & + CD_HermiteCable_Dyn_End, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.141592653589793238462643383279502884197_wp + REAL(wp), PARAMETER :: L0 = 10.0_wp, EI = 100.0_wp, GJ = 80.0_wp, RHOA = 1.0_wp, TENSION = 10.0_wp + INTEGER :: nfail = 0 + + CALL gate_t1() + CALL gate_t2() + CALL gate_t3() + CALL gate_c1() + CALL gate_c2('pinned, rigid torsion', .FALSE., 0.0_wp, 0.0_wp) + CALL gate_c2('pinned, elastic torsion', .FALSE., 0.05_wp, 0.0_wp) + CALL gate_c2('clamped, rigid torsion', .TRUE., 0.0_wp, 0.0_wp) + CALL gate_c2('clamped, elastic torsion, coupling K', .TRUE., 0.02_wp, 300.0_wp) + CALL gate_e() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: modal analysis with torsion' + +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 straight(ne, stretch, q) + !! Straight line along +x of ne elements, unstretched length L0 stretched by lambda. + INTEGER, INTENT(IN) :: ne + REAL(wp), INTENT(IN) :: stretch + REAL(wp), INTENT(OUT) :: q(:) + INTEGER :: k + q = 0.0_wp + DO k = 1, ne + 1 + q(6*k - 5) = stretch*L0*REAL(k - 1, wp)/REAL(ne, wp) + q(6*k - 2) = stretch + END DO + END SUBROUTINE straight + + SUBROUTINE bowed(ne, q) + !! A line along +x bowed by y = 0.3 sin^2(pi s/L0), z = 0.1 sin^2(2 pi s/L0) (end tangents + !! along +x) and stretched by 1 %. + INTEGER, INTENT(IN) :: ne + REAL(wp), INTENT(OUT) :: q(:) + INTEGER :: k + REAL(wp) :: s + q = 0.0_wp + DO k = 1, ne + 1 + s = L0*REAL(k - 1, wp)/REAL(ne, wp) + q(6*k - 5) = 1.01_wp*s + q(6*k - 4) = 0.3_wp*SIN(PI*s/L0)**2 + q(6*k - 3) = 0.1_wp*SIN(2.0_wp*PI*s/L0)**2 + q(6*k - 2) = 1.01_wp + q(6*k - 1) = 0.3_wp*(PI/L0)*SIN(2.0_wp*PI*s/L0) + q(6*k) = 0.1_wp*(2.0_wp*PI/L0)*SIN(4.0_wp*PI*s/L0) + END DO + END SUBROUTINE bowed + + SUBROUTINE build(model, ne, q, ea, clamped, torsion, phi, irn, compliance, ktt) + !! Dynamic line model on q, both end positions held; Rigid bending connections along +x at both + !! ends when clamped; with torsion, both ends restrained (frames +x / +z, imposed twist phi, + !! end compliance, polar inertia irn, torque-tension coupling ktt with EA - ktt^2/GJ as the + !! line's own axial stiffness). + TYPE(CD_HermiteCableDynType), INTENT(OUT) :: model + INTEGER, INTENT(IN) :: ne + REAL(wp), INTENT(IN) :: q(:), ea, phi, irn, compliance, ktt + LOGICAL, INTENT(IN) :: clamped, torsion + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: le(ne), g(SIZE(q)), raw, ea_line + INTEGER :: es, ndof + CHARACTER(512) :: em + ndof = SIZE(q) + le = L0/REAL(ne, wp) + ea_line = ea + IF (torsion) ea_line = ea - ktt**2/GJ + CALL CD_HermiteCable_Dyn_Init(model, le, [(ea_line, es=1, ne)], [(EI, es=1, ne)], [(RHOA, es=1, ne)], & + [(0.0_wp, es=1, ne)], q, [1, 2, 3, ndof - 5, ndof - 4, ndof - 3], -1.0e3_wp, & + 0.0_wp, 0.8_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'model init: '//TRIM(em)) + IF (clamped) THEN + CALL CD_HermiteCable_Dyn_Set_EndConnection(model, [0.0_wp, 0.0_wp], & + RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + es, em, connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + CALL require(es == CD_HCDYN_OK, 'end connections: '//TRIM(em)) + END IF + IF (.NOT. torsion) RETURN + tors%active = .TRUE. + tors%phi = phi + tors%ends = RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 1.0_wp, 0.0_wp, 0.0_wp, & + 0.0_wp, 0.0_wp, 1.0_wp], [3, 4]) + tors%end_compliance = compliance + ALLOCATE (tors%gj(ne), tors%irn(ne)) + tors%gj = GJ + tors%irn = irn + IF (ABS(ktt) > 0.0_wp) THEN + ALLOCATE (tors%couple(ne)) + tors%couple = ktt/GJ + CALL CD_HermiteTorsion_Line(q, le, tors%ends, raw, g, es, em, couple=tors%couple) + ELSE + CALL CD_HermiteTorsion_Line(q, le, tors%ends, raw, g, es, em) + END IF + CALL require(es == CD_HTORS_OK, 'seed twist: '//TRIM(em)) + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + CALL CD_HermiteCable_Dyn_Set_Torsion(model, tors, es, em) + CALL require(es == CD_HCDYN_OK .AND. model%tw_active, 'torsion: '//TRIM(em)) + END SUBROUTINE build + + SUBROUTINE modes(model, nm, om, polar, nf, label) + !! The nm lowest modes of model: omega (rad/s) and polar share. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: nm + REAL(wp), ALLOCATABLE, INTENT(OUT) :: om(:), polar(:) + INTEGER, INTENT(OUT) :: nf + CHARACTER(*), INTENT(IN) :: label + REAL(wp), ALLOCATABLE :: om2(:), sh(:, :) + INTEGER :: es, dpn + CHARACTER(1024) :: em + CALL CD_Modal_Hermite_Line(model, nm, om2, sh, nf, dpn, polar, es, em) + CALL require(es == CD_MODAL_OK .AND. nf == nm, label//': modal solve: '//TRIM(em)) + ALLOCATE (om(MAX(nf, 1))) + om = SQRT(MAX(om2, 0.0_wp)) + END SUBROUTINE modes + + SUBROUTINE old_modes(model, nm, om) + !! The modal route without the twist: CD_Modal_Hermite_Band, the cable's freemask (the end + !! connections ignored), no twist DOFs. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: nm + REAL(wp), INTENT(OUT) :: om(nm) + REAL(wp), ALLOCATABLE :: kb(:, :), mb(:, :), om2(:), sh(:, :) + INTEGER :: kd, es, nf + CHARACTER(1024) :: em + om = 0.0_wp + CALL CD_Modal_Hermite_Band(model%q, model%l0, model%EA, model%EI, model%rho_a, kd, kb, mb, es, em) + ALLOCATE (om2(nm), sh(model%ndof, nm)) + IF (es == CD_MODAL_OK) CALL CD_Modal_Solve_Band(kb, mb, kd, model%freemask, nm, om2, sh, nf, es, em) + IF (es == CD_MODAL_OK) om = SQRT(MAX(om2, 0.0_wp)) + END SUBROUTINE old_modes + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE gate_t1() + !! T1: rigid torsional ends, Phi = 0, Irn = 0.04 (torsional modes at 14.05 and 28.10 rad/s, + !! between the bending pairs; EA = 1e4 puts the first axial mode at 31.4 rad/s). + INTEGER, PARAMETER :: NE = 40, NM = 13 + REAL(wp), PARAMETER :: IRN = 0.04_wp, EA = 1.0e4_wp + TYPE(CD_HermiteCableDynType) :: mt, mf + REAL(wp), ALLOCATABLE :: om(:), pol(:), omf(:), polf(:) + REAL(wp) :: q(6*(NE + 1)), cont, chain, err_c, err_d, bound, err_nt, mix, oold(NM) + INTEGER :: nf, nff, j, n, jn + CALL straight(NE, 1.0_wp + TENSION/EA, q) + CALL build(mt, NE, q, EA, .TRUE., .TRUE., 0.0_wp, IRN, 0.0_wp, 0.0_wp) + CALL build(mf, NE, q, EA, .TRUE., .FALSE., 0.0_wp, IRN, 0.0_wp, 0.0_wp) + CALL modes(mt, NM, om, pol, nf, 'T1 torsion') + CALL modes(mf, NM, omf, polf, nff, 'T1 free') + IF (nf /= NM .OR. nff /= NM) RETURN + n = 0 + jn = 0 + err_nt = 0.0_wp + mix = 0.0_wp + DO j = 1, NM + IF (pol(j) > 0.5_wp) THEN + n = n + 1 + cont = REAL(n, wp)*PI/L0*SQRT(GJ/IRN) + chain = 2.0_wp*SQRT(GJ/IRN)/(L0/REAL(NE, wp))*SIN(REAL(n, wp)*PI/(2.0_wp*REAL(NE, wp))) + err_c = ABS(om(j)/cont - 1.0_wp) + err_d = ABS(om(j)/chain - 1.0_wp) + bound = 1.0_wp - SIN(REAL(n, wp)*PI/(2.0_wp*REAL(NE, wp)))/(REAL(n, wp)*PI/(2.0_wp*REAL(NE, wp))) + WRITE (*, '(A,I0,A,F10.5,A,F10.5,A,ES9.2,A,ES9.2,A,ES9.2,A,ES9.2)') ' T1 torsional mode ', n, & + ': omega ', om(j), ' continuum ', cont, ' error ', err_c, ' (bound ', 1.01_wp*bound, '), chain error ', & + err_d, ', polar share 1 - ', 1.0_wp - pol(j) + CALL require(err_c <= 1.01_wp*bound + 1.0e-9_wp, 'T1: torsional mode against the continuum') + CALL require(err_d <= 1.0e-9_wp, 'T1: torsional mode against the lumped chain') + CALL require(1.0_wp - pol(j) <= 1.0e-9_wp, 'T1: a torsional mode carries no translation') + ELSE + jn = jn + 1 + IF (jn > nff) CYCLE + err_nt = MAX(err_nt, ABS(om(j)/omf(jn) - 1.0_wp)) + mix = MAX(mix, pol(j)) + END IF + END DO + WRITE (*, '(A,I0,A,ES9.2,A,ES9.2)') ' T1 ', jn, ' bending/axial modes against the line without torsion: ', & + err_nt, ', largest polar share ', mix + CALL require(n == 2, 'T1: two torsional modes among the 13 lowest') + CALL require(err_nt <= 1.0e-9_wp, 'T1: the bending and axial modes are those of the line without torsion') + CALL require(mix <= 1.0e-9_wp, 'T1: the bending and axial modes carry no twist') + CALL old_modes(mt, NM, oold) + WRITE (*, '(A,F10.5,A,F10.5,A)') ' T1 old route: no torsional mode; its first mode ', oold(1), & + ' rad/s against ', omf(1), ' rad/s of the clamped line (end connections ignored)' + CALL CD_HermiteCable_Dyn_End(mt) + CALL CD_HermiteCable_Dyn_End(mf) + END SUBROUTINE gate_t1 + + SUBROUTINE gate_t2() + !! T2: elastic torsional ends k = 2 GJ/L0 at both ends (Phi = 0, Irn = 0.04). + INTEGER, PARAMETER :: NE = 40, NM = 16, NT = 2 + REAL(wp), PARAMETER :: IRN = 0.04_wp, EA = 1.0e4_wp, KT = 2.0_wp*GJ/L0 + TYPE(CD_HermiteCableDynType) :: mt + REAL(wp), ALLOCATABLE :: om(:), pol(:) + REAL(wp) :: q(6*(NE + 1)), cont(NT), chain(NT), err_c, err_d, h + REAL(wp) :: kc(NE + 1, NE + 1), mc(NE + 1, NE + 1), w2(NE + 1), sh(NE + 1, NE + 1) + LOGICAL :: fr(NE + 1) + INTEGER :: nf, j, n, e, es + CHARACTER(512) :: em + CALL straight(NE, 1.0_wp + TENSION/EA, q) + CALL build(mt, NE, q, EA, .TRUE., .TRUE., 0.0_wp, IRN, 1.0_wp/KT, 0.0_wp) + CALL modes(mt, NM, om, pol, nf, 'T2') + IF (nf /= NM) RETURN + ! continuum: ((GJ b)^2 - k^2) sin(b L0) - 2 k GJ b cos(b L0) = 0, bracketed on a fine grid + CALL elastic_roots(KT, IRN, cont) + ! the lumped chain with its end springs (dense reference solve) + h = L0/REAL(NE, wp) + kc = 0.0_wp + mc = 0.0_wp + DO e = 1, NE + kc(e, e) = kc(e, e) + GJ/h + kc(e + 1, e + 1) = kc(e + 1, e + 1) + GJ/h + kc(e, e + 1) = kc(e, e + 1) - GJ/h + kc(e + 1, e) = kc(e + 1, e) - GJ/h + mc(e, e) = mc(e, e) + 0.5_wp*IRN*h + mc(e + 1, e + 1) = mc(e + 1, e + 1) + 0.5_wp*IRN*h + END DO + kc(1, 1) = kc(1, 1) + KT + kc(NE + 1, NE + 1) = kc(NE + 1, NE + 1) + KT + fr = .TRUE. + CALL CD_Modal_Solve(kc, mc, fr, NE + 1, w2, sh, n, es, em) + CALL require(es == CD_MODAL_OK, 'T2: chain reference solve: '//TRIM(em)) + chain = SQRT(w2(1:NT)) + n = 0 + DO j = 1, NM + IF (pol(j) <= 0.5_wp .OR. n >= NT) CYCLE + n = n + 1 + err_c = ABS(om(j)/cont(n) - 1.0_wp) + err_d = ABS(om(j)/chain(n) - 1.0_wp) + WRITE (*, '(A,I0,A,F10.5,A,F10.5,A,ES9.2,A,ES9.2)') ' T2 elastic-end torsional mode ', n, ': omega ', & + om(j), ' continuum ', cont(n), ' error ', err_c, ', lumped chain error ', err_d + CALL require(err_c <= 1.0e-3_wp, 'T2: elastic-end torsional mode against the continuum') + CALL require(err_d <= 1.0e-9_wp, 'T2: elastic-end torsional mode against the lumped chain') + END DO + CALL require(n == NT, 'T2: two torsional modes found') + CALL CD_HermiteCable_Dyn_End(mt) + END SUBROUTINE gate_t2 + + SUBROUTINE elastic_roots(kt, irn, roots) + !! The lowest roots b of ((GJ b)^2 - k^2) sin(b L0) - 2 k GJ b cos(b L0), as omega. + REAL(wp), INTENT(IN) :: kt, irn + REAL(wp), INTENT(OUT) :: roots(:) + INTEGER, PARAMETER :: NGRID = 20000 + REAL(wp) :: b0, b1, f0, f1, bm, fm + INTEGER :: i, n, it + n = 0 + b0 = 1.0e-6_wp + f0 = elastic_char(kt, b0) + DO i = 1, NGRID + b1 = REAL(i, wp)*(REAL(SIZE(roots) + 1, wp)*PI/L0)/REAL(NGRID, wp) + f1 = elastic_char(kt, b1) + IF (f0*f1 < 0.0_wp) THEN + DO it = 1, 200 + bm = 0.5_wp*(b0 + b1) + fm = elastic_char(kt, bm) + IF (fm*f0 > 0.0_wp) THEN + b0 = bm + f0 = fm + ELSE + b1 = bm + END IF + END DO + n = n + 1 + roots(n) = 0.5_wp*(b0 + b1)*SQRT(GJ/irn) + IF (n == SIZE(roots)) RETURN + b1 = REAL(i, wp)*(REAL(SIZE(roots) + 1, wp)*PI/L0)/REAL(NGRID, wp) + f1 = elastic_char(kt, b1) + END IF + b0 = b1 + f0 = f1 + END DO + END SUBROUTINE elastic_roots + + REAL(wp) FUNCTION elastic_char(kt, b) RESULT(f) + !! ((GJ b)^2 - k^2) sin(b L0) - 2 k GJ b cos(b L0): zero at a torsional mode with end springs k. + REAL(wp), INTENT(IN) :: kt, b + f = ((GJ*b)**2 - kt**2)*SIN(b*L0) - 2.0_wp*kt*GJ*b*COS(b*L0) + END FUNCTION elastic_char + + SUBROUTINE gate_t3() + !! T3: torque-tension coupling K = 300 N m (K^2 < EA GJ), Phi = 0, Irn = 0.04: the coupled + !! axial-torsional modes of the clamped (axially and torsionally held) bar. + INTEGER, PARAMETER :: NE = 60, NM = 24, NT = 4 + REAL(wp), PARAMETER :: IRN = 0.04_wp, EA = 1.0e4_wp, KTT = 300.0_wp + TYPE(CD_HermiteCableDynType) :: mt + REAL(wp), ALLOCATABLE :: om(:), pol(:) + REAL(wp) :: q(6*(NE + 1)), tr, det, c2(2), ref(2*NT), err, bound, x + INTEGER :: nf, j, n, i + CALL straight(NE, 1.0_wp + TENSION/EA, q) + CALL build(mt, NE, q, EA, .TRUE., .TRUE., 0.0_wp, IRN, 0.0_wp, KTT) + CALL modes(mt, NM, om, pol, nf, 'T3') + IF (nf /= NM) RETURN + ! eig(diag(m, Irn)^-1 [[EA, K], [K, GJ]]): the two wave speeds squared + tr = EA/RHOA + GJ/IRN + det = (EA*GJ - KTT**2)/(RHOA*IRN) + c2(1) = 0.5_wp*(tr - SQRT(tr*tr - 4.0_wp*det)) + c2(2) = 0.5_wp*(tr + SQRT(tr*tr - 4.0_wp*det)) + DO i = 1, NT + ref(2*i - 1) = REAL(i, wp)*PI/L0*SQRT(c2(1)) + ref(2*i) = REAL(i, wp)*PI/L0*SQRT(c2(2)) + END DO + CALL sort(ref) + n = 0 + DO j = 1, NM + IF (pol(j) <= 1.0e-6_wp) CYCLE + n = n + 1 + IF (n > NT) EXIT + err = ABS(om(j)/ref(n) - 1.0_wp) + ! the lumped twist's error 1 - sin(x)/x, x = n pi/(2 NE), at the mode's larger wavenumber + ! (the slow family's, n omega/c_slow) bounds the coupled one + x = REAL(CEILING(ref(n)/SQRT(c2(1))*L0/PI - 1.0e-9_wp), wp)*PI/(2.0_wp*REAL(NE, wp)) + bound = 1.0_wp - SIN(x)/x + WRITE (*, '(A,I0,A,F10.5,A,F10.5,A,ES9.2,A,ES9.2,A,F6.3)') ' T3 coupled axial-torsional mode ', n, & + ': omega ', om(j), ' continuum ', ref(n), ' error ', err, ' (bound ', bound, '), polar share ', pol(j) + CALL require(err <= bound + 1.0e-6_wp, 'T3: coupled axial-torsional mode against the continuum') + CALL require(pol(j) > 0.01_wp .AND. pol(j) < 0.99_wp, 'T3: the coupling mixes stretch and twist') + END DO + CALL require(n >= NT, 'T3: four coupled modes found') + CALL CD_HermiteCable_Dyn_End(mt) + END SUBROUTINE gate_t3 + + SUBROUTINE sort(x) + REAL(wp), INTENT(INOUT) :: x(:) + INTEGER :: i, j + REAL(wp) :: t + DO i = 2, SIZE(x) + DO j = i, 2, -1 + IF (x(j) >= x(j - 1)) EXIT + t = x(j) + x(j) = x(j - 1) + x(j - 1) = t + END DO + END DO + END SUBROUTINE sort + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE gate_c1() + !! C1: the straight taut clamped line (T = 10 N, EA = 1e4) under M = 4 EI/L0 = 40 N m with a + !! negligible Irn = 1e-6 (torsional modes above 2800 rad/s), against the Greenhill-cable + !! determinant; the untwisted line (Phi = 0) against the same determinant at M = 0. + INTEGER, PARAMETER :: NE = 100, NROOT = 4, NM = 2*NROOT + REAL(wp), PARAMETER :: EA = 1.0e4_wp, MT = 40.0_wp, IRN = 1.0e-6_wp + TYPE(CD_HermiteCableDynType) :: m1, m0 + REAL(wp), ALLOCATABLE :: om(:), pol(:), om0(:), pol0(:) + REAL(wp) :: q(6*(NE + 1)), lam, ref(NROOT), ref0(NROOT), err, err0, pair, shift_fe, shift_th, oold(NM), mt_model + INTEGER :: nf, nf0, j + lam = 1.0_wp + TENSION/EA + CALL straight(NE, lam, q) + CALL build(m1, NE, q, EA, .TRUE., .TRUE., MT*L0/GJ, IRN, 0.0_wp, 0.0_wp) + CALL build(m0, NE, q, EA, .TRUE., .TRUE., 0.0_wp, IRN, 0.0_wp, 0.0_wp) + mt_model = m1%torsion%torque + WRITE (*, '(A,F12.8,A)') ' C1 torque of the twisted state ', mt_model, ' N m' + CALL require(ABS(mt_model - MT) <= 1.0e-9_wp*MT, 'C1: the twisted state carries M = Phi GJ/L0') + CALL modes(m1, NM, om, pol, nf, 'C1 twisted') + CALL modes(m0, NM, om0, pol0, nf0, 'C1 untwisted') + IF (nf /= NM .OR. nf0 /= NM) RETURN + CALL greenhill_roots(EI/lam**4, MT/lam**2, TENSION/lam, NROOT, ref) + CALL greenhill_roots(EI/lam**4, 0.0_wp, TENSION/lam, NROOT, ref0) + DO j = 1, NROOT + err = MAX(ABS(om(2*j - 1)/ref(j) - 1.0_wp), ABS(om(2*j)/ref(j) - 1.0_wp)) + err0 = MAX(ABS(om0(2*j - 1)/ref0(j) - 1.0_wp), ABS(om0(2*j)/ref0(j) - 1.0_wp)) + pair = ABS(om(2*j)/om(2*j - 1) - 1.0_wp) + shift_th = ref(j)/ref0(j) - 1.0_wp + shift_fe = 0.5_wp*(om(2*j - 1) + om(2*j))/(0.5_wp*(om0(2*j - 1) + om0(2*j))) - 1.0_wp + WRITE (*, '(A,I0,A,F10.6,A,F10.6,A,ES9.2,A,ES9.2,A,F8.4,A,F8.4,A)') ' C1 lateral pair ', j, ': omega ', & + om(2*j - 1), ' Greenhill cable ', ref(j), ' error ', err, ' (untwisted ', err0, '), shift ', & + 100.0_wp*shift_fe, ' % (theory ', 100.0_wp*shift_th, ' %)' + CALL require(err <= 1.0e-6_wp, 'C1: lateral frequency under torque against the Greenhill cable') + CALL require(err0 <= 1.0e-6_wp, 'C1: untwisted lateral frequency against the clamped tensioned beam') + CALL require(pair <= 1.0e-8_wp, 'C1: the lateral modes under torque come in pairs') + CALL require(shift_th < 0.0_wp .AND. ABS(shift_fe - shift_th) <= 1.0e-4_wp*ABS(shift_th), & + 'C1: the torque lowers the frequency by the shift theory gives') + CALL require(MAXVAL(pol(2*j - 1:2*j)) <= 1.0e-9_wp, 'C1: the lateral modes carry no twist') + END DO + CALL old_modes(m1, NM, oold) + WRITE (*, '(A,ES9.2,A)') ' C1 old route (pinned, untwisted): first lateral pair error ', & + ABS(oold(1)/ref(1) - 1.0_wp), ' against the Greenhill cable' + CALL CD_HermiteCable_Dyn_End(m1) + CALL CD_HermiteCable_Dyn_End(m0) + END SUBROUTINE gate_c1 + + SUBROUTINE greenhill_roots(eie, me, te, nroot, om) + !! The nroot lowest omega of the clamped Greenhill cable eie u'''' - i me u''' - te u'' = m omega^2 u + !! on [0, L0]: sign changes of Im(D exp(-i L0 sum k/2)) over omega^2, refined by bisection. + REAL(wp), INTENT(IN) :: eie, me, te + INTEGER, INTENT(IN) :: nroot + REAL(wp), INTENT(OUT) :: om(nroot) + INTEGER, PARAMETER :: NGRID = 40000 + REAL(wp) :: lmax, l0g, l1g, f0, f1, lm, fm, re_max, im_max + COMPLEX(wp) :: d + INTEGER :: i, n, it + ! an upper bound of the nroot-th root: the clamped beam's (n + 1/2) pi/L0 wavenumber with + ! tension, enlarged + lmax = 2.0_wp*(eie*((REAL(nroot, wp) + 0.5_wp)*PI/L0)**4 + te*((REAL(nroot, wp) + 0.5_wp)*PI/L0)**2)/RHOA + re_max = 0.0_wp + im_max = 0.0_wp + n = 0 + om = 0.0_wp + l0g = 1.0e-9_wp*lmax + d = det_norm(eie, me, te, RHOA*l0g) + f0 = AIMAG(d) + DO i = 1, NGRID + l1g = lmax*REAL(i, wp)/REAL(NGRID, wp) + d = det_norm(eie, me, te, RHOA*l1g) + re_max = MAX(re_max, ABS(REAL(d, wp))) + im_max = MAX(im_max, ABS(AIMAG(d))) + f1 = AIMAG(d) + IF (f0*f1 < 0.0_wp .AND. n < nroot) THEN + DO it = 1, 200 + lm = 0.5_wp*(l0g + l1g) + fm = AIMAG(det_norm(eie, me, te, RHOA*lm)) + IF (fm*f0 > 0.0_wp) THEN + l0g = lm + f0 = fm + ELSE + l1g = lm + END IF + END DO + n = n + 1 + om(n) = SQRT(0.5_wp*(l0g + l1g)) + l1g = lmax*REAL(i, wp)/REAL(NGRID, wp) + f1 = AIMAG(det_norm(eie, me, te, RHOA*l1g)) + END IF + l0g = l1g + f0 = f1 + END DO + CALL require(n == nroot, 'C1: the Greenhill determinant has the expected roots') + ! the normalised determinant is purely imaginary (the oracle's own consistency) + CALL require(re_max <= 1.0e-8_wp*im_max, 'C1: the normalised Greenhill determinant is imaginary') + END SUBROUTINE greenhill_roots + + COMPLEX(wp) FUNCTION det_norm(eie, me, te, lambda) RESULT(dn) + !! The clamped-clamped determinant of the Greenhill cable at m omega^2 = lambda, times + !! exp(-i L0 sum k_j/2): rows u(0), u'(0)/i, u(L0), u'(L0)/i of the four exp(i k_j s0). + REAL(wp), INTENT(IN) :: eie, me, te, lambda + COMPLEX(wp) :: k(4), a(4, 4) + INTEGER :: j + CALL quartic_roots([CMPLX(-lambda/eie, 0.0_wp, wp), (0.0_wp, 0.0_wp), CMPLX(te/eie, 0.0_wp, wp), & + CMPLX(-me/eie, 0.0_wp, wp)], k) + DO j = 1, 4 + a(1, j) = (1.0_wp, 0.0_wp) + a(2, j) = k(j) + a(3, j) = EXP((0.0_wp, 1.0_wp)*k(j)*L0) + a(4, j) = k(j)*a(3, j) + END DO + dn = det4(a)*EXP(-(0.0_wp, 0.5_wp)*L0*SUM(k)) + END FUNCTION det_norm + + SUBROUTINE quartic_roots(c, z) + !! Roots of z^4 + c(4) z^3 + c(3) z^2 + c(2) z + c(1) (Durand-Kerner, then Newton polish). + COMPLEX(wp), INTENT(IN) :: c(4) + COMPLEX(wp), INTENT(OUT) :: z(4) + COMPLEX(wp) :: den, dz, p, dp + REAL(wp) :: r + INTEGER :: it, i, j + r = 1.0_wp + MAXVAL(ABS(c)) + DO i = 1, 4 + z(i) = r*(0.4_wp, 0.9_wp)**i + END DO + DO it = 1, 2000 + dz = (0.0_wp, 0.0_wp) + DO i = 1, 4 + den = (1.0_wp, 0.0_wp) + DO j = 1, 4 + IF (j /= i) den = den*(z(i) - z(j)) + END DO + p = (((z(i) + c(4))*z(i) + c(3))*z(i) + c(2))*z(i) + c(1) + z(i) = z(i) - p/den + dz = dz + ABS(p/den) + END DO + IF (ABS(dz) <= 1.0e-15_wp*r) EXIT + END DO + DO i = 1, 4 + DO it = 1, 3 + p = (((z(i) + c(4))*z(i) + c(3))*z(i) + c(2))*z(i) + c(1) + dp = ((4.0_wp*z(i) + 3.0_wp*c(4))*z(i) + 2.0_wp*c(3))*z(i) + c(2) + IF (ABS(dp) > 0.0_wp) z(i) = z(i) - p/dp + END DO + END DO + END SUBROUTINE quartic_roots + + COMPLEX(wp) FUNCTION det4(a0) RESULT(d) + !! Determinant of a complex 4 x 4 matrix (Gaussian elimination, partial pivoting). + COMPLEX(wp), INTENT(IN) :: a0(4, 4) + COMPLEX(wp) :: a(4, 4), t(4), f + INTEGER :: i, j, p + a = a0 + d = (1.0_wp, 0.0_wp) + DO j = 1, 4 + p = j - 1 + MAXLOC(ABS(a(j:4, j)), 1) + IF (p /= j) THEN + t = a(j, :) + a(j, :) = a(p, :) + a(p, :) = t + d = -d + END IF + d = d*a(j, j) + IF (.NOT. ABS(a(j, j)) > 0.0_wp) RETURN + DO i = j + 1, 4 + f = a(i, j)/a(j, j) + a(i, j:4) = a(i, j:4) - f*a(j, j:4) + END DO + END DO + END FUNCTION det4 + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE gate_c2(label, clamped, compliance, ktt) + !! C2: Schur complement of the twist angles against the condensed static tangent, analytic + !! and by central differences of the condensed static residual, on the bowed line (NE = 12, + !! Phi = 1 rad, Irn = 1). + CHARACTER(*), INTENT(IN) :: label + LOGICAL, INTENT(IN) :: clamped + REAL(wp), INTENT(IN) :: compliance, ktt + INTEGER, PARAMETER :: NE = 12, NN = NE + 1, N6 = 6*NN, N7 = 7*NN + REAL(wp), PARAMETER :: EA = 1.0e4_wp, PHI = 1.0_wp + TYPE(CD_HermiteCableDynType) :: model + REAL(wp), ALLOCATABLE :: kb(:, :), mb(:, :) + LOGICAL, ALLOCATABLE :: free(:) + REAL(wp) :: q(N6), k7(N7, N7), kc(N6, N6), kel(N6, N6), tr(N6, N6), s(N6, N6), dq(N6), dl(N6), gp(N6) + REAL(wp) :: gm(N6), fd(N6) + REAL(wp) :: sd(N6), kpp(NN, NN), kpq(NN, N6), x(NN, N6), basis(3, 3), h, err_a, err_f, scale, old_err, g0 + INTEGER, ALLOCATABLE :: iq(:), ip(:) + LOGICAL :: qfree(N6) + INTEGER :: kd, dpn, es, i, j, nq, np, i6, iend, b0, seed + CHARACTER(1024) :: em + CALL bowed(NE, q) + CALL build(model, NE, q, EA, clamped, .TRUE., PHI, 1.0_wp, compliance, ktt) + IF (.NOT. model%tw_active) RETURN + CALL CD_Modal_Hermite_Line_Band(model, kd, kb, mb, free, dpn, es, em) + CALL require(es == CD_MODAL_OK .AND. dpn == 7, 'C2 '//label//': band: '//TRIM(em)) + IF (es /= CD_MODAL_OK) RETURN + k7 = 0.0_wp + DO j = 1, N7 + DO i = MAX(1, j - kd), j + k7(i, j) = kb(kd + 1 + i - j, j) + k7(j, i) = k7(i, j) + END DO + END DO + ! free q DOFs (cable numbering) and free angles + DO i6 = 1, N6 + qfree(i6) = free(i6 + (i6 - 1)/6) + END DO + nq = COUNT(qfree) + np = COUNT(free(7:N7:7)) + ALLOCATE (iq(nq), ip(np)) + iq = PACK([(i6, i6=1, N6)], qfree) + ip = PACK([(i, i=1, NN)], free(7:N7:7)) + ! Schur complement on the free set: S = K_qq - K_qp K_pp^-1 K_pq + DO j = 1, np + DO i = 1, np + kpp(i, j) = k7(7*ip(i), 7*ip(j)) + END DO + DO i = 1, nq + kpq(j, i) = k7(7*ip(j), iq(i) + (iq(i) - 1)/6) + END DO + END DO + x(1:np, 1:nq) = kpq(1:np, 1:nq) + CALL spd_solve(kpp(1:np, 1:np), x(1:np, 1:nq)) + s = 0.0_wp + DO j = 1, nq + DO i = 1, nq + s(iq(i), iq(j)) = k7(iq(i) + (iq(i) - 1)/6, iq(j) + (iq(j) - 1)/6) - DOT_PRODUCT(kpq(1:np, i), x(1:np, j)) + END DO + END DO + ! the rigid ends' basis (identity elsewhere) + tr = 0.0_wp + DO i = 1, N6 + tr(i, i) = 1.0_wp + END DO + IF (clamped) THEN + DO iend = 1, 2 + CALL CD_EndConn_Basis(model%endconn_d0(:, iend), basis, es, em) + b0 = 6*(MERGE(1, NN, iend == 1) - 1) + 3 + tr(b0 + 1:b0 + 3, b0 + 1:b0 + 3) = basis + END DO + END IF + ! the condensed static tangent in the same coordinates + CALL condensed(model, q, kc, g0, kel) + kc = MATMUL(TRANSPOSE(tr), MATMUL(kc, tr)) + kel = MATMUL(TRANSPOSE(tr), MATMUL(kel, tr)) + scale = 0.0_wp + err_a = 0.0_wp + old_err = 0.0_wp + DO j = 1, nq + DO i = 1, nq + scale = MAX(scale, ABS(kc(iq(i), iq(j)))) + err_a = MAX(err_a, ABS(s(iq(i), iq(j)) - kc(iq(i), iq(j)))) + old_err = MAX(old_err, ABS(kel(iq(i), iq(j)) - kc(iq(i), iq(j)))) + END DO + END DO + err_a = err_a/scale + ! central differences of the condensed residual along a pseudo-random free direction + seed = 4242 + dl = 0.0_wp + DO i = 1, nq + seed = MOD(69069*seed + 1, 2147483647) + dl(iq(i)) = REAL(MOD(seed, 2001) - 1000, wp)/1000.0_wp + END DO + dq = MATMUL(tr, dl) + h = 1.0e-6_wp + CALL condensed_residual(model, q + h*dq, gp) + CALL condensed_residual(model, q - h*dq, gm) + fd = MATMUL(TRANSPOSE(tr), (gp - gm)/(2.0_wp*h)) + sd = MATMUL(s, dl) + err_f = 0.0_wp + DO i = 1, nq + err_f = MAX(err_f, ABS(fd(iq(i)) - sd(iq(i)))) + END DO + err_f = err_f/MAX(nan_max_abs(sd), TINY(1.0_wp)) + WRITE (*, '(A,A,A,F9.4,A,ES9.2,A,ES9.2,A,ES9.2)') ' C2 ', label, ': torque ', model%torsion%torque, & + ' N m; Schur complement against the condensed tangent ', err_a, ', against central differences ', err_f, & + '; old route (no twist) ', old_err/scale + CALL require(err_a <= 1.0e-9_wp, 'C2 '//label//': Schur complement against the condensed static tangent') + CALL require(err_f <= 1.0e-6_wp, 'C2 '//label//': Schur complement against the condensed residual') + CALL CD_HermiteCable_Dyn_End(model) + END SUBROUTINE gate_c2 + + SUBROUTINE gate_e() + !! E: finite bending springs k at both ends, between pinned and clamped. + INTEGER, PARAMETER :: NE = 40, NK = 4 + REAL(wp), PARAMETER :: EA = 1.0e4_wp + REAL(wp), PARAMETER :: KS(NK) = [1.0e-1_wp, 1.0e1_wp, 1.0e3_wp, 1.0e5_wp]*EI/L0 + TYPE(CD_HermiteCableDynType) :: mp, mc, mk + REAL(wp), ALLOCATABLE :: om(:), pol(:) + REAL(wp) :: q(6*(NE + 1)), w_pin, w_clamp, w_prev + INTEGER :: nf, i, es + CHARACTER(512) :: em + LOGICAL :: ordered + CALL straight(NE, 1.0_wp + TENSION/EA, q) + CALL build(mp, NE, q, EA, .FALSE., .FALSE., 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp) + CALL build(mc, NE, q, EA, .TRUE., .FALSE., 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp) + CALL modes(mp, 2, om, pol, nf, 'E pinned') + w_pin = om(1) + CALL modes(mc, 2, om, pol, nf, 'E clamped') + w_clamp = om(1) + w_prev = w_pin + ordered = .TRUE. + DO i = 1, NK + CALL build(mk, NE, q, EA, .FALSE., .FALSE., 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp) + CALL CD_HermiteCable_Dyn_Set_EndConnection(mk, [KS(i), KS(i)], & + RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + es, em, connection_mode=[CD_ENDCONN_FINITE, CD_ENDCONN_FINITE]) + CALL require(es == CD_HCDYN_OK, 'E: finite end connections: '//TRIM(em)) + CALL modes(mk, 2, om, pol, nf, 'E finite') + WRITE (*, '(A,ES9.2,A,F10.6,A,F10.6,A,F10.6,A)') ' E end springs k L0/EI = ', KS(i)*L0/EI, ': omega_1 ', & + om(1), ' (pinned ', w_pin, ', clamped ', w_clamp, ')' + ordered = ordered .AND. om(1) > w_prev .AND. om(1) < w_clamp + w_prev = om(1) + CALL CD_HermiteCable_Dyn_End(mk) + END DO + CALL require(ordered, 'E: the end springs put the frequency between pinned and clamped, rising with k') + CALL require(ABS(w_prev/w_clamp - 1.0_wp) <= 1.0e-4_wp, 'E: a stiff end spring approaches the clamp') + CALL CD_HermiteCable_Dyn_End(mp) + CALL CD_HermiteCable_Dyn_End(mc) + END SUBROUTINE gate_e + + SUBROUTINE condensed(model, qc, kc, mt, kel) + !! The condensed static tangent at qc: the element Hessians (kel) + M_t d2(-Theta)/dq2 + + !! (1/C) g g^T, M_t = (Phi - Theta)/C (Theta unwrapped against the model's accepted value). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: qc(:) + REAL(wp), INTENT(OUT) :: kc(:, :), mt, kel(:, :) + REAL(wp) :: ee, fe(12), ke(12, 12), raw, th, c, g(SIZE(qc)), hb(2*CD_HTORS_KBAND + 1, SIZE(qc)) + INTEGER :: e, es, i, j, n + CHARACTER(512) :: em + n = SIZE(qc) + kc = 0.0_wp + DO e = 1, model%ne + CALL CD_HermiteCable_Element(qc(6*e - 5:6*e + 6), model%l0(e), model%EA(e), model%EI(e), ee, fe, ke, es, em) + kc(6*e - 5:6*e + 6, 6*e - 5:6*e + 6) = kc(6*e - 5:6*e + 6, 6*e - 5:6*e + 6) + ke + END DO + hb = 0.0_wp + IF (ALLOCATED(model%torsion%couple)) THEN + CALL CD_HermiteTorsion_Line(qc, model%l0, model%torsion%ends, raw, g, es, em, hband=hb, & + couple=model%torsion%couple) + ELSE + CALL CD_HermiteTorsion_Line(qc, model%l0, model%torsion%ends, raw, g, es, em, hband=hb) + END IF + CALL require(es == CD_HTORS_OK, 'C2: condensed twist: '//TRIM(em)) + kel = kc + th = CD_HermiteTorsion_Unwrap(raw, model%torsion%theta) + c = CD_HermiteTorsion_Compliance(model%torsion, model%l0) + mt = (model%torsion%phi - th)/c + DO j = 1, n + DO i = MAX(1, j - CD_HTORS_KBAND), MIN(n, j + CD_HTORS_KBAND) + kc(i, j) = kc(i, j) - mt*hb(CD_HTORS_KBAND + 1 + i - j, j) + END DO + kc(:, j) = kc(:, j) + g*g(j)/c + END DO + END SUBROUTINE condensed + + SUBROUTINE condensed_residual(model, qc, r) + !! The condensed static residual (no external load): sum_e f_int - M_t dTheta/dq. + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + REAL(wp), INTENT(IN) :: qc(:) + REAL(wp), INTENT(OUT) :: r(:) + REAL(wp) :: ee, fe(12), raw, th, c, g(SIZE(qc)) + INTEGER :: e, es + CHARACTER(512) :: em + r = 0.0_wp + DO e = 1, model%ne + CALL CD_HermiteCable_Element(qc(6*e - 5:6*e + 6), model%l0(e), model%EA(e), model%EI(e), ee, fe, & + ErrStat=es, ErrMsg=em) + r(6*e - 5:6*e + 6) = r(6*e - 5:6*e + 6) + fe + END DO + IF (ALLOCATED(model%torsion%couple)) THEN + CALL CD_HermiteTorsion_Line(qc, model%l0, model%torsion%ends, raw, g, es, em, couple=model%torsion%couple) + ELSE + CALL CD_HermiteTorsion_Line(qc, model%l0, model%torsion%ends, raw, g, es, em) + END IF + th = CD_HermiteTorsion_Unwrap(raw, model%torsion%theta) + c = CD_HermiteTorsion_Compliance(model%torsion, model%l0) + r = r - (model%torsion%phi - th)/c*g + END SUBROUTINE condensed_residual + + SUBROUTINE spd_solve(a, b) + !! b <- a^-1 b for a small symmetric positive definite a (Cholesky). + REAL(wp), INTENT(IN) :: a(:, :) + REAL(wp), INTENT(INOUT) :: b(:, :) + REAL(wp) :: l(SIZE(a, 1), SIZE(a, 1)) + INTEGER :: n, i, j + n = SIZE(a, 1) + l = 0.0_wp + DO j = 1, n + l(j, j) = SQRT(a(j, j) - DOT_PRODUCT(l(j, 1:j - 1), l(j, 1:j - 1))) + DO i = j + 1, n + l(i, j) = (a(i, j) - DOT_PRODUCT(l(i, 1:j - 1), l(j, 1:j - 1)))/l(j, j) + END DO + END DO + DO j = 1, SIZE(b, 2) + DO i = 1, n + b(i, j) = (b(i, j) - DOT_PRODUCT(l(i, 1:i - 1), b(1:i - 1, j)))/l(i, i) + END DO + DO i = n, 1, -1 + b(i, j) = (b(i, j) - DOT_PRODUCT(l(i + 1:n, i), b(i + 1:n, j)))/l(i, i) + END DO + END DO + END SUBROUTINE spd_solve + +END PROGRAM test_modal_torsion diff --git a/tests/test_modal_torsion_deck.py b/tests/test_modal_torsion_deck.py new file mode 100644 index 00000000..092ac0fd --- /dev/null +++ b/tests/test_modal_torsion_deck.py @@ -0,0 +1,218 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Driver gates of the modal analysis (OPTION nModes) of finite-EI lines restrained in torsion. + +1. A straight taut 10 m line (neutrally buoyant, no added mass), clamped (bending Rigid) and + rigid in torsion at both ends, 40 elements: its four torsional modes among the 24 lowest + (PolarShare > 0.5) are the lumped chain's 2 sqrt(GJ/Irn)/l0 sin(n pi/(2 NE)) and the + continuum's n pi/L0 sqrt(GJ/Irn) within the chain's own error 1 - sin(x)/x, + x = n pi/(2 NE); the first one's dTwist is sin(pi s/L0) with no translation; every other + mode (bending, axial) has the frequency of the same deck with TorsStiffness Free and no + twist. "Exact" comparisons allow 2e-8, the rounding of the table's nine digits. Turned 30 + degrees about +z, the line has the same frequencies, and the table its positions in the + deck's axes. +2. tests/data/torsion_lazy_wave_modes.dat, the lazy wave twisted two turns, runs its modes: + 12 ascending, finite frequencies with PolarShare in [0, 1] and a dTwist column. +Both fail closed on a driver that refuses nModes with torsion. +""" + +from __future__ import annotations + +import argparse +import math +import subprocess +from pathlib import Path + +L0, NE, EA, EI, GJ, IRN, TENSION = 10.0, 40, 1.0e6, 100.0, 80.0, 0.04, 1000.0 +RHO_W, DIAM = 1025.0, 0.1 +N_MODES = 24 +# the table writes nine significant digits +REL_EXACT = 2.0e-8 + + +def straight_deck(torsion: str, heading_deg: float = 0.0) -> str: + mass = RHO_W * math.pi * DIAM**2 / 4.0 # neutrally buoyant: the line stays straight + span = L0 * (1.0 + TENSION / EA) + c, s = math.cos(math.radians(heading_deg)), math.sin(math.radians(heading_deg)) + bar = "-" * 21 + return f"""{bar} CableDyn Input File {bar} +straight taut line clamped and restrained in torsion ({torsion}) at both ends +{bar} LINE TYPES {bar} +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +cab {DIAM!r} {mass!r} {EA!r} 0.0 {EI!r} 1.0e8 {GJ!r} 1.0 {IRN!r} 1.2 0.0 0.0 0.0 +{bar} POINTS {bar} +ID Type X Y Z +1 Coupled 0.0 0.0 -100.0 +2 Fixed {span * c!r} {span * s!r} -100.0 +{bar} LINES {bar} +ID NodeA NodeB Outputs +1 1 2 - +{bar} SECTIONS {bar} +LineID LineType Length NumSegs +1 cab {L0!r} {NE} +{bar} END CONNECTIONS {bar} +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +1 A Rigid {c!r} {s!r} 0 {torsion} 0 0 1 0 +1 B Rigid {c!r} {s!r} 0 {torsion} 0 0 1 0 +{bar} OPTIONS {bar} +9.80665 g +{RHO_W!r} rhoW +500.0 WtrDpth +0.01 dtM +0.01 TMax +{N_MODES} nModes +{bar} OUTPUTS {bar} +FairTen1 +{bar} need this line {bar} +""" + + +def read_modes(path: Path) -> tuple[list[str], list[list[float]], list[str], list[list[float]]]: + """The frequency and mode-shape tables of a .modes.out file: (header, rows) for each.""" + lines = path.read_text(encoding="utf-8").splitlines() + tables: list[tuple[list[str], list[list[float]]]] = [] + i = 0 + while i < len(lines): + if lines[i].startswith("# Natural frequencies") or lines[i].startswith("# Mode shapes"): + header = lines[i + 1].split("\t") + rows = [] + j = i + 3 + while j < len(lines) and not lines[j].startswith("#"): + rows.append([float(x) for x in lines[j].split("\t")]) + j += 1 + tables.append((header, rows)) + i = j + else: + i += 1 + if len(tables) != 2: + raise AssertionError(f"{path}: expected two tables, found {len(tables)}") + return tables[0][0], tables[0][1], tables[1][0], tables[1][1] + + +def run(exe: str, deck: Path, root: Path) -> Path: + proc = subprocess.run([exe, str(deck), str(root)], capture_output=True, text=True, check=False) + if proc.returncode != 0: + raise AssertionError(f"{deck.name}: driver exit {proc.returncode}\n{proc.stdout}\n{proc.stderr}") + return root.with_name(root.name + ".modes.out") + + +def check_straight(exe: str, out: Path) -> list[str]: + failures: list[str] = [] + files = {} + for torsion in ("Rigid", "Free"): + deck = out / f"straight_{torsion.lower()}.dat" + deck.write_text(straight_deck(torsion), encoding="utf-8") + files[torsion] = run(exe, deck, out / f"straight_{torsion.lower()}") + fh, freq, sh, shapes = read_modes(files["Rigid"]) + fh0, freq0, _, _ = read_modes(files["Free"]) + if fh[-1] != "PolarShare" or sh[-1] != "dTwist": + failures.append(f"torsion deck: no PolarShare/dTwist columns ({fh}, {sh})") + return failures + if "PolarShare" in fh0: + failures.append("the TorsStiffness Free deck writes twist columns") + omega = [row[4] for row in freq] + polar = [row[5] for row in freq] + omega0 = [row[4] for row in freq0] + l0 = L0 / NE + n = 0 + other = [] + for j, (om, share) in enumerate(zip(omega, polar), start=1): + if share > 0.5: + n += 1 + x = n * math.pi / (2.0 * NE) + chain = 2.0 * math.sqrt(GJ / IRN) / l0 * math.sin(x) + cont = n * math.pi / L0 * math.sqrt(GJ / IRN) + err_d, err_c = abs(om / chain - 1.0), abs(om / cont - 1.0) + bound = 1.0 - math.sin(x) / x + print( + f" torsional mode {n} (mode {j}): omega {om:.6f} rad/s, continuum {cont:.6f}, error " + f"{err_c:.2e} (bound {1.01 * bound:.2e}), chain error {err_d:.2e}, polar share 1 - {1 - share:.1e}" + ) + if err_d > REL_EXACT or err_c > 1.01 * bound + REL_EXACT or 1.0 - share > REL_EXACT: + failures.append(f"torsional mode {n}: omega {om} against chain {chain}, continuum {cont}") + if n == 1: + rows = [r for r in shapes if int(r[1]) == j] + twist = [r[9] for r in rows] + trans = max(abs(v) for r in rows for v in r[6:9]) + ref = [math.sin(math.pi * k / NE) for k in range(NE + 1)] + sign = 1.0 if twist[NE // 2] > 0.0 else -1.0 + err_s = max(abs(sign * t - r) for t, r in zip(twist, ref)) + print(f" torsional mode 1 shape: dTwist against sin(pi s/L0) {err_s:.2e}, translations {trans:.1e}") + if err_s > 1.0e-6 or trans > REL_EXACT: + failures.append(f"torsional mode 1 shape: {err_s}, translations {trans}") + else: + other.append((om, share)) + err_o = max(abs(om / om0 - 1.0) for (om, _), om0 in zip(other, omega0)) + mix = max(share for _, share in other) + print( + f" {len(other)} bending/axial modes against TorsStiffness Free: {err_o:.2e}, largest polar share {mix:.1e}" + ) + if n != 4: + failures.append(f"expected 4 torsional modes among the {N_MODES} lowest, found {n}") + if err_o > REL_EXACT or mix > REL_EXACT: + failures.append(f"bending/axial modes differ from the Free deck by {err_o} (polar share {mix})") + # the same line turned 30 degrees about +z: the same frequencies, positions in the deck's axes + deck = out / "straight_heading.dat" + deck.write_text(straight_deck("Rigid", 30.0), encoding="utf-8") + _, freq_h, _, shapes_h = read_modes(run(exe, deck, out / "straight_heading")) + err_h = max(abs(a[4] / b[4] - 1.0) for a, b in zip(freq_h, freq)) + c, s = math.cos(math.radians(30.0)), math.sin(math.radians(30.0)) + span = L0 * (1.0 + TENSION / EA) + rows = [r for r in shapes_h if int(r[1]) == 1] + err_x = max( + abs(r[3] - span * c * k / NE) + abs(r[4] - span * s * k / NE) for k, r in enumerate(rows) + ) + # the first mode is lateral: its translation is normal to the line's axis + along = max(abs(r[6] * c + r[7] * s) for r in rows) + print(f" heading 30 deg: frequencies {err_h:.2e}, node positions {err_x:.1e} m, mode 1 axial " + f"translation {along:.1e}") + if err_h > REL_EXACT or err_x > 1.0e-6 or along > 1.0e-6: + failures.append(f"heading 30 deg: frequencies {err_h}, positions {err_x}, axial {along}") + return failures + + +def check_lazy_wave(exe: str, source: Path, out: Path) -> list[str]: + failures: list[str] = [] + path = run(exe, source / "tests" / "data" / "torsion_lazy_wave_modes.dat", out / "torsion_lazy_wave_modes") + fh, freq, sh, shapes = read_modes(path) + omega = [row[4] for row in freq] + polar = [row[5] for row in freq] + print(f" twisted lazy wave: {len(omega)} modes, {omega[0]:.5f} to {omega[-1]:.5f} rad/s, polar share <= " + f"{max(polar):.1e}") + if fh[-1] != "PolarShare" or sh[-1] != "dTwist": + failures.append("twisted lazy wave: no twist columns") + if len(omega) != 12 or any(not math.isfinite(x) or x <= 0.0 for x in omega): + failures.append(f"twisted lazy wave: frequencies {omega}") + if any(b < a for a, b in zip(omega, omega[1:])): + failures.append("twisted lazy wave: frequencies not ascending") + if any(not 0.0 <= p <= 1.0 for p in polar): + failures.append(f"twisted lazy wave: polar shares {polar}") + if any(not math.isfinite(v) for r in shapes for v in r): + failures.append("twisted lazy wave: non-finite mode shape") + return failures + + +def main() -> int: + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--exe", required=True) + parser.add_argument("--source", required=True, type=Path) + parser.add_argument("--output", required=True, type=Path) + args = parser.parse_args() + args.output.mkdir(parents=True, exist_ok=True) + failures: list[str] = [] + try: + failures += check_straight(args.exe, args.output) + failures += check_lazy_wave(args.exe, args.source, args.output) + except AssertionError as exc: + failures.append(str(exc)) + for failure in failures: + print(f"FAIL: {failure}") + if failures: + return 1 + print("PASS: modal analysis of decks with torsion") + return 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index e82e29d8..c20f5ceb 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -945,7 +945,23 @@ SUBROUTINE check_errors() [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 cab 100.0 40'], & [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & [CHARACTER(24) :: '0.1 dtM', '0.0 TMax', '3 nModes'], OUTS) - CALL expect_error('modal analysis with torsion is refused', 'tdeck_e11.dat', 'tdeck_e11', 'modal analysis') + ! modal analysis of a line restrained in torsion carries the twist (test_modal_torsion) + BLOCK + LOGICAL :: ok_m + CHARACTER(512) :: em_m, header + INTEGER :: u_m, ios_m + CALL run_deck('tdeck_e11.dat', 'tdeck_e11', ok_m, em_m) + CALL require(ok_m, 'modal analysis with torsion runs (got: '//TRIM(em_m)//')') + header = '' + OPEN (NEWUNIT=u_m, FILE='tdeck_e11.modes.out', STATUS='OLD', ACTION='READ', IOSTAT=ios_m) + IF (ios_m == 0) THEN + READ (u_m, '(A)', IOSTAT=ios_m) header + READ (u_m, '(A)', IOSTAT=ios_m) header + READ (u_m, '(A)', IOSTAT=ios_m) header + CLOSE (u_m) + END IF + CALL require(INDEX(header, 'PolarShare') > 0, 'the modes of a line with torsion carry the twist columns') + END BLOCK ! coupled entries CALL write_deck('tdeck_e12.dat', [neutral_type], no_rows, & [CHARACTER(48) :: '1 Coupled 0.0 0.0 -50.0 0 0 0 0', '2 Fixed 100.0 0.0 -50.0 0 0 0 0'], & diff --git a/validation/scripts/openfast_lin_torsion.py b/validation/scripts/openfast_lin_torsion.py new file mode 100644 index 00000000..6efbe120 --- /dev/null +++ b/validation/scripts/openfast_lin_torsion.py @@ -0,0 +1,414 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +"""OpenFAST linearisation of finite-EI lines restrained in torsion (CompMooring = 5). + +Two decks, each linearised once at t = 0 in the case of openfast_lin_ab.py (the IEA-15MW +UMaine model, platform DOFs only, still water, OutFmt ES24.15E3, module-level output), with +the deck below as the only mooring: + + 1. A straight, neutrally buoyant 100 m line held taut at 0.5 % strain between a coupled + fairlead (0, 0, -20) and a fixed anchor below it, pinned in bending and rigid in torsion + at both ends, GJ = 5e4 N m^2, polar inertia Irn = 2 kg m, 50 elements, no drag or added + mass. Gated: + * the torsional modes from the eigenvalues of the module's A (the modes whose + eigenvectors lie on the twist states): the first three frequencies against the + continuum's n pi/L sqrt(GJ/Irn), within the lumped-inertia discretisation error + (n pi/N)^2/24, and against the lumped chain's 2 sqrt(GJ/Irn)/h sin(n pi/(2N)); + * the roll stiffness of the coupled point: -(D - C A^-1 B) of the fairlead moment about + the line axis per unit rotation about it against GJ/L; the feedthrough D alone is + printed (the end element's GJ/l_e: what a linearisation without twist states gives). + 2. The lazy-wave power cable of examples/iea15mw_umaine_mixed_cabledyn.dat (line 4, the + same mesh, seabed friction off) alone, with GJ = 5e4 N m^2 and the sections' polar + inertia, pinned in bending at both ends with the directors along its static end tangents, + rigid in torsion, and twisted by --pretwist (default 90 deg) at End B: a twisted, + non-planar lazy wave. Gated against the standalone driver's static solutions of the same + deck (TMax = 0), by central differences: + * rotation about the End A director d: Pretwist(A) = +-delta (--dtwist, default 0.5 deg) + rolls the fairlead frame about d as a platform rotation about d does, so + -d Torq1N1/d delta is d^T K_rot d (the moment on the fairlead about d is the torque); + * translation: the coupled point moved +-h (--cable-h, default 0.05 m) along each axis: + the 3x3 force stiffness and the torque row d^T K_M,x; + * the force column per rotation about d, K_F,rot d, against that torque row, its + reciprocal (the static stiffness is symmetric): the static force changes by about + 1e-3 N over the rotation step, below the 8 digits the driver writes, so its direct + difference is only printed; + entries >= 10 % of the largest of their block within --pct (default 1 %), every entry + >= 1 % of it within twice that. The operating-point moment about d must equal the + static Torq1N1. + +Measured (the 0.4.0 module): the three torsional modes are the lumped chain's to 5e-14 and the +continuum's within -1.6e-4, -6.6e-4, -1.5e-3; the straight line's roll stiffness is GJ/L to +1.5e-14 (feedthrough D alone 25 000 = GJ/l_e); the twisted lazy wave matches its static +solutions to 4.9e-4 (the moment about d per unit rotation 82.4268 / 82.4263 N m/rad, 5.9e-6). +An executable without twist states refuses both decks at initialisation ("formal OpenFAST +linearization of a line restrained in torsion is not supported"); with the twist angles held +the straight line's roll stiffness would be the end element's GJ/l_e, 50 times GJ/L. + +Usage: + python validation/scripts/openfast_lin_torsion.py --exe --case-dir + --driver [--ref-cd IEA-15-UMaine_CompMooring5_CableDyn.fst] + [--mixed-deck examples/iea15mw_umaine_mixed_cabledyn.dat] [--pretwist 90] + [--dtwist 0.5] [--cable-h 0.05] [--pct 1.0] [--skip-run] +""" + +from __future__ import annotations + +import argparse +import subprocess +import sys +from pathlib import Path + +import numpy as np + +sys.path.insert(0, str(Path(__file__).resolve().parent)) +import openfast_lin_ab as ab + +RHOW = 1025.0 +GJ = 5.0e4 +L_STRAIGHT = 100.0 +N_STRAIGHT = 50 +IRN_STRAIGHT = 2.0 + + +def straight_deck() -> str: + mass = RHOW * 0.25 * np.pi * 0.2**2 + return "\n".join([ + "--------------------- CableDyn Input File ------------------------------------", + "Straight vertical line restrained in torsion (openfast_lin_torsion.py)", + "--------------------- LINE TYPES ---------------------------------------------", + "Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat", + "(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)", + f"cab 0.2 {mass:.16e} 1.0e7 0.0 1.0e6 1.0e8 {GJ:.1e} 1.0 {IRN_STRAIGHT} 0.0 0.0 0.0 0.0", + "--------------------- POINTS ------------------------------------------------", + "ID Type X Y Z", + "(-) (-) (m) (m) (m)", + "1 Coupled 0.0 0.0 -20.0", + "2 Fixed 0.0 0.0 -120.5", + "--------------------- LINES -------------------------------------------------", + "ID NodeA NodeB Outputs", + "(-) (-) (-) (-)", + "1 1 2 -", + "--------------------- SECTIONS ----------------------------------------------", + "LineID LineType Length NumSegs", + "(-) (-) (m) (-)", + f"1 cab {L_STRAIGHT} {N_STRAIGHT}", + "--------------------- END CONNECTIONS ---------------------------------------", + "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist", + "(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)", + "1 A Pinned 0 0 -1 Rigid 1 0 0 0", + "1 B Pinned 0 0 -1 Rigid 1 0 0 0", + "--------------------- OPTIONS -----------------------------------------------", + "0.025 dtM - CableDyn time step (s)", + "--------------------- OUTPUTS -----------------------------------------------", + '"Torq1N1"', + "END", + "--------------------- need this line ----------------------------------------", + "", + ]) + + +def lazy_wave_parts(mixed: Path) -> dict: + """Line 4 of the mixed example: its line types, end points, sections and options.""" + if not mixed.is_file(): + ab.die(f"mixed deck not found: {mixed}") + lines = mixed.read_text().splitlines() + sec = None + types, points, sections, options = {}, {}, [], [] + for ln in lines: + if ln.lstrip().startswith("-"): + up = ln.upper() + sec = next((s for s in ("LINE TYPES", "POINTS", "LINES", "SECTIONS", "OPTIONS", "OUTPUTS") + if s in up), None) + continue + tok = ln.split() + if not tok or tok[0].startswith("("): + continue + if sec == "LINE TYPES" and len(tok) == 10 and tok[0] in ("bare", "buoy"): + types[tok[0]] = tok + elif sec == "POINTS" and tok[0] in ("7", "8"): + points[tok[0]] = [float(v) for v in tok[2:5]] + elif sec == "SECTIONS" and tok[0] == "4": + sections.append(tok) + elif sec == "OPTIONS" and len(tok) >= 2 and tok[1] in ("kBot", "cBot", "rhoInf", "dtM"): + options.append(ln) + if set(types) != {"bare", "buoy"} or set(points) != {"7", "8"} or not sections: + ab.die(f"{mixed.name}: line 4 (bare/buoy lazy wave between points 7 and 8) not found") + return {"types": types, "points": points, "sections": sections, "options": options} + + +def lazy_wave_deck(parts: dict, ez_a, ez_b, pretwist_a: float, pretwist_b: float, torsion: bool, + point_a=None) -> str: + """The lazy-wave cable alone (line 1 between points 1 and 2), restrained in torsion.""" + # GAs, Irt and the polar inertia Irn of each section take the circular-section closure values + # EA/(2 (1 + 0.3)), m d^2/16 and m d^2/8 + rows = [] + for name in ("bare", "buoy"): + t = parts["types"][name] + d, m, ea = float(t[1]), float(t[2]), float(t[3]) + rows.append(f"{name} {t[1]} {t[2]} {t[3]} {t[4]} {t[5]} {ea / 2.6:.6e} {GJ:.1e} {m * d * d / 16:.6e} " + f"{m * d * d / 8:.6e} {' '.join(t[6:10])}") + pa = parts["points"]["7"] if point_a is None else point_a + pb = parts["points"]["8"] + out = [ + "--------------------- CableDyn Input File ------------------------------------", + "Twisted lazy-wave power cable restrained in torsion (openfast_lin_torsion.py)", + "--------------------- LINE TYPES ---------------------------------------------", + "Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat", + "(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)", + *rows, + "--------------------- POINTS ------------------------------------------------", + "ID Type X Y Z", + "(-) (-) (m) (m) (m)", + f"1 Coupled {pa[0]:.10f} {pa[1]:.10f} {pa[2]:.10f}", + f"2 Fixed {pb[0]:.10f} {pb[1]:.10f} {pb[2]:.10f}", + "--------------------- LINES -------------------------------------------------", + "ID NodeA NodeB Outputs", + "(-) (-) (-) (-)", + "1 1 2 -", + "--------------------- SECTIONS ----------------------------------------------", + "LineID LineType Length NumSegs", + "(-) (-) (m) (-)", + *["1 " + " ".join(s[1:4]) for s in parts["sections"]], + ] + if torsion: + out += [ + "--------------------- END CONNECTIONS ---------------------------------------", + "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist", + "(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)", + f"1 A Pinned {ez_a[0]:.12f} {ez_a[1]:.12f} {ez_a[2]:.12f} Rigid 0 1 0 {pretwist_a:.12f}", + f"1 B Pinned {ez_b[0]:.12f} {ez_b[1]:.12f} {ez_b[2]:.12f} Rigid 0 1 0 {pretwist_b:.12f}", + ] + out += [ + "--------------------- OPTIONS -----------------------------------------------", + *parts["options"], + "200.0 WtrDpth - Water depth (m)", + "none frictionMu - Seabed friction coefficient", + "--------------------- OUTPUTS -----------------------------------------------", + '"Point1Fx"', '"Point1Fy"', '"Point1Fz"', '"L1N1px"', '"L1N1py"', '"L1N1pz"', '"L1N2px"', + '"L1N2py"', '"L1N2pz"', + ] + if torsion: + out.append('"Torq1N1"') + out += ["END", "--------------------- need this line ----------------------------------------", ""] + return "\n".join(out) + + +def driver_solve(driver: Path, text: str, work: Path) -> dict: + """The deck solved by the standalone driver at TMax = 0; its first output row by name.""" + work.mkdir(parents=True, exist_ok=True) + text = text.replace("--------------------- OUTPUTS", + "0.0 TMax - Standalone duration (s); 0 solves the static start\n" + "--------------------- OUTPUTS", 1) + (work / "trial.dat").write_text(text) + proc = subprocess.run([str(driver), "trial.dat", "trial"], cwd=work, capture_output=True, text=True, + timeout=3600, check=False) + if proc.returncode != 0: + tail = "\n".join((proc.stdout + proc.stderr).splitlines()[-15:]) + ab.die(f"driver failed:\n{tail}") + rows = [r for r in (work / "trial.out").read_text().splitlines() if r.strip() and not r.startswith("#")] + head = rows[0].split() + vals = [float(v) for v in rows[1].split()] + return dict(zip(head, vals)) + + +def lin_case(args: argparse.Namespace, case: Path, name: str, deck_text: str) -> dict: + """Linearise the deck alone in the openfast_lin_ab case (its prepared CableDyn .fst).""" + deck = case / f"CableDyn_{name}.dat" + deck.write_text(deck_text) + base = case / "Main_lin_cd5.fst" + if not base.is_file(): + ab.prepare_lin_deck(case / args.ref_cd, base, 0.0, "ES24.15E3", 400.0) + fst = case / f"Main_lin_{name}.fst" + text = base.read_text() + moor = ab.file_entry(text, "MooringFile", base.name) + fst.write_text(text.replace(f'"{moor}"', f'"{deck.name}"')) + if not args.skip_run: + print(f"running {fst.name} ...") + ab.run_case(args.exe, fst) + return ab.parse_module_lin(case / f"Main_lin_{name}.1.CD.lin") + + +def mesh_rows(mod: dict, kinds: list[str], labels: str) -> list[int]: + out = [] + for kind in kinds: + idx = ab.match_indices(mod[labels], [kind]) + if len(idx) != 3: + ab.die(f"expected 3 '{kind}' labels on the single coupled point, got {len(idx)}") + out += idx + return out + + +def reduced_6x6(mod: dict) -> tuple[np.ndarray, np.ndarray]: + """K = -(D - C A^-1 B) and the feedthrough -D over [force; moment] x [translation; rotation].""" + K = ab.static_impedance(mod) + rows = mesh_rows(mod, [" force", " moment"], "y_labels") + cols = mesh_rows(mod, ["translation displacement", "orientation angle"], "u_labels") + return -K[np.ix_(rows, cols)], -mod["D"][np.ix_(rows, cols)] + + +def gate_straight(args: argparse.Namespace, case: Path) -> list[str]: + mod = lin_case(args, case, "tors_straight", straight_deck()) + fails = [] + # torsional modes: eigenvectors on the twist states + labels = [ab_label(s) for s in state_labels(case / "Main_lin_tors_straight.1.CD.lin", mod["n_x"])] + tw = np.array(["twist" in s for s in labels]) + print(f"straight line: {mod['n_x']} states, {int(tw.sum())} twist") + ev, vec = np.linalg.eig(mod["A"]) + share = np.sum(np.abs(vec[tw, :])**2, axis=0) / np.sum(np.abs(vec)**2, axis=0) + pick = (ev.imag > 1e-9) & (share > 0.999) + w = np.sort(np.abs(ev[pick])) + h = L_STRAIGHT / N_STRAIGHT + c = np.sqrt(GJ / IRN_STRAIGHT) + worst_c = worst_d = 0.0 + leak = float(np.max(1.0 - share[pick])) if pick.any() else 1.0 + if len(w) < 3: + ab.die(f"found {len(w)} torsional modes, expected at least 3") + for n in (1, 2, 3): + wc = n * np.pi / L_STRAIGHT * c + wd = 2.0 / h * c * np.sin(n * np.pi / (2 * N_STRAIGHT)) + ec, ed = w[n - 1] / wc - 1.0, w[n - 1] / wd - 1.0 + bound = 1.2 * (n * np.pi / N_STRAIGHT) ** 2 / 24.0 + 1e-6 + print(f" torsional mode {n}: {w[n - 1] / (2 * np.pi):.8f} Hz; continuum {wc / (2 * np.pi):.8f} " + f"({ec:+.3e}, bound {bound:.2e}); lumped chain {wd / (2 * np.pi):.8f} ({ed:+.3e})") + worst_c = max(worst_c, abs(ec) / bound) + worst_d = max(worst_d, abs(ed)) + print(f" max non-twist share of a torsional eigenvector {leak:.2e}") + if worst_c > 1.0 or worst_d > 1e-6: + fails.append("the torsional modes of A differ from n pi/L sqrt(GJ/Irn)") + K, Dft = reduced_6x6(mod) + k_zz, d_zz = K[5, 5], Dft[5, 5] + print(f" roll stiffness about the line axis -(D - C A^-1 B) = {k_zz:.9e} N m/rad; GJ/L = " + f"{GJ / L_STRAIGHT:.9e} ({k_zz / (GJ / L_STRAIGHT) - 1.0:+.2e}); feedthrough -D = {d_zz:.6e} " + f"(GJ/l_e = {GJ / h:.6e})") + print(f" rotational block about x, y: {K[3, 3]:.3e}, {K[4, 4]:.3e} N m/rad") + if abs(k_zz / (GJ / L_STRAIGHT) - 1.0) > 1e-6: + fails.append("the straight line's roll stiffness differs from GJ/L") + return fails + + +def state_labels(path: Path, n_x: int) -> list[str]: + text = path.read_text().splitlines() + out: list[str] = [] + for i, ln in enumerate(text): + if "Order of continuous states" in ln: + j = i + 1 + while j < len(text) and len(out) < n_x: + row = text[j].strip() + j += 1 + if row and row.split()[0].isdigit(): + out.append(row) + break + if len(out) != n_x: + ab.die(f"{path.name}: expected {n_x} state labels, got {len(out)}") + return out + + +def ab_label(row: str) -> str: + return row.split(None, 4)[-1] + + +def gate_lazy_wave(args: argparse.Namespace, case: Path) -> list[str]: + parts = lazy_wave_parts(args.mixed_deck.resolve()) + work = case / "tors_lw_work" + # the static end tangents of the untwisted, unrestrained cable: the bending-pinned directors + p0 = driver_solve(args.driver, lazy_wave_deck(parts, None, None, 0.0, 0.0, False), work) + t_a = np.array([p0["L1N2px"] - p0["L1N1px"], p0["L1N2py"] - p0["L1N1py"], p0["L1N2pz"] - p0["L1N1pz"]]) + t_a /= np.linalg.norm(t_a) + ez_b = np.array([1.0, 0.0, 0.0]) + deck = lazy_wave_deck(parts, t_a, ez_b, 0.0, args.pretwist, True) + mod = lin_case(args, case, "tors_lazywave", deck) + K, _ = reduced_6x6(mod) + d = t_a + rows = mesh_rows(mod, [" moment"], "y_labels") + m_op = ab.op_values(mod["y_labels"], rows) + s0 = driver_solve(args.driver, deck, work) + print(f"twisted lazy wave (Pretwist B {args.pretwist} deg): {mod['n_x']} states; End A director " + f"{np.array2string(d, precision=5)}") + print(f" operating point: moment about d {m_op @ d:.9e} N m, static Torq1N1 {s0['Torq1N1']:.9e} N m") + fails = [] + if abs(m_op @ d - s0["Torq1N1"]) > 1e-6 * max(abs(s0["Torq1N1"]), 1.0): + fails.append("the operating-point moment about the End A director is not the static torque") + # the static reference: rotation about d (Pretwist A) and translations of the coupled point + dl = np.radians(args.dtwist) + ref_rot = np.zeros(4) # [F; M.d] per unit rotation about d + sp = driver_solve(args.driver, lazy_wave_deck(parts, t_a, ez_b, args.dtwist, args.pretwist, True), work) + sm = driver_solve(args.driver, lazy_wave_deck(parts, t_a, ez_b, -args.dtwist, args.pretwist, True), work) + for k, c in enumerate("xyz"): + ref_rot[k] = -(sp[f"Point1F{c}"] - sm[f"Point1F{c}"]) / (2 * dl) + ref_rot[3] = -(sp["Torq1N1"] - sm["Torq1N1"]) / (2 * dl) + ref_tr = np.zeros((4, 3)) # [F; M.d] per unit translation + pa = np.array(parts["points"]["7"]) + for j in range(3): + e = np.zeros(3) + e[j] = args.cable_h + sp = driver_solve(args.driver, lazy_wave_deck(parts, t_a, ez_b, 0.0, args.pretwist, True, pa + e), work) + sm = driver_solve(args.driver, lazy_wave_deck(parts, t_a, ez_b, 0.0, args.pretwist, True, pa - e), work) + for k, c in enumerate("xyz"): + ref_tr[k, j] = -(sp[f"Point1F{c}"] - sm[f"Point1F{c}"]) / (2 * args.cable_h) + ref_tr[3, j] = -(sp["Torq1N1"] - sm["Torq1N1"]) / (2 * args.cable_h) + lin_rot = np.concatenate([K[0:3, 3:6] @ d, [d @ K[3:6, 3:6] @ d]]) + lin_tr = np.vstack([K[0:3, 0:3], d @ K[3:6, 0:3]]) + tol = args.pct / 100.0 + + def compare(what: str, lin: np.ndarray, ref: np.ndarray, units: list[str]) -> tuple[float, float]: + big = np.abs(ref).max() + dom = allv = 0.0 + for i in range(lin.shape[0]): + cells = [] + for j in range(lin.shape[1]): + rel = (lin[i, j] - ref[i, j]) / ref[i, j] if abs(ref[i, j]) > 1e-2 * big else 0.0 + if abs(ref[i, j]) >= 0.1 * big: + dom = max(dom, abs(rel)) + if abs(ref[i, j]) >= 1e-2 * big: + allv = max(allv, abs(rel)) + cells.append(f"{lin[i, j]:12.6g} / {ref[i, j]:12.6g} / {rel:+.2e}") + print(f" {what} {units[i]}: " + " | ".join(cells)) + return dom, allv + + print(" K lin / K static / rel. diff; the moment about d per unit rotation about d (N m/rad):") + d1, a1 = compare("rot", lin_rot[3:4, None], ref_rot[3:4, None], ["M.d"]) + print(" the force per unit translation x | y | z (N/m):") + d2, a2 = compare("tr ", lin_tr[0:3], ref_tr[0:3], ["Fx", "Fy", "Fz"]) + print(" the moment about d per unit translation x | y | z (N m/m):") + d3, a3 = compare("tr ", lin_tr[3:4], ref_tr[3:4], ["M.d"]) + # The force per unit rotation changes the fairlead force (1e4 N, written with 8 digits) by + # about 1e-3 N over the rotation step, below the output resolution: it is gated against the + # static moment per unit translation, its reciprocal (the static stiffness is symmetric), and + # the direct static difference is only printed. + print(" the force per unit rotation about d (N/rad) against the static moment per unit translation:") + d4, a4 = compare("rot", lin_rot[0:3, None], ref_tr[3:4].T, ["Fx", "Fy", "Fz"]) + print(" (the static force per unit rotation, at the output resolution: " + + ", ".join(f"{v:.4g}" for v in ref_rot[0:3]) + " N/rad)") + dom, allv = max(d1, d2, d3, d4), max(a1, a2, a3, a4) + print(f" twisted lazy wave: dominant entries max rel. diff {dom:.2e} (gate {tol:.1e}); all entries " + f">= 1% of block max {allv:.2e} (gate {2 * tol:.1e})") + if dom > tol or allv > 2 * tol: + fails.append("the twisted lazy wave's linearised stiffness differs from its static solutions") + return fails + + +def main() -> None: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", type=Path, required=True) + ap.add_argument("--case-dir", type=Path, required=True) + ap.add_argument("--driver", type=Path, required=True) + ap.add_argument("--ref-cd", default="IEA-15-UMaine_CompMooring5_CableDyn.fst") + ap.add_argument("--mixed-deck", type=Path, + default=Path(__file__).resolve().parents[2] / "examples" / "iea15mw_umaine_mixed_cabledyn.dat") + ap.add_argument("--pretwist", type=float, default=90.0, help="End B pretwist of the lazy wave (deg)") + ap.add_argument("--dtwist", type=float, default=0.5, help="Pretwist(A) step of the static reference (deg)") + ap.add_argument("--cable-h", type=float, default=0.05, help="coupled-point step of the static reference (m)") + ap.add_argument("--pct", type=float, default=1.0, help="lazy-wave tolerance in %%") + ap.add_argument("--skip-run", action="store_true") + args = ap.parse_args() + if not args.driver.is_file(): + ab.die(f"driver not found: {args.driver}") + case = args.case_dir + fails = gate_straight(args, case) + gate_lazy_wave(args, case) + if fails: + ab.die("; ".join(fails)) + print("PASS") + + +if __name__ == "__main__": + main() From e992e9f59091ff25ff6f2416c4af36033b7c3618 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 10:39:57 +0900 Subject: [PATCH 25/51] feat(torsion): torsion on the mixed deck, at one restrained end and on a Fixed rod end, the routes combined (#74) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squash title: `feat(torsion): torsion on the mixed deck, at one restrained end and on a Fixed rod end, the routes combined` ## What changed Three more torsion route limits are lifted, then the torsion routes of 0.4.0 are combined. This PR sits on the linearisation / control / modal PR; each of the first three features was built and reviewed on its own branch from dev 66e3e83. ### Prescribed motion and torsion on the standalone mixed deck A standalone deck that mixes `EI = 0` and finite-EI lines between `Fixed`/`Coupled`/`Vessel` points runs on the coupled aggregate. It held its coupled ends and refused `motionFile`, `vesselMotion` and every line restrained in torsion. The driver now marches the deck's prescribed motion on the aggregate as the single-line cubic-Hermite route does (row 1 installed before `t = 0`, a `TMax = 0` run writes the static state); a vessel turns the end-connection and torsion frames of the cables on its points, and the `motionFile` roll column imposes the twist. `vesselRAO` stays refused with the deck waves; `CableDyn_InitDeck`/`InitDeckAt` keep their refusal. ### A line restrained in torsion at one end only A finite-EI line whose `END CONNECTIONS` restrain its twist at one end only (the other end `TorsStiffness Free`, or no row) was noted and solved as without the columns. Where its `LINE TYPES` rows give `GJ` it is now solved in torsion: the free end carries no torque and turns with the twist of the line, statically by `Twist = −Σ (K/GJ)(l − L)` under `GJ|K`, and in the dynamics with torsional waves that reflect at it. The `Torq`/`Twist` channels and range columns work on such a line. A line that misses a rule (no `GJ`, two moving ends, the configuration blend in a dynamic run, a restrained End A on a free, pinned or Coupled rod end or a non-Rigid6 body) keeps the 6-column meaning, with a note naming the rule. ### A torsional END CONNECTION on a Fixed rod end A line restrained in torsion may hang from an end of a `Fixed` rod (an I-tube or J-tube), whose frame holds the End A torsion frame, with `Nx` in the rod's deck axes; the ends of a rod fixed to a Rigid6 body roll with the body. `RodM` of a rod fixed to a body now includes the connection moment of a cable clamped at its end (it read 0). Free, pinned and Coupled/Vessel rods refuse the torsion by name, and so does `staggered bodyScheme` on a body or rod. A finite-EI line written anchor first onto a rod end is turned around like the other anchor-first lines; a line between two rods is refused as ending on a rod end. ### The routes combined Each branch was built alone, so the one-end feature still left a line unsolved in torsion under `ATTACHMENTS`, `CONTROL`, `nModes` and a rod End A. Those rules are lifted (natively and in the Python validator): - the torsion stage after the attachment polish (#71) handles a free end: it takes the stage's final mesh, which after the polish is `l0` (reading the pre-polish `l0_am`, which the polish has moved, crashed); - the modal twist Hessian skips a free end, which it took for an elastic end of compliance 0 (a non-finite stiffness); - a restrained End A may be on a `Fixed` rod end; - the staggered body scheme refuses a torsional End A only when End A is restrained. OpenFAST linearisation already took a line free at one end; its gate is added. `ATTACHMENTS` on a line restrained at both ends already ran on the mixed route and on a rod end (both build the cable through the same builder as the single-line route); their gates are added. ## Gates Mixed deck (`mixed_route_torsion`, `step_allocations_motion_*`): vessel roll 20°, pitch 4°, heave 1 m from rest on a sagging clamped line restrained in torsion, alone and beside a moving chain: torque, twist and node positions agree to the printed digits (≤ 0.50 of a unit), end tensions, inclination and End A bend moment within 6.6e-6 of their range; a 1 m surge with a 20° roll column: ≤ 0.57 printed units, loads within 8.2e-6 (the Newton tolerance: with the single-line controls every channel agrees to 0.36 printed units). A straight line rolled by 30° gives `Twist1 = Pretwist − roll` to 5e-7° and `Torq = GJ Φ/L` to 4.7e-6 N·m. No heap allocation per step. One restrained end (`torsion_one_end`, `step_allocations_torsion_one_end`): a straight line held rigidly at one end rings at the clamped–free frequencies `(2n − 1)π/(2L) √(GJ/Irn)` (3e-4, 3e-3); a roll of the restrained end gives the continuum's free-end turn `A/cos kL` and reaction `GJ A k tan kL` to 0.5 % below and above the first mode; deck statics with `GJ|K` give `Twist1 = −(K/GJ) dl` to 8.5e-9 and the tension `(EA − K²/GJ) ε` to 4.6e-9; the same on the coupled aggregate under a platform roll. Rod end (`rod_end_torsion`): two turns on an inclined Fixed J-tube give `GJ Φ/L` to 1.1e-9, the held Coupled point's torque to the printed digits, `Rod1M = M_t a` to 1.1e-8; on a rod fixed to a rolling Rigid6 body the torque follows `GJ (Φ − θ)/L` to 4.1e-11 and `Rod1M` carries it to 2.0e-7. Routes combined (VALIDATION T-17; each of the first five fails on the code before the last commit): | Gate | Oracle | Measured | |------|--------|----------| | `torsion_one_end` T1: vertical `GJ\|K` cable with two clumps and a buoy (net 14.6, −9.1, 5.8 kN), free at End A, then at End B | `Twist1 = −(K/GJ)(H − L0)`; tensions from the module weights; mid-line twist from the piecewise tension | 8.5e-9; 2.9e-9; 3.9e-4 (first order in the mesh: 1.9e-4, 9.6e-5 at 80, 160 elements); no torque | | T2: neutral modules on the rolled line (`kL = π/8`) | the continuum's free-end twist and end torques | 9e-4 | | `control_torsion` O: `CONTROL` deck on the aggregate, free at the fairlead, then at the anchor, paid out 0.2 m | `Twist1 = −(K/GJ)(H − L(t))`; no torque; mean held tension `(EA − K²/GJ) ε` | 3.7e-11; 8.2e-11 of `K ε`; 1.2e-4 | | `modal_torsion_deck` 3: the clamped line free at End B, then End A | clamped–free chain `2 √(GJ/Irn)/l0 sin((2n − 1)π/(4N))`; quarter-wave within `1 − sin x/x`; first shape `sin(π s/(2L))`; other modes = `TorsStiffness Free` | 8e-10; 6.4e-5 (first); 5e-10; exact | | `rod_end_torsion` 4: J-tube line with `GJ\|K`, free at End B, then at the rod end | `Twist1 = −(K/GJ) dl`; the held Coupled point's | 8.5e-9; identical | | `lin_torsion` O (shell recipe) and `openfast_lin_torsion.py` 3 (OpenFAST): the straight line free at End B, then at End A | clamped–free chain; quarter-wave within `x²/6`; roll stiffness 0 | 2e-14 (shell), 2.5e-13 (OpenFAST); 4.1e-5 (first); 0 (End B free: `C A⁻¹ B` cancels the feedthrough `GJ/l_e`) | | `rod_end_torsion` 4: two turns, two clumps and a buoy on the J-tube line | the held Coupled point's torque and twist | identical | | `mixed_route_torsion` 7: three buoyancy modules on the roll-column line | the single-line route | 1.15 printed units; loads 2.1e-5 of range | Ablations: lifting the rules without the mesh fix crashes T1 (SIGSEGV); without the Hessian fix the modal deck stops ("the stiffness or mass matrix is not finite"). ## Changed results - Lines restrained at one end with a `GJ` row now carry the twist in their dynamics: on a swaying lazy-wave cable with `GJ|K` the tensions move by up to 1.5e-4 (7e-8 in a planar heave). A line restrained at End A on a Rigid6 body joins the static body balance; bending-pinned there its body's static moment now balances (on a buoy `Body1My` −103.9 N·m to 1e-6, `FairTen1` 126885 to 126857 N, `Body1Ry` 0.3004 to 0.2984°; the march then differs by up to 2.6 % at `dtM` 0.05 s); clamped there, by about 1e-7. OpenFAST checkpoints of such decks written before do not reload. - `RodM` of a rod fixed to a body includes the connection moment of a cable clamped at its end. ## Combining the branches The six commits are cherry-picked in order (mixed route, one end, rod end; each with its review fix), then one integration commit. Conflicts: - documentation, VALIDATION and the CHANGELOG: every entry kept; the scope paragraphs of `doc/driver_format.md`, `doc/capabilities.rst`, `doc/openfast.rst` and `doc/troubleshooting.rst` rewritten to the combined state (the C API rotating entry of #70, linearisation, control, modal, mixed deck, one end, rod end); the stale "torsion has no inertia" and "no torque–tension coupling" sentences are gone; the mixed deck's VALIDATION entry is T-16; - the torsion message `TORSION_NEEDS_ORIENTATION` and its Python mirror: the C API's `InitDeck`/`InitDeckAt` only (the mixed deck now turns the frames); - the deck driver's torsion stage: #71 split the notes into `torsion_note`, which now returns for a line free at one end (its note is the one-end state's, and no twist stage set the tolerance it reports); the shared roll-column check of the mixed route (`check_motion_roll_lines`) and its roll-column map take the one-end rule (`line_torsion_at_a`: a free End A takes no roll); - `normalize_stock_endpoint_order` takes the line types (rod end) and is followed by `resolve_one_end_torsion` (one end); `test_step_allocations` dispatches `free`, `motion_roll` and `motion_vessel`; - the Python validator's torsion check: the mixed-deck refusal removed, the one-end rules and the rod rules kept, the both-end ATTACHMENTS refusal of the rod branch's base dropped (#71 lifted it). On #72 (rebase): the mixed route's `CD_Init_Deck_Aggregate` counts the host bodies with #72's `CoupledPinned` ones, the aggregate takes both #72's start accelerations and the deck's prescribed motion, the mixed deck still refuses MoorDyn-C `Currents 1`/`2`/`5`, and `test_step_allocations` dispatches `current_grid` beside the torsion and motion gates. Every current sample in the torsion code goes through `deck_current_velocity(opts, position, time, ...)`. `python/tests/test_native_model.py` is dev's (the identity-based handle-release test of #72); the `gc.collect()` variants of the mixed-route and rod-end fixes are dropped, so those two commit messages still name a change they no longer make. ## Checks - Full ctest suite (339) passes; `pytest python/tests tests` (2126 passed, 121 skipped; the native parity tests with `CABLEDYN_TEST_DRIVER`: 221 passed); ruff check/format clean; pre-commit clean; the docs build with `-W` clean. - All 53 example decks are bit-identical to the reference driver (dev 0f53412). Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 63 ++ CMakeLists.txt | 32 +- VALIDATION.md | 74 +- app/cabledyn.f90 | 94 +- doc/capabilities.rst | 34 +- doc/conventions.rst | 7 +- doc/driver_format.md | 129 ++- doc/file_formats.rst | 19 +- doc/index.rst | 3 +- doc/openfast.rst | 19 +- doc/options.rst | 8 +- doc/outputs.rst | 24 +- doc/standalone_driver.rst | 23 +- doc/theory.rst | 36 +- doc/troubleshooting.rst | 63 +- python/cabledyn/deck_file.py | 214 +++-- python/cabledyn/ranges.py | 5 +- python/tests/test_deck_native_parity.py | 280 +++++- src/CableDyn_DeckDriver.f90 | 778 +++++++++++++-- src/CableDyn_HermiteCableDynamic.f90 | 73 +- src/CableDyn_HermiteCableStatic.f90 | 5 + src/CableDyn_HermiteTorsion.f90 | 32 +- src/CableDyn_OpenFAST_Aggregate.f90 | 225 ++++- tests/test_control_torsion.f90 | 129 +++ tests/test_lin_torsion.f90 | 77 +- tests/test_mixed_route_torsion.f90 | 810 ++++++++++++++++ tests/test_modal_torsion_deck.py | 72 +- tests/test_rod_end_torsion.f90 | 586 ++++++++++++ tests/test_step_allocations.f90 | 157 ++- tests/test_torsion_deck.f90 | 28 +- tests/test_torsion_one_end.f90 | 1001 ++++++++++++++++++++ validation/scripts/openfast_lin_torsion.py | 56 +- 32 files changed, 4756 insertions(+), 400 deletions(-) create mode 100644 tests/test_mixed_route_torsion.f90 create mode 100644 tests/test_rod_end_torsion.f90 create mode 100644 tests/test_torsion_one_end.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9001b2f6..7200f2d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -64,6 +64,21 @@ All notable changes to CableDyn are recorded in this file. The format follows fairlead to 4.9e-4. In a `Linearize = True` run every input Jacobian, those of the time march included, steps the coupled-point rotation by 1e-4 rad instead of 0.1 rad, which changes the rotation columns of a deck with a hang-off spring by up to 0.17 %. +- Prescribed motion and torsion on the standalone mixed deck (`EI = 0` and finite-EI lines between + `Fixed`/`Coupled`/`Vessel` points, run on the coupled aggregate): the driver marches a + `motionFile` or `vesselMotion` as on the cubic-Hermite route, row 1 installed before `t = 0` + (also with `TMax = 0`). A vessel turns the end connection and torsion frames of the cables on + its points, and the roll column imposes the twist of a line restrained in torsion, which these + decks no longer refuse. + Under vessel roll, pitch and heave, or a surge with the roll column, a clamped line gives the + single-line route's torque, twist and node positions to the printed eight digits and its end + tensions and bend moment within 8.2e-6 of their range (the coupled cables' Newton tolerance; with + the single-line route's, every channel to the printed digits). These figures are for motions + that start from rest; a start with a jump in velocity differs by several percent of the range + (3 to 11 % in the cases tried) under the coupled Newton tolerance. A straight line rolled + slowly gives `Torq = GJ Phi / L` to 5e-6 N m. A static mixed run (`TMax = 0`) with torsion + takes `False alpha_force_blend`, as the single-line route and the Python reader do. + `vesselRAO` stays refused with the deck waves. - OpenFAST linearisation with the line dynamics, as MoorDyn-F's: the continuous states are the interior-node positions of every `EI = 0` line (MoorDyn's names and order) and the free degrees of freedom of every finite-EI cable (node positions and tangents), then their @@ -112,6 +127,49 @@ All notable changes to CableDyn are recorded in this file. The format follows modes match the clamped Greenhill cable to 3e-7; eliminating the angles reproduces the condensed static tangent to 1e-16. `.modes.out` adds `PolarShare` and `dTwist` when a line carries twist. +- Torsion of a finite-EI line restrained at one end only, the other free to twist (`TorsStiffness` + `Free` there, or no row): solved where a line restrained at both ends is and its LINE TYPES + rows give `GJ`, instead of being ignored. The free end carries no torque and turns with the + twist of the line: statically `Twist = −Σ (K/GJ)(l − L)` under `GJ|K` (End B relative to + End A; to 1e-8 on a stretched straight cable, the moving end free or the anchored one), and in + the dynamics with torsional waves that reflect at it. A straight line held rigidly at the other end rings at the + clamped–free frequencies `(2n − 1) π/(2L) √(GJ/Irn)` (3e-4 and 3e-3 for n = 1, 2), and a roll + of the restrained end gives the continuum's free-end turn `A/cos kL` and reaction + `GJ A k tan kL` to 0.5 % below and above the first mode, in the standalone driver and on the + coupled aggregate. The `Torq`/`Twist` channels and range columns work on such a line, and + its `CurvX`/`CurvY` axes follow its twist. Results change on such decks: the dynamics carry + the twist (on a swaying lazy-wave cable with `GJ|K` the tensions move by up to 1.5e-4, 7e-8 + in a planar heave), and a line restrained at End A on a Rigid6 body joins the static body + balance of the clamped ends: bending-Pinned there, its body's static moment now balances + (Body1My −103.9 N m to 1e-6 on a buoy, FairTen1 126885 to 126857 N, 2.2e-4, Body1Ry + 0.3004 to 0.2984 deg; the march then differs by up to 2.6 % at dtM 0.05 s, 0.5 % at + 0.0125 s); clamped there, by about 1e-7. OpenFAST checkpoints of such decks written before + this change do not reload: the cable's state mirror now carries the nodal twist, and the + rebuild stops at a mirror-extent check (`... mirror extends past the state vector`). A line + restrained at one end that misses a rule (no `GJ`, two moving ends, the configuration blend, + a restrained End A on a free, pinned or Coupled rod end or a non-Rigid6 body) is solved + without torsion as before, with a note naming the rule; a solved one's restrained `Pretwist` + is held within 1000 turns. +- Torsion at a rod end: a line restrained in torsion may hang from an end of a `Fixed` rod (an + I-tube or J-tube), whose frame holds the End A torsion frame, with `Nx` in the rod's deck + axes. Two turns on an inclined J-tube give `GJ Phi / L` to 1.2e-9, the same torque as from a + held Coupled point, and `RodM` the torque along the line axis; the line written anchor + first (MoorDyn's order) runs bit for bit as written rod first. On a rod fixed to a rolling Rigid6 + body the torque follows `GJ (Phi - theta)/L` to 4e-11, and `RodM` of a rod fixed to a body + now includes the connection moment of a cable clamped at its end (it read 0). Free, pinned + and Coupled rods refuse the torsion by name, and so does `staggered bodyScheme` on a body or + rod (it drove the cable end by translation, so the torsion frame did not turn); a line between + two rods is refused as ending on a rod end, not as having two moving ends. +- The torsion routes combined: a line restrained in torsion at one end only takes `ATTACHMENTS`, + `CONTROL`, `nModes` and a `Fixed` rod end, which left it unsolved in torsion. With modules of + net weights 14.6, −9.1 and 5.8 kN on a vertical cable its free end turns by `−(K/GJ)(H − L)` + to 8.5e-9 and its mid-line node with the module tensions to 3.9e-4 (a first-order mesh + error); a paid-out fairlead turns it by `−(K/GJ)(H − L(t))` to 4e-11 with no torque; its modes + and the eigenvalues of the OpenFAST `A` are the clamped–free chain's to 8e-10 and 2e-14 and + the quarter-wave `(2n − 1)π/(2L) √(GJ/Irn)` within the lumped-inertia error, with no roll + stiffness. The modal twist Hessian no longer takes a free end for an elastic one of infinite + stiffness. `ATTACHMENTS` on a line restrained at both ends run on the mixed `EI = 0` + + finite-EI route and on a `Fixed` rod end as on the single-line route (to the printed digits). - Torque–tension coupling of finite-EI cables: the 14-column LINE TYPES row's `GJ` column takes `GJ|K`, with `K` the coupling of an armoured cable or wire rope (`T = EA ε + K τ`, `M = GJ τ + K ε`). The cable carries the axial stiffness `EA − K²/GJ` of a section free to twist. @@ -184,6 +242,11 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Changed +- With a `motionFile` or `vesselMotion`, the single-line finite-EI route writes `.static.out` + before it installs the first motion row, so the file holds the static solve; before, it showed + the fairlead already moved to row 1. A deck whose row 1 is off the deck fairlead changes + `.static.out` only (a 2 cm offset changed the fairlead x by 0.02 m and its tension from 3.5 MN + back to the static 29 kN); the example decks are unchanged. - `TMax = 0` checks the static start of any dynamic deck as it stands: a `motionFile` or `vesselMotion` record may run past `TMax` (its later rows are checked on the `dtM` grid and not used, so a long record also serves a shorter run), and `RangeStart` is accepted at diff --git a/CMakeLists.txt b/CMakeLists.txt index da62485d..e10ad393 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1443,6 +1443,14 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN # And the MoorDyn-C current grid (Currents 2 and 5) every standalone step samples at the nodes. add_test(NAME step_allocations_current_grid COMMAND test_step_allocations current_grid) set_tests_properties(step_allocations_current_grid PROPERTIES LABELS "fortran;dynamic;memory") + # The standalone driver's march of a mixed deck with its prescribed motion (roll column, vessel). + add_test(NAME step_allocations_motion_roll COMMAND test_step_allocations motion_roll) + set_tests_properties(step_allocations_motion_roll PROPERTIES LABELS "fortran;dynamic;memory") + add_test(NAME step_allocations_motion_vessel COMMAND test_step_allocations motion_vessel) + set_tests_properties(step_allocations_motion_vessel PROPERTIES LABELS "fortran;dynamic;memory") + # And with the nodal twist of a line free in torsion at one end. + add_test(NAME step_allocations_torsion_one_end COMMAND test_step_allocations free) + set_tests_properties(step_allocations_torsion_one_end PROPERTIES LABELS "fortran;dynamic;memory") endif() add_executable(test_snap_load tests/test_snap_load.f90) @@ -2157,6 +2165,10 @@ add_test(NAME torsion_attachments COMMAND test_torsion_attachments ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/lazy_wave_torsion_attachments.dat WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(torsion_attachments PROPERTIES LABELS "fortran;driver;integration;static;dynamic") +add_executable(test_rod_end_torsion tests/test_rod_end_torsion.f90) +target_link_libraries(test_rod_end_torsion PRIVATE cabledyn_core) +add_test(NAME rod_end_torsion COMMAND test_rod_end_torsion) +set_tests_properties(rod_end_torsion PROPERTIES LABELS "fortran;driver;integration;static;dynamic") # Where the MoorDyn-parity features meet: a CoupledPinned body in a Currents 2/5 deck (refused on # the coupled aggregate for the current files, standalone for the body), CONTROL on viscoelastic @@ -2199,6 +2211,14 @@ target_link_libraries(test_torsion_coupling PRIVATE cabledyn_core) add_test(NAME torsion_coupling COMMAND test_torsion_coupling) set_tests_properties(torsion_coupling PROPERTIES LABELS "fortran;unit;driver;integration;static") +# Torsion and prescribed motion on the standalone mixed EI = 0 + finite-EI route (the driver +# executable marches the aggregate): route equivalence with the cubic-Hermite route under vessel +# and roll-column motion, quasi-static torque, roll-column refusal. +add_executable(test_mixed_route_torsion tests/test_mixed_route_torsion.f90) +target_link_libraries(test_mixed_route_torsion PRIVATE cabledyn_core) +add_test(NAME mixed_route_torsion COMMAND test_mixed_route_torsion $) +set_tests_properties(mixed_route_torsion PROPERTIES LABELS "fortran;driver;integration;dynamic") + add_executable(test_coupled_torsion tests/test_coupled_torsion.f90) target_link_libraries(test_coupled_torsion PRIVATE cabledyn_core) add_test(NAME coupled_torsion COMMAND test_coupled_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) @@ -2211,6 +2231,13 @@ add_executable(test_lin_torsion tests/test_lin_torsion.f90) target_link_libraries(test_lin_torsion PRIVATE cabledyn_core) add_test(NAME lin_torsion COMMAND test_lin_torsion WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(lin_torsion PROPERTIES LABELS "fortran;unit;dynamic;openfast") +# A line restrained in torsion at one end only: the clamped-free torsional modes and waves of the +# nodal twist, the free end's coupling twist, the deck channels, the standalone driver and the +# coupled aggregate. +add_executable(test_torsion_one_end tests/test_torsion_one_end.f90) +target_link_libraries(test_torsion_one_end PRIVATE cabledyn_core) +add_test(NAME torsion_one_end COMMAND test_torsion_one_end WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(torsion_one_end PROPERTIES LABELS "fortran;unit;driver;integration;static;dynamic;openfast") add_executable(test_torsion_orcaflex tests/test_torsion_orcaflex.f90) target_link_libraries(test_torsion_orcaflex PRIVATE cabledyn_core) @@ -2880,7 +2907,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_hermite_cable_control test_control_torsion test_endconn_spring - test_torsion_coupling) + test_torsion_coupling + test_torsion_one_end) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) endforeach() target_compile_options(test_openfast_aggregate PRIVATE @@ -2888,6 +2916,7 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_torsion_deck PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) + target_compile_options(test_torsion_one_end PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_hermite_cable_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_syrope_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) target_compile_options(test_viscoelastic_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) @@ -2933,6 +2962,7 @@ if(CABLEDYN_ENABLE_COVERAGE) test_hermite_torsion_kernel test_hermite_twist_kernel test_nodal_twist_dynamic + test_torsion_one_end test_hermite_torsion_static test_hermite_torsion_dynamic test_hermite_cable_static diff --git a/VALIDATION.md b/VALIDATION.md index 1ce8ef0c..c6c0594e 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -106,6 +106,8 @@ article's methods, are compared in | **T-13** | Nodal twist (torsional inertia and damping) | condensed torsion in the limit of no inertia; continuum torsional wave; `ζ = ω Bt/(2 GJ)`; energy; restart | ≤6e-7 against the condensed torsion; wave torque 0.07 %; decrement 6 %; energy band 4.9e-4; restart bit-identical | see [Torsion](#torsion) | Pass | | **T-12** | Torque–tension coupling | `T = EA ε + K τ`, `M = GJ τ + K ε` closed forms; kernel FD; march | ≤1e-7 against every closed form; kernel gradient 1.7e-10, Hessian 9.8e-11 | see [Torsion](#torsion) | Pass | | **T-11** | Torsion on the coupled OpenFAST / FAST.Farm route | `GJ (−roll)/L`; single coupled cable; uninterrupted run | twist ≤1.8e-15°, torque ≤1.7e-13 N·m; aggregate = single cable bit for bit; restart bit-identical (aggregate and `openfast -restart`) | see [Torsion](#torsion) | Pass | +| **T-17** | One restrained end with ATTACHMENTS, CONTROL, modes, linearisation and rod ends; ATTACHMENTS on the mixed and rod routes | `-(K/GJ)(H - L)`; module tensions; clamped–free chain and quarter-wave; continuum roll response; zero roll stiffness; a second route | twist ≤8.5e-9, mid-line 3.9e-4 (first-order mesh error); modes chain ≤8e-10, quarter-wave within `1 − sin x/x`; roll stiffness 0; routes to the printed digits | 1e-6; 1e-3; 2e-8 | Pass | +| **T-16** | Torsion and prescribed motion on the standalone mixed deck | the single-line cubic-Hermite route; `GJ Φ/L` | torque, twist, node positions to the printed digits; end loads ≤8.2e-6 of range (all channels to the printed digits with the same Newton controls); torque ≤4.7e-6 N·m | printed digits; 5e-5; 1e-6 GJ | Pass | **Pass** meets the stated acceptance value. **Pass measured** records a measured comparison without an acceptance value. **Informative** is reported but not used for @@ -1101,14 +1103,72 @@ in parentheses). straight line's torsional modes and its bending and axial modes against `TorsStiffness Free` hold to the table's nine digits, turned 30° about +z it keeps its frequencies and writes its positions in the deck's axes, and the lazy wave twisted two turns writes its modes. +- **T-16 standalone mixed deck** (`mixed_route_torsion`, `step_allocations_motion_*`). A deck + that mixes `EI = 0` and finite-EI lines between `Fixed`/`Coupled`/`Vessel` points runs on the + coupled aggregate, which the driver marches through the deck's `motionFile` or + `vesselMotion`. A sagging 100 m finite-EI line clamped and restrained in torsion at both ends + (Pretwist 20° at End B), driven from rest by a vessel rolling 20°, pitching 4° and heaving + 1 m, or by a 1 m surge with a 20° roll column, gives the same channels alone (the single-line + cubic-Hermite route) and beside a moving chain (the mixed route): torque, twist and the + mid-line node to the printed digits (at most 0.57 of a unit in the eighth digit), the fairlead + and anchor tensions, fairlead inclination and End A bend moment within 8.2e-6 of their range, + the out-of-plane node offset within 2.2e-8 m. The difference is the Newton tolerance: the + coupled cables step with the coupled controls (relative tolerance 5e-3, a fresh factor every + step), the single line with the deck's (1e-8, a carried factor); given the single-line + controls, the mixed route reproduces every channel of the single-line route to 0.36 of a + printed unit. The vessel turns the clamp and the torsion frame on both routes: a `motionFile` + of the same point translations, which holds them, changes the End A bend moment by 11 % of + its range and the twist by 19°. A straight neutral line beside a chain, its End A held or + rolled by up to 30° by a vessel or by the roll column, gives `Twist1 = Pretwist − roll` to + 5e-7° and `Torq = GJ Φ/L` at both ends to 4.7e-6 N·m. A non-zero roll column at the chain's + point stops by name, and the march makes no heap allocation after warm-up. The agreement + figures are for motions from rest; a start with a jump in velocity differs by several percent + of the range under the coupled Newton tolerance. With `TMax = 0` and row 1 2 cm off the deck + fairlead both routes write the same `t = 0` row at the installed row and a `.static.out` of + the static solve; a static mixed run with torsion takes `False alpha_force_blend`, and a + dynamic one stops by name. +- **T-17 the routes combined** (`torsion_one_end`, `control_torsion`, `modal_torsion_deck`, + `lin_torsion`, `rod_end_torsion`, `mixed_route_torsion`). A line restrained in torsion at one + end only, its other end free to twist (GJ|K 5e4 N·m²|4e5 N·m unless named otherwise): + - `ATTACHMENTS`: hung vertically, 99 m between points 100 m apart, with two clumps and a buoy + of net weights 14.6, −9.1 and 5.8 kN, free at End A and at End B in turn: `Twist1` is + `−(K/GJ)(H − L0)` to 8.5e-9 whatever the weights, the end tensions carry them to 2.9e-9, no + torque, and the mid-line twist follows the module tensions to 3.9e-4 (the shared nodal + tangent spreads each tension step over two elements: 1.9e-4 at 80 elements, 9.6e-5 at + 160); with neutral modules a roll of the restrained end at `kL = π/8` gives the continuum's + free-end twist and end torques to 9e-4; + - `CONTROL` on the coupled aggregate: the free end, the controlled fairlead or the anchor, + turns with the commanded length, `Twist1 = −(K/GJ)(H − L(t))`, to 3.7e-11 through a 0.2 m + pay-out, with no torque (8.2e-11 of `K ε`) and the mean held tension `(EA − K²/GJ) ε` to 1.2e-4; + - `nModes` (straight clamped line of T-15): the torsional modes are the clamped–free chain's + `2 √(GJ/Irn)/l0 sin((2n − 1)π/(4N))` to 8e-10 and the quarter-wave `(2n − 1)π/(2L) √(GJ/Irn)` + within the chain's `1 − sin x/x` (6.4e-5 on the first), the first mode shape + `sin(π s/(2L))` to 5e-10, the other modes those of `TorsStiffness Free`; + - OpenFAST linearisation (the shell's recipe): the free end's angle is a state, the twist + modes of `A` are the clamped–free chain's to 2e-14 and the quarter-wave's within the + lumped-inertia error (4.1e-5 on the first), and the reduced roll stiffness is 0 (End B free: + `C A⁻¹ B` cancels the feedthrough `GJ/l_e`; End A free: no column); + - on a `Fixed` rod end (the J-tube of the rod-end gate), free at End B or at the rod end: + `Twist1 = −(K/GJ) dl` to 8.5e-9 and the held Coupled point's to the printed digits. + + Before these routes were combined, `ATTACHMENTS`, `CONTROL`, `nModes` and a restrained End A + on a rod end left such a line unsolved in torsion (a note; its twist channels stopped by + name), while the linearisation already took it; lifting the rules alone would not do: the + torsion stage after the attachment polish read the pre-polish mesh (a crash), and the modal + twist Hessian took the free end for an elastic one of infinite stiffness (a non-finite + matrix). `ATTACHMENTS` on a line restrained at both ends + run on the mixed route (three buoyancy modules on the gate-2 line of T-16: the single-line + route's torque and twist to 1.15 printed units, end loads to 2.1e-5 of their range) and on a + `Fixed` rod end (two clumps and a buoy: the held Coupled point's torque and twist to the + printed digits). - **Backward compatibility and refusals** (`torsion_deck`, full suite). Without torsion columns, - with `Free` columns (whatever their normal), or with one restrained end, every output is - byte-identical to the 6-column deck, and `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` - give the same run. Malformed rows, a missing `GJ`, an `EI = 0` line, a rod end, a `Point3` body, - `ATTACHMENTS`, the configuration blend (also on the coupled entries), misuse of - the roll column, channels on an unrestrained line, a coupled caller that passes no orientation - (the C API) and a standalone mixed `EI = 0` + finite-EI deck without a body stop with named - errors. + with `Free` columns (whatever their normal), or with one restrained end on a line whose + `LINE TYPES` rows give no `GJ`, every output is byte-identical to the 6-column deck, and + `Rigid`, `Infinity`, `Inf` and a quoted `"Rigid"` give the same run. Malformed rows, a missing + `GJ`, an `EI = 0` line, the end of a free, pinned or `Coupled` rod, a `Point3` body, + the configuration blend (also on the coupled entries), misuse of the roll column, channels on + an unrestrained line and a coupled caller that passes no orientation (the C API's + `CableDyn_InitDeck`/`InitDeckAt`) stop with named errors. Limits. The torsion model takes no seabed friction against twist and does not resolve self-contact; its statics are condensed (uniform torque). The nodal twist's inertia and damping diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index abb2ad00..9676692b 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -31,7 +31,9 @@ PROGRAM cabledyn CD_AGG_NumChannels, CD_AGG_ChannelHeader, & CD_AGG_EvalChannel, CD_AGG_WriteStaticProfile, & CD_AGG_GetInitMetadata, CD_AGG_GetInitLine, & - CD_AGG_Range_Sample, CD_AGG_Range_Write, CD_AGG_OK, CD_AGG_BADINPUT + CD_AGG_Range_Sample, CD_AGG_Range_Write, CD_AGG_OK, CD_AGG_BADINPUT, & + CD_AGG_UpdateStates_Moving, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations USE CableDyn_Banner, ONLY: CD_Print_Banner USE CableDyn_Linalg, ONLY: CD_Blas_Runtime_Check, CD_LINALG_OK USE CableDyn_FatalReport, ONLY: CD_Fatal_Report_Install, CD_Fatal_Report_Time @@ -452,9 +454,13 @@ END FUNCTION normalized_path SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, has_motion, line_outputs, & run_converged, run_stat, run_msg) !! Standalone owner for a mixed {EI=0 + finite-EI} deck. It deliberately reuses - !! the production OpenFAST aggregate and holds the initialized coupled endpoints. - !! Prescribed reference-body motion and deck-owned ambient fields require separate - !! transformations/updaters and therefore remain explicit fail-closed boundaries. + !! the production OpenFAST aggregate and holds the initialized coupled endpoints, or, + !! with a motionFile or vesselMotion OPTION, marches them through the deck's prescribed + !! motion as the standalone cubic-Hermite route does: the point rows' translations, the + !! vessel's rotation (the orientation and angular rates the fairlead end connection and + !! torsion frames turn with) and the motionFile roll column (the imposed twist of a line + !! restrained in torsion). Deck-owned ambient fields require separate updaters and + !! therefore remain an explicit fail-closed boundary. CHARACTER(*), INTENT(IN) :: deck, root REAL(wp), INTENT(IN) :: dt, run_time LOGICAL, INTENT(IN) :: has_dt, has_run_time, has_motion, line_outputs @@ -464,10 +470,12 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h TYPE(CD_AGG_ModuleType), ALLOCATABLE :: aggregate ! about 37 KB: on the heap, not the stack REAL(wp), ALLOCATABLE :: position(:, :), velocity(:, :), acceleration(:, :), load(:, :) + ! the prescribed motion's frame rotation and roll over the moving surface + REAL(wp), ALLOCATABLE :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) REAL(wp) :: time, first_miss_time, last_miss_time, step_dt INTEGER :: es, n_moving, nstep, step, n_iter, miss_count, consecutive_miss, max_consecutive_miss INTEGER :: unit, ios - LOGICAL :: step_converged, stalled, file_open + LOGICAL :: step_converged, stalled, file_open, turns, rolls CHARACTER(4096) :: em CHARACTER(4096) :: static_path, dynamic_path TYPE(StandaloneProgress) :: progress @@ -477,11 +485,8 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h run_msg = '' file_open = .FALSE. unit = 0 - IF (has_motion) THEN - run_msg = 'CableDyn_driver: mixed-deck motionFile is not supported; platform-reference motion '// & - 'must be rigidly transformed to every coupled hang-off before marching' - RETURN - END IF + turns = .FALSE. + rolls = .FALSE. IF (line_outputs) THEN run_msg = 'CableDyn_driver: mixed-deck LINE Outputs p/t/V are not supported; '// & 'use main OUTPUTS channels or remove the per-line flags' @@ -523,9 +528,12 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h EXIT mixed_run END IF ! The aggregate is caller-driven and cannot refresh standalone wave/current - ! OPTIONS. Reject such decks by name instead of silently holding zero fluid. + ! OPTIONS. Reject such decks by name instead of silently holding zero fluid. The driver + ! holds the line end frames or turns them with the deck's vesselMotion table + ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). CALL CD_AGG_Init_From_Deck(aggregate, deck, step_dt, es, em, forbid_deck_ambient=.TRUE., & - run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE.) + run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE., host_orientation=.TRUE., & + prescribed_motion=has_motion, static_run=nstep == 0) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run @@ -539,7 +547,8 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h EXIT mixed_run END IF ALLOCATE (position(3, n_moving), velocity(3, n_moving), acceleration(3, n_moving), & - load(3, n_moving), STAT=ios) + load(3, n_moving), orientation(3, 3, n_moving), angular_velocity(3, n_moving), & + angular_acceleration(3, n_moving), roll(n_moving), STAT=ios) IF (ios /= 0) THEN run_stat = CD_DECKDRV_SOLVEFAIL run_msg = 'CableDyn_driver: cannot allocate the mixed aggregate boundary workspace' @@ -550,18 +559,43 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run END IF - ! A standalone deck with no motionFile means held coupling boundaries. Initial - ! solver accelerations are not prescribed boundary accelerations and must not be - ! fed back into the first step. - velocity = CD_ZERO - acceleration = CD_ZERO - + ! The static configuration, before a prescribed motion moves the ends. static_path = TRIM(root)//'.static.out' CALL CD_AGG_WriteStaticProfile(aggregate, TRIM(static_path), es, em) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run END IF + IF (has_motion) THEN + ! Install row 1 of the prescribed motion without advancing (it may differ from the deck + ! pose), then recompute the cables' free-node accelerations from their complete + ! residual at that state, as the standalone cubic-Hermite route does before its march + ! (also for TMax = 0, whose single row is then the t = 0 state of the motion). On the + ! EI = 0 lines the transfer re-derives the interior accelerations at that state + ! (CD_FMF_UpdateStates_Moving), which the EI = 0-only route's row-1 transfer does not. + CALL CD_AGG_MotionKinematics(aggregate, 1, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, turns, rolls, es, em) + IF (es == CD_AGG_OK) THEN + IF (turns) THEN + CALL CD_AGG_UpdateStates_Moving(aggregate, position, velocity, acceleration, es, em, & + orientation=orientation, angular_velocity=angular_velocity, & + angular_acceleration=angular_acceleration) + ELSE + CALL CD_AGG_UpdateStates_Moving(aggregate, position, velocity, acceleration, es, em) + END IF + END IF + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(aggregate, es, em) + IF (es /= CD_AGG_OK) THEN + CALL set_aggregate_error(es, em, run_stat, run_msg) + EXIT mixed_run + END IF + ELSE + ! A standalone deck with no prescribed motion means held coupling boundaries. Initial + ! solver accelerations are not prescribed boundary accelerations and must not be + ! fed back into the first step. + velocity = CD_ZERO + acceleration = CD_ZERO + END IF dynamic_path = TRIM(root)//'.out' OPEN (NEWUNIT=unit, FILE=TRIM(dynamic_path), STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) IF (ios /= 0) THEN @@ -604,8 +638,26 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h IF (nstep > 0) CALL start_standalone_progress(progress, nstep, step_dt) DO step = 1, nstep time = REAL(step, wp)*step_dt - CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & - n_iter, es, em, t_committed=time) + IF (has_motion) THEN + ! the prescribed boundary at t + dt: grid row step + 1 + CALL CD_AGG_MotionKinematics(aggregate, step + 1, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, turns, rolls, es, em) + IF (es /= CD_AGG_OK) THEN + CALL set_aggregate_error(es, em, run_stat, run_msg) + EXIT mixed_run + END IF + END IF + IF (turns) THEN + CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & + n_iter, es, em, t_committed=time, orientation=orientation, & + angular_velocity=angular_velocity, angular_acceleration=angular_acceleration) + ELSE IF (rolls) THEN + CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & + n_iter, es, em, t_committed=time, roll=roll) + ELSE + CALL CD_AGG_Step_Moving(aggregate, step_dt, position, velocity, acceleration, step_converged, stalled, & + n_iter, es, em, t_committed=time) + END IF CALL CD_Profile_Enter(CD_PROF_CHECK) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) diff --git a/doc/capabilities.rst b/doc/capabilities.rst index a1ba6767..a4634a59 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -67,10 +67,11 @@ Line and constitutive capability * - Mixed ``EI = 0`` + finite-EI deck - Supported with route limits - a mixed deck of lines between held or coupled points only (no bodies, rods, or - ``Free``/``Connect`` points) runs in OpenFAST and standalone as a static or held-end - dynamic run, and rejects a standalone ``motionFile`` or deck waves; a mixed deck with - bodies, rods, or ``Free``/``Connect`` points runs standalone on the multibody march, with - moving objects and deck waves/current, but not with a ``motionFile`` + ``Free``/``Connect`` points) runs in OpenFAST and standalone as a static run or a dynamic + run with held ends or a ``motionFile``/``vesselMotion`` prescription, and rejects deck + waves standalone (so ``vesselRAO`` too); a mixed deck with bodies, rods, or + ``Free``/``Connect`` points runs standalone on the multibody march, with moving objects + and deck waves/current, but not with a ``motionFile`` * - Viscoelastic rope (MoorDyn ``ElasticMod`` 2/3) - Supported - per-element series-Kelvin state (standard linear solid only when ``BA_D = 0``), @@ -86,20 +87,25 @@ Line and constitutive capability change, as in MoorDyn); finite-EI combinations fail closed by name * - Torsion of finite-EI lines - Supported with limits - - isotropic torsion of a finite-EI line restrained in torsion at both ends + - isotropic torsion of a finite-EI line restrained in torsion at both ends, or at one end + with the other free to twist (the free end carries no torque and turns with the twist of + the line: the stretch's under ``GJ|K``, and torsional waves in dynamics; on every route + and with every feature below that takes a line restrained at both ends) (``END CONNECTIONS`` torsion columns, explicit ``GJ``), with torque–tension coupling (``GJ|K``): condensed (uniform torque) in statics with a stability check and buckling descent, and a twist angle at every node in dynamics, with the polar inertia ``Irn`` and torsional damping (``GJ|K|Bt``), - with turning Rigid6 bodies, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll - column standalone, and with the platform orientation in coupled OpenFAST and FAST.Farm - runs (torque returned to the platform, ``PtfmInit``, checkpoints, linearisation with the - twist angles as states; see :doc:`openfast`) and through the C API with the host's - rotations (``CableDyn_InitDeckRotating``, :doc:`capi`), active line control - (``CONTROL``) of the fairlead segment on the coupled route; ``Torq``/``Twist`` channels and - standalone range graphs. Stopped by name: the standalone mixed ``EI = 0`` + finite-EI - aggregate and ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by - translation only), rod ends, bodies other than Rigid6 and ``False alpha_force_blend``. + with turning Rigid6 bodies (the ends of rods fixed to them included), ends of ``Fixed`` + rods, ``vesselMotion``/``vesselRAO`` and the ``motionFile`` roll column standalone + (``vesselMotion`` and the roll column also on a mixed ``EI = 0`` + finite-EI deck), and + with the platform orientation in coupled OpenFAST and FAST.Farm runs (torque returned to + the platform, ``PtfmInit``, checkpoints, linearisation with the twist angles as states; + see :doc:`openfast`) and through the C API with the host's rotations + (``CableDyn_InitDeckRotating``, :doc:`capi`), active line control (``CONTROL``) of the + fairlead segment on the coupled route; ``Torq``/``Twist`` channels and standalone range + graphs. Stopped by name: ``CableDyn_InitDeck``/``InitDeckAt`` (which move the line ends by + translation only), ends of free and pinned rods (axisymmetric, no roll angle) and of + ``Coupled``/``Vessel`` rods, bodies other than Rigid6 and ``False alpha_force_blend``. Modal analysis carries the twist angle of every node. Not modelled: seabed friction against twist, anisotropic sections, self-contact of a loop (see :ref:`theory-torsion`) * - Hockling loops, nonlinear cross-section laws diff --git a/doc/conventions.rst b/doc/conventions.rst index 811baa10..7b8556b8 100644 --- a/doc/conventions.rst +++ b/doc/conventions.rst @@ -172,7 +172,12 @@ Angles at line ends Torsion signs ------------- -These apply to a finite-EI line restrained in torsion at both ends (:doc:`driver_format`). +These apply to a finite-EI line solved in torsion: restrained at both ends, or at one end with +the other free to twist (:doc:`driver_format`). On a line free at one end the free end's +``Pretwist`` is not used (0), :math:`\Phi` is the restrained end's alone, and ``Twist`` +keeps its sign, the turn of End B relative to End A about the End A → End B tangent: a free +End B turns by ``+Twist`` against End A's frame carried along the line, a free End A by +``−Twist`` against End B's. - The end frame of each end is its direction ``Ez`` (End A → End B) and its reference normal ``Nx``, in the frame of ``Ez``. ``Pretwist`` rolls the end frame about ``Ez`` by a right-handed diff --git a/doc/driver_format.md b/doc/driver_format.md index 22872dd0..371c8667 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -334,13 +334,23 @@ rejected. `EI > 0` is routed as follows. [multibody march](#multibody-march). - When `motionFile` row 1 differs from the deck fairlead, CableDyn installs that boundary state and the initial fluid field, then recomputes the free-node acceleration from the full - structural, contact, and hydrodynamic residual before writing `t = 0`. + structural, contact, and hydrodynamic residual before writing `t = 0` (also with `TMax = 0`). + The `.static.out` profile is written before that, so it holds the static solve. **Standalone mixed deck** (separate `EI = 0` and `EI > 0` lines between `Fixed`/`Coupled`/`Vessel` points only): the deck is partitioned through the same atomic aggregate used by OpenFAST. -`Coupled`/`Vessel` endpoints are held at their deck positions. The run writes the common `.out` -and the all-line `.static.out` tables, plus the range graph of every line with the `r` flag. -Mixed decks reject, by name, `motionFile`, deck wave/current OPTIONS, WaterKin `WaveKinMod 1`, +`Coupled`/`Vessel` endpoints are held at their deck positions, or follow a `motionFile` or +`vesselMotion` as on the cubic-Hermite route: row 1 is installed and the cables' free-node +accelerations recomputed before `t = 0` (also with `TMax = 0`, whose `.out` row is then that +state; `.static.out` holds the static solve), a vessel turns the end connection and torsion +frames of the cables on its points, and the roll column imposes the twist of a line restrained +in torsion. The row-1 transfer also re-derives the interior accelerations of the `EI = 0` lines +at that state, which the `EI = 0`-only route does not, so when row 1 is off the deck pose their +first steps differ from that route's. A static run (`TMax = 0`) of a line restrained in torsion +takes `False alpha_force_blend`, as on the single-line route. +The run writes the common `.out` and the all-line `.static.out` tables, plus the range graph of +every line with the `r` flag. +Mixed decks reject, by name, deck wave/current OPTIONS (so `vesselRAO`), WaterKin `WaveKinMod 1`, MoorDyn-C `WaveKin 3`/`7` and `Currents 1`/`2`/`5`, and per-line `p`/`t` flags. (multibody-march)= @@ -385,8 +395,9 @@ connection moment. On this route: - a finite-EI cable needs a `Fixed` End B, and its End A may be a `Fixed` point, a Rigid6 `Body` point or a rod end, not a `Free`/`Connect` point or a `Point3` buoy; -- a clamped or elastic End A on a body or rod needs `bodyScheme monolithic` (the default); - `staggered` rejects it by name; +- a clamped or elastic End A on a body or rod, or one restrained in torsion (bending-pinned + included), needs `bodyScheme monolithic` (the default); `staggered`, which drives a cable end by + translation, rejects it by name; - every `Free`/`Connect` point carries at least one EI = 0 line; - `motionFile` and `Coupled`/`Vessel` rods are rejected by name. @@ -699,10 +710,11 @@ never both: a `SECTIONS` row for a 7-column line is an error naming the line. **Automatic anchor-first swap.** Stock MoorDyn decks list lines anchor first. When a line's `NodeA` is a `Fixed` point and its `NodeB` is a `Coupled`, `Vessel`, `Body`, `Free`, or -`Connect` point (`Turbine` points count as coupled), the parser swaps the two ends, reverses -that line's `SECTIONS` rows, and swaps its `END CONNECTIONS` ends, negating their reference -directions. Lines already listed fairlead first, and `Free`/`Connect`-to-`Coupled` lines, are left -as written. +`Connect` point (`Turbine` points count as coupled), or a finite-EI line's `NodeB` is a rod +end (`RA`/`RB`), the parser swaps the two ends, reverses that line's `SECTIONS` rows, and +swaps its `END CONNECTIONS` ends, negating their reference directions and pretwists (the +torsion normals swap with their ends). Lines already listed fairlead first, `EI = 0` lines to a +rod end, and `Free`/`Connect`-to-`Coupled` lines are left as written. **Endpoint rules.** @@ -802,8 +814,8 @@ Behaviour: - On a `Body` point the direction is given in the body frame, like the point offset, and turns with the body. On a rod end it must be parallel to the rod axis (either sense, in the frame of the rod's deck coordinates); another direction is rejected by name. The connection - moment is part of `BodyM*`/`RodM*`, and the body or rod carries it in the dynamics and in - the static solve. + moment is part of `BodyM*`/`RodM*` (of both on an end of a rod fixed to a body), and the + body or rod carries it in the dynamics and in the static solve. - A finite stiffness is an isotropic rotational spring on the tangent direction; the tangent magnitude stays free. - `Rigid` is an exact two-coordinate direction constraint, not a large penalty; the tangent @@ -839,10 +851,31 @@ used. Behaviour: -- Torsion is solved only on a line restrained at **both** ends. With one end restrained the - other end is free to twist, the line carries no torque, and the driver prints a note and - solves the line as without the columns (the rules below then do not apply). `Free` columns, - or no columns, reproduce the 6-column results exactly. +- Torsion is solved on a line restrained at both ends, and on a line restrained at **one** end + whose other end is free to twist (`TorsStiffness` `Free` there, or no row), under the rules + below. A free end carries no torque. In statics the line then has none, and its static state + is that of the line without the columns; under torque–tension coupling (`GJ|K`) the stretch + twists it by `Twist = −Σ (K/GJ)(l − L)` over the elements (`l` stretched, `L` + unstretched). `Twist` keeps its sign, the turn of End B relative to End A, right-handed + about the End A → End B tangent: a free End B turns by `+Twist` against End A's frame + carried along the line, a free End A by `−Twist` against End B's. In the dynamics the + polar inertia `Irn` carries torsional waves that reflect at the free end, and the restrained + end (and the body or vessel holding it) takes their torque. The free end's `Nx` and + `Pretwist` are not used. The section axes of `CurvX`/`CurvY` start, with End A restrained, + from End A's `Nx` (not rolled by its `Pretwist`, as on a line restrained at both ends) and, + with End B restrained, from End B's `Nx` rolled by End B's `Pretwist`; either way they are + carried along the line and turned by its twist. `ATTACHMENTS`, `CONTROL`, `nModes` (the + free end's angle is a mode coordinate, with the clamped–free modes) and OpenFAST + linearisation (the free end's angle is a state) take such a line as they take one + restrained at both ends. A line restrained at one end that misses a rule (its `LINE TYPES` + rows give no `GJ`, two moving ends, a dynamic or coupled run with `False alpha_force_blend`, + a restrained End A on a rod end other than a `Fixed` rod's or on a non-Rigid6 body) is + solved as without the columns, and the standalone driver prints a note with the reason. A + solved one's imposed twist, its restrained end's `Pretwist`, must lie within 1000 turns, as + `Pretwist(B) − Pretwist(A)` must on a line restrained at both ends. A line restrained at End A + on a Rigid6 body joins the static balance of the body's clamped and elastic ends, also at a + bending-`Pinned` End A (the body takes its torque). + `Free` columns, or no columns, reproduce the 6-column results exactly. - The imposed twist is `Phi = Pretwist(B) − Pretwist(A)`, measured against the line's own geometric twist `Theta`, the parallel-transport rotation of the End A normal carried along the centreline to End B (zero for a line that stays in a plane, with both normals perpendicular to @@ -853,9 +886,15 @@ Behaviour: set the End B pretwist to minus the static `Twist` of a run with zero pretwist (in degrees); the line then keeps its untwisted shape. - The torsion end frame turns with what carries the end: a Rigid6 body, the vessel of - `vesselMotion`/`vesselRAO`, or nothing at a `Fixed` or held point. The `motionFile` roll - column rolls the frame of the line's moving end + `vesselMotion`/`vesselRAO`, or nothing at a `Fixed` or held point or on a `Fixed` rod. The + `motionFile` roll column rolls the frame of the line's moving end ([Prescribed motion](#prescribed-motion-motionfile)). +- On a rod end (an I-tube or J-tube modelled as a rod), `Ez` lies along the rod axis and `Nx` + is given in the frame of the rod's deck coordinates, as `Ez` is. A `Fixed` rod holds the frame + still, and its `RodM*` carries the torque about the line axis. The ends of a rod fixed to a + Rigid6 body (`RODS` type `Body`) are points of the body: `Ez` and `Nx` are given in the body + frame, the frame rolls with the body, and the torque reaches the body (`BodyM*`) and appears + in the rod's `RodM*`. - A Rigid6 body holding such a line turns by less than 90° per step: a step whose turn would be larger is halved (the twist is read from the body's orientation, which repeats every turn), and a run that still needs more after six halvings stops by name; reduce `dtM`. @@ -869,24 +908,26 @@ Behaviour: dynamics; it is part of `BodyM*`. - Statics solve the imposed twist as the last load stage, in steps of at most 45°, test every stage for stability and, above a buckling onset, leave the unstable straight state for the - buckled one. Dynamics carry the torque in every step; torsion has no inertia (quasi-static - torsion), so the torque follows the imposed twist without a torsional wave. + buckled one. Dynamics carry the torsion in every step with a twist angle at every node and the + polar inertia `Irn` of the `LINE TYPES` row (see [theory](theory.rst)). Scope. A torsionally restrained line needs a finite-EI line with a `Fixed` End B, an explicit -`GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point or a Rigid6 -`Body` point; in a coupled OpenFAST or FAST.Farm run the End A frame turns with the platform -(see the manual's OpenFAST page, Line torsion). Each of the following stops with a named error: -torsion on an `EI = 0` line, on a rod end or on a `Point3` body, -a dynamic or coupled run with `False alpha_force_blend`, any -restrained end (one end included) in a standalone deck mixing `EI = 0` and finite-EI lines -without a body or through the C API's `CableDyn_InitDeck`/`InitDeckAt`, which move the line -ends by translation only (`a line restrained in torsion needs a host that turns its fairlead -frame ...`; with a body such a deck runs on the multibody route, which supports torsion, and a C -API host passes its rotations after `CableDyn_InitDeckRotating`), and a `Torq`/`Twist` channel -on a line that is not restrained at both ends. OpenFAST linearisation includes the twist angles -as states; like any cable, the line must not have a `Rigid` bending connection there. Seabed -friction does not resist twist (the laid part of a line twists freely), and there -is no torque–tension coupling. +`GJ` on every section, and, at End A, a `Fixed`, `Coupled`/`Vessel` point, a Rigid6 `Body` +point (the ends of a `Body` rod included) or an end of a `Fixed` rod; in a coupled OpenFAST +or FAST.Farm run the End A frame turns with the platform (see the manual's OpenFAST page, Line +torsion). Each of the following stops with a named error: torsion on an `EI = 0` line, on an end +of a `Free`, `Pinned`, `BodyPinned` or `CoupledPinned` rod (an axisymmetric rod has no roll +angle about its own axis: no load acts about the axis and its static solve has none, so it +cannot hold the torque) or of a `Coupled`/`Vessel` rod (no route carries a finite-EI line on a +host-driven rod), a line whose End B is a rod end (a line between two rods: put a `Fixed` point +at the rod end), on a `Point3` body, a dynamic or coupled run with `False alpha_force_blend`, +any restrained end (one end included) through the C API's `CableDyn_InitDeck`/`InitDeckAt`, +which move the line ends by translation only (`a line restrained in torsion needs a host that +turns its fairlead frame ...`; a C API host passes its rotations after +`CableDyn_InitDeckRotating`), and a `Torq`/`Twist` channel on a line whose torsion is not +solved. OpenFAST linearisation includes the twist angles as states; like any cable, the line +must not have a `Rigid` bending connection there. Seabed friction does not resist twist (the +laid part of a line twists freely). ### EQUIVALENT BUOYANCY (optional) @@ -1347,14 +1388,16 @@ cases. With an active path: `Free` rods in the same deck are integrated dynamically. - Rigid6 decks prescribe the full 6-DOF body motion from `Body` rows (see [BODIES](#deck-bodies)). -- `Connect`/`Free` point-system decks, FAILURE decks, and mixed `EI = 0` + finite-EI decks reject - `motionFile`. +- A mixed `EI = 0` + finite-EI deck of lines between `Fixed`/`Coupled`/`Vessel` points moves the + points of both line kinds from their rows, and a finite-EI line on them as on the finite-EI + route (row 1 installed before `t = 0`, the roll column below). +- `Connect`/`Free` point-system decks and FAILURE decks reject `motionFile`. Every non-comment record of the motion file is one row `time point_id x y z vx vy vz ax ay az` of -plain numbers; tokens after the eleventh are ignored, except that a deck with a line restrained -in torsion at both ends reads a twelfth, `roll` [deg]: at the point, the roll of the frame of the -line's moving end (End A, or End B in a deck that lists the `Fixed` anchor as End A), right-handed -about the line tangent pointing into the line from that end. Either way it imposes +plain numbers; tokens after the eleventh are ignored, except that a deck with a line solved in +torsion reads a twelfth, `roll` [deg]: at the point, the roll of the frame of the line's moving +end, restrained in torsion (End A, or End B in a deck that lists the `Fixed` anchor as End A), +right-handed about the line tangent pointing into the line from that end. Either way it imposes `Phi(t) = Pretwist(B) − Pretwist(A) − roll(t)`: the roll has the sense of `Pretwist(A)` at End A (where the inward tangent is `Ez`) and the opposite sense to `Pretwist(B)` at End B (where it is `−Ez`). The roll is 0 at @@ -1476,9 +1519,9 @@ bending moment. None of these channels is mandatory. | `TDPLay` | line L layback: horizontal distance from the TDP to the suspended end | m | | `TDPExc` | line L TDP excursion: horizontal TDP displacement from its initial position, along the initial direction toward the suspended end | m | | `TDPGrd` | line L grounded length: deformed chord length along the nodes from the grounded end to the TDP; continuous with the TDP, 0 only when nothing touches (the grounded end has lifted off) | m | -| `TorqN` | line L torque at node J (uniform along the line); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line restrained in torsion at both ends | N·m | -| `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` over the elements in between; 0 at End A, without the end-spring windup. Only on a line restrained in torsion at both ends | deg | -| `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included. Only on a line restrained in torsion at both ends | deg | +| `TorqN` | line L torque at node J (uniform along the line in statics); positive for a right-handed twist of End B relative to End A about the End A → End B tangent. Only on a line solved in torsion (restrained at both ends, or at one end with the other free) | N·m | +| `TwistN` | line L material twist accumulated from End A to node J, `M × Σ L/GJ` (less `(K/GJ)(l − L)` under coupling) over the elements in between; 0 at End A, without the end-spring windup. Only on a line solved in torsion | deg | +| `Twist` | line L total twist `Phi − Theta = M C`, end-spring windup included; on a line free at one end the twist of its elements, the free end's turn. Only on a line solved in torsion | deg | - ``/`

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

`` channel of a ``Coupled``/``Vessel`` point attached **only** to finite-EI lines — that point is not part of the ``EI = 0`` point system that serves point channels. Use the cable's diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index 67abac60..7b3416e5 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -99,20 +99,25 @@ The standalone driver accepts a deck containing separate ``EI = 0`` mooring line power cables between ``Fixed`` and ``Coupled``/``Vessel`` points. It uses the same aggregate that backs ``CompMooring = 5`` in OpenFAST (maintained by NLR, the National Laboratory of the Rockies, formerly NREL) and advances the objects atomically. Every ``Coupled``/``Vessel`` endpoint is held -at its initialised position. A mixed deck that also has bodies, rods or ``Connect``/``Free`` -points runs on the multibody march instead (:doc:`driver_format`), which accepts deck waves and -current. ``examples/iea15mw_umaine_mixed_cabledyn.dat`` is the maintained four-line +at its initialised position, or follows the deck's ``motionFile`` or ``vesselMotion`` (a vessel +turns the end connection and torsion frames of the power cables on its points, and the +``motionFile`` roll column twists a cable restrained in torsion, as on the single-cable route). +A mixed deck that also has bodies, rods or ``Connect``/``Free`` points runs on the multibody +march instead (:doc:`driver_format`), which accepts deck waves and current. ``examples/iea15mw_umaine_mixed_cabledyn.dat`` is the maintained four-line example; its ``TMax = 0`` setting writes the common static configuration. Give a positive ``TMax`` to march held-end dynamics. A static-only mixed deck with no dynamic-only option may instead omit both ``dtM`` and ``TMax``; the time-step option becomes mandatory when a positive-duration march is requested. -A mixed deck rejects ``motionFile`` and deck-owned wave/current OPTIONS by name. Platform -six-DOF motion is defined at the OpenFAST platform reference point, whereas a cable requires each -hang-off's translated and rotated position, velocity, and acceleration, and CableDyn does not -equate those two boundaries. Mixed-deck LINE ``Outputs`` flags ``p`` and ``t`` are rejected as -well; request the needed mixed-deck quantities through the main ``OUTPUTS`` section instead -(the ``r`` range graph is available). +A mixed deck rejects deck-owned wave/current OPTIONS by name, and with them ``vesselRAO``, +which needs deck waves. A ``vesselMotion`` record moves every ``Coupled``/``Vessel`` point +rigidly with the vessel (translation and rotation of each hang-off); a ``motionFile`` gives the +rows of each point. Row 1 is installed before ``t = 0``, also with ``TMax = 0``, after the +``.static.out`` of the static solve is written. On the ``EI = 0`` lines that transfer re-derives +the interior accelerations, which the ``EI = 0``-only route does not, so with row 1 off the deck +pose their first steps differ from that route's. Mixed-deck LINE ``Outputs`` flags ``p`` and +``t`` are rejected as well; request the needed mixed-deck quantities through the main +``OUTPUTS`` section instead (the ``r`` range graph is available). Initialisation report ~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/theory.rst b/doc/theory.rst index fd9f148b..384e1743 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -345,7 +345,9 @@ The section axis :math:`\mathbf{d}_1` (x) starts at End A normal to the End A :math:`\mathbf{t}`: - on a line restrained in torsion, along End A's torsion normal ``Nx``, which turns with the - hang-off; + hang-off; on a line restrained at End B only (End A free to twist), along End A's own + section: End B's ``Nx``, rolled by End B's ``Pretwist``, carried to End A and turned by the + twist of the line (:ref:`a free end `); - otherwise along the static start's upper normal, the projection of global +z normal to the End A tangent (global +x where the tangent is vertical). It is fixed in the hang-off's axes when End A is clamped or held by a finite rotational stiffness, so it turns with the vessel, @@ -496,7 +498,9 @@ length, integrated on the bending rule with its gradient and Hessian. Everything including the rank-one tangent, the step limit and the stability test, holds with :math:`\Theta_{\text{eff}}`. The coupling part has no :math:`2\pi` ambiguity, so the first evaluation unwraps the holonomy alone. A line free to twist at one end carries no torque and -the axial stiffness :math:`EA - K^2/GJ`. Restrained at both ends, a straight stretched line +the axial stiffness :math:`EA - K^2/GJ`, and its free end turns by the element twists, +:math:`-\sum_e (K_e/GJ_e)(l_e - L_{0,e})` (see the free end below). Restrained at both ends, a +straight stretched line cannot twist, so it carries :math:`T = EA\,\varepsilon` and :math:`M = K\varepsilon`. The node tension adds the element's :math:`(K/GJ)\,M`, and the twist channels sum the element twists :math:`M L_0/GJ - (K/GJ)(l - L_0)`. @@ -541,6 +545,28 @@ order, End B, and :math:`\Phi` at End A), so a turn of the frame enters the end reference twist through the same solid angles. A turn of an end frame by more than :math:`\pi/2` about the line within one step is refused, and the step is cut. +.. _theory-free-end: + +**A free end.** A line restrained in torsion at one end only has its other end free to twist: +an infinite end compliance, so the condensed compliance :math:`C` is infinite and the condensed +torque :math:`(\Phi - \Theta_{\text{eff}})/C` zero. The statics are then those of the line +without torsion (with the axial stiffness :math:`EA - K^2/GJ`), and every element twists by +:math:`\hat\tau_e = 0`, i.e. by :math:`-(K_e/GJ_e)(l_e - L_{0,e})` of material twist; their sum +is ``Twist``, the turn of End B relative to End A against the restrained end's frame +carried along the line (a free End A turns by its negative). In the dynamics the free end's node has no spring and no held angle: its angle +is free, its lumped inertia :math:`I_{rn} L_0/2` and its element's torque balance it, and its +end frame is a gauge that nothing reads (the free end's ``Nx`` and ``Pretwist`` are not used). +The torque vanishes at the free end, so torsional waves reflect there, and the line's modes are +the clamped–free ones, :math:`\omega_n = (2n - 1)\,\pi/(2L)\,\sqrt{GJ/I_{rn}}` for a uniform +line held rigidly at the other end; a roll :math:`A\sin\Omega t` of the restrained end turns +the free end by :math:`A/\cos kL` (:math:`k = \Omega\sqrt{I_{rn}/GJ}`) and loads the +restrained end with :math:`GJ A k \tan kL`. Exactly one end is restrained, so no rigid spin of +the angles is left free. The modal analysis and the OpenFAST linearisation take the free end's +angle as a coordinate (no spring term in the twist Hessian) and give these clamped–free modes, +and a free end has no roll stiffness. The test suite checks these frequencies, the driven +response at :math:`kL = \pi/4` and :math:`3\pi/4` and the free end's coupling turn against +the continuum. + In the limit of a negligible inertia the element torques are uniform and equal the condensed torque; the test suite holds the two models to 1e-6 on a rolling, swaying, bowed line with clamped, bending-pinned and elastic ends, and checks the torque of a driven torsional wave @@ -2686,7 +2712,11 @@ end force and moment load the object at the force level :math:`(1-\alpha_f)\,\mathbf{f}_{n+1} + \alpha_f\,\mathbf{f}_n`. Its condensed dynamic end stiffness with respect to the object's translation and rotation enters the Newton matrix by differences of the cable step. On a rod end the direction must lie along the rod axis, so the -moment has no component about the axis, which carries no degree of freedom. The static solve +bending moment has no component about the axis, which carries no degree of freedom on a free +or pinned rod (an axisymmetric rod has no roll angle; a line restrained in torsion is refused +there). A ``Fixed`` rod holds its end frame, and the torque of a line restrained in torsion +returns to it about the line axis; the ends of a rod fixed to a body are points of the body, +whose frame rolls with it. The static solve carries the cable first without bending; passes then add the difference between the cubic-Hermite cable's end force and that surrogate, and the Hermite connection moment, at the previous pass's pose, until these loads change by less than :math:`10^{-7}` of the force scale. At the diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index b69874b5..d6dce3bb 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -215,9 +215,8 @@ Clock, motion, and environment header lines with ``#``. * - motionFile ``... which is not Coupled/Vessel`` / ``duplicate row for point`` - the ``point_id`` is not a prescribed point, or a (point, time) pair appears twice. - * - ``Connect/Free dynamic-point deck does not support motionFile coupling`` / - ``mixed-deck motionFile is not supported`` - - these routes hold their coupled endpoints. Remove ``motionFile`` or separate the model. + * - ``Connect/Free dynamic-point deck does not support motionFile coupling`` + - this route holds its coupled endpoints. Remove ``motionFile`` or separate the model. * - ``bathymetry file must define one complete rectangular grid`` / ``grid is incomplete`` / ``duplicate x/y entries`` / ``needs at least a 2x2 grid`` / ``depths must be positive`` - the ``x y depth`` rows must cover every combination of the distinct ``x`` and ``y`` @@ -361,6 +360,7 @@ Model data finite-EI line with Fixed End B`` - bending end connections apply only to ``EI > 0`` lines whose End B is an anchor. * - ``a clamped or elastic END CONNECTION on a body or rod needs bodyScheme monolithic`` / + ``a torsional END CONNECTION on a body or rod needs bodyScheme monolithic`` / ``the END CONNECTION direction on a rod end must be parallel to the rod axis`` - remove ``staggered bodyScheme``; on a rod end give the direction along the rod axis (either sense). @@ -392,17 +392,23 @@ Torsion * - ``torsional END CONNECTIONS ... require a finite-EI line`` / ``require a finite-EI line with Fixed End B`` - torsion is solved on cubic-Hermite lines whose End B is an anchor. - * - ``a torsional END CONNECTION on a rod end is not supported`` / ``on a body needs a Rigid6 - body`` - - outside the torsion scope (:doc:`capabilities`). Move End A to a ``Fixed``, - ``Coupled``/``Vessel`` point or a Rigid6 body. + * - ``a torsional END CONNECTION on the end of ROD (...) is not supported: a free or + pinned rod is axisymmetric`` / ``on the end of Coupled/Vessel ROD is not supported`` / + ``on a body needs a Rigid6 body`` + - outside the torsion scope (:doc:`capabilities`). A free or pinned rod has no roll angle + about its own axis, so it cannot hold the torque. Move End A to a ``Fixed`` rod, a rod fixed + to a Rigid6 body (``RODS`` type ``Body``), a Rigid6 body or a ``Fixed`` point (a + ``Coupled``/``Vessel`` End A only in a deck without bodies and rods: a deck with them runs + on the multibody march, which takes no ``Coupled`` End A for a finite-EI line). + * - ``... require a finite-EI line with Fixed End B; line ends (End B) on a rod end`` + - the cable holds its End B at a ``Fixed`` point only, so a line between two rods (a J-tube + to a J-tube) is not supported. For a ``Fixed`` rod, end the line on a ``Fixed`` point at + the rod end's position; that rod's ``Rod`` loads then leave its force out. * - ``a line restrained in torsion needs a host that turns its fairlead frame`` - - the standalone deck that mixes ``EI = 0`` and finite-EI lines without a body, and the C - API's ``CableDyn_InitDeck``/``InitDeckAt``, move the line ends by translation only. Run the - line in a coupled OpenFAST or FAST.Farm run, initialise a C API handle with - ``CableDyn_InitDeckRotating`` and pass the host's rotations, add a body (such a deck runs - on the multibody route, which supports torsion), or set ``TorsStiffness Free`` in every - ``END CONNECTIONS`` row. + - the C API's ``CableDyn_InitDeck``/``InitDeckAt`` move the line ends by translation only. + Run the line in a coupled OpenFAST or FAST.Farm run or in the standalone driver, + initialise a C API handle with ``CableDyn_InitDeckRotating`` and pass the host's + rotations, or set ``TorsStiffness Free`` in every ``END CONNECTIONS`` row. * - ``torsion: the twist would move more than pi/2 from its committed value`` - the host turned a fairlead by more than 90° about the line's end direction without a step (an output probe or a non-stepping input update). Keep the platform turn per @@ -413,11 +419,15 @@ Torsion * - ``torsion in a dynamic run needs the force-blended generalised-alpha (OPTION alpha_force_blend True)`` - remove ``False alpha_force_blend`` from a deck with torsion. - * - ``OUTPUT "Torq...": line is not torsionally restrained at both ends ..., so it carries - no torque`` - - a ``Torq``/``Twist`` channel needs a line with a torsional restraint at both ends. - * - ``motionFile: point has a non-zero roll column, but no line restrained in torsion at - both ends ... has its moving (non-Fixed) end there`` / ``the roll column of point must + * - ``OUTPUT "Torq...": line is not torsionally restrained (END CONNECTIONS + TorsStiffness), so it carries no torque`` / ``... line is torsionally restrained at + one end only and its torsion is not solved: `` + - a ``Torq``/``Twist`` channel needs a line solved in torsion: restrained at both ends, or + at one end with the other free to twist; the second message gives the rule a line + restrained at one end missed (see the note below). + * - ``motionFile: point has a non-zero roll column, but no line restrained in torsion + (END CONNECTIONS TorsStiffness) at its moving (non-Fixed) end has that end there`` / + ``the roll column of point must be 0 at t = 0`` / ``gives the roll column (12th) on some rows only`` / ``the roll column (12th, degrees) must be a finite number`` - the roll column drives the frame of a torsional line's moving end, starts from 0 (put a @@ -620,9 +630,20 @@ Warnings and notes that do not stop a run * - Message - Cause and fix - * - ``Note: line is torsionally restrained at one end only; ... no torsion is solved`` - - with the other end free to twist the line carries no torque, so the torsion columns of the - restrained end have no effect. Restrain both ends to solve torsion. + * - ``Note: line is torsionally restrained at one end only and its torsion is not solved: + `` + - a line restrained at one end, its other end free to twist, is solved in torsion (its free + end turns with the twist of the line) where a line restrained at both ends would be; the + reason names the rule it misses: no ``GJ`` in its ``LINE TYPES`` rows (give the 14-column + row), two moving ends, ``False alpha_force_blend`` in a dynamic run, or a restrained End A + on the end of a free, pinned or ``Coupled``/``Vessel`` rod or on a body other than Rigid6. + The line is then solved as without the torsion columns. + * - ``Note: line : torsion restrained at End only: no static torque; Twist = + deg (End B relative to End A, right-handed about the End A -> End B tangent)`` + - a line restrained in torsion at one end: it carries no static torque, and under + torque–tension coupling (``GJ|K``) its stretch twists it by + :math:`-\sum (K/GJ)(l - L)`, so a free End B turns by :math:`+x` and a free End A by + :math:`-x` about the End A → End B tangent. * - ``Note: line : torsion solved, imposed twist ... deg, torque ... N m ( twist stage(s), buckling descent(s))`` - the static twist stage of a torsional line. A non-zero descent count means the straight or diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 631d1f33..22856450 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -372,6 +372,12 @@ _RIGID_END_CONNECTIONS = frozenset({"rigid", "infinity", "inf"}) # TorsStiffness keywords of an end free to twist (a numeric 0 is free too) _FREE_TORSION_KEYWORDS = frozenset({"free", "zero"}) +# native ROD_END_B_NOTE: a finite-EI line with an END CONNECTION whose End B is a rod end +_ROD_END_B_NOTE = ( + " ends (End B) on a rod end: a line between two rods is not supported in this build (the " + "cable holds its End B at a Fixed point only); for a Fixed rod, end the line on a Fixed " + "point at the rod end's position (its force then stays out of that rod's Rod loads)" +) # native CD_HTORS_MAX_TWIST: the largest imposed static twist, 1000 turns _MAX_STATIC_TWIST_DEG = 360000.0 # Native TORS_NX_PARALLEL_TOL: smallest |Nx x Ez| of unit vectors (about 0.06 degrees off Ez). @@ -3019,6 +3025,16 @@ def end_key(token: str) -> str: normalized_line_endpoints: dict[str, tuple[str, str]] = {} # lines whose stock anchor-first row the native reader turns around (its ends swap) swapped_lines: set[str] = set() + # native finite_ei_by_name (normalize_stock_endpoint_order): the lines whose SECTIONS + # rows name a line type with EI > 0 + finite_ei_lines: set[str] = set() + for section in self._rows("SECTIONS"): + if len(section.tokens) < 2: + continue + meta = line_type_meta.get(section.tokens[1].lower()) + if meta is not None and meta[3] > 0.0: + with contextlib.suppress(ValueError): + finite_ei_lines.add(str(_native_int(section.tokens[0]))) range_lines = 0 lift_lines = 0 # lines with the VIV lift file (flag V) series_lines = 0 # lines with per-line time-series files (flags p, t, V) @@ -3096,11 +3112,19 @@ def end_key(token: str) -> str: # when NodeB is a fairlead (Coupled/Vessel/Body/Turbine), or a Free/Connect # point at or above the Fixed NodeA. A Fixed NodeA above a Free/Connect # NodeB is an elevated hang-off already in CableDyn (upper-end-first) order. + # A finite-EI line to a rod end swaps too (it runs only from the rod, End A, to a + # Fixed End B); an EI = 0 line to a rod end keeps its written order. + line_key = str(_native_int(row.tokens[0])) + line_is_finite_ei = line_key in finite_ei_lines or ( + len(row.tokens) == 7 + and line_type_meta.get(row.tokens[1].lower(), (0.0, 0.0, 0.0, 0.0))[3] > 0.0 + ) upper_b = ( type_b in {"coupled", "vessel"} or type_b.startswith("body") or _is_turbine_point_type(type_b) or (type_b in {"connect", "free"} and point_z[node_a] <= point_z[node_b]) + or (line_is_finite_ei and _rod_point(type_b) is not None) ) if type_a == "fixed" and upper_b: node_a, node_b = node_b, node_a @@ -3245,7 +3269,9 @@ def end_key(token: str) -> str: assigned_end_connections: set[tuple[str, str]] = set() # (line, end) held by a Rigid or rotational-spring row, in native End A/B order held_ends: set[tuple[str, str]] = set() - # line id -> {end: torsionally restrained} from the optional torsion columns + # line id -> {end: torsionally restrained} from the optional torsion columns, and the + # pretwists, in native End A/B order (after the anchor-first swap, which reverses Ez and + # so negates a pretwist) torsion_ends: dict[str, dict[str, bool]] = {} torsion_pretwist: dict[str, dict[str, float]] = {} for row in self.end_connections: @@ -3334,11 +3360,15 @@ def end_key(token: str) -> str: pretwist = 0.0 if len(row.tokens) == 11: pretwist = numeric(row.tokens[10], row, "END CONNECTIONS pretwist") - torsion_pretwist.setdefault(line_id, {})[end] = pretwist + native_end = end + if line_id in swapped_lines: + native_end = {"a": "b", "b": "a"}[end] + pretwist = -pretwist + torsion_pretwist.setdefault(line_id, {})[native_end] = pretwist if restrained: # a Free end has no torsion frame: its normal is not checked (native) self._check_torsion_normal(where, row, normal, direction, norm) - torsion_ends.setdefault(line_id, {})[end] = restrained + torsion_ends.setdefault(line_id, {})[native_end] = restrained if non_pinned: swapped = line_id in swapped_lines held_ends.add((line_id, {"a": "b", "b": "a"}[end] if swapped else end)) @@ -3349,6 +3379,11 @@ def end_key(token: str) -> str: if not has_finite_ei: raise DeckFormatError(f"{where} END CONNECTIONS requires a finite-EI line") end_b = normalized_line_endpoints[line_id][1] + if _rod_point(point_types[end_b]) is not None: + raise DeckFormatError( + f"{where} non-pinned END CONNECTIONS require a finite-EI line with Fixed " + f"End B; line {line_id}{_ROD_END_B_NOTE}" + ) if point_types[end_b] != "fixed": raise DeckFormatError( f"{where} non-pinned END CONNECTIONS require " @@ -3437,7 +3472,7 @@ def end_key(token: str) -> str: ) for row in bodies } - torsion_lines = self._check_torsion_lines( + torsion_lines, torsion_notes = self._check_torsion_lines( torsion_ends, torsion_pretwist, section_types_by_line, @@ -3448,7 +3483,6 @@ def end_key(token: str) -> str: body_types, option_by_key, has_tmax, - mixed_route, ) rod_types = self._rows("ROD TYPES") @@ -3622,18 +3656,15 @@ def end_key(token: str) -> str: # deck driver, whose dispatch gates follow. deck_driver_route = not self.caller_driven and not mixed_route if self.caller_driven or mixed_route: - # native CD_Init_Deck_Aggregate: the host (or, for a standalone mixed deck, the - # driver holding the initialized ends) drives the coupled boundary + # native CD_Init_Deck_Aggregate: the host drives the coupled boundary; a standalone + # mixed deck is driven by the driver, which holds the initialized ends or marches + # the deck's motionFile/vesselMotion (prescribed_motion; vesselRAO needs deck + # waves, which the still-water mixed route refuses below) if has_motion_file and self.caller_driven: raise DeckFormatError( f"{self._label}: the coupled boundary is driven by the host, not a deck " "motionFile; remove the motionFile OPTION" ) - if has_motion_file: - raise DeckFormatError( - f"{self._label}: a mixed EI=0/finite-EI deck does not support motionFile " - "(the driver holds its coupled ends)" - ) if not line_ids: raise DeckFormatError(f"{self._label}: the coupled route needs at least one line") if self.caller_driven: @@ -4201,11 +4232,16 @@ def is_body_kind(kind: str, pinned: bool) -> bool: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r} node exceeds the line node count" ) + if line_id in torsion_notes: + raise DeckFormatError( + f"{self._label}: OUTPUT {channel!r}: line {line_id} is torsionally " + "restrained at one end only and its torsion is not solved: " + f"{torsion_notes[line_id]}" + ) if line_id not in torsion_lines: raise DeckFormatError( f"{self._label}: OUTPUT {channel!r}: line {line_id} is not torsionally " - "restrained at both ends (END CONNECTIONS TorsStiffness), so it carries " - "no torque" + "restrained (END CONNECTIONS TorsStiffness), so it carries no torque" ) continue if lowered.startswith(("ten", "curv", "bendmom", "stfmom", "l")): @@ -4285,35 +4321,98 @@ def _check_torsion_lines( body_types: dict[str, str], option_by_key: dict[str, OptionRecord], has_tmax: bool, - aggregate_route: bool, - ) -> set[str]: - """Native ``check_torsion_line`` and the driver's torsion scope; the torsional lines. + ) -> tuple[set[str], dict[str, str]]: + """Native ``check_torsion_line`` and the driver's torsion scope. + + Returns the lines solved in torsion and, for a line restrained at one end only whose + torsion is not solved, why (native ``resolve_one_end_torsion``). A line with a torsional END CONNECTIONS restraint (TorsStiffness Rigid or a - stiffness) must be finite-EI. With one restrained end it carries no torque and is - solved as without the columns. Restrained at both ends, torsion is solved: End B must - be Fixed, every section type needs an explicit GJ > 0, no ATTACHMENTS, End A neither a - rod end nor on a body other than Rigid6. A deck with torsion runs dynamics only with - the force-blended generalised-alpha (a coupled run is always dynamic); its modal - analysis (nModes) carries the twist. A standalone mixed EI = 0 + finite-EI deck - without bodies (``aggregate_route``, run on the aggregate, which moves the line ends by - translation only) refuses any torsion column, one restrained end included; the coupled - OpenFAST and FAST.Farm routes turn the fairlead frame with the platform and accept it. + stiffness) must be finite-EI. Restrained at both ends, torsion is solved: End B must + be Fixed, every section type needs an explicit GJ > 0, End A neither on a rod other than + a Fixed one (a free or pinned rod has no roll angle, a Coupled/Vessel rod carries no + finite-EI line; the ends of a rod fixed to a body are body points) nor on a body other + than Rigid6. Restrained at one end only (its other end free to twist), it is solved in + torsion under the same rules and with a force-blended march; otherwise it keeps the + meaning of the 6-column rows (no error). ATTACHMENTS, CONTROL and the modal analysis + (nModes, whose modes carry the twist) take a line solved in torsion. A deck with torsion + runs dynamics only with the force-blended generalised-alpha (a coupled run is always + dynamic). The coupled OpenFAST and FAST.Farm routes turn the fairlead frame with the + platform, and the standalone mixed EI = 0 + finite-EI deck without bodies (run on the + aggregate) holds it or turns it with its vesselMotion and rolls it with the motionFile + roll column, as the standalone cubic-Hermite route does. """ - # _check_attachments has already accepted every LineID as an integer + rod_kinds = self._rod_rows_by_id() + tmax_row = option_by_key.get("tmax") + # a coupled run is always dynamic (the host owns TMax) + dynamic = self.caller_driven or ( + has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 + ) + blend_row = option_by_key.get("alpha_force_blend") + force_blend = blend_row is None or blend_row.values[0].lower() in { + "true", + "t", + "yes", + "y", + "on", + "1", + } torsion_lines: set[str] = set() - has_torsion_column = False + torsion_notes: dict[str, str] = {} for line_id, ends in torsion_ends.items(): if not any(ends.values()): continue - has_torsion_column = True if not any(line_type_meta[name][3] > 0.0 for name in section_types_by_line[line_id]): raise DeckFormatError( f"{self._label}: torsional END CONNECTIONS (TorsStiffness Rigid or a " f"stiffness) require a finite-EI line; line {line_id} has EI = 0" ) - # one restrained end only carries no torque: noted and ignored if not (ends.get("a", False) and ends.get("b", False)): + # one restrained end: solved where the rules hold, noted otherwise + end_a, end_b = normalized_line_endpoints[line_id] + note = "" + if not all(line_type_gj[name] > 0.0 for name in section_types_by_line[line_id]): + note = ( + "its LINE TYPES rows give no GJ (the 14-column row; torsion has no " + "EI/1.3 default)" + ) + elif point_types[end_b] != "fixed": + note = "it has two moving ends (torsion needs a Fixed End B)" + elif dynamic and not force_blend: + note = ( + "torsion in a dynamic run needs the force-blended generalised-alpha " + "(alpha_force_blend True)" + ) + elif ends.get("a", False): + body_id = _body_point_id(point_types[end_a]) + rod_end = _rod_point(point_types[end_a]) + rod_kind = None if rod_end is None else rod_kinds.get(rod_end[0], (None, 0))[0] + if rod_end is not None and rod_kind is not None and rod_kind != "fixed": + if rod_kind in {"coupled", "vessel"}: + note = ( + "its restrained End A is on a Coupled/Vessel rod end (no route " + "carries a finite-EI line on a host-driven rod)" + ) + else: + note = ( + "its restrained End A is on the end of a free or pinned rod " + "(axisymmetric, with no roll angle to hold the torque)" + ) + elif body_id > 0 and body_types.get(str(body_id), "rigid6") != "rigid6": + note = "its restrained End A is on a body that is not Rigid6" + if note: + torsion_notes[line_id] = note + continue + # native check_torsion_line: the restrained end's pretwist is the imposed twist + restrained_end = "a" if ends.get("a", False) else "b" + twist = torsion_pretwist[line_id].get(restrained_end, 0.0) + if abs(twist) > _MAX_STATIC_TWIST_DEG: + raise DeckFormatError( + f"{self._label}: line {line_id}: the Pretwist of its restrained End " + f"{restrained_end.upper()} = {twist:.5e} deg exceeds 1000 turns " + "(360000 deg), the largest twist" + ) + torsion_lines.add(line_id) continue twist = torsion_pretwist[line_id]["b"] - torsion_pretwist[line_id]["a"] if abs(twist) > _MAX_STATIC_TWIST_DEG: @@ -4322,6 +4421,11 @@ def _check_torsion_lines( f"{twist:.5e} deg exceeds 1000 turns (360000 deg), the largest static twist" ) end_a, end_b = normalized_line_endpoints[line_id] + if _rod_point(point_types[end_b]) is not None: + raise DeckFormatError( + f"{self._label}: torsional END CONNECTIONS require a finite-EI line with Fixed " + f"End B; line {line_id}{_ROD_END_B_NOTE}" + ) if point_types[end_b] != "fixed": raise DeckFormatError( f"{self._label}: torsional END CONNECTIONS require a finite-EI line with Fixed " @@ -4334,10 +4438,24 @@ def _check_torsion_lines( f'its LINE TYPES row "{name}" must give an explicit GJ > 0 (the 14-column ' "row; torsion has no EI/1.3 default)" ) - if _rod_point(point_types[end_a]) is not None: + rod_end = _rod_point(point_types[end_a]) + rod_kind = None if rod_end is None else rod_kinds.get(rod_end[0], (None, 0))[0] + if rod_end is not None and rod_kind is not None and rod_kind != "fixed": + if re.fullmatch(r"body[0-9]+pin", rod_kind): + rod_kind += "ned" + if rod_kind in {"coupled", "vessel"}: + raise DeckFormatError( + f"{self._label}: line {line_id}: a torsional END CONNECTION on the end of " + f"Coupled/Vessel ROD {rod_end[0]} is not supported: no route of this build " + "carries a finite-EI line on a host-driven rod" + ) raise DeckFormatError( - f"{self._label}: line {line_id}: a torsional END CONNECTION on a rod end is " - "not supported (a rod has no spin angle in this build)" + f"{self._label}: line {line_id}: a torsional END CONNECTION on the end of ROD " + f"{rod_end[0]} ({rod_kind}) is not supported: a free or pinned rod is " + "axisymmetric, with no roll about its own axis (no load acts about the axis " + "and its static solve has no roll angle), so it cannot hold the line's torque; " + "restrain End A on a Fixed rod, on a rod fixed to a Rigid6 body (RODS type " + "Body), on a Rigid6 body point or on a Fixed point" ) body_id = _body_point_id(point_types[end_a]) if body_id > 0 and body_types.get(str(body_id), "rigid6") != "rigid6": @@ -4346,40 +4464,14 @@ def _check_torsion_lines( "a Rigid6 body" ) torsion_lines.add(line_id) - # native CD_Init_Deck_Aggregate (deck_has_torsion_columns): a standalone mixed EI = 0 + - # finite-EI deck without bodies moves its line ends by translation only and refuses any - # restrained end; the OpenFAST and FAST.Farm hosts turn the fairlead frame - if has_torsion_column and aggregate_route and not self.caller_driven: - raise DeckFormatError( - f"{self._label}: a line restrained in torsion needs a host that turns its fairlead " - "frame: coupled OpenFAST and FAST.Farm runs do, and a C API host initialised with " - "CableDyn_InitDeckRotating, while CableDyn_InitDeck/InitDeckAt and a standalone " - "deck that mixes EI = 0 and finite-EI lines without a BODY move the line ends by " - "translation only (with a BODY such a deck runs on the multibody route, which " - "supports torsion); set TorsStiffness Free in every END CONNECTIONS row" - ) if not torsion_lines: - return torsion_lines - tmax_row = option_by_key.get("tmax") - # a coupled run is always dynamic (the host owns TMax) - dynamic = self.caller_driven or ( - has_tmax and tmax_row is not None and _native_float(tmax_row.values[0]) > 0.0 - ) - blend_row = option_by_key.get("alpha_force_blend") - force_blend = blend_row is None or blend_row.values[0].lower() in { - "true", - "t", - "yes", - "y", - "on", - "1", - } + return torsion_lines, torsion_notes if dynamic and not force_blend: raise DeckFormatError( f"{self._label}: torsion in a dynamic run needs the force-blended " "generalised-alpha (OPTION alpha_force_blend True)" ) - return torsion_lines + return torsion_lines, torsion_notes def _line_type_fields(self, record: DeckRecord) -> tuple[str, ...]: fields = _FIELDS["line_type"] diff --git a/python/cabledyn/ranges.py b/python/cabledyn/ranges.py index f823c8eb..be641e19 100644 --- a/python/cabledyn/ranges.py +++ b/python/cabledyn/ranges.py @@ -455,8 +455,9 @@ def read_range_graphs(source: str | os.PathLike[str] | OutputTable) -> dict[str, LINES ``Outputs`` flag ``r``: the minimum, maximum, and mean over the output times of the range window of the node tension, curvature, bend moment, and declination, the seabed clearance when the deck has a - seabed, and the torque and twist from End A when the line is restrained - in torsion at both ends, at every node against its arc length. + seabed, and the torque and twist from End A when the line is solved in + torsion (restrained at both ends, or at one end with the other free), at + every node against its arc length. Parameters ---------- diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index f481cd63..eb00bbe5 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -846,7 +846,11 @@ def test_standalone_mixed_deck_runs_on_the_still_water_aggregate(): _rejects(_options(_MIXED, "uniform 0.5 0 0 current"), "runs in still water") _rejects(_options(_MIXED, "airy 2 8 0 waves"), "runs in still water") _rejects(_edit(_MIXED, ("2 2 3 -", "2 2 3 pt")), "writes no per-line files") - _rejects(_options(_MIXED, "m.txt motionFile"), "mixed EI=0/finite-EI deck does not support") + # the driver marches the deck's motionFile or vesselMotion; vesselRAO needs deck waves + DeckFile.from_text(_options(_MIXED, "m.txt motionFile")) + DeckFile.from_text(_options(_MIXED, "v.txt vesselMotion", "0|0|0 vesselRef")) + _rejects(_options(_MIXED, "r.txt vesselRAO"), "vesselRAO needs deck waves") + _rejects(_options(_MIXED, "r.txt vesselRAO", "airy 2 8 0 waves"), "runs in still water") def test_coupled_route_takes_no_motion_file_and_needs_a_line(): @@ -970,6 +974,9 @@ def test_end_connection_errors_name_the_line_end_and_value(row, message): _rejects(_edit(_TORSION, (_TORSION_ROW_A, row)), message) +_NO_TORSION_OUTPUTS_ONE_END = ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n") + + def test_torsion_line_rules_follow_the_native_checks(): # torsion has no EI/1.3 default: the 10-column LINE TYPES row has no GJ no_gj = _edit( @@ -992,10 +999,53 @@ def test_torsion_line_rules_follow_the_native_checks(): ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"), ) _rejects(ei0, "require a finite-EI line; line 1 has EI = 0") - # one restrained end is accepted (it carries no torque), but takes no torsion channel + # one restrained end, the other free to twist, is solved in torsion with its channels ... one_end = _edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n")) - _rejects(one_end, "is not torsionally restrained at both ends") - DeckFile.from_text(_edit(one_end, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"))) + DeckFile.from_text(one_end) + # ... where both-end torsion would be; otherwise it is not, and its channels are refused + one_end_no_gj = _edit( + one_end, + ( + "Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat\n", + "Name Diam Mass EA BA EI Cdn Cdt Can Cat\n", + ), + ( + "cab 0.2 32.2 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0", + "cab 0.2 32.2 1.0e7 0.0 1.0e6 0 0 0 0", + ), + ) + _rejects( + one_end_no_gj, "restrained at one end only and its torsion is not solved: its LINE TYPES" + ) + DeckFile.from_text(_edit(one_end_no_gj, ("Torq1N1\nTwist1N41\nTwist1\n", "FairTen1\n"))) + one_end_dyn = _edit(one_end, ("0.0 TMax\n", "10.0 TMax\n")) + DeckFile.from_text(one_end_dyn) + _rejects( + _options(one_end_dyn, "False alpha_force_blend"), + "torsion is not solved: torsion in a dynamic run needs the force-blended", + ) + # the modal analysis, ATTACHMENTS and CONTROL take a line solved at one end, its channels too + DeckFile.from_text(_options(one_end, "3 nModes")) + DeckFile.from_text( + _edit( + one_end, + ( + f"{_BAR} OPTIONS {_BAR}", + f"{_BAR} ATTACHMENTS {_BAR}\nLineID ArcLength Mass Volume CdA Ca\n" + f"1 50.0 10.0 0.0 0.0 0.0\n{_BAR} OPTIONS {_BAR}", + ), + ) + ) + DeckFile.from_text( + _edit( + one_end, + ( + f"{_BAR} OPTIONS {_BAR}", + f"{_BAR} CONTROL {_BAR}\nChannelID Line(s)\n(-) (-)\n1 1\n{_BAR} OPTIONS {_BAR}", + ), + ), + caller_driven=True, + ) # the dynamic run needs the force blend; modal analysis carries the twist dynamic = _edit(_TORSION, ("0.0 TMax\n", "10.0 TMax\n")) DeckFile.from_text(dynamic) @@ -1045,6 +1095,24 @@ def _torsion_two_moving(row_a: str) -> str: ) +def _one_end_rod(rod_kind: str) -> str: + """The pure-torsion line hung from End B of a rod of the given kind along its axis (+x), + restrained in torsion there only (End B of the line free to twist).""" + return _edit( + _TORSION_DYN, + ( + f"{_BAR} POINTS {_BAR}", + f"{_BAR} ROD TYPES {_BAR}\nName Diam Mass Cd Ca CdEnd CaEnd\n" + "spar 1.0 300.0 0.8 1.0 0.0 0.0\n" + f"{_BAR} RODS {_BAR}\nID RodType Type XA YA ZA XB YB ZB NumSegs Outputs\n" + f"1 spar {rod_kind} -10 0 -50 0 0 -50 2 -\n{_BAR} POINTS {_BAR}", + ), + ("1 1 2 -", "1 R1B 2 -"), + ("1 Coupled 0.0 0.0 -50.0 0 0 0 0\n", ""), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Free 0 0 1 0"), + ) + + def test_torsion_scope_rules_follow_the_native_checks(): # End A on a Rigid6 body is supported, on a Point3 body or a rod end it stops by name DeckFile.from_text( @@ -1066,7 +1134,66 @@ def test_torsion_scope_rules_follow_the_native_checks(): ("1 1 2 -", "1 R1A 2 -"), ("1 Coupled 0.0 0.0 -50.0 0 0 0 0\n", ""), ) - _rejects(rod_end, "a torsional END CONNECTION on a rod end is not supported") + # a Fixed rod holds the End A torsion frame still; a free or pinned rod has no roll angle, + # and a Coupled rod carries no finite-EI line on any route + DeckFile.from_text(rod_end) + axisymmetric = "is not supported: a free or pinned rod is axisymmetric, with no roll about" + _rejects( + _edit(rod_end, ("1 spar Fixed", "1 spar Pinned")), + rf"line 1: a torsional END CONNECTION on the end of ROD 1 \(pinned\) {axisymmetric}", + ) + _rejects( + _edit(rod_end, ("1 spar Fixed", "1 spar Free")), + rf"on the end of ROD 1 \(free\) {axisymmetric}", + ) + _rejects( + _edit( + rod_end, + ( + f"{_BAR} ROD TYPES {_BAR}", + f"{_BAR} BODIES {_BAR}\n" + "ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz\n" + "1 Rigid6 0 0 -30 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3\n" + f"{_BAR} ROD TYPES {_BAR}", + ), + ("1 spar Fixed 0 0 -50 0 0 -40", "1 spar Body1Pin 0 0 -20 0 0 -10"), + ), + rf"on the end of ROD 1 \(body1pinned\) {axisymmetric}", + ) + # written anchor first (MoorDyn's order) the finite-EI line is turned around, onto the Fixed + # rod as onto a pinned one; a line between two rods ends on a rod end + anchor_first = _edit(rod_end, ("1 R1A 2 -", "1 2 R1A -")) + DeckFile.from_text(anchor_first) + _rejects( + _edit(anchor_first, ("1 spar Fixed", "1 spar Pinned")), + rf"on the end of ROD 1 \(pinned\) {axisymmetric}", + ) + _rejects( + _edit( + rod_end, + ( + "1 spar Fixed 0 0 -50 0 0 -40 2 -\n", + "1 spar Fixed 0 0 -50 0 0 -40 2 -\n2 spar Fixed 100 0 -50 100 0 -60 2 -\n", + ), + ("1 R1A 2 -", "1 R1A R2A -"), + ), + # the bending row is checked first here, the torsion first natively: one remedy + r"END CONNECTIONS require a finite-EI line with Fixed End B; line 1 ends \(End B\) on a " + "rod end: a line between two rods is not supported in this build", + ) + _rejects( + _options(_edit(rod_end, ("1 spar Fixed", "1 spar Coupled")), "rod.motion motionFile"), + "a torsional END CONNECTION on the end of Coupled/Vessel ROD 1 is not supported: no route " + "of this build carries a finite-EI line on a host-driven rod", + ) + # restrained at the rod end only (End B free to twist): solved on a Fixed rod, noted on a + # pinned one, whose twist channels are then refused with the reason + DeckFile.from_text(_one_end_rod("Fixed")) + _rejects( + _one_end_rod("Pinned"), + "its torsion is not solved: its restrained End A is on the end of a free or pinned rod", + ) + DeckFile.from_text(_edit(_one_end_rod("Pinned"), _NO_TORSION_OUTPUTS)) attachments = _edit( _TORSION, ( @@ -1096,12 +1223,14 @@ def test_torsion_scope_rules_follow_the_native_checks(): (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Free 0 0 1 720"), ) - _rejects(both_free, "is not torsionally restrained at both ends") + _rejects(both_free, "is not torsionally restrained \\(END CONNECTIONS") DeckFile.from_text(_edit(both_free, _NO_TORSION_OUTPUTS)) -def test_torsion_on_a_standalone_mixed_deck_is_refused(): - # a mixed EI = 0 + finite-EI deck without bodies runs on the aggregate, which has no torsion +def test_torsion_on_a_standalone_mixed_deck_is_accepted(): + # a mixed EI = 0 + finite-EI deck without bodies runs on the aggregate, whose driver holds the + # line end frames or turns them with the deck's vesselMotion and rolls them with the + # motionFile roll column (test_mixed_route_torsion) gj_cable = _edit( _MIXED, ( @@ -1128,8 +1257,21 @@ def test_torsion_on_a_standalone_mixed_deck_is_refused(): "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist", *rows, ) - _rejects(text, "mixes EI = 0 and finite-EI lines without a BODY") - _rejects(_options(text, "10.0 TMax"), "mixes EI = 0 and finite-EI lines without a BODY") + DeckFile.from_text(text) + DeckFile.from_text(_edit(text, ("10.0 TMax\n", "0.0 TMax\n"))) + DeckFile.from_text(_options(text, "m.txt motionFile")) + DeckFile.from_text(_options(text, "v.txt vesselMotion", "0|0|0 vesselRef")) + # a static run (TMax = 0) marches no step and takes the configuration blend, as native + # CD_Init_Deck_Aggregate with static_run (test_mixed_route_torsion gate 6) + DeckFile.from_text( + _options(_edit(text, ("10.0 TMax\n", "0.0 TMax\n")), "False alpha_force_blend") + ) + if "Free" not in rows[1]: + # restrained at both ends, the dynamic run needs the force blend, as on every route + _rejects( + _options(text, "False alpha_force_blend"), + "needs the force-blended generalised-alpha", + ) @pytest.mark.parametrize( @@ -1250,7 +1392,7 @@ def test_static_twist_of_1000_turns_is_accepted(): def test_torsion_rows_get_the_native_verdict(row_a, tmp_path): text = _edit(_TORSION, (_TORSION_ROW_A, f"{row_a}\n")) if row_a.split()[6].lower() in {"free", "zero"}: - # one restrained end carries no torque: judge the row, not the torsion channels + # a Free End A: judge the row (its normal and pretwist), not the torsion channels text = _edit(text, _NO_TORSION_OUTPUTS) try: DeckFile.from_text(text) @@ -1317,6 +1459,122 @@ def test_torsion_channels_get_the_native_verdict(channel, tmp_path): assert python_accepts == (_native_exit(text, tmp_path) != 1) +def _stock_body(body_row: str, row_a: str, row_b: str) -> str: + """A line written anchor first (NodeA the Fixed anchor, NodeB on body 1), which the reader + turns around: its deck End B becomes End A.""" + return f"""{_BAR} CableDyn Input File {_BAR} +in-memory fixture: an anchor-first line restrained in torsion at one end +{_BAR} LINE TYPES {_BAR} +Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat +cab 0.2 32.2 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0 0.0 0.0 0.0 0.0 +{_BAR} BODIES {_BAR} +ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz +{body_row} +{_BAR} POINTS {_BAR} +ID Type X Y Z Mass Vol CdA Ca +1 Body1 0.0 0.0 0.0 0 0 0 0 +2 Fixed 100.0 0.0 -50.0 0 0 0 0 +{_BAR} LINES {_BAR} +ID NodeA NodeB Outputs +1 2 1 - +{_BAR} SECTIONS {_BAR} +LineID LineType Length NumSegs +1 cab 100.0 40 +{_BAR} END CONNECTIONS {_BAR} +LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist +{row_a} +{row_b} +{_BAR} OPTIONS {_BAR} +9.80665 g +1025.0 rhoW +50.0 WtrDpth +0.1 dtM +1.0 TMax +{_BAR} OUTPUTS {_BAR} +FairTen1 +Twist1 +{_BAR} need this line {_BAR} +""" + + +# restrained at the deck's End B, the body, which the anchor-first swap makes End A +_STOCK_POINT3_AT_BODY = _stock_body( + "1 Point3 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0", + "1 A Rigid -1 0 0 Free 0 0 1 0", + "1 B Rigid -1 0 0 Rigid 0 0 1 0", +) +_STOCK_RIGID6_AT_BODY = _stock_body( + "1 Rigid6 0 0 -50 0 0 0 1.0e5 97.56 0 0 0 0 0 1.0e3 1.0e3 1.0e3", + "1 A Rigid -1 0 0 Free 0 0 1 0", + "1 B Rigid -1 0 0 Rigid 0 0 1 0", +) + + +def test_one_end_torsion_follows_the_anchor_first_swap(): + # a Point3 body does not carry torsion: the line restrained there is not solved, and its + # twist channel is refused; on a Rigid6 body it is solved + _rejects(_STOCK_POINT3_AT_BODY, "its restrained End A is on a body that is not Rigid6") + DeckFile.from_text(_STOCK_RIGID6_AT_BODY) + + +def test_one_end_pretwist_stays_within_1000_turns(): + one_end = _edit( + _TORSION, + (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Rigid 0 0 1 1e8"), + ) + _rejects(one_end, "the Pretwist of its restrained End B = 1.00000e\\+08 deg exceeds 1000 turns") + # the free end's pretwist rolls nothing and is not checked + DeckFile.from_text(_edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 1e8\n"))) + + +@pytest.mark.skipif( + not _PARITY_DRIVER or not Path(_PARITY_DRIVER).is_file(), + reason="set CABLEDYN_TEST_DRIVER to a built native driver to run the native torsion parity", +) +@pytest.mark.parametrize( + "text", + [ + _STOCK_POINT3_AT_BODY, + _STOCK_RIGID6_AT_BODY, + _edit( + _TORSION, + (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), + ("1 B Rigid 1 0 0 Rigid 0 0 1 720", "1 B Rigid 1 0 0 Rigid 0 0 1 1e8"), + ), + _options(_edit(_TORSION, (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n")), "3 nModes"), + _edit( + _TORSION, + (_TORSION_ROW_A, "1 A Rigid 1 0 0 Free 0 0 1 0\n"), + ( + f"{_BAR} OPTIONS {_BAR}", + f"{_BAR} ATTACHMENTS {_BAR}\nLineID ArcLength Mass Volume CdA Ca\n" + f"1 50.0 10.0 0.0 0.0 0.0\n{_BAR} OPTIONS {_BAR}", + ), + ), + _one_end_rod("Fixed"), + _one_end_rod("Pinned"), + ], + ids=[ + "stock-point3-body", + "stock-rigid6-body", + "one-end-huge-pretwist", + "one-end-nmodes", + "one-end-attachments", + "one-end-fixed-rod", + "one-end-pinned-rod", + ], +) +def test_one_end_torsion_gets_the_native_verdict(text, tmp_path): + try: + DeckFile.from_text(text) + python_accepts = True + except DeckFormatError: + python_accepts = False + # exit code 1 is an input refusal; 0 a run and 2 a solve failure after validation + assert python_accepts == (_native_exit(text, tmp_path) != 1) + + @pytest.mark.parametrize( ("channel", "message"), [ diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 57a4214e..2fc338ce 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -113,7 +113,8 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Element_Twist, CD_HermiteCable_Dyn_Coupling_Tension, & CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & - CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping + CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping, CD_HermiteTorsion_Line, & + CD_HermiteTorsion_Unwrap, CD_HermiteTorsion_Element_Stretch, CD_HTORS_OK USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID USE CableDyn_Vessel, ONLY: CD_VesselRAOType, CD_Vessel_Euler_DCM, CD_Vessel_Euler_Angular, & CD_Vessel_Point_Kinematics, CD_Vessel_RAO_Set, CD_Vessel_RAO_Eval, & @@ -215,6 +216,11 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_Rigid6_ScatterHostPoints, CD_Rigid6_HostWrench, CD_Rigid6_Stage, CD_Rigid6_Unstage PUBLIC :: CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations PUBLIC :: CD_RodRuntimeType + ! Prescribed motion of a standalone mixed deck: the aggregate owns the schedule the standalone + ! driver marches it with (opaque; MotionTable/DeckPoint stay private). + PUBLIC :: CD_MotionRuntimeType + PUBLIC :: CD_Motion_Active, CD_Motion_NColumns, CD_Motion_Has_Rotation, CD_Motion_Has_Roll + PUBLIC :: CD_Motion_Kinematics, CD_Motion_Deck_Positions, CD_Motion_End PUBLIC :: CD_Init_Deck_Aggregate_Rod, CD_Step_Aggregate_Rod PUBLIC :: CD_Rod_NRods, CD_Rod_Snapshot, CD_Rod_Restore, CD_Rod_End PUBLIC :: CD_Rod_MirrorSize, CD_Rod_Get_States, CD_Rod_Set_States, CD_Rod_Apply_States @@ -285,11 +291,10 @@ MODULE CableDyn_DeckDriver CHARACTER(*), PARAMETER :: INSPECTION_NOTE = ' Output contains only committed states and is for inspection only.' ! a line restrained in torsion on an entry whose caller does not turn the fairlead frame CHARACTER(*), PARAMETER :: TORSION_NEEDS_ORIENTATION = 'a line restrained in torsion needs a host that '// & - 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, and a C API host '// & - 'initialised with CableDyn_InitDeckRotating, while CableDyn_InitDeck/InitDeckAt '// & - 'and a standalone deck that mixes EI = 0 and finite-EI lines without a BODY move '// & - 'the line ends by translation only (with a BODY such a deck runs on the multibody '// & - 'route, which supports torsion); set TorsStiffness Free in every END CONNECTIONS row' + 'turns its fairlead frame: coupled OpenFAST and FAST.Farm runs do, as does the '// & + 'standalone driver and a C API host initialised with CableDyn_InitDeckRotating, '// & + 'while CableDyn_InitDeck/InitDeckAt move the line ends by translation only; set '// & + 'TorsStiffness Free in every END CONNECTIONS row' CHARACTER(*), PARAMETER :: TORSION_NEEDS_FORCE_BLEND = 'torsion in a dynamic run needs the force-blended '// & 'generalised-alpha (OPTION alpha_force_blend True)' CHARACTER(*), PARAMETER :: CONTROL_NEEDS_FORCE_BLEND = 'active line control of a finite-EI line needs the '// & @@ -492,6 +497,12 @@ MODULE CableDyn_DeckDriver ! Smallest |Nx x Ez| / |Nx| accepted for a reference normal (about 0.06 degrees off Ez). REAL(wp), PARAMETER :: TORS_NX_PARALLEL_TOL = 1.0e-3_wp REAL(wp), PARAMETER :: DEG2RAD_TORS = 3.14159265358979323846264338327950288_wp/180.0_wp + ! A finite-EI line with a bending or torsional END CONNECTION whose End B is a rod end (also a + ! line between two rods, a J-tube to a J-tube): the cable holds End B at a Fixed point only. + CHARACTER(*), PARAMETER :: ROD_END_B_NOTE = ' ends (End B) on a rod end: a line between two rods is not '// & + 'supported in this build (the cable holds its End B at a Fixed point only); for a '// & + 'Fixed rod, end the line on a Fixed point at the rod end''s position (its force then '// & + 'stays out of that rod''s Rod loads)' TYPE :: DeckLine INTEGER :: id = 0, nodeA = 0, nodeB = 0 @@ -513,11 +524,16 @@ MODULE CableDyn_DeckDriver ! Torsional end restraint of the optional END CONNECTIONS columns (End A, End B): mode ! TORS_FREE (default), TORS_RIGID or TORS_FINITE with stiffness tors_k [N m/rad]; tors_nx the ! unit zero-twist reference normal in the frame of Ez (perpendicular to Ez); tors_pretwist - ! the roll of the end frame about Ez [rad]. Torsion is active only with both ends restrained. + ! the roll of the end frame about Ez [rad]. Torsion is solved with both ends restrained, or + ! with one (line_torsion_active): tors_free_end is then the deck end free in torsion (1 = End + ! A, 2 = End B; resolve_one_end_torsion, which zeroes its Pretwist), 0 otherwise; tors_note + ! says why a line restrained at one end only is not solved in torsion. INTEGER :: tors_mode(2) = TORS_FREE REAL(wp) :: tors_k(2) = CD_ZERO REAL(wp) :: tors_nx(3, 2) = CD_ZERO REAL(wp) :: tors_pretwist(2) = CD_ZERO + INTEGER :: tors_free_end = 0 + CHARACTER(200) :: tors_note = '' INTEGER :: deck_line = 0 ! deck file line of the row, for error messages ! True when the anchor-first swap (normalize_stock_endpoint_order) exchanged the two ends: ! the deck's written NodeB (MoorDyn's AttachB) is then End A, otherwise End B. Active line @@ -1042,6 +1058,25 @@ MODULE CableDyn_DeckDriver TYPE(RodState), ALLOCATABLE :: stage_rods(:) END TYPE + !> Opaque prescribed-motion schedule of a standalone mixed deck, which the standalone driver + !> marches on the coupled aggregate: the deck's motionFile or vesselMotion table (read by + !> CD_Init_Deck_Aggregate with prescribed_motion) and, per aggregate moving column, the + !> Coupled/Vessel point that drives it. CD_Motion_Kinematics returns one grid row of the + !> moving surface: the point translations, the vessel rotation of a vesselMotion table (the + !> orientation the end connection and torsion frames turn with) and the motionFile roll column. + TYPE :: CD_MotionRuntimeType + PRIVATE + LOGICAL :: active = .FALSE. + TYPE(MotionTable) :: motion + ! per aggregate moving column: the motion-table point that drives it, and its deck position + INTEGER, ALLOCATABLE :: col_point(:) + REAL(wp), ALLOCATABLE :: col_pos(:, :) + ! per aggregate moving column: the column takes the roll column of its point (the moving + ! End A of a finite-EI line restrained in torsion at both ends, as on the standalone + ! cubic-Hermite route) + LOGICAL, ALLOCATABLE :: col_roll(:) + END TYPE + TYPE :: FiniteDeckModel TYPE(CD_FiniteEIModelType) :: model INTEGER :: n_elem = 0 @@ -1180,6 +1215,9 @@ MODULE CableDyn_DeckDriver ! Range graphs (LINES flag r, standalone only) and the touchdown references of the ! TDP channels, keyed by deck line id and fixed at the converged initial state. TYPE(CD_RangeSet) :: ranges + ! The deck's own prescribed motion (prescribed_motion: the standalone driver), in the + ! aggregate moving-set order; inactive otherwise. + TYPE(CD_MotionRuntimeType) :: motion END TYPE CONTAINS @@ -1853,7 +1891,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp), ALLOCATABLE :: ei_cable(:) REAL(wp) :: att_offset ! Condensed torsion (both END CONNECTIONS rows torsionally restrained): solved as the last - ! static load stage on the final mesh, then installed in the cable. + ! static load stage on the final mesh, then installed in the cable; a line restrained at one + ! end only (ln%tors_free_end) has no static torque and installs its free end. LOGICAL :: tors_line TYPE(CD_HermiteTorsionType) :: tors ! the residual tolerance the accepted torsion stage met (torsion_note) @@ -2001,9 +2040,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ABS(endconn_d0_local(2, i)) > 64.0_wp*EPSILON(CD_ONE)) require_3d_static = .TRUE. END DO ! A twisted line leaves the plane of its chord (the torque bends it out of plane), so a - ! torsional line is solved in 3D from the start. + ! torsional line is solved in 3D from the start; a line free in torsion at one end carries no + ! static torque, so its statics are those of the line without torsion. tors_line = line_torsion_active(ln) - IF (tors_line) require_3d_static = .TRUE. + IF (tors_line .AND. ln%tors_free_end == 0) require_3d_static = .TRUE. ! A current with a component across the vertical plane of the chord pushes the line out ! of that plane, which the dynamics (endpoints held, every other DOF free) follow: the ! static equilibrium is then solved in 3D as well. @@ -3231,7 +3271,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable end-connection wiring failed: '//TRIM(em)); RETURN END IF END IF - IF (tors_line) THEN + IF (tors_line .AND. ln%tors_free_end == 1) THEN + ! a free End A: its torsion frame is a gauge, which no parent turns + CALL CD_HFMF_Set_Torsion(cable, tors, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI cable torsion wiring failed: '//TRIM(em)); RETURN + END IF + ELSE IF (tors_line) THEN ! The End A torsion frame (director -Ez, reference normal Nx, in the frame of Ez) is held ! by End A's parent and turns with it in the dynamics, whatever the bending connection. BLOCK @@ -3388,11 +3434,15 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) !! f_nodal: the stage of a line with ATTACHMENTS, after the attachment polish (the final !! mesh then is l0, with the bare weights w_bare and the deck mesh l0_deck_att), with the !! attachments' lumped loads. + !! A line restrained at one end only (ln%tors_free_end) carries no static torque: the + !! untwisted state is its static state, Theta is evaluated there, and the free end's frame + !! is a gauge (end_free): the end's connection direction, or its static tangent at a + !! bending-pinned end, with the restrained end's normal made normal to it. INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) REAL(wp) :: nvec(3), dvec(3), tol_t - INTEGER :: k, attempt + INTEGER :: k, attempt, kf LOGICAL :: nodal_loads TYPE(CD_HermiteTorsionType) :: tors0 ! the deck mesh, the final mesh and its per-element arrays of this stage @@ -3439,7 +3489,11 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) END IF END DO END IF + ! the free end, internal end 3 - tors_free_end (0: none) + kf = 0 + IF (ln%tors_free_end > 0) kf = 3 - ln%tors_free_end DO k = 1, 2 + IF (k == kf) CYCLE dvec = endconn_d0_local(:, k)/NORM2(endconn_d0_local(:, k)) IF (k == 1) THEN nvec = ln%tors_nx(:, 2) @@ -3460,6 +3514,10 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) IF (ln%tors_mode(2) == TORS_FINITE) tors%end_compliance(1) = CD_ONE/ln%tors_k(2) IF (ln%tors_mode(1) == TORS_FINITE) tors%end_compliance(2) = CD_ONE/ln%tors_k(1) tors%phi = ln%tors_pretwist(2) - ln%tors_pretwist(1) + IF (kf > 0) THEN + CALL one_end_state(kf, lf, est, emt) + RETURN + END IF ! Rotating a buckled shape about a common clamp axis is an exact symmetry only without ! weight or current, with both ends clamped on one axis. nodal_loads = .FALSE. @@ -3508,8 +3566,10 @@ END SUBROUTINE torsion_stage SUBROUTINE torsion_note() !! The notes of the accepted torsion stage: a residual floor above the tolerance, and the - !! imposed twist and torque. + !! imposed twist and torque. A line restrained at one end only solves no twist stage; its + !! note is one_end_state's. CHARACTER(320) :: tnote + IF (ln%tors_free_end > 0) RETURN IF (tors_tol_used > static_tol_target) THEN WRITE (tnote, '(A,I0,A,ES9.2,A,ES9.2)') 'line ', ln%id, ': torsion static residual floor above the '// & 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tors_tol_used @@ -3595,6 +3655,65 @@ SUBROUTINE twisted_attachment_checks(est, emt) END IF END SUBROUTINE twisted_attachment_checks + SUBROUTINE one_end_state(kf, lf, est, emt) + !! torsion_stage of a line restrained at one end only (internal end 3 - kf restrained, the + !! other set up here): the free end's gauge frame, Theta at the untwisted static state + !! (has_theta, no torque), and the note of the free end's static turn, the summed element + !! twists -sum (K/GJ)(l_e - l0_e) of torque-tension coupling (Twist). lf: the stage's + !! final mesh (l0_am, or l0 after the attachment polish of a line with ATTACHMENTS). + INTEGER, INTENT(IN) :: kf + REAL(wp), INTENT(IN) :: lf(:) + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + REAL(wp), ALLOCATABLE :: gth(:) + REAL(wp) :: raw, twist, ax(3), nvec(3), dvec(3) + INTEGER :: node, e, ks + CHARACTER(320) :: tnote + est = CD_DECKDRV_OK + emt = '' + IF (NORM2(endconn_d0_local(:, kf)) > CD_ZERO .AND. endconn_mode(kf) /= CD_ENDCONN_PINNED) THEN + dvec = endconn_d0_local(:, kf)/NORM2(endconn_d0_local(:, kf)) + ELSE + node = MERGE(1, SIZE(lf) + 1, kf == 1) + dvec = q_static(6*node - 2:6*node)/NORM2(q_static(6*node - 2:6*node)) + END IF + nvec = tors%ends(:, 2*(3 - kf)) + nvec = nvec - DOT_PRODUCT(nvec, dvec)*dvec + IF (NORM2(nvec) < TORS_NX_PARALLEL_TOL) THEN + ! the restrained normal along this end's director: any normal of it is the gauge + ax = CD_ZERO + ax(MINLOC(ABS(dvec), DIM=1)) = CD_ONE + nvec = ax - DOT_PRODUCT(ax, dvec)*dvec + END IF + tors%ends(:, 2*kf - 1) = dvec + tors%ends(:, 2*kf) = nvec/NORM2(nvec) + tors%end_free(kf) = .TRUE. + ALLOCATE (gth(SIZE(q_static))) + CALL CD_HermiteTorsion_Line(q_static, lf, tors%ends, raw, gth, ks, emt, couple=tors%couple, & + quadrature_order=tors%quadrature_order) + IF (ks /= CD_HTORS_OK) THEN + est = CD_DECKDRV_SOLVEFAIL + emt = 'torsion at the static state: '//TRIM(emt) + RETURN + END IF + tors%theta = CD_HermiteTorsion_Unwrap(raw, CD_ZERO) + tors%has_theta = .TRUE. + tors%torque = CD_ZERO + twist = CD_ZERO + IF (ALLOCATED(tors%couple)) THEN + DO e = 1, SIZE(lf) + twist = twist - tors%couple(e)*(CD_HermiteTorsion_Element_Stretch(q_static(6*e - 5:6*e + 6), lf(e), & + tors%quadrature_order) - lf(e)) + END DO + END IF + ! Twist is the turn of End B relative to End A, right-handed about the End A -> End B + ! tangent: a free End B turns by +Twist, a free End A by -Twist + WRITE (tnote, '(A,I0,A,A,A,ES12.5,A)') 'line ', ln%id, ': torsion restrained at End ', & + MERGE('B', 'A', ln%tors_free_end == 1), ' only: no static torque; Twist = ', twist*45.0_wp/QUARTER_PI, & + ' deg (End B relative to End A, right-handed about the End A -> End B tangent)' + CALL report_note(tnote) + END SUBROUTINE one_end_state + SUBROUTINE bow_route(done, why) !! A line too long for its span whose anchor walk failed or reached an equilibrium the !! audit rejects (an arch facing the anchor that has looped through itself): trace the @@ -7124,7 +7243,8 @@ END SUBROUTINE CD_Init_Deck_HermiteCable SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation, static_current) + range_files, host_orientation, static_current, prescribed_motion, & + static_run) !! Parse a MIXED deck ONCE and partition its lines into {EI=0 mooring} and !! {finite-EI cable}, returning the raw parts the OpenFAST aggregate facade wraps: !! the EI=0 mooring SYSTEM built from the mooring subset (over ALL deck points, the @@ -7138,8 +7258,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi !! Scope: EI=0 lines with Fixed/Coupled/Vessel/Connect/Free points, Point3 buoys, Rigid6 !! bodies and RODs (free, fixed, pinned, host-coupled or host-pinned), CONTROL, FAILURE and !! FAST.Farm turbines, plus finite-EI cables. Fails closed with a clear message on: a - !! motionFile (the host drives the coupled boundary); deck waves (the host supplies wave - !! kinematics); a deck current on + !! motionFile (the host drives the coupled boundary; prescribed_motion excepted); deck + !! waves (the host supplies wave kinematics); a deck current on !! a deck with a finite-EI cable, a Rigid6 body or a rod, under a host fluid field, or in !! FAST.Farm mode; a deck with a finite-EI cable that also carries Free/Connect dynamic !! points. A deck current on any other deck is a steady field applied through the lines. @@ -7192,9 +7312,10 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! mixed route); a coupled host does not, so the flag fails closed there. LOGICAL, INTENT(IN), OPTIONAL :: range_files ! host_orientation: the caller passes each moving point's orientation with every update - ! (the OpenFAST and FAST.Farm shells), which turns the fairlead frame of a finite-EI line - ! restrained in torsion. Without it (the C API, the standalone mixed route) a deck with - ! torsion columns fails closed rather than holding that frame fixed. + ! (the OpenFAST and FAST.Farm shells, and the standalone mixed route, which holds the frame + ! or turns it with its vesselMotion table), which turns the fairlead frame of a finite-EI + ! line restrained in torsion. Without it (the C API) a deck with torsion columns fails + ! closed rather than holding that frame fixed. LOGICAL, INTENT(IN), OPTIONAL :: host_orientation ! static_current (4, n): the host's steady current as a depth profile, rows z (ascending), ! ux, uy, uz -- the OpenFAST shell's SeaState CurrMod 1 current at SeaState's grid levels. @@ -7204,9 +7325,17 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! dynamics take the host field alone: the profile goes into a copy of the options that ! only the static builders see. REAL(wp), INTENT(IN), OPTIONAL :: static_current(:, :) + ! prescribed_motion: the caller marches the deck's own motionFile or vesselMotion table + ! (the standalone driver on a mixed deck of lines between Fixed/Coupled/Vessel points): + ! the table is read into agg%motion in the moving-set order instead of being refused. + LOGICAL, INTENT(IN), OPTIONAL :: prescribed_motion + ! static_run: the caller marches no step (the standalone driver's TMax = 0 run), so a line + ! restrained in torsion needs no force-blended step, as on the single-line standalone route; + ! a coupled host always marches. + LOGICAL, INTENT(IN), OPTIONAL :: static_run INTEGER :: nturb - LOGICAL :: host_turns + LOGICAL :: host_turns, own_motion, dynamic_points, static_only TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -7239,14 +7368,18 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven=.TRUE., env_gravity=env_gravity, & env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.TRUE., & - failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE.) + failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE., & + static_run=static_run) IF (ErrStat == CD_DECKDRV_OK) THEN host_turns = .FALSE. IF (PRESENT(host_orientation)) host_turns = host_orientation IF (deck_has_torsion_columns(lines) .AND. .NOT. host_turns) THEN CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_ORIENTATION); RETURN END IF - IF (ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]) .AND. .NOT. opts%alpha_force_blend) THEN + static_only = .FALSE. + IF (PRESENT(static_run)) static_only = static_run + IF (ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))]) .AND. .NOT. opts%alpha_force_blend .AND. & + .NOT. static_only) THEN CALL fail(ErrStat, ErrMsg, TORSION_NEEDS_FORCE_BLEND); RETURN END IF END IF @@ -7498,10 +7631,22 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi n_host_rod = COUNT(rods%rod_type == 'coupled' .OR. rods%rod_type == 'vessel' .OR. & rods%rod_type == 'coupledpinned') n_host_body = COUNT(bodies%host_coupled .OR. bodies%host_pinned) - IF (opts%has_motion_file) THEN + own_motion = .FALSE. + IF (PRESENT(prescribed_motion)) own_motion = prescribed_motion .AND. opts%has_motion_file + IF (opts%has_motion_file .AND. .NOT. own_motion) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the coupled boundary is driven by the host, '// & 'not a deck motionFile; remove the motionFile OPTION'); RETURN END IF + IF (own_motion) THEN + ! the deck's table moves the Coupled/Vessel line points; the caller marches it from the + ! deck pose (no host placement) over lines between Fixed/Coupled/Vessel points only + dynamic_points = deck_has_dynamic_points(points) + IF (dynamic_points .OR. SIZE(bodies) > 0 .OR. n_rod > 0 .OR. nturb > 0 .OR. & + PRESENT(ptfm_init) .OR. PRESENT(coupled_positions) .OR. PRESENT(farm_ptfm_init)) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a deck-prescribed motion drives lines between '// & + 'Fixed/Coupled/Vessel points only, from the deck pose'); RETURN + END IF + END IF IF (SIZE(lines) == 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: deck defines no lines'); RETURN END IF @@ -7923,6 +8068,13 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_Deck_Aggregate(agg); RETURN END IF + ! The deck's own prescribed motion over the same moving-set order. + IF (own_motion) THEN + CALL build_aggregate_motion(points, lines, is_fin, opts, agg%motion, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) THEN + CALL CD_End_Deck_Aggregate(agg); RETURN + END IF + END IF ! Range graphs and touchdown channels: fix the TDP references at the converged state. BLOCK @@ -8483,10 +8635,204 @@ SUBROUTINE CD_End_Deck_Aggregate(agg) agg%has_rod = .FALSE. agg%has_point3 = .FALSE. CALL CD_Range_End(agg%ranges) + CALL CD_Motion_End(agg%motion) agg%gravity = CD_ZERO agg%rho_water = CD_ZERO END SUBROUTINE CD_End_Deck_Aggregate + SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrMsg) + !! The deck's motionFile or vesselMotion table, keyed to the aggregate moving-set order (the + !! enumeration of apply_coupled_positions: the system's BOUND Coupled/Vessel points in deck + !! POINT order, then one coupled fairlead per finite-EI cable in deck LINE order). The roll + !! column of a motionFile drives the moving End A of a line solved in torsion whose End A is + !! restrained, as on the standalone cubic-Hermite route (check_motion_roll_lines). + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(IN) :: lines(:) + LOGICAL, INTENT(IN) :: is_fin(:) + TYPE(DeckOptions), INTENT(IN) :: opts + TYPE(CD_MotionRuntimeType), INTENT(INOUT) :: rt + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: i, l, n, pass, ip + LOGICAL :: bound_ei0 + + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + CALL CD_Motion_End(rt) + CALL read_motion_file(opts%motion_file, points, opts, rt%motion, ErrStat, ErrMsg, & + with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))])) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL check_motion_roll_lines(rt%motion, lines, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! pass 1 counts the moving columns, pass 2 fills them + DO pass = 1, 2 + n = 0 + DO i = 1, SIZE(points) + SELECT CASE (TRIM(points(i)%ptype)) + CASE ('coupled', 'vessel') + bound_ei0 = .FALSE. + DO l = 1, SIZE(lines) + IF (is_fin(l)) CYCLE + IF (lines(l)%nodeA == points(i)%id .OR. lines(l)%nodeB == points(i)%id) THEN + bound_ei0 = .TRUE.; EXIT + END IF + END DO + IF (bound_ei0) THEN + n = n + 1 + IF (pass == 2) CALL set_column(n, i, .FALSE.) + END IF + END SELECT + END DO + DO l = 1, SIZE(lines) + IF (.NOT. is_fin(l)) CYCLE + DO i = 1, SIZE(points) + IF (points(i)%id /= lines(l)%nodeA .AND. points(i)%id /= lines(l)%nodeB) CYCLE + SELECT CASE (TRIM(points(i)%ptype)) + CASE ('coupled', 'vessel') + n = n + 1 + IF (pass == 2) CALL set_column(n, i, rt%motion%has_roll .AND. line_torsion_at_a(lines(l)) .AND. & + points(i)%id == lines(l)%nodeA) + END SELECT + END DO + END DO + IF (pass == 1) ALLOCATE (rt%col_point(n), rt%col_pos(3, n), rt%col_roll(n)) + END DO + IF (ErrStat /= CD_DECKDRV_OK) RETURN + rt%active = .TRUE. + + CONTAINS + + SUBROUTINE set_column(col, ipt, takes_roll) + INTEGER, INTENT(IN) :: col, ipt + LOGICAL, INTENT(IN) :: takes_roll + ip = find_motion_point(rt%motion, points(ipt)%id) + IF (ip < 1) THEN + CALL fail(ErrStat, ErrMsg, 'the prescribed motion has no rows for point '//TRIM(int_to_str(points(ipt)%id))) + ip = 1 + END IF + rt%col_point(col) = ip + rt%col_pos(:, col) = points(ipt)%pos + rt%col_roll(col) = takes_roll + END SUBROUTINE set_column + END SUBROUTINE build_aggregate_motion + + LOGICAL FUNCTION CD_Motion_Active(rt) RESULT(active) + !! The schedule holds the deck's prescribed motion. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + active = rt%active + END FUNCTION CD_Motion_Active + + INTEGER FUNCTION CD_Motion_NColumns(rt) RESULT(n) + !! Moving columns the schedule drives (0 when inactive). + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + n = 0 + IF (rt%active) n = SIZE(rt%col_point) + END FUNCTION CD_Motion_NColumns + + LOGICAL FUNCTION CD_Motion_Has_Rotation(rt) RESULT(has) + !! A vesselMotion table: the moving points turn with the vessel. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + has = .FALSE. + IF (rt%active) has = rt%motion%has_rot + END FUNCTION CD_Motion_Has_Rotation + + LOGICAL FUNCTION CD_Motion_Has_Roll(rt) RESULT(has) + !! A motionFile roll column drives some column (a line restrained in torsion). + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + has = .FALSE. + IF (rt%active) has = ANY(rt%col_roll) + END FUNCTION CD_Motion_Has_Roll + + SUBROUTINE CD_Motion_Deck_Positions(rt, position, ErrStat, ErrMsg) + !! Deck position of the point that drives each moving column (3, n): the caller checks the + !! column map against its own moving surface at the static state. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + REAL(wp), INTENT(OUT) :: position(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + position = CD_ZERO + ErrStat = CD_DECKDRV_BADINPUT + IF (.NOT. rt%active) THEN + ErrMsg = 'CD_Motion_Deck_Positions: no prescribed motion'; RETURN + END IF + IF (SIZE(position, 1) /= 3 .OR. SIZE(position, 2) /= SIZE(rt%col_point)) THEN + ErrMsg = 'CD_Motion_Deck_Positions: position must be shaped (3, n_columns)'; RETURN + END IF + position = rt%col_pos + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + END SUBROUTINE CD_Motion_Deck_Positions + + SUBROUTINE CD_Motion_Kinematics(rt, time_index, position, velocity, acceleration, orientation, angular_velocity, & + angular_acceleration, roll, ErrStat, ErrMsg) + !! Grid row time_index (1 = t 0) of the moving surface, columns in the aggregate moving-set + !! order: position, velocity and acceleration of each driving point (3, n); the + !! global-to-parent DCM (3, 3, n) and the global-axis angular velocity and acceleration + !! (3, n) -- the vessel's under a vesselMotion table, the identity and zero otherwise, so a + !! motionFile turns no frame -- and the motionFile roll [rad] of each column that takes one + !! (zero elsewhere). Allocation free. + TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt + INTEGER, INTENT(IN) :: time_index + REAL(wp), INTENT(OUT) :: position(:, :), velocity(:, :), acceleration(:, :) + REAL(wp), INTENT(OUT) :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: col, ip, n + + ErrStat = CD_DECKDRV_BADINPUT + ErrMsg = '' + IF (.NOT. rt%active) THEN + ErrMsg = 'CD_Motion_Kinematics: no prescribed motion'; RETURN + END IF + n = SIZE(rt%col_point) + IF (SIZE(position, 1) /= 3 .OR. SIZE(position, 2) /= n .OR. SIZE(velocity, 1) /= 3 .OR. & + SIZE(velocity, 2) /= n .OR. SIZE(acceleration, 1) /= 3 .OR. SIZE(acceleration, 2) /= n .OR. & + SIZE(orientation, 1) /= 3 .OR. SIZE(orientation, 2) /= 3 .OR. SIZE(orientation, 3) /= n .OR. & + SIZE(angular_velocity, 1) /= 3 .OR. SIZE(angular_velocity, 2) /= n .OR. & + SIZE(angular_acceleration, 1) /= 3 .OR. SIZE(angular_acceleration, 2) /= n .OR. SIZE(roll) /= n) THEN + ErrMsg = 'CD_Motion_Kinematics: arrays must be shaped (3, n), (3, 3, n) and (n) over the moving columns' + RETURN + END IF + IF (time_index < 1 .OR. time_index > rt%motion%n_time) THEN + ErrMsg = 'CD_Motion_Kinematics: time index '//TRIM(int_to_str(time_index))//' outside the motion grid of '// & + TRIM(int_to_str(rt%motion%n_time))//' rows' + RETURN + END IF + DO col = 1, n + ip = rt%col_point(col) + position(:, col) = rt%motion%q(:, ip, time_index) + velocity(:, col) = rt%motion%v(:, ip, time_index) + acceleration(:, col) = rt%motion%a(:, ip, time_index) + IF (rt%motion%has_rot) THEN + ! the vessel-to-global rotation R: the parent DCM is its transpose (global to vessel) + orientation(:, :, col) = TRANSPOSE(rt%motion%rot(:, :, time_index)) + angular_velocity(:, col) = rt%motion%omega(:, time_index) + angular_acceleration(:, col) = rt%motion%alpha(:, time_index) + ELSE + orientation(:, :, col) = CD_ZERO + orientation(1, 1, col) = CD_ONE + orientation(2, 2, col) = CD_ONE + orientation(3, 3, col) = CD_ONE + angular_velocity(:, col) = CD_ZERO + angular_acceleration(:, col) = CD_ZERO + END IF + roll(col) = CD_ZERO + IF (rt%col_roll(col)) roll(col) = rt%motion%roll(ip, time_index) + END DO + ErrStat = CD_DECKDRV_OK + END SUBROUTINE CD_Motion_Kinematics + + SUBROUTINE CD_Motion_End(rt) + !! Release the schedule. Idempotent. + TYPE(CD_MotionRuntimeType), INTENT(INOUT) :: rt + TYPE(MotionTable) :: empty + rt%motion = empty + IF (ALLOCATED(rt%col_point)) DEALLOCATE (rt%col_point) + IF (ALLOCATED(rt%col_pos)) DEALLOCATE (rt%col_pos) + IF (ALLOCATED(rt%col_roll)) DEALLOCATE (rt%col_roll) + rt%active = .FALSE. + END SUBROUTINE CD_Motion_End + SUBROUTINE CD_Run_Deck_Driver(deck_path, out_root, converged, ErrStat, ErrMsg) !! Parse a MoorDyn-style deck, run static IC and optional held-end dynamic march, !! write `.out`. @@ -8539,14 +8885,16 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (ANY([(CD_Is_Line_Node_Channel(channels(j)), j=1, SIZE(channels))]) .OR. & ANY([(line_outputs_requested(lines(j)%outputs), j=1, SIZE(lines))])) & WRITE (output_unit, '(A)') ' Note: '//CD_LINE_NODE_NUMBERING_NOTE//'.' - ! Torsion (both ends of a line torsionally restrained) runs on the standalone cubic-Hermite - ! route and the multibody march, in statics and dynamics (quasi-static torsion: no torsional - ! inertia). One restrained end carries no torque (the other end is free to twist), so it is - ! noted and ignored. + ! Torsion (a line torsionally restrained at both ends, or at one with the other free to + ! twist) runs on the standalone cubic-Hermite route, the multibody march and the mixed + ! EI = 0 + finite-EI aggregate, in statics and in dynamics with the nodal twist's polar + ! inertia and the torque-tension coupling. A line restrained at one end only whose torsion + ! is not solved (resolve_one_end_torsion) is noted with the reason. DO li = 1, SIZE(lines) - IF (COUNT(lines(li)%tors_mode /= TORS_FREE) == 1) WRITE (output_unit, '(A)') ' Note: line '// & - TRIM(int_to_str(lines(li)%id))//' is torsionally restrained at one end only; with the other end free '// & - 'to twist it carries no torque, so no torsion is solved.' + IF (COUNT(lines(li)%tors_mode /= TORS_FREE) == 1 .AND. lines(li)%tors_free_end == 0 .AND. & + LEN_TRIM(lines(li)%tors_note) > 0) WRITE (output_unit, '(A)') ' Note: line '// & + TRIM(int_to_str(lines(li)%id))//' is torsionally restrained at one end only and its torsion is not '// & + 'solved: '//TRIM(lines(li)%tors_note)//'.' END DO ! rhoInf near 1 leaves the march without numerical dissipation of the modes dtM does not ! resolve (axial waves, slack-taut transitions). In an irregular sea a finite-EI lazy wave @@ -12062,7 +12410,8 @@ END SUBROUTINE solve_one_line SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven, env_gravity, env_rho_water, env_wtrdpth, & - allow_turbine, failures, controls, run_tmax, allow_static_finite_ei, host_coupled_objects) + allow_turbine, failures, controls, run_tmax, allow_static_finite_ei, host_coupled_objects, & + static_run) !! Sectioned MoorDyn-style parser. Sections: LINE TYPES / BODIES / ROD TYPES / RODS / !! POINTS / LINES / SECTIONS / OPTIONS / OUTPUTS (TABLE sections skip the column-name !! + units rows). Unsupported variants fail closed during validation. @@ -12098,6 +12447,10 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti ! host_coupled_objects: ONLY the CompMooring=5 aggregate drives Coupled/Vessel rods/bodies from its ! host mesh; every other entry point keeps the motionFile requirement. LOGICAL, INTENT(IN), OPTIONAL :: host_coupled_objects + ! static_run: a caller-driven deck whose caller marches no step (the standalone driver's + ! TMax = 0 run on the aggregate): a line restrained in torsion at one end is then resolved + ! as in a static run, needing no force-blended step (resolve_one_end_torsion) + LOGICAL, INTENT(IN), OPTIONAL :: static_run ! FAILURE rows. A deck DECLARING failures parsed by an entry point that does not ! consume them fails closed (never silently ignore a declared failure). TYPE(DeckFailure), ALLOCATABLE, INTENT(OUT), OPTIONAL :: failures(:) @@ -12119,7 +12472,7 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti INTEGER, ALLOCATABLE :: stf_lines(:) INTEGER :: n_stf CHARACTER(2*NAMELEN), ALLOCATABLE :: channel_keys(:) - LOGICAL :: ext_march, types_stock_cols, rodtypes_legacy_cols, turb_ok, static_finite_ok + LOGICAL :: ext_march, types_stock_cols, rodtypes_legacy_cols, turb_ok, static_finite_ok, tors_marched INTEGER :: unit, ios, section, nt, nb, nrt, nr, np, nlin, nsec, neq, nch, nfl, nct, nec, lineno CHARACTER(DECK_RECLEN) :: line ! list_safe_row output: every token may gain a pair of quotes @@ -12461,7 +12814,10 @@ SUBROUTINE parse_deck(path, types, bodies, rod_types, rods, points, lines, secti RETURN END IF END DO - CALL normalize_stock_endpoint_order(points, lines, sections) + CALL normalize_stock_endpoint_order(points, lines, sections, types) + tors_marched = ext_march + IF (PRESENT(static_run)) tors_marched = ext_march .AND. .NOT. static_run + CALL resolve_one_end_torsion(types, bodies, rods, points, lines, sections, opts, tors_marched) CALL finalize_and_validate(types, bodies, rod_types, rods, points, lines, sections, opts, channels, ext_march, & static_finite_ok, ErrStat, ErrMsg, channel_lines) IF (ErrStat == 0) CALL set_azimuth_ranges(points, lines) @@ -16816,7 +17172,7 @@ SUBROUTINE set_azimuth_ranges(points, lines) END DO END SUBROUTINE set_azimuth_ranges - SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) + SUBROUTINE normalize_stock_endpoint_order(points, lines, sections, types) !! Stock MoorDyn decks write lines anchor (End A) -> fairlead (End B); the CableDyn !! deck convention is the reverse (End A = fairlead side, End B = anchor). When a !! line arrives in stock order -- NodeA a Fixed anchor, NodeB a Coupled/Vessel/ @@ -16827,12 +17183,17 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) !! point ids are untouched. The normalization runs on dynamic-point decks too: their !! anchored Fixed<->Coupled legs carry the same stock-order convention (a clump-split !! farm deck's anchor legs would otherwise reach the builders reversed). + !! A finite-EI line (types given) from a Fixed NodeA to a rod end NodeB swaps too: such a + !! line runs only from the rod (End A, on the multibody march) to a Fixed End B, so the + !! stock row would otherwise stop. An EI = 0 line to a rod end keeps its written order. TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(INOUT) :: lines(:) TYPE(DeckSection), INTENT(INOUT) :: sections(:) + TYPE(DeckLineType), INTENT(IN), OPTIONAL :: types(:) INTEGER :: i, ia, ib, tmp, mode_tmp REAL(wp) :: k_tmp, ez_tmp(3) CHARACTER(NAMELEN) :: ta, tb + LOGICAL :: rod_b DO i = 1, SIZE(lines) ia = find_point(points, lines(i)%nodeA) ib = find_point(points, lines(i)%nodeB) @@ -16849,8 +17210,12 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) ! that line is already in CableDyn order (End A = upper end) and is left as written, ! so the internal anchor->fairlead model keeps its fairlead above its anchor. (Both ! positions are global there; Coupled/Vessel/Body points may be body-relative.) + rod_b = .FALSE. + IF (PRESENT(types) .AND. TRIM(ta) == 'fixed') THEN + IF (is_rod_point_type(tb)) rod_b = finite_ei_by_name(lines(i)%id) + END IF IF (TRIM(ta) == 'fixed' .AND. (TRIM(tb) == 'coupled' .OR. TRIM(tb) == 'vessel' .OR. & - starts_with(TRIM(tb), 'body') .OR. & + starts_with(TRIM(tb), 'body') .OR. rod_b .OR. & ((TRIM(tb) == 'free' .OR. TRIM(tb) == 'connect') .AND. & points(ia)%pos(3) <= points(ib)%pos(3)))) THEN tmp = lines(i)%nodeA @@ -16888,6 +17253,19 @@ SUBROUTINE normalize_stock_endpoint_order(points, lines, sections) CALL reverse_line_sections(sections, lines(i)%id) END IF END DO + CONTAINS + LOGICAL FUNCTION finite_ei_by_name(line_id) RESULT(fin) + !! line_is_finite_ei before the SECTIONS line types are resolved (by name). + INTEGER, INTENT(IN) :: line_id + INTEGER :: j, it + fin = .FALSE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= line_id) CYCLE + it = find_type(types, sections(j)%ltype_name) + IF (it < 1) CYCLE + IF (types(it)%ei > CD_ZERO) fin = .TRUE. + END DO + END FUNCTION finite_ei_by_name END SUBROUTINE normalize_stock_endpoint_order SUBROUTINE reverse_line_sections(sections, line_id) @@ -17959,6 +18337,13 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio ! as pinned, while retaining finite/rigid connections at either end of every ! supported Fixed-End-B cable. j = find_point(points, lines(i)%nodeB) + IF (j > 0) THEN + IF (is_rod_point_type(points(j)%ptype)) THEN + CALL fail(ErrStat, ErrMsg, 'non-pinned END CONNECTIONS require a finite-EI line with Fixed End B; '// & + 'line '//TRIM(int_to_str(lines(i)%id))//ROD_END_B_NOTE) + RETURN + END IF + END IF IF (j < 1 .OR. TRIM(points(j)%ptype) /= 'fixed') THEN CALL fail(ErrStat, ErrMsg, 'non-pinned END CONNECTIONS require a finite-EI line with Fixed End B; '// & 'the two-moving-end compatibility solver does not apply bending connections') @@ -17995,12 +18380,22 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio SUBROUTINE check_torsion_line(ln, es_t, em_t) !! A line with a torsional END CONNECTIONS restraint: a finite-EI (cubic-Hermite) line. With !! both ends restrained (torsion active) End B must be Fixed, every section's LINE TYPES row - !! must give an explicit GJ, End A may not be a rod end, and a body End A must be a Rigid6 - !! body. + !! must give an explicit GJ, a body End A must be a Rigid6 body, and a rod End A must be on a + !! Fixed rod. + !! + !! The End A torsion frame (director, reference normal) is held by End A's parent and turns + !! with its whole orientation, its roll about the line included. A Fixed rod holds it still, + !! as a Fixed point does; the ends of a rod fixed to a Rigid6 body (RODS type Body) are + !! points of the body (resolve_rod_end_tokens) and turn with it. A Free or Pinned rod (also + !! BodyPinned, CoupledPinned) is an axisymmetric body: no load acts about its axis, its + !! static solve has no roll angle and its roll in the dynamics is never loaded, so the line's + !! torque would have nothing to react it. A Coupled/Vessel rod carries no finite-EI line on + !! any route of this build (the multibody march takes no motionFile, the coupled aggregate no + !! rod beside a finite-EI cable), so its host-driven frame is not wired to the torsion. TYPE(DeckLine), INTENT(IN) :: ln INTEGER, INTENT(OUT) :: es_t CHARACTER(*), INTENT(OUT) :: em_t - INTEGER :: js, jp, jb + INTEGER :: js, jp, jb, rid, rend CHARACTER(32) :: lid es_t = 0 em_t = '' @@ -18010,8 +18405,25 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) 'finite-EI line; line '//TRIM(lid)//' has EI = 0') RETURN END IF - ! one restrained end only carries no torque (noted and ignored): the rules below apply to a - ! line restrained at both ends + ! one restrained end only: solved in torsion where resolve_one_end_torsion found the rules + ! below met, otherwise noted (no torsion); the rules apply to a line restrained at both ends. + ! A solved one's imposed twist is its restrained end's Pretwist (the free end's is 0), within + ! the same 1000 turns. + IF (ln%tors_free_end > 0) THEN + js = 3 - ln%tors_free_end + IF (ABS(ln%tors_pretwist(js)) > CD_HTORS_MAX_TWIST) THEN + BLOCK + CHARACTER(32) :: tw + INTEGER :: tw_ios + tw = '' + WRITE (tw, '(ES12.5)', IOSTAT=tw_ios) ln%tors_pretwist(js)/DEG2RAD_TORS + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': the Pretwist of its restrained End '// & + MERGE('A', 'B', js == 1)//' = '//TRIM(ADJUSTL(tw))//' deg exceeds 1000 turns '// & + '(360000 deg), the largest twist') + END BLOCK + END IF + RETURN + END IF IF (.NOT. ALL(ln%tors_mode /= TORS_FREE)) RETURN IF (ABS(ln%tors_pretwist(2) - ln%tors_pretwist(1)) > CD_HTORS_MAX_TWIST) THEN BLOCK @@ -18026,6 +18438,11 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) END IF jp = find_point(points, ln%nodeB) IF (jp < 1) RETURN + IF (is_rod_point_type(points(jp)%ptype)) THEN + CALL fail(es_t, em_t, 'torsional END CONNECTIONS require a finite-EI line with Fixed End B; line '// & + TRIM(lid)//ROD_END_B_NOTE) + RETURN + END IF IF (TRIM(points(jp)%ptype) /= 'fixed') THEN CALL fail(es_t, em_t, 'torsional END CONNECTIONS require a finite-EI line with Fixed End B; line '// & TRIM(lid)//' has two moving ends') @@ -18044,9 +18461,26 @@ SUBROUTINE check_torsion_line(ln, es_t, em_t) jp = find_point(points, ln%nodeA) IF (jp < 1) RETURN IF (is_rod_point_type(points(jp)%ptype)) THEN - CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on a rod end is not supported '// & - '(a rod has no spin angle in this build)') - RETURN + CALL parse_rod_point_type(points(jp)%ptype, rid, rend) + jb = find_rod(rods, rid) + IF (jb > 0) THEN + SELECT CASE (TRIM(rods(jb)%rod_type)) + CASE ('fixed') + CASE ('coupled', 'vessel') + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on the end of Coupled/Vessel '// & + 'ROD '//TRIM(int_to_str(rid))//' is not supported: no route of this build carries a '// & + 'finite-EI line on a host-driven rod') + RETURN + CASE DEFAULT + CALL fail(es_t, em_t, 'line '//TRIM(lid)//': a torsional END CONNECTION on the end of ROD '// & + TRIM(int_to_str(rid))//' ('//TRIM(rods(jb)%rod_type)//') is not supported: a free or '// & + 'pinned rod is axisymmetric, with no roll about its own axis (no load acts about the axis '// & + 'and its static solve has no roll angle), so it cannot hold the line''s torque; restrain '// & + 'End A on a Fixed rod, on a rod fixed to a Rigid6 body (RODS type Body), on a Rigid6 '// & + 'body point or on a Fixed point') + RETURN + END SELECT + END IF END IF IF (starts_with(TRIM(points(jp)%ptype), 'body')) THEN jb = find_body(bodies, points(jp)%body_id) @@ -20230,7 +20664,8 @@ SUBROUTINE object_channel_value(ch, val, found, rigid, rods, points, opts, time, !! MoorDyn's roll and pitch of the axis from the vertical [deg]. Loads are evaluated at the !! committed state: Body F/M is the net external load about the reference point, Rod F/M !! about End A (weight, buoyancy, hydrodynamic and seabed loads, external loads, the line - !! end forces and, for a body, its fixed rods and the pin forces of its pinned rods); Rod + !! end forces, the connection moments of clamped cables and, for a body, its fixed rods and + !! the pin forces of its pinned rods); Rod !! TenA/TenB is the magnitude of the summed line force at End A/B, Sub the submerged !! fraction of its length. CHARACTER(*), INTENT(IN) :: ch @@ -20500,7 +20935,8 @@ END SUBROUTINE body_net_wrench SUBROUTINE rod_net_wrench(rs, body_of, points, opts, time, f6, ten, sub, ErrStat, ErrMsg, system, mb, bathymetry, & added6) !! Net external force and moment on a rod about its End A (global axes) at its committed - !! state (weight, buoyancy, Morison and seabed loads, the line forces at its ends), the + !! state (weight, buoyancy, Morison and seabed loads, the line forces at its ends and the + !! connection moments, bending and torque, of the cables clamped there), the !! summed line force magnitudes at End A and End B, and its submerged length fraction. !! body_of > 0: the rod is fixed to that body, and its end lines are the body attachment !! points made from its ends (DeckPoint rod_ref/rod_end). added6: its 6x6 added mass @@ -20558,12 +20994,21 @@ SUBROUTINE rod_net_wrench(rs, body_of, points, opts, time, f6, ten, sub, ErrStat ten(2) = NORM2(fe(:, 2)) f = f + fe(:, 1) + fe(:, 2) m = m + cross3(pb - pa, fe(:, 2)) - ! the connection moments of the cables clamped (or elastically connected) to the rod's ends - IF (PRESENT(mb) .AND. body_of == 0) THEN + ! the connection moments of the cables clamped (or elastically connected) to the rod's ends: + ! on a rod of the march its rod-end attachments, on a rod fixed to a body the body points made + ! from its ends (whose cables the body carries) + IF (PRESENT(mb)) THEN IF (ALLOCATED(mb%cab_mend)) THEN DO ip = 1, SIZE(mb%cables) - IF (mb%cab_kind(ip) /= 2) CYCLE - IF (mb%rods(mb%cab_obj(ip))%rod_id == rs%rod_id) m = m + mb%cab_mend(:, ip) + IF (body_of == 0) THEN + IF (mb%cab_kind(ip) /= 2) CYCLE + IF (mb%rods(mb%cab_obj(ip))%rod_id == rs%rod_id) m = m + mb%cab_mend(:, ip) + ELSE + IF (mb%cab_kind(ip) /= 1 .OR. mb%cab_obj(ip) /= body_of .OR. .NOT. ALLOCATED(mb%cable_points)) CYCLE + e = find_point(points, mb%cable_points(1, ip)) + IF (e < 1) CYCLE + IF (points(e)%rod_ref == rs%rod_id .AND. points(e)%rod_end > 0) m = m + mb%cab_mend(:, ip) + END IF END DO END IF END IF @@ -21169,12 +21614,21 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 'standalone driver runs with its Coupled points held still (that route takes no motionFile '// & 'either)'); RETURN END IF - IF (lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED .AND. TRIM(points(pa)%ptype) /= 'fixed') THEN - ! a clamped or elastic End A on a body or rod: implicit (monolithic step) only + IF ((lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_at_a(lines(i))) .AND. & + TRIM(points(pa)%ptype) /= 'fixed') THEN + ! a clamped, elastic or torsionally restrained End A on a body or rod: implicit (monolithic + ! step) only; the staggered step drives the cable end by translation, so its End A frame + ! would not turn with the object nor return the torque IF (opts%body_scheme_staggered) THEN - CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a clamped or '// & - 'elastic END CONNECTION on a body or rod needs bodyScheme monolithic (the staggered '// & - 'scheme couples cable ends as point forces)') + IF (lines(i)%endconn_mode(1) /= CD_ENDCONN_PINNED) THEN + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a clamped or '// & + 'elastic END CONNECTION on a body or rod needs bodyScheme monolithic (the staggered '// & + 'scheme couples cable ends as point forces)') + ELSE + CALL fail(ErrStat, ErrMsg, 'finite-EI LINE '//TRIM(int_to_str(lines(i)%id))//': a torsional END '// & + 'CONNECTION on a body or rod needs bodyScheme monolithic (the staggered scheme drives cable '// & + 'ends by translation and couples them as point forces)') + END IF RETURN END IF BLOCK @@ -21271,19 +21725,20 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod pc = points pa = find_point(points, cab_lines(c)%nodeA) IF (TRIM(pc(pa)%ptype) /= 'fixed') pc(pa)%ptype = 'coupled' - mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_active(cab_lines(c))) & + mb%cab_clamp(c) = (cab_lines(c)%endconn_mode(1) /= CD_ENDCONN_PINNED .OR. line_torsion_at_a(cab_lines(c))) & .AND. TRIM(points(pa)%ptype) /= 'fixed' IF (mb%cab_clamp(c)) THEN ! End A clamped or elastic on its object: the connection direction is stored in the object ! frame and turns with the object's orientation (the OpenFAST parent-frame contract) BLOCK TYPE(DeckLine) :: lnc - REAL(wp) :: rclamp(3, 3), dclamp(3) + REAL(wp) :: rclamp(3, 3), dclamp(3), nclamp(3) lnc = cab_lines(c) CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, & - check_axis=.NOT. opts%body_ic_static) + check_axis=.NOT. opts%body_ic_static, nx0=nclamp) IF (ErrStat /= CD_DECKDRV_OK) GOTO 900 lnc%endconn_ez_ref(:, 1) = dclamp + lnc%tors_nx(:, 1) = nclamp CALL build_one_hermite_cable(lnc, sections, types, pc, opts, opts%dtM, mb%cables(c), node, & ErrStat, ErrMsg, standalone_controls=.TRUE., bathymetry=bathymetry, & fairlead_orientation=TRANSPOSE(rclamp), install_viv=.TRUE., & @@ -23426,7 +23881,9 @@ SUBROUTINE mb_torsion_turn_limit(mb, x, dt, beta_na, limited) limited = .FALSE. IF (.NOT. ALLOCATED(mb%cables)) RETURN DO c = 1, SIZE(mb%cables) + ! (a free End A: the body's turn does not twist the line) IF (mb%cab_kind(c) /= 1 .OR. .NOT. mb%cables(c)%line%torsion%active) CYCLE + IF (mb%cables(c)%line%torsion%end_free(2)) CYCLE ib = mb%cab_obj(c) o = mb%jb_off(ib) IF (o < 0) CYCLE @@ -27057,7 +27514,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, ALLOCATE (cl(0)) IF (.NOT. only_points .AND. .NOT. PRESENT(jac_check_err) .AND. opts%body_ic_static) THEN DO j = 1, SIZE(lines) - IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_active(lines(j))) CYCLE + IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) CYCLE IF (.NOT. line_is_finite_ei(lines(j), types, sections)) CYCLE pa = find_point(points, lines(j)%nodeA) IF (pa < 1) CYCLE @@ -27090,7 +27547,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, pass_tol_eff = PASS_TOL DO e = 1, ncl ext_pt(e) = find_point(points, lines(cl(e))%nodeA) - IF (line_torsion_active(lines(cl(e)))) pass_tol_eff = PASS_TOL_TORSION + IF (line_torsion_at_a(lines(cl(e)))) pass_tol_eff = PASS_TOL_TORSION END DO ext_fm = CD_ZERO ext_km = CD_ZERO @@ -27157,17 +27614,19 @@ SUBROUTINE hermite_end_loads(jl, fm, km, rot) TYPE(CD_HFMF_ModuleType) :: cab TYPE(DeckLine) :: lnc TYPE(DeckPoint), ALLOCATABLE :: pc(:) - REAL(wp) :: rclamp(3, 3), dclamp(3), dtb + REAL(wp) :: rclamp(3, 3), dclamp(3), nclamp(3), dtb INTEGER :: node, es CHARACTER(1024) :: note CHARACTER(1024) :: em fm = CD_ZERO km = CD_ZERO lnc = lines(jl) - CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, check_axis=.FALSE.) + CALL clamp_object_frame(lnc, points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, check_axis=.FALSE., & + nx0=nclamp) rot = rclamp IF (ErrStat /= CD_DECKDRV_OK) RETURN lnc%endconn_ez_ref(:, 1) = dclamp + lnc%tors_nx(:, 1) = nclamp pc = points pc(find_point(points, lnc%nodeA))%ptype = 'coupled' dtb = CD_ONE @@ -29768,6 +30227,9 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca IF (ErrStat /= CD_DECKDRV_OK) RETURN CALL check_motion_roll(ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN + ! The static configuration, before row 1 moves the fairlead. + CALL write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) + IF (ErrStat /= CD_DECKDRV_OK) RETURN ! Install row 1 without advancing the cable clock. The first pass makes the ! t=0 fluid sample use the prescribed geometry. The held-field setter refreshes ! the consistent free acceleration and deliberately zeros fixed DOFs, so repeat @@ -29810,7 +30272,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CALL write_hermite_model_row(unit, CD_ZERO, channels, lines, points, cables, ErrStat, ErrMsg, & motion=motion, motion_time_index=MERGE(1, 0, opts%has_motion_file), & has_motion=opts%has_motion_file, ranges=ranges) - IF (ErrStat == CD_DECKDRV_OK) & + IF (ErrStat == CD_DECKDRV_OK .AND. .NOT. opts%has_motion_file) & CALL write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) IF (ErrStat == CD_DECKDRV_OK) & CALL write_dynamic_hermite_line_outputs(CD_ZERO, lines, cables, pos_units, ten_units, ErrStat, ErrMsg, & @@ -29845,7 +30307,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca u_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), & u_angular_velocity=motion%omega(:, step + 1), & u_angular_acceleration=motion%alpha(:, step + 1)) - ELSE IF (motion%has_roll .AND. line_torsion_active(lines(i)) .AND. & + ELSE IF (motion%has_roll .AND. line_torsion_at_a(lines(i)) .AND. & find_motion_point(motion, lines(i)%nodeA) > 0) THEN ! imposed roll of End A about its director: Phi = Pretwist(B) - (Pretwist(A) + roll) CALL CD_HFMF_UpdateStates(cables(i), up, uv, ua, es, em, & @@ -29926,37 +30388,45 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CONTAINS SUBROUTINE check_motion_roll(est, emt) - !! The motionFile roll column drives a torsional line through its moving end only (internal - !! End A after the anchor-first swap: the user's End A, or End B of an anchor-first deck), - !! right-handed about the tangent pointing into the line, so Phi = Pretwist(B) - - !! Pretwist(A) - roll in either order; it starts from the static state (roll 0 at t = 0). INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt - INTEGER :: ip, li - LOGICAL :: used - est = CD_DECKDRV_OK - emt = '' - IF (.NOT. motion%has_roll) RETURN - DO ip = 1, motion%n_point - IF (.NOT. ANY(ABS(motion%roll(ip, :)) > CD_ZERO)) CYCLE - used = .FALSE. - DO li = 1, SIZE(lines) - IF (lines(li)%nodeA == motion%point_ids(ip) .AND. line_torsion_active(lines(li))) used = .TRUE. - END DO - IF (.NOT. used) THEN - CALL fail(est, emt, 'motionFile: point '//TRIM(int_to_str(motion%point_ids(ip)))//' has a non-zero roll '// & - 'column, but no line restrained in torsion at both ends (END CONNECTIONS TorsStiffness) '// & - 'has its moving (non-Fixed) end there'); RETURN - END IF - IF (ABS(motion%roll(ip, 1)) > CD_ZERO) THEN - CALL fail(est, emt, 'motionFile: the roll column of point '//TRIM(int_to_str(motion%point_ids(ip)))// & - ' must be 0 at t = 0 (the static solve uses the END CONNECTIONS Pretwist, which takes a '// & - 'constant twist)'); RETURN - END IF - END DO + CALL check_motion_roll_lines(motion, lines, est, emt) END SUBROUTINE check_motion_roll END SUBROUTINE write_hermite_dynamic_out + SUBROUTINE check_motion_roll_lines(motion, lines, est, emt) + !! The motionFile roll column drives a torsional line through its moving end only (internal + !! End A after the anchor-first swap: the user's End A, or End B of an anchor-first deck), + !! right-handed about the tangent pointing into the line, so Phi = Pretwist(B) - + !! Pretwist(A) - roll in either order; it starts from the static state (roll 0 at t = 0). + TYPE(MotionTable), INTENT(IN) :: motion + TYPE(DeckLine), INTENT(IN) :: lines(:) + INTEGER, INTENT(OUT) :: est + CHARACTER(*), INTENT(OUT) :: emt + INTEGER :: ip, li + LOGICAL :: used + est = CD_DECKDRV_OK + emt = '' + IF (.NOT. motion%has_roll) RETURN + DO ip = 1, motion%n_point + IF (.NOT. ANY(ABS(motion%roll(ip, :)) > CD_ZERO)) CYCLE + used = .FALSE. + DO li = 1, SIZE(lines) + IF (lines(li)%nodeA == motion%point_ids(ip) .AND. line_torsion_at_a(lines(li))) used = .TRUE. + END DO + IF (.NOT. used) THEN + CALL fail(est, emt, 'motionFile: point '//TRIM(int_to_str(motion%point_ids(ip)))//' has a non-zero roll '// & + 'column, but no line restrained in torsion (END CONNECTIONS TorsStiffness) at its moving '// & + '(non-Fixed) end has that end there'); RETURN + END IF + IF (ABS(motion%roll(ip, 1)) > CD_ZERO) THEN + CALL fail(est, emt, 'motionFile: the roll column of point '//TRIM(int_to_str(motion%point_ids(ip)))// & + ' must be 0 at t = 0 (the static solve uses the END CONNECTIONS Pretwist, which takes a '// & + 'constant twist)'); RETURN + END IF + END DO + END SUBROUTINE check_motion_roll_lines + SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg) !! Persist the converged finite-EI initialization as the same engineering range !! table emitted by the coupled OpenFAST facade. This is independent of OUTPUTS: @@ -34479,10 +34949,13 @@ SUBROUTINE check_channel(ch, lines, points, sections, ErrStat, ErrMsg, bodies, r IF (node > nelem + 1) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": node index exceeds line node count'); RETURN END IF - IF (.NOT. line_torsion_active(lines(li))) THEN + IF (.NOT. line_torsion_active(lines(li)) .AND. LEN_TRIM(lines(li)%tors_note) > 0) THEN + CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' is '// & + 'torsionally restrained at one end only and its torsion is not solved: '// & + TRIM(lines(li)%tors_note)); RETURN + ELSE IF (.NOT. line_torsion_active(lines(li))) THEN CALL fail(ErrStat, ErrMsg, 'OUTPUT "'//TRIM(ch)//'": line '//TRIM(int_to_str(line_id))//' is not '// & - 'torsionally restrained at both ends (END CONNECTIONS TorsStiffness), so it carries no '// & - 'torque'); RETURN + 'torsionally restrained (END CONNECTIONS TorsStiffness), so it carries no torque'); RETURN END IF ELSE IF (starts_with(lo, 'ten') .OR. starts_with(lo, 'curv') .OR. & starts_with(lo, 'bendmom') .OR. starts_with(lo, 'stfmom') .OR. starts_with(lo, 'l')) THEN @@ -37677,11 +38150,110 @@ PURE FUNCTION ptfm_zyx_dcm(theta) RESULT(m) END FUNCTION ptfm_zyx_dcm PURE LOGICAL FUNCTION line_torsion_active(ln) RESULT(active) - !! Condensed torsion is solved on a line only when both ends declare a torsional restraint. + !! Torsion is solved on a line whose two ends declare a torsional restraint, or one of them + !! with the other free to twist (tors_free_end, resolve_one_end_torsion). TYPE(DeckLine), INTENT(IN) :: ln - active = ALL(ln%tors_mode /= TORS_FREE) + active = ALL(ln%tors_mode /= TORS_FREE) .OR. ln%tors_free_end > 0 END FUNCTION line_torsion_active + PURE LOGICAL FUNCTION line_torsion_at_a(ln) RESULT(at_a) + !! The line is solved in torsion and its End A is restrained in torsion: End A's object takes + !! the torque, and a roll or a turn of that object twists the line. + TYPE(DeckLine), INTENT(IN) :: ln + at_a = line_torsion_active(ln) .AND. ln%tors_mode(1) /= TORS_FREE + END FUNCTION line_torsion_at_a + + SUBROUTINE resolve_one_end_torsion(types, bodies, rods, points, lines, sections, opts, caller_driven) + !! A finite-EI line restrained in torsion at one end only (the other end TorsStiffness Free, + !! or no END CONNECTIONS row there) is solved in torsion where a line restrained at both ends + !! is: every section gives GJ (the 14-column LINE TYPES row, whose Irn > 0 gives the nodal + !! twist its inertia), End B is Fixed, a march (TMax > 0, or a caller-driven deck) is + !! force-blended, and a restrained End A is on no body but a Rigid6 one and on no rod end but + !! a Fixed rod's (check_torsion_line). ATTACHMENTS, CONTROL and the modal analysis take it as + !! they take a line restrained at both ends. Its free end carries no torque and turns with + !! the twist of the line: the stretch's under torque-tension coupling, and the torsional + !! waves of the dynamics. tors_free_end is then the free deck end and its Pretwist 0 (it + !! rolls nothing: Phi is the restrained end's Pretwist alone). Otherwise the line keeps the + !! meaning of the 6-column rows and tors_note says why. Runs after the anchor-first swap; + !! sections are matched to their LINE TYPES by name (validation resolves them later). + TYPE(DeckLineType), INTENT(IN) :: types(:) + TYPE(DeckBody), INTENT(IN) :: bodies(:) + TYPE(DeckRod), INTENT(IN) :: rods(:) + TYPE(DeckPoint), INTENT(IN) :: points(:) + TYPE(DeckLine), INTENT(INOUT) :: lines(:) + TYPE(DeckSection), INTENT(IN) :: sections(:) + TYPE(DeckOptions), INTENT(IN) :: opts + LOGICAL, INTENT(IN) :: caller_driven + INTEGER :: i, j, k, ifree, ja, jb, rid, rend + LOGICAL :: finite, has_gj + CHARACTER(200) :: why + DO i = 1, SIZE(lines) + lines(i)%tors_free_end = 0 + lines(i)%tors_note = '' + IF (COUNT(lines(i)%tors_mode /= TORS_FREE) /= 1) CYCLE + ifree = MERGE(1, 2, lines(i)%tors_mode(1) == TORS_FREE) + finite = .FALSE. + has_gj = .TRUE. + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(i)%id) CYCLE + k = find_type(types, sections(j)%ltype_name) + IF (k < 1) THEN + has_gj = .FALSE. + CYCLE + END IF + IF (types(k)%ei > CD_ZERO) finite = .TRUE. + IF (.NOT. (types(k)%gj > CD_ZERO)) has_gj = .FALSE. + END DO + ! (an EI = 0 line with a torsional restraint is refused by name in finalize_checks) + IF (.NOT. finite) CYCLE + why = '' + j = find_point(points, lines(i)%nodeB) + IF (.NOT. has_gj) THEN + why = 'its LINE TYPES rows give no GJ (the 14-column row; torsion has no EI/1.3 default)' + ELSE IF (j < 1) THEN + why = 'its End B point is undefined' + ELSE IF (TRIM(points(j)%ptype) /= 'fixed') THEN + why = 'it has two moving ends (torsion needs a Fixed End B)' + ELSE IF (.NOT. opts%alpha_force_blend .AND. (caller_driven .OR. (opts%has_tmax .AND. opts%tmax > CD_ZERO))) THEN + why = 'torsion in a dynamic run needs the force-blended generalised-alpha (alpha_force_blend True)' + ELSE IF (ifree == 2) THEN + ! the restrained End A turns with its object + ja = find_point(points, lines(i)%nodeA) + IF (ja > 0) THEN + IF (is_rod_point_type(points(ja)%ptype)) THEN + ! a Fixed rod holds the End A torsion frame; a free or pinned rod is axisymmetric (no + ! roll angle to react the torque), and no route carries a finite-EI line on a + ! Coupled/Vessel rod + CALL parse_rod_point_type(points(ja)%ptype, rid, rend) + jb = find_rod(rods, rid) + IF (jb > 0) THEN + SELECT CASE (TRIM(rods(jb)%rod_type)) + CASE ('fixed') + CASE ('coupled', 'vessel') + why = 'its restrained End A is on a Coupled/Vessel rod end (no route carries a finite-EI line '// & + 'on a host-driven rod)' + CASE DEFAULT + why = 'its restrained End A is on the end of a free or pinned rod (axisymmetric, with no roll '// & + 'angle to hold the torque)' + END SELECT + END IF + ELSE IF (starts_with(TRIM(points(ja)%ptype), 'body')) THEN + jb = find_body(bodies, int_suffix(TRIM(points(ja)%ptype), 5)) + IF (jb > 0) THEN + IF (TRIM(bodies(jb)%btype) /= 'rigid6') why = 'its restrained End A is on a body that is not Rigid6' + END IF + END IF + END IF + END IF + IF (LEN_TRIM(why) > 0) THEN + lines(i)%tors_note = why + ELSE + lines(i)%tors_free_end = ifree + lines(i)%tors_pretwist(ifree) = CD_ZERO + END IF + END DO + END SUBROUTINE resolve_one_end_torsion + PURE LOGICAL FUNCTION deck_has_torsion_columns(lines) RESULT(has) !! Some END CONNECTIONS row declares a torsional restraint (TorsStiffness not Free). TYPE(DeckLine), INTENT(IN) :: lines(:) @@ -38042,15 +38614,19 @@ PURE FUNCTION rod_orientation_from_axis(axis) RESULT(rot) rot(:, 3) = zaxis END FUNCTION rod_orientation_from_axis - SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg, check_axis) + SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg, check_axis, nx0) !! The object frame of a finite-EI line's End A END CONNECTION on a Rigid6 body point or a rod !! end, at the object's current pose (its static-equilibrium pose once solved): rot, the !! object-to-global rotation, and d0, the connection direction (End A to End B) in the object !! frame. On a body point the deck direction is given in the body frame. On a rod end it must !! be parallel to the rod axis (either sense, in the frame of the rod's deck coordinates): a - !! rod has no spin angle in its static solve, and a direction along the axis makes the - !! connection moment normal to the axis. check_axis = .FALSE. (after the static solve has - !! turned the rod; the deck direction was checked before it) keeps only the sense. + !! free or pinned rod has no spin angle in its static solve, and a direction along the axis + !! makes the connection moment normal to the axis. check_axis = .FALSE. (after the static + !! solve has turned the rod; the deck direction was checked before it) keeps only the sense. + !! nx0: End A's torsion reference normal in the object frame. On a body point the deck gives + !! it in the body frame; on an end of a Fixed rod in the frame of the rod's deck coordinates, + !! so it is carried into the rod frame rot: nx0 = rot^T Nx. On any other rod (torsion refused + !! there, check_torsion_line) nx0 is the deck's Nx unchanged, not a normal in that rod's frame. TYPE(DeckLine), INTENT(IN) :: ln TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckBody), INTENT(IN) :: bodies(:) @@ -38059,6 +38635,7 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg LOGICAL, INTENT(IN), OPTIONAL :: check_axis + REAL(wp), INTENT(OUT), OPTIONAL :: nx0(3) INTEGER :: pa, ib, ir, rid, iend REAL(wp) :: axis(3), ez(3), an LOGICAL :: check @@ -38072,6 +38649,7 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg rot(3, 3) = CD_ONE ez = ln%endconn_ez_ref(:, 1) d0 = ez + IF (PRESENT(nx0)) nx0 = ln%tors_nx(:, 1) check = .TRUE. IF (PRESENT(check_axis)) check = check_axis who = 'finite-EI LINE '//TRIM(int_to_str(ln%id))//' End A' @@ -38113,6 +38691,10 @@ SUBROUTINE clamp_object_frame(ln, points, bodies, rods, rot, d0, ErrStat, ErrMsg IF (ib > 0) axis = MATMUL(deck_body_pose_rotation(bodies(ib)), axis) END IF rot = rod_orientation_from_axis(axis) + ! a Fixed rod keeps the frame init_rod_states gives it (rod_orientation_from_axis of its deck + ! axis), in which the march holds the End A frame (mb_attachment_motion); a free or pinned + ! rod's march frame differs from rot by a roll, and torsion is refused there + IF (PRESENT(nx0) .AND. TRIM(rods(ir)%rod_type) == 'fixed') nx0 = MATMUL(TRANSPOSE(rot), ln%tors_nx(:, 1)) ELSE CALL fail(ErrStat, ErrMsg, TRIM(who)//': a clamped or elastic END CONNECTION needs a Fixed point, a '// & 'Rigid6 body point or a rod end'); RETURN diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index a7ac4008..21116950 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -5828,7 +5828,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, c strain = strain + 0.5_wp*model%torsion%gj(e)/model%l0(e)*tau*tau END DO DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, ErrStat, em2) IF (ErrStat /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HermiteCable_Dyn_Energy: '//TRIM(em2) @@ -6005,11 +6005,13 @@ SUBROUTINE CD_HermiteCable_Dyn_Section_Curvature(model, ref_a, kx, ky, ErrStat, t = -unit_tangent(model, model%nn) d1 = r - DOT_PRODUCT(r, t)*t rn = NORM2(d1) - IF (.NOT. rn > 1.0e-6_wp*MAX(NORM2(r), TINY(CD_ONE))) THEN + ! (a free End A's torsion frame is a gauge: its section is the material director below) + IF (.NOT. rn > 1.0e-6_wp*MAX(NORM2(r), TINY(CD_ONE)) .AND. .NOT. (model%tw_active .AND. & + model%torsion%end_free(2))) THEN ErrStat = CD_HCDYN_BADINPUT ErrMsg = 'CD_HermiteCable_Dyn_Section_Curvature: the section reference lies along the End A tangent'; RETURN END IF - d1 = d1/rn + IF (rn > CD_ZERO) d1 = d1/rn IF (model%tw_active) THEN ! Nodal twist: the material director Rot(t_k, phi - Phi) u of every node (t_k the solve ! tangent, End 1 -> End 2), on the frame convention above: End A (node nn) takes the @@ -6763,7 +6765,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End_Twist(model, twist, ErrStat, ErrMsg) RETURN END IF DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HermiteCable_Dyn_End_Twist: '//TRIM(ErrMsg) @@ -6802,7 +6804,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Check(model, q_check, ends, ErrStat, ErrMsg END IF END DO DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, q_check, ends, .FALSE., psi, gl, hl, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN ErrMsg = 'CD_HermiteCable_Dyn_Twist_Check: '//TRIM(ErrMsg); RETURN @@ -6820,7 +6822,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Hessian(model, eg, eh, ek, emt, lg, lh, lk, !! without damping), so d2E/dq2 = emt eh + ek eg eg^T, d2E/dphi_{e+1} dq = ek eg = -d2E/dphi_e dq !! and d2E/dphi2 = ek [[1, -1], [-1, 1]]. Per end k (columns): lg = d psi/dm and lh = d2 psi/dm2 !! in the end node's tangent handle m, lk the spring stiffness (0 at a rigid end, whose - !! angle is held) and lmt = lk tw, so d2E/dm2 = lk lg lg^T -+ lmt lh (- at end 1, + at end 2), + !! angle is held, and at a free end, which has no spring) and lmt = lk tw, so + !! d2E/dm2 = lk lg lg^T -+ lmt lh (- at end 1, + at end 2), !! d2E/dphi dm = -lk lg and d2E/dphi2 = lk. Fails closed without the nodal twist. TYPE(CD_HermiteCableDynType), INTENT(IN) :: model REAL(wp), INTENT(OUT) :: eg(:, :), eh(:, :, :), ek(:), emt(:), lg(3, 2), lh(3, 3, 2), lk(2), lmt(2) @@ -6856,7 +6859,8 @@ SUBROUTINE CD_HermiteCable_Dyn_Twist_Hessian(model, eg, eh, ek, emt, lg, lh, lk, emt(e) = ek(e)*(model%tw_phi(e + 1) - model%tw_phi(e) + rho) END DO DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + ! (a free end, end_free, has no spring: its angle is free and its energy term absent) + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, model%q, model%torsion%ends, .TRUE., psi, lg(:, iend), lh(:, :, iend), & ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) THEN @@ -7417,7 +7421,7 @@ SUBROUTINE CD_HermiteCable_Dyn_EndConnection_Moment(model, node, moment, ErrStat ! director in a transport triangle adds d x dOmega/dd. The slaved tangent of a rigid ! bending end adds its share through the constraint reaction below. The held end section ! turns with the frame and its held angle, chi_dot = -+drho/dw . omega + phi_dot (End 1, - ! End 2): its polar inertia I adds -I chi_ddot dchi/dw. + ! End 2): its polar inertia I adds -I chi_ddot dchi/dw. A free end transmits no torque. BLOCK REAL(wp) :: rho, beta, g(12), h(12, 12), ew(3, 2), psi, gl(3), hl(3, 3), lw(3), tw, sg, chi_dd IF (model%tw_rigid(iend)) THEN @@ -7432,7 +7436,7 @@ SUBROUTINE CD_HermiteCable_Dyn_EndConnection_Moment(model, node, moment, ErrStat sg = MERGE(-CD_ONE, CD_ONE, iend == 1) chi_dd = sg*DOT_PRODUCT(ew(:, iend), model%tw_oal(:, iend)) + model%tw_al(node) moment = moment - model%tw_mass(node)*chi_dd*sg*ew(:, iend) - ELSE + ELSE IF (tw_spring(model, iend)) THEN CALL twist_link(model, iend, model%q, model%torsion%ends, .FALSE., psi, gl, hl, es, em, end_w=lw) IF (es /= CD_HCDYN_OK) THEN ErrStat = es @@ -7745,7 +7749,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Torsion_State(model, theta, torque, ErrStat, ErrM RETURN END IF theta = CD_HermiteTorsion_Unwrap(raw, model%torsion%theta) - IF (ABS(theta - model%torsion%theta) > CD_HTORS_MAX_STEP) THEN + ! (a line free at one end carries no condensed torque on any branch: the nodal twist, not + ! Theta, holds its state, and its accepted Theta is only the view Phi less the summed twist) + IF (ABS(theta - model%torsion%theta) > CD_HTORS_MAX_STEP .AND. .NOT. ANY(model%torsion%end_free)) THEN ErrStat = CD_HCDYN_NOCONVERGE ErrMsg = 'torsion: the twist moved more than pi/2 from its accepted value' theta = CD_ZERO @@ -9182,7 +9188,7 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K model%tw_lk = CD_ZERO END IF DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, q_cfg, ends, want_tangent, psi, gl, hl, es, em) IF (es /= CD_HCDYN_OK) THEN ErrStat = es @@ -9348,7 +9354,10 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) !! holonomy), angles accumulated from the element twists mt l0/GJ - rho_e and the end !! compliances, rates zero. A rigid end 2 holds phi = Phi: the last element's reference !! twist takes the multiple of 2 pi the accumulated angle needs, as an elastic end 2's psi - !! does; a remainder above STATE_TOL (a static state off equilibrium) fails closed. + !! does; a remainder above STATE_TOL (a static state off equilibrium) fails closed. A free + !! end (mt = 0) has no reference of its own: a free end 1 starts the directors from its + !! gauge frame and the angles shift as one to meet the restrained end 2 (its held Phi or a + !! slack spring); a free end 2 ends the accumulation. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model REAL(wp), INTENT(IN) :: mt INTEGER, INTENT(OUT) :: ErrStat @@ -9415,15 +9424,15 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) model%tw_som = CD_ZERO model%tw_om = CD_ZERO model%tw_oal = CD_ZERO - IF (.NOT. model%tw_rigid(1)) model%tw_psi(1) = CD_HermiteTwist_Angle(model%tw_u(:, 1), & - CD_HermiteTwist_Carry(ends(:, 1), & - model%tw_tn(:, 1), & - ends(:, 2)), & - model%tw_tn(:, 1)) + IF (tw_spring(model, 1)) model%tw_psi(1) = CD_HermiteTwist_Angle(model%tw_u(:, 1), & + CD_HermiteTwist_Carry(ends(:, 1), & + model%tw_tn(:, 1), & + ends(:, 2)), & + model%tw_tn(:, 1)) ! angles from the uniform torque tol = STATE_TOL*MAX(CD_ONE, ABS(phi_end)) model%tw_phi = CD_ZERO - IF (.NOT. model%tw_rigid(1)) model%tw_phi(1) = mt*model%torsion%end_compliance(1) + model%tw_psi(1) + IF (tw_spring(model, 1)) model%tw_phi(1) = mt*model%torsion%end_compliance(1) + model%tw_psi(1) model%tors_use_step = .FALSE. DO e = 1, ne CALL twist_reference(model, e, model%q, ends, .FALSE., rho, beta, g, h, es, em2) @@ -9433,7 +9442,12 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) RETURN END IF model%tw_phi(e + 1) = model%tw_phi(e) + mt*model%l0(e)/model%torsion%gj(e) - rho - IF (e == ne .AND. model%tw_rigid(2)) THEN + IF (e == ne .AND. model%tw_rigid(2) .AND. model%torsion%end_free(1)) THEN + ! a free end 1: the angles shift as one to the held Phi of end 2 + diff = model%tw_phi(nn) - phi_end + model%tw_phi = model%tw_phi - diff + model%tw_phi(nn) = phi_end + ELSE IF (e == ne .AND. model%tw_rigid(2)) THEN diff = model%tw_phi(nn) - phi_end kk = ANINT(diff/(2.0_wp*CD_HTORS_PI)) IF (ABS(diff - 2.0_wp*CD_HTORS_PI*kk) > tol) THEN @@ -9446,11 +9460,13 @@ SUBROUTINE tw_init(model, mt, ErrStat, ErrMsg) model%tw_phi(nn) = phi_end END IF END DO - IF (.NOT. model%tw_rigid(2)) THEN + IF (tw_spring(model, 2)) THEN ! the End-2 spring: its psi at the committed state is the director angle itself, on the - ! branch that puts the static end twist mt/k_2 on it + ! branch that puts the static end twist mt/k_2 on it (a free end 1: the angles shift as + ! one to leave the spring slack, mt = 0) psi = CD_HermiteTwist_Angle(model%tw_u(:, nn), CD_HermiteTwist_Carry(ends(:, 3), model%tw_tn(:, nn), & ends(:, 4)), model%tw_tn(:, nn)) + IF (model%torsion%end_free(1)) model%tw_phi = model%tw_phi + (psi + phi_end - model%tw_phi(nn)) diff = mt*model%torsion%end_compliance(2) - (psi + phi_end - model%tw_phi(nn)) kk = ANINT(diff/(2.0_wp*CD_HTORS_PI)) IF (ABS(diff - 2.0_wp*CD_HTORS_PI*kk) > tol) THEN @@ -9476,11 +9492,12 @@ END SUBROUTINE tw_init SUBROUTINE tw_set_derived(model, tors) !! The rigid ends, held angles and lumped polar inertia (half of each adjacent element's - !! Irn l0) the torsion description tors gives. + !! Irn l0) the torsion description tors gives. A free end (tors%end_free) is neither rigid + !! nor elastic: its angle is free and nothing twists it against its end frame. TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model TYPE(CD_HermiteTorsionType), INTENT(IN) :: tors INTEGER :: e - model%tw_rigid = .NOT. (tors%end_compliance > CD_ZERO) + model%tw_rigid = .NOT. (tors%end_compliance > CD_ZERO) .AND. .NOT. tors%end_free model%tw_free = .TRUE. IF (model%tw_rigid(1)) model%tw_free(1) = .FALSE. IF (model%tw_rigid(2)) model%tw_free(model%nn) = .FALSE. @@ -9491,6 +9508,14 @@ SUBROUTINE tw_set_derived(model, tors) END DO END SUBROUTINE tw_set_derived + PURE LOGICAL FUNCTION tw_spring(model, iend) RESULT(spring) + !! End iend of the nodal twist is elastic: a torsional spring between its end node and its + !! end frame (neither rigid, holding the angle, nor free, without restraint). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER, INTENT(IN) :: iend + spring = .NOT. (model%tw_rigid(iend) .OR. model%torsion%end_free(iend)) + END FUNCTION tw_spring + SUBROUTINE tw_settle_committed(model) !! After an evaluation of the committed state (solve_consistent_acceleration): the angles' !! accelerations staged in tw_ak, the element torques, and the condensed view Theta_eff = @@ -9540,7 +9565,7 @@ SUBROUTINE tw_advance_reference(model, q_new, ends_new, ErrStat, ErrMsg) END DO model%tw_spsi = model%tw_psi DO iend = 1, 2 - IF (model%tw_rigid(iend)) CYCLE + IF (.NOT. tw_spring(model, iend)) CYCLE CALL twist_link(model, iend, q_new, ends_new, .FALSE., psi, gl, hl, ErrStat, ErrMsg) IF (ErrStat /= CD_HCDYN_OK) RETURN model%tw_spsi(iend) = psi diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 29f2b3bb..f4eac2af 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -743,6 +743,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ IF (es /= CD_HTORS_OK) THEN CALL fail(TRIM(ErrMsg)); RETURN END IF + ! a free end (infinite end compliance): the static torque is zero, nothing to solve + IF (ANY(torsion%end_free)) THEN + CALL fail('torsion: a line free in torsion at one end carries no static torque; solve it without '// & + 'torsion'); RETURN + END IF tors_c = CD_HermiteTorsion_Compliance(torsion, l0) IF (.NOT. (tors_c > CD_ZERO) .OR. .NOT. CD_Is_Finite(tors_c)) THEN CALL fail('torsion: the line compliance must be finite and positive'); RETURN diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index d93094f6..6f97c2f3 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -109,6 +109,12 @@ MODULE CableDyn_HermiteTorsion REAL(wp) :: ends(3, 4) = CD_ZERO !! Torsional end compliances 1/k_t [rad/(N m)] at ends 1 and 2 (0 for a rigid end). REAL(wp) :: end_compliance(2) = CD_ZERO + !! A free end (no torsional restraint, at most one of the two): an infinite end compliance. + !! The line then carries no condensed torque, C = +Inf, and its twist is carried by the nodal + !! twist alone (irn required): torque-tension coupling and the torsional inertia twist it, and + !! the free end turns by the element twists, sum (M_e l0/GJ - (K/GJ)(l_e - l0)). Its end + !! frame is a gauge only (no spring, no held angle) and end_compliance there stays 0. + LOGICAL :: end_free(2) = .FALSE. !! Torsional stiffness GJ of every element [N m^2/rad] (the line compliance is the sum of !! l0/GJ over the elements plus the end compliances). REAL(wp), ALLOCATABLE :: gj(:) @@ -167,15 +173,20 @@ MODULE CableDyn_HermiteTorsion ! ------------------------------------------------------------------------------------------ PURE REAL(wp) FUNCTION CD_HermiteTorsion_Compliance(tors, l0) RESULT(c) - !! Line torsional compliance C = sum_e l0_e/GJ_e + 1/k_t1 + 1/k_t2 [rad/(N m)]. Meant for a - !! description that passed CD_HermiteTorsion_Validate: without one GJ per element it - !! returns NaN (so no caller can take the end compliances alone for the line's). - USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN + !! Line torsional compliance C = sum_e l0_e/GJ_e + 1/k_t1 + 1/k_t2 [rad/(N m)]; +Inf with a + !! free end (end_free), so the condensed torque (Phi - Theta)/C and stiffness 1/C are zero. + !! Meant for a description that passed CD_HermiteTorsion_Validate: without one GJ per + !! element it returns NaN (so no caller can take the end compliances alone for the line's). + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN, IEEE_POSITIVE_INF TYPE(CD_HermiteTorsionType), INTENT(IN) :: tors REAL(wp), INTENT(IN) :: l0(:) c = IEEE_VALUE(c, IEEE_QUIET_NAN) IF (.NOT. ALLOCATED(tors%gj)) RETURN IF (SIZE(tors%gj) /= SIZE(l0)) RETURN + IF (ANY(tors%end_free)) THEN + c = IEEE_VALUE(c, IEEE_POSITIVE_INF) + RETURN + END IF c = tors%end_compliance(1) + tors%end_compliance(2) + SUM(l0/tors%gj) END FUNCTION CD_HermiteTorsion_Compliance @@ -282,6 +293,19 @@ PURE SUBROUTINE CD_HermiteTorsion_Validate(tors, l0, ErrStat, ErrMsg) ErrMsg = 'torsion: end compliances must be non-negative' RETURN END IF + IF (ALL(tors%end_free)) THEN + ErrMsg = 'torsion: both ends are free, so the line carries no torque (describe it without torsion)' + RETURN + END IF + IF (ANY(tors%end_free .AND. tors%end_compliance > CD_ZERO)) THEN + ErrMsg = 'torsion: a free end has no end compliance' + RETURN + END IF + IF (ANY(tors%end_free) .AND. .NOT. ALLOCATED(tors%irn)) THEN + ErrMsg = 'torsion: a line free at one end carries no condensed torque; its twist needs the nodal twist '// & + '(the polar rotary inertia irn)' + RETURN + END IF IF (tors%quadrature_order < 1 .OR. tors%quadrature_order > NG_MAX) THEN ErrMsg = 'torsion: quadrature order must lie in [1,6]' RETURN diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 53446968..2652e6b8 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -57,7 +57,7 @@ MODULE CableDyn_OpenFAST_Aggregate CD_HFMF_End, CD_HFMF_OK, CD_HFMF_BADINPUT, & CD_HFMF_Snapshot, CD_HFMF_Restore, & CD_HFMF_Set_Held_Fluid, CD_HFMF_NNodes, CD_HFMF_GetNodePositions, & - CD_HFMF_Set_SegmentLength + CD_HFMF_Set_SegmentLength, CD_HFMF_Refresh_Acceleration USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_Profile_Enabled, CD_HermiteCableControlSaveType, & CD_HermiteCable_Dyn_Save_Control, CD_HermiteCable_Dyn_Restore_Control, & CD_HCDYN_OK @@ -82,7 +82,10 @@ MODULE CableDyn_OpenFAST_Aggregate CD_Rod_NHost, CD_Rod_SetHostKinematics, CD_Rod_GetHostKinematics, & CD_Rod_ScatterHostPoints, CD_Rod_HostWrench, CD_Rod_Stage, CD_Rod_Unstage, & CD_Rigid6_StartAccelerations, CD_Rod_StartAccelerations, & - CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write + CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write, & + CD_MotionRuntimeType, CD_Motion_Active, CD_Motion_NColumns, & + CD_Motion_Has_Rotation, CD_Motion_Has_Roll, CD_Motion_Kinematics, & + CD_Motion_Deck_Positions, CD_Motion_End USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & CD_Get_System_Line_State, & @@ -121,6 +124,8 @@ MODULE CableDyn_OpenFAST_Aggregate PUBLIC :: CD_AGG_Get_Failure_Flags, CD_AGG_Set_Failure_Flags PUBLIC :: CD_AGG_NCtrlChans, CD_AGG_Apply_LineControl PUBLIC :: CD_AGG_IsInitialized + ! The deck's own prescribed motion on the standalone mixed route (not a coupled-host surface) + PUBLIC :: CD_AGG_HasMotion, CD_AGG_MotionKinematics, CD_AGG_Refresh_Accelerations ! OpenFAST CompMooring=5 output-channel surface (consumed by CableDyn_OF): the deck OUTPUTS ! channel count/header/unit for registration, and the per-channel evaluator for CalcOutput. PUBLIC :: CD_AGG_NumChannels @@ -160,6 +165,13 @@ MODULE CableDyn_OpenFAST_Aggregate REAL(wp), ALLOCATABLE :: mv_pos(:, :), mv_vel(:, :), mv_acc(:, :), mv_load(:, :), mv_moment(:, :) REAL(wp), ALLOCATABLE :: mv_omega(:, :), mv_alpha(:, :) REAL(wp), ALLOCATABLE :: mv_orient(:, :, :) + ! The roll of each moving column of a step (CD_AGG_Step_Moving roll), and the static + ! imposed twist Phi_0 = Pretwist(B) - Pretwist(A) of each cable restrained in torsion: the + ! step's imposed twist is Phi_0 - roll. + REAL(wp), ALLOCATABLE :: mv_roll(:) + REAL(wp), ALLOCATABLE :: cable_phi0(:) + ! The deck's own prescribed motion (standalone mixed route; inactive for a coupled host). + TYPE(CD_MotionRuntimeType) :: motion ! Per-cable status staging lets independent finite-EI cables advance concurrently while ! preserving deterministic, cable-order error reporting after the parallel region. INTEGER, ALLOCATABLE :: cable_stat(:) @@ -259,7 +271,7 @@ MODULE CableDyn_OpenFAST_Aggregate SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation, static_current) + range_files, host_orientation, static_current, prescribed_motion, static_run) !! Build the aggregate from ONE mixed deck: partition its lines into {EI=0 mooring} !! and {finite-EI cable}, wrap the mooring subset into a CD_FMF, and own one CD_HFMF !! per cable. Same signature philosophy as CD_FMF_Init_From_Deck (host environment @@ -301,6 +313,12 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ! static_current (4, n): the host's steady current (z, ux, uy, uz by ascending z) for the ! static solves only (see CD_Init_Deck_Aggregate) REAL(wp), INTENT(IN), OPTIONAL :: static_current(:, :) + ! prescribed_motion: the caller marches the deck's own motionFile or vesselMotion table + ! (CD_AGG_MotionKinematics; the standalone driver, see CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: prescribed_motion + ! static_run: the caller marches no step (the standalone TMax = 0 run; see + ! CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: static_run ! Both bundles (about 70 KB together) are built on the heap: initialisation runs on the ! thread of the calling host, whose stack size CableDyn does not choose. @@ -340,7 +358,8 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi turbine_ref_pos=turbine_ref_pos, farm_ptfm_init=farm_ptfm_init, & forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & range_files=range_files, host_orientation=host_orientation, & - static_current=static_current) + static_current=static_current, prescribed_motion=prescribed_motion, & + static_run=static_run) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF @@ -458,6 +477,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi IF (ALLOCATED(parts%line_is_cable)) CALL MOVE_ALLOC(parts%line_is_cable, candidate%line_is_cable) IF (ALLOCATED(parts%line_obj_index)) CALL MOVE_ALLOC(parts%line_obj_index, candidate%line_obj_index) candidate%ranges = parts%ranges + candidate%motion = parts%motion IF (ALLOCATED(parts%cable_points)) THEN CALL MOVE_ALLOC(parts%cable_points, candidate%cable_points) ELSE @@ -501,13 +521,19 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ALLOCATE (candidate%mv_pos(3, ncp_total), candidate%mv_vel(3, ncp_total), candidate%mv_acc(3, ncp_total), & candidate%mv_load(3, ncp_total), candidate%mv_moment(3, ncp_total), & candidate%mv_omega(3, ncp_total), candidate%mv_alpha(3, ncp_total), & - candidate%mv_orient(3, 3, ncp_total), STAT=istat) + candidate%mv_orient(3, 3, ncp_total), candidate%mv_roll(ncp_total), & + candidate%cable_phi0(candidate%ncable), STAT=istat) IF (istat /= 0) THEN ErrStat = CD_AGG_ALLOCFAIL ErrMsg = 'CableDyn_OpenFAST_Aggregate: moving-surface scratch allocation failed' CALL CD_AGG_End(candidate, es, em) RETURN END IF + candidate%mv_roll = CD_ZERO + candidate%cable_phi0 = CD_ZERO + DO ich = 1, candidate%ncable + IF (candidate%cables(ich)%line%torsion%active) candidate%cable_phi0(ich) = candidate%cables(ich)%line%torsion%phi + END DO IF (candidate%ncable > 0) THEN ALLOCATE (candidate%cable_stat(candidate%ncable), candidate%cable_msg(candidate%ncable), STAT=istat) IF (istat /= 0) THEN @@ -537,6 +563,13 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi END IF candidate%dt = dt ! freeze the coupling step for the fixed-dt Step_Moving guard candidate%initialized = .TRUE. + IF (CD_Motion_Active(candidate%motion)) THEN + CALL check_motion_columns(candidate, ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) THEN + CALL CD_AGG_End(candidate, es, em) + RETURN + END IF + END IF CALL CD_AGG_End(self, es, em) self = candidate CALL CD_AGG_End(candidate, es, em) @@ -921,7 +954,7 @@ SUBROUTINE CD_AGG_UpdateStates_Moving(self, position, velocity, acceleration, Er END SUBROUTINE CD_AGG_UpdateStates_Moving SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, converged, stalled, n_iter, ErrStat, & - ErrMsg, t_committed, orientation, angular_velocity, angular_acceleration) + ErrMsg, t_committed, orientation, angular_velocity, angular_acceleration, roll) !! Advance every owned object one coupling step of dt with the moving points prescribed. !! The EI=0 system columns route to CD_FMF_Step_Moving; each cable's fairlead column !! routes to CD_HFMF_UpdateStates (the implicit prescribed-motion step). Aggregate @@ -951,9 +984,16 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver REAL(wp), INTENT(IN), OPTIONAL :: t_committed REAL(wp), INTENT(IN), OPTIONAL :: orientation(:, :, :) REAL(wp), INTENT(IN), OPTIONAL :: angular_velocity(:, :), angular_acceleration(:, :) + ! roll (ncp_total) [rad]: the roll of the line end frames at each moving point about their + ! directors at t + dt, from the static state, right-handed about the tangent into the line + ! (the standalone motionFile roll column). A cable restrained in torsion takes the imposed + ! twist Phi = Phi_0 - roll of its column, Phi_0 = Pretwist(B) - Pretwist(A), as on the + ! standalone cubic-Hermite route; the other columns carry no twist and ignore it. Without + ! it the imposed twist is held. + REAL(wp), INTENT(IN), OPTIONAL :: roll(:) INTEGER :: c, col, es, nsys, nsub - LOGICAL :: csys, ssys, staged + LOGICAL :: csys, ssys, staged, use_roll REAL(wp) :: t_start CHARACTER(1024) :: em @@ -1021,12 +1061,27 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver RETURN END IF END IF + use_roll = PRESENT(roll) + IF (use_roll) THEN + IF (SIZE(roll) /= ncp_all(self)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: roll must be shaped (ncp_total)' + RETURN + END IF + IF (.NOT. CD_All_Finite(roll)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: roll must be finite' + RETURN + END IF + END IF self%mv_omega = CD_ZERO self%mv_alpha = CD_ZERO IF (PRESENT(angular_velocity)) THEN self%mv_omega = angular_velocity self%mv_alpha = angular_acceleration END IF + self%mv_roll = CD_ZERO + IF (use_roll) self%mv_roll = roll ! stage: snapshot every sub-object before any of them steps (multi-object only; a ! single sub-object is already atomic -- the hot mooring-only path skips this). ! A Rigid6 deck is single-subobject (ncable == 0) yet still needs staging: its branch @@ -1178,30 +1233,29 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver n_iter = MAX(n_iter, nsys) END IF IF (PRESENT(orientation)) THEN - !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration, orientation) & + !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration, orientation, use_roll) & !$OMP PRIVATE(c, col, es, em) & !$OMP IF(self%ncable > 1 .AND. .NOT. CD_HermiteCable_Dyn_Profile_Enabled()) CALL CD_Fatal_Thread_Init() ! this thread can report its own stack overflow !$OMP DO SCHEDULE(STATIC) DO c = 1, self%ncable col = self%ncp_sys + c - CALL CD_HFMF_UpdateStates(self%cables(c), position(:, col), velocity(:, col), acceleration(:, col), & - es, em, orientation(:, :, col), self%mv_omega(:, col), self%mv_alpha(:, col)) + CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em, & + orientation(:, :, col)) self%cable_stat(c) = es self%cable_msg(c) = em END DO !$OMP END DO !$OMP END PARALLEL ELSE - !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration) PRIVATE(c, col, es, em) & + !$OMP PARALLEL DEFAULT(NONE) SHARED(self, position, velocity, acceleration, use_roll) & + !$OMP PRIVATE(c, col, es, em) & !$OMP IF(self%ncable > 1 .AND. .NOT. CD_HermiteCable_Dyn_Profile_Enabled()) CALL CD_Fatal_Thread_Init() ! this thread can report its own stack overflow !$OMP DO SCHEDULE(STATIC) DO c = 1, self%ncable col = self%ncp_sys + c - CALL CD_HFMF_UpdateStates(self%cables(c), position(:, col), velocity(:, col), acceleration(:, col), es, em, & - u_angular_velocity=self%mv_omega(:, col), & - u_angular_acceleration=self%mv_alpha(:, col)) + CALL step_cable(self, c, position(:, col), velocity(:, col), acceleration(:, col), use_roll, es, em) self%cable_stat(c) = es self%cable_msg(c) = em END DO @@ -1270,6 +1324,146 @@ SUBROUTINE rewind_step() END SUBROUTINE rewind_step END SUBROUTINE CD_AGG_Step_Moving + SUBROUTINE step_cable(self, c, u_pos, u_vel, u_acc, use_roll, ErrStat, ErrMsg, u_orientation) + !! One cable's implicit step to its column's t + dt kinematics (CD_HFMF_UpdateStates): the + !! parent orientation when given, the column's angular rates, and with use_roll the imposed + !! twist Phi_0 - roll of a cable restrained in torsion. Touches cable c alone, so the cables + !! step concurrently. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(IN) :: c + REAL(wp), INTENT(IN) :: u_pos(3), u_vel(3), u_acc(3) + LOGICAL, INTENT(IN) :: use_roll + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: u_orientation(3, 3) + INTEGER :: col + REAL(wp) :: twist + col = self%ncp_sys + c + IF (use_roll .AND. self%cables(c)%line%torsion%active) THEN + twist = self%cable_phi0(c) - self%mv_roll(col) + IF (PRESENT(u_orientation)) THEN + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & + self%mv_omega(:, col), self%mv_alpha(:, col), u_twist=twist) + ELSE + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, & + u_angular_velocity=self%mv_omega(:, col), & + u_angular_acceleration=self%mv_alpha(:, col), u_twist=twist) + END IF + ELSE IF (PRESENT(u_orientation)) THEN + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, u_orientation, & + self%mv_omega(:, col), self%mv_alpha(:, col)) + ELSE + CALL CD_HFMF_UpdateStates(self%cables(c), u_pos, u_vel, u_acc, ErrStat, ErrMsg, & + u_angular_velocity=self%mv_omega(:, col), & + u_angular_acceleration=self%mv_alpha(:, col)) + END IF + END SUBROUTINE step_cable + + LOGICAL FUNCTION CD_AGG_HasMotion(self) RESULT(has) + !! The aggregate carries the deck's own prescribed motion (Init prescribed_motion). + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + has = self%initialized .AND. CD_Motion_Active(self%motion) + END FUNCTION CD_AGG_HasMotion + + SUBROUTINE CD_AGG_MotionKinematics(self, time_index, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, has_rotation, has_roll, & + ErrStat, ErrMsg) + !! Grid row time_index (1 = t 0) of the deck's prescribed motion over the moving surface, + !! shaped as CD_AGG_Step_Moving takes it: translations (3, ncp_total), the global-to-parent + !! DCM (3, 3, ncp_total) with the global-axis angular velocity and acceleration (3, + !! ncp_total), and the roll (ncp_total). has_rotation: a vesselMotion table, whose + !! orientation and rates the step takes (the fairlead end connection and torsion frames + !! turn with the vessel, as on the standalone cubic-Hermite route); has_roll: a motionFile + !! roll column the step takes as roll. Without them (motionFile point rows) the frames are + !! held and the step takes the translations alone. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + INTEGER, INTENT(IN) :: time_index + REAL(wp), INTENT(OUT) :: position(:, :), velocity(:, :), acceleration(:, :) + REAL(wp), INTENT(OUT) :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) + LOGICAL, INTENT(OUT) :: has_rotation, has_roll + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(1024) :: em + has_rotation = .FALSE. + has_roll = .FALSE. + IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN + IF (.NOT. CD_Motion_Active(self%motion)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: the aggregate carries no prescribed motion' + RETURN + END IF + CALL CD_Motion_Kinematics(self%motion, time_index, position, velocity, acceleration, orientation, & + angular_velocity, angular_acceleration, roll, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + has_rotation = CD_Motion_Has_Rotation(self%motion) + has_roll = CD_Motion_Has_Roll(self%motion) + ErrStat = CD_AGG_OK + ErrMsg = '' + END SUBROUTINE CD_AGG_MotionKinematics + + SUBROUTINE CD_AGG_Refresh_Accelerations(self, ErrStat, ErrMsg) + !! Recompute every cable's free-node acceleration from its complete residual at the + !! committed state, keeping the coupled node's prescribed acceleration + !! (CD_HFMF_Refresh_Acceleration): after CD_AGG_UpdateStates_Moving installs the first row + !! of a prescribed motion, so the first step does not start from the static acceleration + !! (the standalone cubic-Hermite route's row-1 station). The EI = 0 system is unchanged. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: c, es + CHARACTER(1024) :: em + IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN + DO c = 1, self%ncable + CALL CD_HFMF_Refresh_Acceleration(self%cables(c), es, em) + IF (es /= CD_HFMF_OK) THEN + CALL map_hfmf_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + END DO + ErrStat = CD_AGG_OK + ErrMsg = '' + END SUBROUTINE CD_AGG_Refresh_Accelerations + + SUBROUTINE check_motion_columns(self, ErrStat, ErrMsg) + !! The prescribed-motion columns match the moving surface: one column per moving point, and + !! each column's driving point at that moving point's static position (a column map that + !! drifted from the aggregate's moving-set order would drive the wrong point). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es, col + REAL(wp), ALLOCATABLE :: deck_pos(:, :) + CHARACTER(1024) :: em + IF (CD_Motion_NColumns(self%motion) /= ncp_all(self) .OR. self%nhost_rod + self%nhost_body > 0) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: the prescribed motion does not cover the moving surface' + RETURN + END IF + CALL CD_AGG_GetMovingPointMesh(self, self%mv_pos, self%mv_vel, self%mv_acc, self%mv_load, ErrStat, ErrMsg, & + cable_loads=.FALSE.) + IF (ErrStat /= CD_AGG_OK) RETURN + ALLOCATE (deck_pos(3, ncp_all(self))) + CALL CD_Motion_Deck_Positions(self%motion, deck_pos, es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + DO col = 1, ncp_all(self) + IF (ANY(ABS(deck_pos(:, col) - self%mv_pos(:, col)) > 1.0e-9_wp*(CD_ONE + MAXVAL(ABS(deck_pos(:, col)))))) THEN + ErrStat = CD_AGG_BADINPUT + WRITE (ErrMsg, '(A,I0,A)') 'CableDyn_OpenFAST_Aggregate: the prescribed motion of moving point ', col, & + ' is not keyed to that point' + RETURN + END IF + END DO + ErrStat = CD_AGG_OK + ErrMsg = '' + END SUBROUTINE check_motion_columns + SUBROUTINE CD_AGG_Snapshot(self, ErrStat, ErrMsg) !! Capture the committed state of EVERY sub-object (system + all cables), any !! composition -- the caller-facing twin of the internal staged snapshot (which the @@ -2020,6 +2214,9 @@ SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) IF (ALLOCATED(self%mv_orient)) DEALLOCATE (self%mv_orient) IF (ALLOCATED(self%mv_omega)) DEALLOCATE (self%mv_omega) IF (ALLOCATED(self%mv_alpha)) DEALLOCATE (self%mv_alpha) + IF (ALLOCATED(self%mv_roll)) DEALLOCATE (self%mv_roll) + IF (ALLOCATED(self%cable_phi0)) DEALLOCATE (self%cable_phi0) + CALL CD_Motion_End(self%motion) IF (ALLOCATED(self%cable_stat)) DEALLOCATE (self%cable_stat) IF (ALLOCATED(self%cable_msg)) DEALLOCATE (self%cable_msg) IF (ALLOCATED(self%channels)) DEALLOCATE (self%channels) diff --git a/tests/test_control_torsion.f90 b/tests/test_control_torsion.f90 index e63a3ec6..850884ba 100644 --- a/tests/test_control_torsion.f90 +++ b/tests/test_control_torsion.f90 @@ -43,6 +43,15 @@ PROGRAM test_control_torsion !! (the CompMooring = 5 route; the standalone driver takes no CONTROL) initialises, its !! Torq1N1 follows GJ Twist1/L(t) through a haul-in ramp, and the shell's checkpoint recipe !! continues bit-identically. + !! O deck, a line restrained in torsion at one end only: a straight neutral cable (EA 1e7 N, + !! GJ|K 5e4 N m2|4e5 N m, Irn 1e-9 kg m) of L0 = 99 m held H = 100 m apart, free in torsion + !! at End A (the controlled fairlead) and, in turn, at End B, paid out by 0.2 m on a half + !! cosine over 2 s and held. With no torque the section is free to twist, so each element + !! twists by -(K/GJ)(l_e - l0_e) and the free end turns with the commanded length: + !! Twist1 = -(K/GJ)(H - L0 - dL(t)) at every step, with no torque at either end; over the + !! hold the tension, about which the undamped axial waves of the ramp ring, has the mean + !! (EA - K^2/GJ)(H - L0 - dL)/(L0 + dL) of a section free to twist (within 5e-4: the 2 s mean + !! of the 2.4e-3 ringing). USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & @@ -92,6 +101,8 @@ PROGRAM test_control_torsion CALL check_lag() CALL check_restart() CALL check_deck() + CALL check_deck_one_end(1) + CALL check_deck_one_end(2) IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -1045,4 +1056,122 @@ SUBROUTINE check_deck() CALL CD_AGG_End(b, es, em) END SUBROUTINE check_deck + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_deck_one_end(kfree) + !! O: the controlled line free in torsion at deck End kfree (1 = A, the fairlead, 2 = B). + REAL(wp), PARAMETER :: DT = 0.05_wp, GJD = 5.0e4_wp, KD = 4.0e5_wp, EAD = 1.0e7_wp, H0 = 100.0_wp, & + L0D = 99.0_wp, DLMAX = 0.2_wp, TR = 2.0_wp, DEG = PI/180.0_wp + INTEGER, PARAMETER :: NSTEP = 80 + INTEGER, INTENT(IN) :: kfree + TYPE(CD_AGG_ModuleType) :: a + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), orient(3, 3, 1), omega(3, 1), alpha(3, 1) + REAL(wp) :: dl, dldot, tw, tqa, tqb, ten, tw_ref, ten_ref, e_tw, e_tq, e_ten, t, ten_sum + INTEGER :: es, ni, k, u, n_hold + LOGICAL :: cv, st + CHARACTER(512) :: em + CHARACTER(160) :: ltype + CHARACTER(2) :: tag + tag = MERGE('A ', 'B ', kfree == 1) + WRITE (ltype, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4|4.0e5 1.0 1.0e-9 0.0 0.0 0.0 0.0' + OPEN (NEWUNIT=u, FILE='ctl_torsion_one_end.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'controlled line restrained in torsion at one end' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(ltype) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 99.0 40' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + IF (kfree == 1) THEN + WRITE (u, '(A)') '1 A Rigid 1 0 0 Free 0 0 1' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 30' + ELSE + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 -30' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Free 0 0 1' + END IF + WRITE (u, '(A)') '--- CONTROL ---' + WRITE (u, '(A)') 'ChannelID Line(s)' + WRITE (u, '(A)') '(-) (-)' + WRITE (u, '(A)') '1 1' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Twist1' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N41' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_AGG_Init_From_Deck(a, 'ctl_torsion_one_end.dat', DT, es, em, host_orientation=.TRUE.) + CALL require(es == CD_AGG_OK, 'O (End '//TRIM(tag)//' free): a CONTROL deck on a line restrained at one end '// & + 'initialises with its twist channels: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(a%ctrl_is_cable(1) .AND. a%cables(1)%line%tw_active .AND. & + a%cables(1)%line%torsion%end_free(3 - kfree), & + 'O: the row controls the nodal-twist cable, free at the deck end') + CALL CD_AGG_GetMovingPointMesh(a, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + e_tw = 0.0_wp + e_tq = 0.0_wp + e_ten = 0.0_wp + ten_sum = 0.0_wp + n_hold = 0 + DO k = 1, NSTEP + t = DT*REAL(k, wp) + IF (t < TR) THEN + dl = DLMAX*0.5_wp*(1.0_wp - COS(PI*t/TR)) + dldot = DLMAX*0.5_wp*PI/TR*SIN(PI*t/TR) + ELSE + dl = DLMAX + dldot = 0.0_wp + END IF + CALL CD_AGG_Apply_LineControl(a, [dl], [dldot], es, em) + CALL require(es == CD_AGG_OK, 'O: command: '//TRIM(em)) + CALL CD_AGG_Step_Moving(a, DT, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'O: step: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL CD_AGG_CalcOutput(a, es, em) + CALL CD_AGG_EvalChannel(a, 1, tw, es, em) + CALL CD_AGG_EvalChannel(a, 2, tqa, es, em) + CALL CD_AGG_EvalChannel(a, 3, tqb, es, em) + CALL CD_AGG_EvalChannel(a, 4, ten, es, em) + tw_ref = -(KD/GJD)*(H0 - L0D - dl)/DEG + e_tw = MAX(e_tw, ABS(tw - tw_ref)/ABS(tw_ref)) + ! against the torque K eps the coupling would give a section held from twisting + e_tq = MAX(e_tq, ABS(tqa), ABS(tqb)) + IF (t > TR) THEN + ten_sum = ten_sum + ten + n_hold = n_hold + 1 + END IF + END DO + ten_ref = (EAD - KD**2/GJD)*(H0 - L0D - DLMAX)/(L0D + DLMAX) + e_ten = ABS(ten_sum/REAL(n_hold, wp) - ten_ref)/ten_ref + e_tq = e_tq/(KD*(H0 - L0D - DLMAX)/(L0D + DLMAX)) + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,3ES10.3)') 'O deck, End ', TRIM(tag), ' free, paid out 0.2 m: Twist1 ', tw, & + ' deg (-(K/GJ)(H - L) ', tw_ref, '); max rel. errors twist, |torque| / K eps, mean held tension ', e_tw, & + e_tq, e_ten + CALL require(e_tw <= 1.0e-6_wp, 'O: the free end turns with the commanded length, -(K/GJ)(H - L(t))') + CALL require(e_tq <= 1.0e-6_wp, 'O: no torque at either end') + CALL require(e_ten <= 5.0e-4_wp, 'O: the mean held tension is (EA - K^2/GJ) eps') + CALL CD_AGG_End(a, es, em) + END SUBROUTINE check_deck_one_end + END PROGRAM test_control_torsion diff --git a/tests/test_lin_torsion.f90 b/tests/test_lin_torsion.f90 index efd33dd4..c0bcdd5f 100644 --- a/tests/test_lin_torsion.f90 +++ b/tests/test_lin_torsion.f90 @@ -28,6 +28,14 @@ PROGRAM test_lin_torsion !! velocity of the platform about the line axis is Bt/L, the steady-roll torque of the !! march (test_nodal_twist_dynamic D), and it vanishes without the frame rates; the moment !! per unit angular acceleration is the held end section's polar inertia Irn l_e/2. + !! O one restrained end: the line of F free in torsion at End B (the anchor), then at End A + !! (the fairlead); the free end's angle is a state too (N of them), and the twist modes of + !! A are the clamped-free ones, the continuum's quarter-wave (2n - 1) pi/(2L) sqrt(GJ/Irn) + !! within the lumped-inertia error and the lumped chain's 2 sqrt(GJ/Irn)/h + !! sin((2n - 1) pi/(4N)) to 1e-6; a free end carries no torque, so the reduced roll + !! stiffness vanishes (to 1e-6 of GJ/L): with End B free the platform turns the line as a + !! whole (the feedthrough D, GJ/l_e, is cancelled by C A^-1 B), with End A free the platform + !! roll does not reach the line at all. USE CableDyn_Precision, ONLY: wp USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & @@ -59,13 +67,15 @@ PROGRAM test_lin_torsion CALL check_condensed() CALL check_elastic_end() CALL check_frame_rates() + CALL check_free_end(2) + CALL check_free_end(1) IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' ERROR STOP 1 END IF WRITE (*, '(A)') 'PASS: linearisation of a line restrained in torsion (modes, roll stiffness, condensed, '// & - 'elastic end, frame rates)' + 'elastic end, frame rates, one restrained end)' CONTAINS @@ -77,13 +87,13 @@ SUBROUTINE require(cond, label) WRITE (*, '(A)') 'FAIL: '//TRIM(label) END SUBROUTINE require - SUBROUTINE write_deck(path, irn_v, bt_v, tors_b) + SUBROUTINE write_deck(path, irn_v, bt_v, tors_b, tors_a) !! The straight vertical line, neutrally buoyant (mass rhoW pi d^2/4) and without drag or !! added mass, so the 0.5 % strain is uniform; Irn irn_v, torsional damping bt_v, and the - !! torsional restraint of End B tors_b (default Rigid). + !! torsional restraints of End B tors_b and End A tors_a (default Rigid). CHARACTER(*), INTENT(IN) :: path REAL(wp), INTENT(IN) :: irn_v, bt_v - CHARACTER(*), INTENT(IN), OPTIONAL :: tors_b + CHARACTER(*), INTENT(IN), OPTIONAL :: tors_b, tors_a INTEGER :: u CHARACTER(240) :: ltype CHARACTER(40) :: gj_col @@ -113,7 +123,11 @@ SUBROUTINE write_deck(path, irn_v, bt_v, tors_b) WRITE (u, '(A)') '--- END CONNECTIONS ---' WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' - WRITE (u, '(A)') '1 A Pinned 0 0 -1 Rigid 1 0 0 0' + IF (PRESENT(tors_a)) THEN + WRITE (u, '(A)') '1 A Pinned 0 0 -1 '//tors_a//' 1 0 0 0' + ELSE + WRITE (u, '(A)') '1 A Pinned 0 0 -1 Rigid 1 0 0 0' + END IF IF (PRESENT(tors_b)) THEN WRITE (u, '(A)') '1 B Pinned 0 0 -1 '//tors_b//' 1 0 0 0' ELSE @@ -583,4 +597,57 @@ SUBROUTINE check_frame_rates() CALL require(.NOT. MAXVAL(ABS(b)) > 0.0_wp, 'R: the angular acceleration does not drive the line states') CALL CD_AGG_End(agg, es, em) END SUBROUTINE check_frame_rates + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_free_end(kfree) + !! O: the line of F free in torsion at deck End kfree (1 = A, 2 = B). + INTEGER, INTENT(IN) :: kfree + REAL(wp), ALLOCATABLE :: amat(:, :), cmom(:, :), b(:), omega(:) + REAL(wp) :: dmom(3), coupling, w_cont, w_disc, e_cont, e_disc, k_red, h, x + INTEGER :: n, es + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(5) :: tag + tag = MERGE('End A', 'End B', kfree == 1) + IF (kfree == 1) THEN + CALL write_deck('lin_torsion_free.dat', IRN, 0.0_wp, tors_a='Free') + ELSE + CALL write_deck('lin_torsion_free.dat', IRN, 0.0_wp, tors_b='Free') + END IF + CALL setup('lin_torsion_free.dat', ok) + IF (.NOT. ok) RETURN + CALL require(agg%cables(1)%line%torsion%end_free(3 - kfree), 'O ('//tag//' free): the line is solved free there') + ! the held end's angle is not a state, the free end's is + CALL require(ntw == NE, 'O ('//tag//' free): the free end''s angle is a state') + IF (ntw /= NE) THEN + CALL CD_AGG_End(agg, es, em) + RETURN + END IF + ALLOCATE (amat(2*nx2, 2*nx2), cmom(3, 2*nx2), b(2*nx2), omega(ntw)) + CALL state_matrix(amat, cmom) + CALL twist_eigen(amat, omega, coupling) + h = L/REAL(NE, wp) + WRITE (*, '(A,A,A,I0,A,I0,A,ES10.3)') 'O: ', tag, ' free: ', 2*nx2, ' states (', 2*ntw, & + ' twist); twist-line coupling / block ', coupling + CALL require(coupling <= 1.0e-8_wp, 'O: the twist block is decoupled from the line states') + DO n = 1, 3 + x = REAL(2*n - 1, wp)*PI/(4.0_wp*REAL(NE, wp)) + w_cont = REAL(2*n - 1, wp)*PI/(2.0_wp*L)*SQRT(GJ/IRN) + w_disc = 2.0_wp/h*SQRT(GJ/IRN)*SIN(x) + e_cont = omega(n)/w_cont - 1.0_wp + e_disc = omega(n)/w_disc - 1.0_wp + WRITE (*, '(A,A,A,I0,A,F12.8,A,F12.8,A,ES10.3,A,F12.8,A,ES10.3,A)') 'O: ', tag, ' free: mode ', n, ' omega ', & + omega(n), ' rad/s; quarter-wave ', w_cont, ' (', e_cont, '); clamped-free chain ', w_disc, ' (', e_disc, ')' + CALL require(ABS(e_disc) <= 1.0e-6_wp, 'O: the twist mode matches the clamped-free chain') + ! the lumped-inertia chain lies x^2/6 below the continuum + CALL require(ABS(e_cont) <= 1.2_wp*x**2/6.0_wp + 1.0e-6_wp, & + 'O: the twist mode matches the quarter-wave (2n - 1) pi/(2L) sqrt(GJ/Irn)') + END DO + CALL input_columns(3, 1, b, dmom) + k_red = reduced(amat, cmom, b, dmom, 3) + WRITE (*, '(A,A,A,ES12.4,A,ES16.9,A,ES16.9)') 'O: ', tag, ' free: -(D - C A^-1 B) ', k_red, & + ' N m/rad (GJ/L ', GJ/L, '); feedthrough D alone ', -dmom(3) + CALL require(ABS(k_red) <= 1.0e-6_wp*GJ/L, 'O: a line free at one end has no roll stiffness') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_free_end + END PROGRAM test_lin_torsion diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 new file mode 100644 index 00000000..57bf791d --- /dev/null +++ b/tests/test_mixed_route_torsion.f90 @@ -0,0 +1,810 @@ +! File: tests/test_mixed_route_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Torsion and prescribed motion on the standalone mixed route: a deck that mixes EI = 0 and +!> finite-EI lines without bodies, rods or Free/Connect points runs on the coupled aggregate, +!> marched by the standalone driver (the executable given as the first argument) through the +!> deck's motionFile or vesselMotion table. +!> 1. Vessel roll, pitch and heave from rest (vesselMotion) drive a sagging finite-EI line +!> clamped (Rigid) at both ends and restrained in torsion (Pretwist 20 deg at End B), run +!> alone on the standalone cubic-Hermite route and beside a moving EI = 0 chain on the mixed +!> route. Torq, Twist and the mid-line node agree to the printed precision of the .out +!> (8 digits), the fairlead and anchor tension, fairlead inclination and End A bend moment +!> (the Rigid clamp turns with the vessel on both routes) to 5e-5 of their range: the +!> coupled cables step with the coupled Newton controls (relative tolerance 5e-3, a fresh +!> factor every step), the standalone line with the deck's (1e-8, a carried factor). With +!> the aggregate cables given the standalone controls the mixed route reproduces every +!> channel of the standalone route to the printed precision. The same chain moved by a +!> motionFile of the same point translations holds the frames: the End A bend moment and +!> the twist then differ from the turning-vessel run (the rotation is not dropped). +!> 2. A motionFile surge with a roll column (End A rolls 20 deg about its director, from +!> rest) gives the same agreement between the two routes. +!> 3. Quasi-static torsion of a straight neutral line on the mixed route, End A held, or rolled +!> slowly about the line axis by a vessel or by the roll column: Twist1 = Pretwist - roll +!> and Torq = GJ Twist / L at both ends at every step (1e-6 GJ). +!> 4. A non-zero roll column at the chain's point (no line restrained in torsion there) is +!> refused by name on the mixed route. +!> 5. TMax = 0 with a motionFile whose first row is 2 cm off the deck fairlead: both routes write +!> the t = 0 row at that installed row (the fairlead element takes the 2 cm against the +!> static interior: FairTen 3.5 MN against 29 kN) and agree to the printed precision, and +!> both write the .static.out of the static solve (fairlead x = 0) before it. +!> 6. Without the force blend a line restrained in torsion runs a static mixed deck (TMax = 0, +!> no step) and its torque, as the single-line route, and a dynamic one stops by name; so +!> does a line restrained at one end only (static: Torq/Twist channels, no torque at the +!> free end), which the caller-driven parse must still resolve as a static run. +!> 7. ATTACHMENTS: the gate 2 line carrying three buoyancy modules (ATTACHMENTS, with drag and +!> added mass), its torsion stage after the attachment polish on both routes, gives the gate 2 +!> agreement between the single-line route and the mixed route beside the chain. +PROGRAM test_mixed_route_torsion + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_EvalChannel, & + CD_AGG_NumChannels, CD_AGG_End, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations, CD_AGG_HasMotion, CD_AGG_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, D2R = PI/180.0_wp, RHOW = 1025.0_wp + REAL(wp), PARAMETER :: DT = 0.05_wp, TMAX = 10.0_wp, PERIOD = 10.0_wp + INTEGER, PARAMETER :: NSTEP = 200, MAXCOL = 32, MAXROW = 400 + ! gate 3: End A held, rolled by a vessel, rolled by the motionFile roll column + INTEGER, PARAMETER :: QS_HELD = 0, QS_VESSEL = 1, QS_ROLL = 2 + CHARACTER(*), PARAMETER :: CAB_T = 'cab 0.2 60.0 4.0e8 0.0 1.0e4 1.0e8 1.0e4 1.0 1.0e-12 1.2 0.1 1.0 0.0' + CHARACTER(*), PARAMETER :: CHAIN_T = 'chain 0.1 50.0 1.0e9 -1.0 0.0 0 0 0 0 1.37 0.64 1.0 0.0' + ! channels compared to the printed precision, the loads to LOAD_TOL of their range, the + ! out-of-plane node offset (about 1e-4 m) to POS_TOL + CHARACTER(16), PARAMETER :: EXACT(5) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'L1N21px', 'L1N21pz'] + CHARACTER(16), PARAMETER :: LOADS(4) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'FairIncl1', 'BendMom1N1'] + ! the gate 1 and 2 channels of line 1 (the same in both decks) and the chain's + CHARACTER(16), PARAMETER :: OUTS(10) = [LOADS, EXACT(1:3), [CHARACTER(16) :: 'L1N21px', 'L1N21py', 'L1N21pz']] + CHARACTER(16), PARAMETER :: CHAIN_OUTS(2) = [CHARACTER(16) :: 'FairTen2', 'Point3pz'] + REAL(wp), PARAMETER :: LOAD_TOL = 5.0e-5_wp, POS_TOL = 1.0e-6_wp + ! printed precision of ES15.7E3: half a unit in the 8th significant digit of each value, with a + ! unit of the 8th digit of the channel's range for a value that crosses zero + REAL(wp), PARAMETER :: PRINT_TOL = 6.0e-8_wp, PRINT_FLOOR = 1.0e-7_wp + CHARACTER(1024) :: driver + CHARACTER(160) :: neutral_t + INTEGER :: n_fail = 0 + + IF (COMMAND_ARGUMENT_COUNT() < 1) ERROR STOP 'usage: test_mixed_route_torsion ' + CALL GET_COMMAND_ARGUMENT(1, driver) + ! neutral 0.2 m section of test_torsion_deck: EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 + WRITE (neutral_t, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + + CALL check_vessel_routes() + CALL check_roll_routes() + CALL check_quasi_static(QS_HELD) + CALL check_quasi_static(QS_VESSEL) + CALL check_quasi_static(QS_ROLL) + CALL check_refusal() + CALL check_static_row1() + CALL check_static_blend() + CALL check_attachment_routes() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' mixed-route torsion gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: torsion and prescribed motion on the standalone mixed route' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, outs, atts) + CHARACTER(*), INTENT(IN) :: path, types(:), points(:), lines(:), sections(:), endconns(:), options(:), outs(:) + ! ATTACHMENTS rows (none when absent) + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'mixed-route torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + DO i = 1, SIZE(types) + WRITE (u, '(A)') TRIM(types(i)) + END DO + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(points) + WRITE (u, '(A)') TRIM(points(i)) + END DO + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + DO i = 1, SIZE(lines) + WRITE (u, '(A)') TRIM(lines(i)) + END DO + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + DO i = 1, SIZE(sections) + WRITE (u, '(A)') TRIM(sections(i)) + END DO + IF (PRESENT(atts)) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(atts) + WRITE (u, '(A)') TRIM(atts(i)) + END DO + END IF + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + DO i = 1, SIZE(endconns) + WRITE (u, '(A)') TRIM(endconns(i)) + END DO + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE sag_deck(path, point_type, chain, options, tmax_row, atts) + !! Gates 1 and 2: a 100 m finite-EI line from End A (0, 0, -50) on a point_type point to a + !! Fixed End B (95, 0, -60), 40 elements, both ends Rigid in bending and in torsion + !! (Pretwist 20 deg at End B); with chain, an EI = 0 chain from (0, 20, -50) on a second + !! point_type point to a Fixed (0, 110, -100); atts: ATTACHMENTS rows of line 1. + CHARACTER(*), INTENT(IN) :: path, point_type, options(:) + LOGICAL, INTENT(IN) :: chain + ! the TMax row (default 10 s) + CHARACTER(*), INTENT(IN), OPTIONAL :: tmax_row + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + CHARACTER(48) :: points(4), tm + CHARACTER(96) :: ec(2) + ec(1) = '1 A Rigid 1 0 -0.1 Rigid 0 0 1 0' + ec(2) = '1 B Rigid 1 0 0.1 Rigid 0 0 1 20' + tm = '10.0 TMax' + IF (PRESENT(tmax_row)) tm = tmax_row + points(1) = '1 '//point_type//' 0.0 0.0 -50.0 0 0 0 0' + points(2) = '2 Fixed 95.0 0.0 -60.0 0 0 0 0' + points(3) = '3 '//point_type//' 0.0 20.0 -50.0 0 0 0 0' + points(4) = '4 Fixed 0.0 110.0 -100.0 0 0 0 0' + IF (PRESENT(atts)) THEN + IF (chain) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T, CHAIN_T], points, [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], & + [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], [OUTS, CHAIN_OUTS], atts) + ELSE + CALL write_deck(path, [CHARACTER(96) :: CAB_T], points(1:2), [CHARACTER(16) :: '1 1 2 -'], & + [CHARACTER(24) :: '1 cab 100.0 40'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], OUTS, atts) + END IF + ELSE IF (chain) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T, CHAIN_T], points, [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], & + [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], [OUTS, CHAIN_OUTS]) + ELSE + CALL write_deck(path, [CHARACTER(96) :: CAB_T], points(1:2), [CHARACTER(16) :: '1 1 2 -'], & + [CHARACTER(24) :: '1 cab 100.0 40'], EC, & + [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', tm, options], OUTS) + END IF + END SUBROUTINE sag_deck + + PURE SUBROUTINE smooth(amplitude, t, f, df, d2f) + !! f = F (1 - cos w t) / 2 and its rates, w = 2 pi / PERIOD: a motion from rest. + REAL(wp), INTENT(IN) :: amplitude, t + REAL(wp), INTENT(OUT) :: f, df, d2f + REAL(wp) :: w + w = 2.0_wp*PI/PERIOD + f = 0.5_wp*amplitude*(1.0_wp - COS(w*t)) + df = 0.5_wp*amplitude*w*SIN(w*t) + d2f = 0.5_wp*amplitude*w*w*COS(w*t) + END SUBROUTINE smooth + + SUBROUTINE vessel_state(t, r, v, a, rot, omega, alpha) + !! The gate 1 vessel about its reference (0, 0, -50): heave 1 m, roll 20 deg and pitch 4 deg + !! from rest, R = Ry(pitch) Rx(roll); the global angular velocity of these Euler rates is + !! omega = Ry(pitch) (roll', 0, 0) + (0, pitch', 0), alpha its derivative. + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: r(3), v(3), a(3), rot(3, 3), omega(3), alpha(3) + REAL(wp) :: z, vz, az, ro, dro, d2ro, p, dp, d2p, cr, sr, cp, sp + CALL smooth(1.0_wp, t, z, vz, az) + CALL smooth(20.0_wp*D2R, t, ro, dro, d2ro) + CALL smooth(4.0_wp*D2R, t, p, dp, d2p) + r = [0.0_wp, 0.0_wp, -50.0_wp + z] + v = [0.0_wp, 0.0_wp, vz] + a = [0.0_wp, 0.0_wp, az] + cr = COS(ro); sr = SIN(ro); cp = COS(p); sp = SIN(p) + ! rot = Ry(p) Rx(ro), columns + rot(:, 1) = [cp, 0.0_wp, -sp] + rot(:, 2) = [sp*sr, cr, cp*sr] + rot(:, 3) = [sp*cr, -sr, cp*cr] + omega = [dro*cp, dp, -dro*sp] + alpha = [d2ro*cp - dro*dp*sp, d2p, -d2ro*sp - dro*dp*cp] + END SUBROUTINE vessel_state + + FUNCTION cross(x, y) RESULT(c) + REAL(wp), INTENT(IN) :: x(3), y(3) + REAL(wp) :: c(3) + c = [x(2)*y(3) - x(3)*y(2), x(3)*y(1) - x(1)*y(3), x(1)*y(2) - x(2)*y(1)] + END FUNCTION cross + + SUBROUTINE write_vessel_record(path) + !! The gate 1 vessel as a vesselMotion record (time x y z roll pitch yaw vx vy vz wx wy wz ax ay + !! az alx aly alz). + CHARACTER(*), INTENT(IN) :: path + REAL(wp) :: t, r(3), v(3), a(3), rot(3, 3), omega(3), alpha(3), ro, dro, d2ro, p, dp, d2p + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL vessel_state(t, r, v, a, rot, omega, alpha) + CALL smooth(20.0_wp, t, ro, dro, d2ro) + CALL smooth(4.0_wp, t, p, dp, d2p) + WRITE (u, '(F8.3,18ES25.16E3)') t, r, ro, p, 0.0_wp, v, omega, a, alpha + END DO + CLOSE (u) + END SUBROUTINE write_vessel_record + + SUBROUTINE write_vessel_points(path) + !! The translations the gate 1 vessel gives points 1 and 3 (x = r + R p, v = v_r + w x R p, + !! a = a_r + al x R p + w x (w x R p)) as motionFile rows without a roll column. + CHARACTER(*), INTENT(IN) :: path + REAL(wp) :: t, r(3), v(3), a(3), rot(3, 3), omega(3), alpha(3), rp(3) + REAL(wp), PARAMETER :: P_LOCAL(3, 2) = RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 20.0_wp, 0.0_wp], [3, 2]) + INTEGER :: u, k, j + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL vessel_state(t, r, v, a, rot, omega, alpha) + DO j = 1, 2 + rp = MATMUL(rot, P_LOCAL(:, j)) + WRITE (u, '(F8.3,I3,9ES25.16E3)') t, 2*j - 1, r + rp, v + cross(omega, rp), & + a + cross(alpha, rp) + cross(omega, cross(omega, rp)) + END DO + END DO + CLOSE (u) + END SUBROUTINE write_vessel_points + + SUBROUTINE write_roll_rows(path, with_chain_point) + !! Gate 2 motionFile: point 1 surges 1 m and rolls 20 deg (roll column), from rest; point 3 + !! (with_chain_point) surges with it and gives no roll column. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: with_chain_point + REAL(wp) :: t, x, vx, ax, ro, dro, d2ro + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL smooth(1.0_wp, t, x, vx, ax) + CALL smooth(20.0_wp, t, ro, dro, d2ro) + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3)') t, ' 1 ', x, ' 0 -50 ', vx, ' 0 0 ', ax, & + ' 0 0 ', ro + IF (with_chain_point) WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 3 ', x, ' 20 -50 ', vx, & + ' 0 0 ', ax, ' 0 0' + END DO + CLOSE (u) + END SUBROUTINE write_roll_rows + + SUBROUTINE run_driver(deck, root, ok) + !! Run the driver executable on a deck, its stdout and stderr to .log. + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ex, cs + CALL EXECUTE_COMMAND_LINE('"'//TRIM(driver)//'" '//deck//' '//root//' > '//root//'.log 2>&1', & + WAIT=.TRUE., EXITSTAT=ex, CMDSTAT=cs) + ok = cs == 0 .AND. ex == 0 + END SUBROUTINE run_driver + + LOGICAL FUNCTION log_has(root, text) RESULT(found) + CHARACTER(*), INTENT(IN) :: root, text + CHARACTER(4096) :: line + INTEGER :: u, ios + found = .FALSE. + OPEN (NEWUNIT=u, FILE=root//'.log', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (INDEX(line, text) > 0) found = .TRUE. + END DO + CLOSE (u) + END FUNCTION log_has + + SUBROUTINE read_out(path, names, vals, nrow) + !! The channel names and rows of a driver .out file (Time first). + CHARACTER(*), INTENT(IN) :: path + CHARACTER(32), INTENT(OUT) :: names(MAXCOL) + REAL(wp), INTENT(OUT) :: vals(MAXROW, MAXCOL) + INTEGER, INTENT(OUT) :: nrow + CHARACTER(4096) :: buf + INTEGER :: u, ios, ncol, k + names = '' + vals = 0.0_wp + nrow = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + READ (buf, *, IOSTAT=ios) names + ncol = 0 + DO k = 1, MAXCOL + IF (LEN_TRIM(names(k)) > 0) ncol = k + END DO + DO + IF (nrow == MAXROW) EXIT + READ (u, *, IOSTAT=ios) vals(nrow + 1, 1:ncol) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + END SUBROUTINE read_out + + INTEGER FUNCTION col_of(names, name) RESULT(c) + CHARACTER(32), INTENT(IN) :: names(:) + CHARACTER(*), INTENT(IN) :: name + INTEGER :: k + c = 0 + DO k = 1, SIZE(names) + IF (TRIM(names(k)) == TRIM(name)) c = k + END DO + END FUNCTION col_of + + REAL(wp) FUNCTION range_error(a, b, n) RESULT(e) + !! max |b - a| over the rows, relative to the range max |a|. + REAL(wp), INTENT(IN) :: a(:), b(:) + INTEGER, INTENT(IN) :: n + e = MAXVAL(ABS(b(1:n) - a(1:n)))/MAX(MAXVAL(ABS(a(1:n))), TINY(1.0_wp)) + IF (.NOT. IEEE_IS_FINITE(e)) e = HUGE(1.0_wp) + END FUNCTION range_error + + REAL(wp) FUNCTION print_error(a, b, n) RESULT(e) + !! max over the rows of |b - a| in units of the printed precision of a (PRINT_TOL |a|, at least + !! PRINT_FLOOR of the channel's range): <= 1 when b equals a to the digits printed. + REAL(wp), INTENT(IN) :: a(:), b(:) + INTEGER, INTENT(IN) :: n + REAL(wp) :: scale + INTEGER :: k + scale = MAXVAL(ABS(a(1:n))) + e = 0.0_wp + DO k = 1, n + e = MAX(e, ABS(b(k) - a(k))/MAX(PRINT_TOL*ABS(a(k)), PRINT_FLOOR*scale, TINY(1.0_wp))) + END DO + IF (.NOT. IEEE_IS_FINITE(e)) e = HUGE(1.0_wp) + END FUNCTION print_error + + SUBROUTINE compare_routes(label, root_a, root_b) + !! Gate 1/2 comparison of the standalone cubic-Hermite route (root_a.out) and the mixed route + !! (root_b.out) over the channels of line 1. + CHARACTER(*), INTENT(IN) :: label, root_a, root_b + CHARACTER(32) :: na(MAXCOL), nb(MAXCOL) + REAL(wp), ALLOCATABLE :: va(:, :), vb(:, :) + INTEGER :: ra, rb, k, ca, cb + REAL(wp) :: e, e_exact, e_loads + ALLOCATE (va(MAXROW, MAXCOL), vb(MAXROW, MAXCOL)) + CALL read_out(root_a//'.out', na, va, ra) + CALL read_out(root_b//'.out', nb, vb, rb) + CALL require(ra == NSTEP + 1 .AND. rb == NSTEP + 1, label//': both routes write every row') + IF (ra /= NSTEP + 1 .OR. rb /= NSTEP + 1) RETURN + e_exact = 0.0_wp + DO k = 1, SIZE(EXACT) + ca = col_of(na, EXACT(k)) + cb = col_of(nb, EXACT(k)) + CALL require(ca > 0 .AND. cb > 0, label//': channel '//TRIM(EXACT(k))//' in both outputs') + IF (ca == 0 .OR. cb == 0) CYCLE + e = print_error(va(:, ca), vb(:, cb), ra) + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': '//TRIM(EXACT(k))//' difference ', e, ' printed units' + e_exact = MAX(e_exact, e) + END DO + e_loads = 0.0_wp + DO k = 1, SIZE(LOADS) + ca = col_of(na, LOADS(k)) + cb = col_of(nb, LOADS(k)) + CALL require(ca > 0 .AND. cb > 0, label//': channel '//TRIM(LOADS(k))//' in both outputs') + IF (ca == 0 .OR. cb == 0) CYCLE + e = range_error(va(:, ca), vb(:, cb), ra) + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': '//TRIM(LOADS(k))//' difference ', e, ' of its range' + e_loads = MAX(e_loads, e) + END DO + ca = col_of(na, 'L1N21py') + cb = col_of(nb, 'L1N21py') + e = HUGE(1.0_wp) + IF (ca > 0 .AND. cb > 0) e = MAXVAL(ABS(vb(1:ra, cb) - va(1:ra, ca))) + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': L1N21py difference ', e, ' m' + CALL require(e_exact <= 2.0_wp, label//': torque, twist and node positions agree to the printed precision') + CALL require(e_loads <= LOAD_TOL, label//': end loads and bend moment agree within the Newton tolerances') + CALL require(e <= POS_TOL, label//': the out-of-plane node offset agrees within the Newton tolerances') + END SUBROUTINE compare_routes + + SUBROUTINE march_library(deck, root_a, label) + !! The mixed route's march (CableDyn_driver run_mixed_held_deck) through the aggregate library + !! with every cable given the standalone route's Newton controls (the deck's dynamic tolerance + !! 1e-8, 30 iterations, the carried factor): each channel of line 1 is compared at every + !! step with the standalone route's output root_a.out to its printed precision. + CHARACTER(*), INTENT(IN) :: deck, root_a, label + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :), omega(:, :), alpha(:, :) + REAL(wp), ALLOCATABLE :: roll(:), va(:, :), got(:, :) + CHARACTER(32) :: na(MAXCOL) + CHARACTER(2048) :: em + INTEGER :: es, n, c, step, ra, k, ca, nch, n_iter + LOGICAL :: turns, rolls, conv, stalled + REAL(wp) :: worst, v + ALLOCATE (agg, va(MAXROW, MAXCOL)) + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em, forbid_deck_ambient=.TRUE., run_tmax=TMAX, & + host_orientation=.TRUE., prescribed_motion=.TRUE.) + CALL require(es == CD_AGG_OK .AND. CD_AGG_HasMotion(agg), label//': the aggregate takes the deck motion: '// & + TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + DO c = 1, agg%ncable + agg%cables(c)%tol = 1.0e-8_wp + agg%cables(c)%max_iter = 30 + agg%cables(c)%line%tangent_reuse = .TRUE. + END DO + n = CD_AGG_NMovingPoints(agg, es, em) + nch = CD_AGG_NumChannels(agg) + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), load(3, n), orient(3, 3, n), omega(3, n), alpha(3, n), roll(n), & + got(NSTEP + 1, nch)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em) + CALL CD_AGG_MotionKinematics(agg, 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + IF (turns) THEN + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + ELSE + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em) + END IF + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(agg, es, em) + CALL require(es == CD_AGG_OK, label//': the first motion row installs: '//TRIM(em)) + DO step = 0, NSTEP + IF (step > 0) THEN + CALL CD_AGG_MotionKinematics(agg, step + 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + IF (turns) THEN + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step, & + orientation=orient, angular_velocity=omega, angular_acceleration=alpha) + ELSE IF (rolls) THEN + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step, & + roll=roll) + ELSE + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step) + END IF + IF (es /= CD_AGG_OK .OR. .NOT. conv) THEN + CALL require(.FALSE., label//': library march step: '//TRIM(em)) + EXIT + END IF + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + DO k = 1, nch + CALL CD_AGG_EvalChannel(agg, k, v, es, em) + got(step + 1, k) = v + END DO + END DO + CALL read_out(root_a//'.out', na, va, ra) + worst = 0.0_wp + IF (ra == NSTEP + 1) THEN + DO k = 1, SIZE(OUTS) + ca = col_of(na, OUTS(k)) + IF (ca > 0) worst = MAX(worst, print_error(va(:, ca), got(:, k), ra)) + END DO + ELSE + worst = HUGE(1.0_wp) + END IF + WRITE (*, '(A,A,A,ES10.3,A)') ' ', label, ': mixed route with the standalone Newton controls, largest '// & + 'difference ', worst, ' printed units' + CALL require(worst <= 2.0_wp, label//': with the same Newton controls the mixed route reproduces the '// & + 'standalone route') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE march_library + + SUBROUTINE check_vessel_routes() + !! Gate 1. + CHARACTER(32) :: nb(MAXCOL), nc(MAXCOL) + REAL(wp), ALLOCATABLE :: vb(:, :), vc(:, :) + INTEGER :: rb, rc + LOGICAL :: ok + REAL(wp) :: dm, dt_twist + CHARACTER(48), PARAMETER :: VM(2) = [CHARACTER(48) :: 'tmrt_vessel.txt vesselMotion', '0|0|-50 vesselRef'] + CALL write_vessel_record('tmrt_vessel.txt') + CALL sag_deck('tmrt_vessel_a.dat', 'Vessel', .FALSE., VM) + CALL sag_deck('tmrt_vessel_b.dat', 'Vessel', .TRUE., VM) + CALL run_driver('tmrt_vessel_a.dat', 'tmrt_vessel_a', ok) + CALL require(ok, '1: the vessel deck runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_vessel_b.dat', 'tmrt_vessel_b', ok) + CALL require(ok, '1: the mixed vessel deck with a line restrained in torsion runs') + CALL require(log_has('tmrt_vessel_b', 'mixed standalone aggregate'), '1: the mixed deck runs on the aggregate') + CALL compare_routes('1 vessel', 'tmrt_vessel_a', 'tmrt_vessel_b') + CALL march_library('tmrt_vessel_b.dat', 'tmrt_vessel_a', '1 vessel') + ! the same point translations as a motionFile: the frames are held + CALL write_vessel_points('tmrt_vessel_points.txt') + CALL sag_deck('tmrt_vessel_c.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_vessel_points.txt motionFile']) + CALL run_driver('tmrt_vessel_c.dat', 'tmrt_vessel_c', ok) + CALL require(ok, '1: the mixed deck of the vessel point translations runs') + ALLOCATE (vb(MAXROW, MAXCOL), vc(MAXROW, MAXCOL)) + CALL read_out('tmrt_vessel_b.out', nb, vb, rb) + CALL read_out('tmrt_vessel_c.out', nc, vc, rc) + IF (rb == NSTEP + 1 .AND. rc == NSTEP + 1) THEN + dm = range_error(vb(:, col_of(nb, 'BendMom1N1')), vc(:, col_of(nc, 'BendMom1N1')), rb) + dt_twist = MAXVAL(ABS(vb(1:rb, col_of(nb, 'Twist1')) - vc(1:rc, col_of(nc, 'Twist1')))) + WRITE (*, '(A,ES10.3,A,F8.3,A)') ' 1 vessel: held frames change the End A bend moment by ', dm, & + ' of its range and the twist by ', dt_twist, ' deg' + CALL require(dm > 0.01_wp .AND. dt_twist > 10.0_wp, '1: the vessel rotation turns the end frames (a '// & + 'motionFile of the same translations holds them)') + ! the chain moves with the vessel + CALL require(MAXVAL(vb(1:rb, col_of(nb, 'Point3pz'))) - MINVAL(vb(1:rb, col_of(nb, 'Point3pz'))) > 5.0_wp, & + '1: the chain point rolls with the vessel') + ELSE + CALL require(.FALSE., '1: the turning and the held-frame outputs are complete') + END IF + END SUBROUTINE check_vessel_routes + + SUBROUTINE check_roll_routes() + !! Gate 2. + LOGICAL :: ok + CALL write_roll_rows('tmrt_roll_1.txt', .FALSE.) + CALL write_roll_rows('tmrt_roll_2.txt', .TRUE.) + CALL sag_deck('tmrt_roll_a.dat', 'Coupled', .FALSE., [CHARACTER(48) :: 'tmrt_roll_1.txt motionFile']) + CALL sag_deck('tmrt_roll_b.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_roll_2.txt motionFile']) + CALL run_driver('tmrt_roll_a.dat', 'tmrt_roll_a', ok) + CALL require(ok, '2: the roll-column deck runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_roll_b.dat', 'tmrt_roll_b', ok) + CALL require(ok, '2: the mixed roll-column deck runs') + CALL compare_routes('2 roll column', 'tmrt_roll_a', 'tmrt_roll_b') + CALL march_library('tmrt_roll_b.dat', 'tmrt_roll_a', '2 roll column') + END SUBROUTINE check_roll_routes + + SUBROUTINE check_attachment_routes() + !! Gate 7: the gate 2 decks with three buoyancy modules on line 1. + LOGICAL :: ok + CHARACTER(48), PARAMETER :: ATTS(3) = [CHARACTER(48) :: '1 40.0 100.0 0.5 0.5 1.0', '1 50.0 100.0 0.5 0.5 1.0', & + '1 60.0 100.0 0.5 0.5 1.0'] + CALL write_roll_rows('tmrt_att_1.txt', .FALSE.) + CALL write_roll_rows('tmrt_att_2.txt', .TRUE.) + CALL sag_deck('tmrt_att_a.dat', 'Coupled', .FALSE., [CHARACTER(48) :: 'tmrt_att_1.txt motionFile'], atts=ATTS) + CALL sag_deck('tmrt_att_b.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_att_2.txt motionFile'], atts=ATTS) + CALL run_driver('tmrt_att_a.dat', 'tmrt_att_a', ok) + CALL require(ok, '7: the roll-column deck with ATTACHMENTS runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_att_b.dat', 'tmrt_att_b', ok) + CALL require(ok, '7: the mixed roll-column deck with ATTACHMENTS runs') + CALL require(log_has('tmrt_att_b', 'mixed standalone aggregate'), '7: the mixed deck runs on the aggregate') + CALL compare_routes('7 attachments', 'tmrt_att_a', 'tmrt_att_b') + END SUBROUTINE check_attachment_routes + + SUBROUTINE check_quasi_static(mode) + !! Gate 3: the straight 100 m neutral line of test_torsion_deck from (0, 0, -50) to a Fixed + !! (100, 0, -50), clamped and restrained at both ends (Pretwist 90 deg at End B), beside a + !! chain from (0, 10, -50) to a Fixed (0, 100, -100); End A held (roll 0) or rolled about the + !! line axis by up to 30 deg from rest over 10 s (dtM 0.1): Twist1 = 90 - roll, + !! Torq = GJ Twist / L at both ends. + INTEGER, INTENT(IN) :: mode + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + CHARACTER(48) :: points(4) + CHARACTER(48), ALLOCATABLE :: options(:) + CHARACTER(32) :: names(MAXCOL) + REAL(wp), ALLOCATABLE :: vals(:, :) + REAL(wp) :: t, ro, dro, d2ro, werr, terr, twist + INTEGER :: u, k, nrow + LOGICAL :: ok + CHARACTER(16) :: label + REAL(wp) :: amplitude + OPEN (NEWUNIT=u, FILE='tmrt_qs_motion.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, 100 + t = 0.1_wp*k + CALL smooth(30.0_wp, t, ro, dro, d2ro) + IF (mode == QS_VESSEL) THEN + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 0 0 -50 ', ro, ' 0 0 0 0 0 ', dro*D2R, & + ' 0 0 0 0 0 ', d2ro*D2R, ' 0 0' + ELSE IF (mode == QS_ROLL) THEN + WRITE (u, '(F8.3,A,ES25.16E3)') t, ' 1 0 0 -50 0 0 0 0 0 0 ', ro + WRITE (u, '(F8.3,A)') t, ' 3 0 10 -50 0 0 0 0 0 0' + END IF + END DO + CLOSE (u) + points(1) = '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + points(2) = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + points(3) = '3 Coupled 0.0 10.0 -50.0 0 0 0 0' + points(4) = '4 Fixed 0.0 100.0 -100.0 0 0 0 0' + amplitude = 30.0_wp + SELECT CASE (mode) + CASE (QS_VESSEL) + label = '3 vessel roll' + points(1) = '1 Vessel 0.0 0.0 -50.0 0 0 0 0' + points(3) = '3 Vessel 0.0 10.0 -50.0 0 0 0 0' + options = [CHARACTER(48) :: '0.1 dtM', '10.0 TMax', 'tmrt_qs_motion.txt vesselMotion', '0|0|-50 vesselRef'] + CASE (QS_ROLL) + label = '3 roll column' + options = [CHARACTER(48) :: '0.1 dtM', '10.0 TMax', 'tmrt_qs_motion.txt motionFile'] + CASE DEFAULT + label = '3 held' + amplitude = 0.0_wp + options = [CHARACTER(48) :: '0.1 dtM', '10.0 TMax'] + END SELECT + CALL write_deck('tmrt_qs.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + options, [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'FairTen2']) + CALL run_driver('tmrt_qs.dat', 'tmrt_qs', ok) + CALL require(ok, TRIM(label)//': the mixed deck runs') + ALLOCATE (vals(MAXROW, MAXCOL)) + CALL read_out('tmrt_qs.out', names, vals, nrow) + CALL require(nrow == 101, TRIM(label)//': every row written') + werr = 0.0_wp + terr = 0.0_wp + DO k = 1, nrow + CALL smooth(amplitude, vals(k, 1), ro, dro, d2ro) + twist = 90.0_wp - ro + werr = MAX(werr, ABS(vals(k, col_of(names, 'Twist1')) - twist)) + terr = MAX(terr, ABS(vals(k, col_of(names, 'Torq1N1')) - GJ*twist*D2R/L), & + ABS(vals(k, col_of(names, 'Torq1N41')) - GJ*twist*D2R/L)) + END DO + IF (nrow == 0) THEN + werr = HUGE(1.0_wp) + terr = HUGE(1.0_wp) + END IF + WRITE (*, '(A,A,ES10.3,A,ES10.3,A)') ' ', TRIM(label)//': Twist1 error ', werr, ' deg, torque error ', terr, & + ' N m' + CALL require(werr <= 1.0e-6_wp, TRIM(label)//': Twist1 = Pretwist - roll at every step') + CALL require(terr <= 1.0e-6_wp*GJ, TRIM(label)//': Torq = GJ Twist / L at both ends at every step') + END SUBROUTINE check_quasi_static + + SUBROUTINE check_refusal() + !! Gate 4. + LOGICAL :: ok + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE='tmrt_bad_roll.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + WRITE (u, '(F8.3,A,F6.2)') DT*k, ' 1 0 0 -50 0 0 0 0 0 0 ', 0.0_wp + WRITE (u, '(F8.3,A,F6.2)') DT*k, ' 3 0 20 -50 0 0 0 0 0 0 ', MERGE(0.0_wp, 5.0_wp, k == 0) + END DO + CLOSE (u) + CALL sag_deck('tmrt_bad.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_bad_roll.txt motionFile']) + CALL run_driver('tmrt_bad.dat', 'tmrt_bad', ok) + CALL require(.NOT. ok, '4: a roll column at the chain point stops the run') + CALL require(log_has('tmrt_bad', 'has a non-zero roll column'), '4: the roll column at the chain point is named') + END SUBROUTINE check_refusal + + REAL(wp) FUNCTION static_fairlead(root, column) RESULT(x) + !! Column `column` of line 1's End A (the first node row) in .static.out (4: X, 7: + !! tension). + CHARACTER(*), INTENT(IN) :: root + INTEGER, INTENT(IN) :: column + CHARACTER(4096) :: buf + REAL(wp) :: row(12) + INTEGER :: u, ios, k + x = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE=root//'.static.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO k = 1, 3 + READ (u, '(A)', IOSTAT=ios) buf + END DO + READ (u, *, IOSTAT=ios) row + IF (ios == 0) x = row(column) + CLOSE (u) + END FUNCTION static_fairlead + + SUBROUTINE check_static_row1() + !! Gate 5. + CHARACTER(32) :: na(MAXCOL), nb(MAXCOL) + REAL(wp), ALLOCATABLE :: va(:, :), vb(:, :) + INTEGER :: u, ra, rb, k, ca, cb + LOGICAL :: ok + REAL(wp) :: e, xa, xb, ta, tb + DO k = 1, 2 + OPEN (NEWUNIT=u, FILE=MERGE('tmrt_t0_1.txt', 'tmrt_t0_2.txt', k == 1), STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '0 1 0.02 0 -50 0 0 0 0 0 0' + IF (k == 2) WRITE (u, '(A)') '0 3 0.02 20 -50 0 0 0 0 0 0' + CLOSE (u) + END DO + CALL sag_deck('tmrt_t0_a.dat', 'Coupled', .FALSE., [CHARACTER(48) :: 'tmrt_t0_1.txt motionFile'], '0.0 TMax') + CALL sag_deck('tmrt_t0_b.dat', 'Coupled', .TRUE., [CHARACTER(48) :: 'tmrt_t0_2.txt motionFile'], '0.0 TMax') + CALL run_driver('tmrt_t0_a.dat', 'tmrt_t0_a', ok) + CALL require(ok, '5: the TMax = 0 motion deck runs on the single-line route') + CALL run_driver('tmrt_t0_b.dat', 'tmrt_t0_b', ok) + CALL require(ok, '5: the TMax = 0 mixed motion deck runs') + ALLOCATE (va(MAXROW, MAXCOL), vb(MAXROW, MAXCOL)) + CALL read_out('tmrt_t0_a.out', na, va, ra) + CALL read_out('tmrt_t0_b.out', nb, vb, rb) + CALL require(ra == 1 .AND. rb == 1, '5: one t = 0 row on each route') + IF (ra /= 1 .OR. rb /= 1) RETURN + e = 0.0_wp + DO k = 1, SIZE(OUTS) + ca = col_of(na, OUTS(k)) + cb = col_of(nb, OUTS(k)) + IF (ca == 0 .OR. cb == 0) THEN + e = HUGE(1.0_wp) + ELSE IF (TRIM(OUTS(k)) == 'L1N21py') THEN + e = MAX(e, ABS(vb(1, cb) - va(1, ca))/POS_TOL) + ELSE IF (ANY(LOADS == OUTS(k))) THEN + e = MAX(e, ABS(vb(1, cb) - va(1, ca))/(LOAD_TOL*ABS(va(1, ca)))) + ELSE + e = MAX(e, print_error(va(:, ca), vb(:, cb), 1)/2.0_wp) + END IF + END DO + xa = static_fairlead('tmrt_t0_a', 4) + xb = static_fairlead('tmrt_t0_b', 4) + ta = static_fairlead('tmrt_t0_a', 7) + tb = static_fairlead('tmrt_t0_b', 7) + WRITE (*, '(A,ES10.3,A,2ES12.4,A)') ' 5 TMax = 0, row 1 off by 2 cm: t = 0 rows agree to ', e, & + ' of their tolerances; static fairlead x ', xa, xb, ' m' + CALL require(e <= 1.0_wp, '5: both routes write the t = 0 row at the installed row 1') + CALL require(va(1, col_of(na, 'FairTen1')) > 10.0_wp*ta .AND. vb(1, col_of(nb, 'FairTen1')) > 10.0_wp*tb, & + '5: the t = 0 row carries the installed row 1, not the static state') + CALL require(ABS(xa) <= 1.0e-9_wp .AND. ABS(xb) <= 1.0e-9_wp, & + '5: both routes write the static configuration before row 1 moves the fairlead') + END SUBROUTINE check_static_row1 + + SUBROUTINE check_static_blend() + !! Gate 6. + REAL(wp), PARAMETER :: GJ = 5.0e4_wp, L = 100.0_wp + CHARACTER(32) :: names(MAXCOL) + REAL(wp), ALLOCATABLE :: vals(:, :) + CHARACTER(48) :: points(4) + INTEGER :: nrow + LOGICAL :: ok + REAL(wp) :: terr + points(1) = '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + points(2) = '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + points(3) = '3 Coupled 0.0 10.0 -50.0 0 0 0 0' + points(4) = '4 Fixed 0.0 100.0 -100.0 0 0 0 0' + CALL write_deck('tmrt_blend_s.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + [CHARACTER(48) :: '0.1 dtM', '0.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + CALL run_driver('tmrt_blend_s.dat', 'tmrt_blend_s', ok) + CALL require(ok, '6: a static mixed deck with torsion runs without the force blend') + ALLOCATE (vals(MAXROW, MAXCOL)) + CALL read_out('tmrt_blend_s.out', names, vals, nrow) + terr = HUGE(1.0_wp) + IF (nrow == 1) terr = ABS(vals(1, col_of(names, 'Torq1N1')) - GJ*90.0_wp*D2R/L) + WRITE (*, '(A,ES10.3,A)') ' 6 static mixed deck without the force blend: torque error ', terr, ' N m' + CALL require(terr <= 1.0e-6_wp*GJ, '6: the static torque is GJ Phi / L') + CALL write_deck('tmrt_blend_d.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & + [CHARACTER(48) :: '0.1 dtM', '1.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + CALL run_driver('tmrt_blend_d.dat', 'tmrt_blend_d', ok) + CALL require(.NOT. ok, '6: a dynamic mixed deck with torsion and the configuration blend stops') + CALL require(log_has('tmrt_blend_d', 'torsion in a dynamic run needs the force-blended'), & + '6: the configuration blend of a dynamic torsion run is named') + ! one restrained end: the aggregate parses the deck caller-driven, so the static run must + ! reach the one-end resolution, or the line is left unsolved in torsion and its channels + ! refused; the free End B carries no torque + CALL write_deck('tmrt_blend_s1.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], & + [CHARACTER(48) :: '0.1 dtM', '0.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + BLOCK + INTEGER :: u, ios + ! no output of an earlier run may stand in for this one + OPEN (NEWUNIT=u, FILE='tmrt_blend_s1.out', STATUS='OLD', IOSTAT=ios) + IF (ios == 0) CLOSE (u, STATUS='DELETE') + END BLOCK + CALL run_driver('tmrt_blend_s1.dat', 'tmrt_blend_s1', ok) + CALL require(ok, '6: a static mixed deck with one restrained end runs without the force blend') + terr = HUGE(1.0_wp) + nrow = 0 + IF (ok) CALL read_out('tmrt_blend_s1.out', names, vals, nrow) + IF (nrow == 1) terr = ABS(vals(1, col_of(names, 'Torq1N1'))) + WRITE (*, '(A,ES10.3,A)') ' 6 static mixed deck, one restrained end: torque ', terr, ' N m' + CALL require(terr <= 1.0e-6_wp*GJ*90.0_wp*D2R/L, '6: the free end of a static one-end line carries no torque') + CALL write_deck('tmrt_blend_d1.dat', [CHARACTER(160) :: neutral_t, CHAIN_T], points, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], & + [CHARACTER(48) :: '0.1 dtM', '1.0 TMax', 'False alpha_force_blend'], & + [CHARACTER(16) :: 'Torq1N1', 'Twist1']) + CALL run_driver('tmrt_blend_d1.dat', 'tmrt_blend_d1', ok) + CALL require(.NOT. ok, '6: a dynamic one-end torsion run with the configuration blend stops') + CALL require(log_has('tmrt_blend_d1', 'torsion in a dynamic run needs the force-blended'), & + '6: the configuration blend of a dynamic one-end torsion run is named') + END SUBROUTINE check_static_blend +END PROGRAM test_mixed_route_torsion diff --git a/tests/test_modal_torsion_deck.py b/tests/test_modal_torsion_deck.py index 092ac0fd..b316ab9b 100644 --- a/tests/test_modal_torsion_deck.py +++ b/tests/test_modal_torsion_deck.py @@ -14,7 +14,15 @@ deck's axes. 2. tests/data/torsion_lazy_wave_modes.dat, the lazy wave twisted two turns, runs its modes: 12 ascending, finite frequencies with PolarShare in [0, 1] and a dTwist column. -Both fail closed on a driver that refuses nModes with torsion. +3. The straight line of 1 restrained in torsion at one end only, the other free to twist (End B + free, then End A): its torsional modes are the clamped-free chain's + 2 sqrt(GJ/Irn)/l0 sin((2n - 1) pi/(4 NE)) (the free end's half polar mass is the mid-node of + a clamped-clamped chain twice as long) and the continuum's quarter-wave (2n - 1) pi/(2 L0) + sqrt(GJ/Irn) within the chain's own 1 - sin(x)/x, x = (2n - 1) pi/(4 NE); the first one's + dTwist is sin(pi s/(2 L0)) from the restrained end, largest at the free end; the bending and + axial modes are those of the TorsStiffness Free deck. +1 and 2 fail closed on a driver that refuses nModes with torsion, 3 on one that does not solve +the torsion of a line restrained at one end with nModes (no twist columns). """ from __future__ import annotations @@ -31,7 +39,7 @@ REL_EXACT = 2.0e-8 -def straight_deck(torsion: str, heading_deg: float = 0.0) -> str: +def straight_deck(torsion: str, heading_deg: float = 0.0, torsion_b: str | None = None) -> str: mass = RHO_W * math.pi * DIAM**2 / 4.0 # neutrally buoyant: the line stays straight span = L0 * (1.0 + TENSION / EA) c, s = math.cos(math.radians(heading_deg)), math.sin(math.radians(heading_deg)) @@ -54,7 +62,7 @@ def straight_deck(torsion: str, heading_deg: float = 0.0) -> str: {bar} END CONNECTIONS {bar} LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist 1 A Rigid {c!r} {s!r} 0 {torsion} 0 0 1 0 -1 B Rigid {c!r} {s!r} 0 {torsion} 0 0 1 0 +1 B Rigid {c!r} {s!r} 0 {torsion if torsion_b is None else torsion_b} 0 0 1 0 {bar} OPTIONS {bar} 9.80665 g {RHO_W!r} rhoW @@ -172,6 +180,63 @@ def check_straight(exe: str, out: Path) -> list[str]: return failures +def check_one_end(exe: str, out: Path) -> list[str]: + failures: list[str] = [] + _, freq0, _, _ = read_modes(run_deck(exe, out, "straight_free", straight_deck("Free"))) + omega0 = [row[4] for row in freq0] + l0 = L0 / NE + for label, row_a, row_b in (("End B free", "Rigid", "Free"), ("End A free", "Free", "Rigid")): + name = "one_end_" + label.split()[1].lower() + fh, freq, sh, shapes = read_modes(run_deck(exe, out, name, straight_deck(row_a, torsion_b=row_b))) + if fh[-1] != "PolarShare" or sh[-1] != "dTwist": + failures.append(f"{label}: no PolarShare/dTwist columns ({fh}, {sh})") + continue + n = 0 + other = [] + for j, row in enumerate(freq, start=1): + om, share = row[4], row[5] + if share <= 0.5: + other.append(om) + continue + n += 1 + x = (2 * n - 1) * math.pi / (4.0 * NE) + chain = 2.0 * math.sqrt(GJ / IRN) / l0 * math.sin(x) + cont = (2 * n - 1) * math.pi / (2.0 * L0) * math.sqrt(GJ / IRN) + err_d, err_c = abs(om / chain - 1.0), abs(om / cont - 1.0) + bound = 1.0 - math.sin(x) / x + print( + f" {label}: torsional mode {n} (mode {j}): omega {om:.6f} rad/s, quarter-wave " + f"{cont:.6f}, error {err_c:.2e} (bound {1.01 * bound:.2e}), clamped-free chain error " + f"{err_d:.2e}, polar share 1 - {1 - share:.1e}" + ) + if err_d > REL_EXACT or err_c > 1.01 * bound + REL_EXACT or 1.0 - share > REL_EXACT: + failures.append(f"{label}: torsional mode {n}: omega {om}, chain {chain}, continuum {cont}") + if n == 1: + rows = [r for r in shapes if int(r[1]) == j] + twist = [r[9] for r in rows] + # the node index from End A; the restrained end is End A when End B is free + ks = range(NE + 1) if row_a == "Rigid" else range(NE, -1, -1) + ref = [math.sin(0.5 * math.pi * k / NE) for k in ks] + sign = 1.0 if twist[NE // 2] * ref[NE // 2] > 0.0 else -1.0 + err_s = max(abs(sign * t - r) for t, r in zip(twist, ref)) + print(f" {label}: torsional mode 1 shape against sin(pi s/(2 L0)) {err_s:.2e}") + if err_s > 1.0e-6: + failures.append(f"{label}: torsional mode 1 shape {err_s}") + err_o = max(abs(om / om0 - 1.0) for om, om0 in zip(other, omega0)) + print(f" {label}: {n} torsional modes; {len(other)} others against TorsStiffness Free {err_o:.2e}") + if n < 3: + failures.append(f"{label}: expected at least 3 torsional modes among the {N_MODES} lowest, found {n}") + if err_o > REL_EXACT: + failures.append(f"{label}: bending/axial modes differ from the Free deck by {err_o}") + return failures + + +def run_deck(exe: str, out: Path, name: str, text: str) -> Path: + deck = out / f"{name}.dat" + deck.write_text(text, encoding="utf-8") + return run(exe, deck, out / name) + + def check_lazy_wave(exe: str, source: Path, out: Path) -> list[str]: failures: list[str] = [] path = run(exe, source / "tests" / "data" / "torsion_lazy_wave_modes.dat", out / "torsion_lazy_wave_modes") @@ -204,6 +269,7 @@ def main() -> int: try: failures += check_straight(args.exe, args.output) failures += check_lazy_wave(args.exe, args.source, args.output) + failures += check_one_end(args.exe, args.output) except AssertionError as exc: failures.append(str(exc)) for failure in failures: diff --git a/tests/test_rod_end_torsion.f90 b/tests/test_rod_end_torsion.f90 new file mode 100644 index 00000000..3923feb2 --- /dev/null +++ b/tests/test_rod_end_torsion.f90 @@ -0,0 +1,586 @@ +! File: tests/test_rod_end_torsion.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> A torsional END CONNECTION on a rod end (an I-tube or J-tube modelled as a rod): the End A +!> torsion frame is held by the rod and turns with its whole orientation, and the line's torque +!> returns to the rod about the line axis. Gates (multibody march, the route of every deck with +!> rods and finite-EI lines): +!> 1. a straight neutral line, stretched by 1e-4 and restrained in torsion, hung along the axis +!> of an inclined Fixed rod (the J-tube; its frame is not the global one), with the reference +!> normals given in global axes: two turns of pretwist give Torq = GJ Phi / L at every node, +!> the same torque as the line hung from a Coupled point held still (a second route, the +!> standalone finite-EI march) to the printed digits, and equal normals with equal pretwists +!> give no torque (the End A normal is carried into the rod frame; taken in the rod frame instead it +!> would twist the line by the roll of that frame); RodM about the rod's End A is the +!> torque along the line axis, M_t a (the moment returned to the rod); a 1 s march keeps the +!> torque; a bending-pinned, torsionally rigid End A carries the same torque; the deck written +!> anchor first (MoorDyn's order, NodeA the anchor) is turned around and runs bit for bit; +!> 2. a rod fixed to a rolling Rigid6 body (RODS type Body, the body attitude rolled, +!> pitched and yawed), the line hung along the rod axis and pretwisted by 30 deg, the body +!> released from rest: the body and its rod roll about the line axis as a torsional pendulum +!> (Omega = sqrt(GJ / (L I)), I the body's roll inertia plus the rod's polar inertia), at every +!> step the torque is GJ (Phi - theta) / L with theta the body's roll (quasi-static torsion), +!> the moment returned to the body is the torque along the turned line axis, and the rod's +!> RodM channel carries it (it left out the connection moment of a cable at the end of a +!> body-fixed rod); +!> 3. named refusals: a Pinned, a Free and a BodyPinned rod are axisymmetric with no roll +!> angle and cannot hold the torque; a Coupled rod carries no finite-EI line on any route; the +!> staggered body scheme, which drives a cable end by translation, refuses a torsional End A +!> on a body-fixed rod even when its bending is pinned (it ran with the frame frozen); a line +!> written anchor first onto a Pinned rod meets the Pinned rod's refusal (it read "two moving +!> ends"), and a line between two Fixed rods is refused as one with End B on a rod end. +!> 4. with the other routes: the gate 1 line on the Fixed J-tube, with torque-tension coupling +!> (GJ|K 5e4 N m2|4e5 N m) and restrained in torsion at the rod end only (End B free to twist), +!> carries no torque and its free end turns with the 1e-4 stretch, Twist1 = -(K/GJ) dl, the +!> same as from the held Coupled point; free at the rod end and restrained at the anchor +!> instead, the same twist. The gate 1 line twisted two turns and carrying two clumps and a +!> buoy (ATTACHMENTS, which bend it off the rod axis) gives the torque and twist of the same +!> line from the held Coupled point to the printed digits. +!> The multibody march has no restart (checkpoint) path, so there is no restart gate. +PROGRAM test_rod_end_torsion + USE CableDyn_Precision, ONLY: wp + USE CableDyn_Conventions, ONLY: CD_Body_Rotation + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Multibody_Probe_Arm, CD_Multibody_Probe_Get + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp, GJ = 5.0e4_wp + INTEGER :: n_fail = 0 + CHARACTER(160) :: neutral_type, rod_type + + ! neutral 0.2 m section: EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 (massless torsion) + WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + ! neutral 0.2 m rod without hydrodynamic coefficients + WRITE (rod_type, '(A,ES24.16,A)') 'arm 0.2 ', RHOW*0.25_wp*PI*0.04_wp, ' 0.0 0.0 0.0 0.0' + + CALL check_fixed_rod() + CALL check_body_rod_roll() + CALL check_refusals() + CALL check_one_end_rod() + CALL check_attachments_rod() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' rod-end torsion gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: rod-end torsion (Fixed rod, rod on a rolling body, refusals)' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE write_deck(path, bodies, rods, points, line, length_segs, endconns, options, outs, atts) + !! A one-line deck: the neutral line type, optional BODIES and RODS rows (the arm rod type), + !! POINTS, one LINES row, its SECTIONS row, optional ATTACHMENTS rows atts, END CONNECTIONS, + !! OPTIONS (g, rhoW, WtrDpth 200 and the given rows) and OUTPUTS. + CHARACTER(*), INTENT(IN) :: path, bodies(:), rods(:), points(:), line, length_segs, endconns(:), options(:), & + outs(:) + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'rod-end torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(neutral_type) + IF (SIZE(bodies) > 0) THEN + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm) (Nm) (m2) (-) (kgm2) (kgm2) (kgm2)' + DO i = 1, SIZE(bodies) + WRITE (u, '(A)') TRIM(bodies(i)) + END DO + END IF + IF (SIZE(rods) > 0) THEN + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(rod_type) + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + DO i = 1, SIZE(rods) + WRITE (u, '(A)') TRIM(rods(i)) + END DO + END IF + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(points) + WRITE (u, '(A)') TRIM(points(i)) + END DO + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(line) + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab '//TRIM(length_segs) + IF (PRESENT(atts)) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(atts) + WRITE (u, '(A)') TRIM(atts(i)) + END DO + END IF + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + DO i = 1, SIZE(endconns) + WRITE (u, '(A)') TRIM(endconns(i)) + END DO + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run_deck(path, root, ok, em_out) + CHARACTER(*), INTENT(IN) :: path, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: em_out + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(path, root, conv, es, em_out) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run_deck + + SUBROUTINE read_row(path, row, vals, ok) + !! Data row `row` (0 = first) of a driver .out file. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: row + REAL(wp), INTENT(OUT) :: vals(:) + LOGICAL, INTENT(OUT) :: ok + INTEGER :: u, ios, i + CHARACTER(2048) :: buf + ok = .FALSE. + vals = 0.0_wp + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO i = 0, row + READ (u, *, IOSTAT=ios) vals + IF (ios /= 0) THEN + CLOSE (u) + RETURN + END IF + END DO + CLOSE (u) + ok = ALL(IEEE_IS_FINITE(vals)) + END SUBROUTINE read_row + + LOGICAL FUNCTION same_file(a, b) RESULT(same) + !! Byte-identical text files. + CHARACTER(*), INTENT(IN) :: a, b + INTEGER :: ua, ub, ia, ib + CHARACTER(4096) :: la, lb + same = .FALSE. + OPEN (NEWUNIT=ua, FILE=a, STATUS='OLD', ACTION='READ', IOSTAT=ia) + IF (ia /= 0) RETURN + OPEN (NEWUNIT=ub, FILE=b, STATUS='OLD', ACTION='READ', IOSTAT=ib) + IF (ib /= 0) THEN + CLOSE (ua) + RETURN + END IF + DO + READ (ua, '(A)', IOSTAT=ia) la + READ (ub, '(A)', IOSTAT=ib) lb + IF (ia /= 0 .OR. ib /= 0) EXIT + IF (la /= lb) THEN + CLOSE (ua) + CLOSE (ub) + RETURN + END IF + END DO + same = ia /= 0 .AND. ib /= 0 + CLOSE (ua) + CLOSE (ub) + END FUNCTION same_file + + FUNCTION vec(v) RESULT(s) + !! Three numbers at full precision for a deck row. + REAL(wp), INTENT(IN) :: v(3) + CHARACTER(80) :: s + WRITE (s, '(3ES25.16E3)') v + END FUNCTION vec + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_fixed_rod() + !! Gate 1. The rod runs 10 m from (0, 0, -30) along a = (0.48, 0.36, -0.8); the 100 m line + !! hangs from its End B along a to an anchor 100.01 m away, both ends Rigid in bending and + !! torsion with Ez = a and Nx = (0.6, -0.8, 0) (normal to a, global axes). + CHARACTER(16), PARAMETER :: OUTS(6) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1', 'Rod1Mx', 'Rod1My', & + 'Rod1Mz'] + REAL(wp), PARAMETER :: AX(3) = [0.48_wp, 0.36_wp, -0.8_wp], NX(3) = [0.6_wp, -0.8_wp, 0.0_wp] + REAL(wp), PARAMETER :: LN = 100.0_wp + REAL(wp) :: pa(3), pb(3), anchor(3), m_ref, v(7), vp(7), e_ref, e_route, e_zero, e_mom, e_dyn, e_pin + CHARACTER(256) :: rrow, prow, arow, ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + INTEGER :: k + pa = [0.0_wp, 0.0_wp, -30.0_wp] + pb = pa + 10.0_wp*AX + anchor = pb + (LN*1.0001_wp)*AX + rrow = '1 arm Fixed '//TRIM(vec(pa))//' '//TRIM(vec(pb))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + m_ref = GJ*4.0_wp*PI/LN + ! (a) two turns between the ends, from a nonzero End A pretwist + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 750' + CALL write_deck('trod_fixed.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_fixed.dat', 'trod_fixed', ok, em) + CALL require(ok, '1: a torsional End A on a Fixed rod runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_row('trod_fixed.out', 0, v, ok) + CALL require(ok, '1: Fixed rod output readable') + e_ref = nan_max_abs(v(2:3) - m_ref)/m_ref + ! Rod1M about the rod's End A: the line pulls along the rod axis through End B, the neutral + ! rod's weight and buoyancy cancel, so the moment is the connection moment M_t a + e_mom = NORM2(v(5:7) - m_ref*AX)/m_ref + ! (b) the same line hung from a Coupled point at the rod's End B, which the standalone finite-EI + ! march (a second route; it takes no Fixed End A) holds still + WRITE (prow, '(A,A,A)') '1 Coupled ', TRIM(vec(pb)), ' 0 0 0 0' + CALL write_deck('trod_point.dat', [CHARACTER(8) ::], [CHARACTER(8) ::], [prow, arow], '1 1 2 -', '100.0 40', & + [ca, cb], [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS(1:3)) + CALL run_deck('trod_point.dat', 'trod_point', ok, em) + CALL require(ok, '1: the same line from a held Coupled point runs: '//TRIM(em)) + e_route = 1.0_wp + IF (ok) CALL read_row('trod_point.out', 0, vp(1:4), ok) + IF (ok) e_route = nan_max_abs(v(2:4) - vp(2:4))/m_ref + ! (c) equal normals and pretwists: no twist, whatever the roll of the rod frame + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 45' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 45' + CALL write_deck('trod_zero.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_zero.dat', 'trod_zero', ok, em) + CALL require(ok, '1: the untwisted rod-end line runs: '//TRIM(em)) + CALL read_row('trod_zero.out', 0, vp, ok) + e_zero = nan_max_abs([vp(2:3), NORM2(vp(5:7))])/m_ref + ! (d) a 1 s march holds the torque + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 750' + CALL write_deck('trod_dyn.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '1.0 TMax'], OUTS) + CALL run_deck('trod_dyn.dat', 'trod_dyn', ok, em) + CALL require(ok, '1: the Fixed rod march runs: '//TRIM(em)) + e_dyn = 0.0_wp + DO k = 0, 10 + CALL read_row('trod_dyn.out', k, vp, ok) + IF (.NOT. ok) EXIT + e_dyn = nan_max_abs([e_dyn, nan_max_abs(vp(2:3) - m_ref)/m_ref, NORM2(vp(5:7) - m_ref*AX)/m_ref]) + END DO + CALL require(ok, '1: every march row readable') + ! (e) bending-pinned, torsionally rigid End A (the semi-tangential end): a straight line + ! carries the same torque + ca = '1 A Pinned '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + CALL write_deck('trod_pin.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_pin.dat', 'trod_pin', ok, em) + CALL require(ok, '1: the bending-pinned rod-end line runs: '//TRIM(em)) + CALL read_row('trod_pin.out', 0, vp, ok) + e_pin = nan_max_abs(vp(2:3) - m_ref)/m_ref + ! (f) the deck of (a) written anchor first (MoorDyn's order: NodeA the anchor, NodeB the rod + ! end, each row's Ez from the anchor and its pretwist about it): the reader turns the line + ! around, and the run is (a)'s bit for bit + ca = '1 A Rigid '//TRIM(vec(-AX))//' Rigid '//TRIM(vec(NX))//' -750' + cb = '1 B Rigid '//TRIM(vec(-AX))//' Rigid '//TRIM(vec(NX))//' -30' + CALL write_deck('trod_af.dat', [CHARACTER(8) ::], [rrow], [arow], '1 2 R1B -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_af.dat', 'trod_af', ok, em) + CALL require(ok, '1: the anchor-first line onto the Fixed rod runs: '//TRIM(em)) + CALL require(same_file('trod_fixed.out', 'trod_af.out'), '1: the anchor-first deck runs bit for bit as '// & + 'the rod-first one') + WRITE (*, '(A,2ES15.7,A,ES15.7,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,L1)') & + 'Fixed rod: Torq N1/N41 ', v(2:3), ' ref GJ Phi/L ', m_ref, ' (rel ', e_ref, '); vs a held Coupled point ', & + e_route, '; untwisted ', e_zero, '; Rod1M - M a ', e_mom, '; 1 s march ', e_dyn, '; pinned bending ', e_pin, & + '; anchor-first identical ', same_file('trod_fixed.out', 'trod_af.out') + CALL require(e_ref <= 1.0e-7_wp, '1: Torq = GJ Phi / L on a Fixed rod end') + CALL require(e_route <= 1.0e-7_wp, '1: the same torque and twist as from a held Coupled point') + CALL require(e_zero <= 1.0e-7_wp, '1: equal normals and pretwists give no torque (normal in the rod frame)') + CALL require(e_mom <= 1.0e-7_wp, '1: RodM is the torque along the line axis') + CALL require(e_dyn <= 1.0e-7_wp, '1: the march holds the torque and the rod moment') + CALL require(e_pin <= 1.0e-7_wp, '1: a bending-pinned torsional End A carries the same torque') + END SUBROUTINE check_fixed_rod + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_body_rod_roll() + !! Gate 2. A Rigid6 body (attitude ROT, translation massive, roll inertia IB) carries a rod + !! fixed to it from its reference point along dbody (10 m); the 20 m line hangs from the rod's + !! End B along the rod axis dg = R dbody to an anchor, stretched by 1e-4, and is twisted by + !! PHI at End B. Released from rest, the body rolls about dg: theta = PHI (1 - cos Omega t). + REAL(wp), PARAMETER :: ROT(3) = [10.0_wp, -20.0_wp, 35.0_wp], MB = 1.0e9_wp, IB = 1.0e3_wp, LN = 20.0_wp + REAL(wp), PARAMETER :: PHI_DEG = 30.0_wp, DT = 0.01_wp + INTEGER, PARAMETER :: NSTEP = 400 + REAL(wp), ALLOCATABLE :: rec(:, :) + REAL(wp) :: r0(3, 3), rk(3, 3), q(3, 3), dbody(3), nbody(3), dg(3), dk(3), pb(3), anchor(3), w(3), s, ang + REAL(wp) :: kt, phi, ieff, omega, m0, theta, mt, v(5), e_torque, e_axis, e_rod, e_chan, e_wave, mrod + CHARACTER(256) :: brow, rrow, arow, ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + INTEGER :: k + r0 = CD_Body_Rotation(ROT(1), ROT(2), ROT(3)) + dbody = [0.0_wp, 0.6_wp, -0.8_wp] + nbody = [1.0_wp, 0.0_wp, 0.0_wp] + dg = MATMUL(r0, dbody) + pb = [0.0_wp, 0.0_wp, -60.0_wp] + 10.0_wp*dg + anchor = pb + (LN*1.0001_wp)*dg + WRITE (brow, '(A,3F8.2,A,ES24.16,A,ES24.16,A,3ES12.4)') '1 Rigid6 0 0 -60 ', ROT, ' ', MB, ' ', MB/RHOW, & + ' 0 0 0 0 0 ', IB, IB, IB + rrow = '1 arm Body1 0 0 0 '//TRIM(vec(10.0_wp*dbody))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + ca = '1 A Rigid '//TRIM(vec(dbody))//' Rigid '//TRIM(vec(nbody))//' 0' + WRITE (cb, '(A,A,A,A,F8.2)') '1 B Rigid ', TRIM(vec(dg)), ' Rigid ', TRIM(vec(MATMUL(r0, nbody))), PHI_DEG + CALL write_deck('trod_body.dat', [brow], [rrow], [arow], '1 R1B 2 -', '20.0 20', [ca, cb], & + [CHARACTER(24) :: 'moordyn bodyWetting', 'deck bodyIC', '0.01 dtM', '4.0 TMax'], & + [CHARACTER(12) :: 'Torq1N1', 'Rod1Mx', 'Rod1My', 'Rod1Mz']) + CALL CD_Multibody_Probe_Arm([0.0_wp, 0.0_wp, 0.0_wp], [0.0_wp, 0.0_wp, 0.0_wp]) + CALL run_deck('trod_body.dat', 'trod_body', ok, em) + CALL CD_Multibody_Probe_Get(rec) + ok = ok .AND. ALLOCATED(rec) + CALL require(ok, '2: the rod on a rolling body runs and is probed: '//TRIM(em)) + IF (.NOT. ok) RETURN + ok = UBOUND(rec, 2) >= NSTEP + CALL require(ok, '2: every step is recorded') + IF (.NOT. ok) RETURN + kt = GJ/LN + phi = PHI_DEG*PI/180.0_wp + m0 = kt*phi + ! the roll inertia about dg: the body's and the rod's polar inertia m r^2 / 2 (the rod axis is + ! the roll axis) + mrod = RHOW*0.25_wp*PI*0.04_wp*10.0_wp + ieff = IB + 0.5_wp*mrod*0.1_wp**2 + omega = SQRT(kt/ieff) + e_torque = 0.0_wp + e_axis = 0.0_wp + e_rod = 0.0_wp + e_chan = 0.0_wp + e_wave = 0.0_wp + DO k = 0, NSTEP + CALL read_row('trod_body.out', k, v, ok) + IF (.NOT. ok) EXIT + rk = RESHAPE(rec(8:16, k), [3, 3]) + ! the body's roll since the start, about dg (axis-angle of R_k R_0^T) + q = MATMUL(rk, TRANSPOSE(r0)) + ang = ACOS(MAX(-1.0_wp, MIN(1.0_wp, 0.5_wp*(q(1, 1) + q(2, 2) + q(3, 3) - 1.0_wp)))) + w = [q(3, 2) - q(2, 3), q(1, 3) - q(3, 1), q(2, 1) - q(1, 2)] + s = NORM2(w) + theta = 0.0_wp + IF (s > 1.0e-12_wp) theta = SIGN(ang, DOT_PRODUCT(w, dg)) + dk = MATMUL(q, dg) + ! the moment the line returns to the body (committed connection moment) + mt = DOT_PRODUCT(rec(24:26, k), dk) + e_torque = nan_max_abs([e_torque, ABS(mt - kt*(phi - theta))/m0]) + e_axis = nan_max_abs([e_axis, NORM2(rec(24:26, k) - mt*dk)/m0]) + e_rod = nan_max_abs([e_rod, NORM2(v(3:5) - rec(24:26, k))/m0]) + e_chan = nan_max_abs([e_chan, ABS(v(2) - mt)/m0]) + e_wave = nan_max_abs([e_wave, ABS(theta - phi*(1.0_wp - COS(omega*REAL(k, wp)*DT)))/phi]) + END DO + CALL require(ok, '2: all output rows readable') + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,F8.4,A)') 'rod on a rolling body: torque vs '// & + 'GJ (Phi - theta)/L ', e_torque, ', moment off the line axis ', e_axis, ', Rod1M vs the returned moment ', & + e_rod, ', Torq channel ', e_chan, ' (of GJ Phi/L); roll vs Phi (1 - cos Omega t) ', e_wave, ' of Phi (Omega = ', & + omega, ' rad/s)' + CALL require(e_torque <= 1.0e-6_wp, '2: the torque follows GJ (Phi - theta) / L quasi-statically') + CALL require(e_axis <= 1.0e-6_wp, '2: the moment returned to the body is the torque along the line axis') + CALL require(e_rod <= 1.0e-6_wp, '2: RodM of the body-fixed rod carries the connection moment') + CALL require(e_chan <= 1.0e-6_wp, '2: TorqN1 is the returned torque') + CALL require(e_wave <= 1.0e-2_wp, '2: the body and rod swing as a torsional pendulum at sqrt(GJ/(L I))') + END SUBROUTINE check_body_rod_roll + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_refusals() + !! Gate 3. A rod without a roll angle refuses the torsion by name; so does a Coupled rod. + CHARACTER(256) :: brow + CALL refused('Pinned', '1 arm Pinned 0 0 -30 0 0 -40 4 -', [CHARACTER(8) ::], & + 'on the end of ROD 1 (pinned) is not supported: a free or pinned rod is axisymmetric') + CALL refused('Free', '1 arm Free 0 0 -30 0 0 -40 4 -', [CHARACTER(8) ::], & + 'on the end of ROD 1 (free) is not supported: a free or pinned rod is axisymmetric') + brow = '1 Rigid6 0 0 -20 0 0 0 1.0e9 975609.75609756098 0 0 0 0 0 1.0e3 1.0e3 1.0e3' + CALL refused('BodyPinned', '1 arm Body1Pinned 0 0 -10 0 0 -20 4 -', [brow], & + 'on the end of ROD 1 (body1pinned) is not supported: a free or pinned rod is axisymmetric') + CALL refused('Coupled', '1 arm Coupled 0 0 -30 0 0 -40 4 -', [CHARACTER(8) ::], & + 'on the end of Coupled/Vessel ROD 1 is not supported: no route of this build carries a finite-EI '// & + 'line on a host-driven rod', 'trod_none.motion motionFile') + ! the staggered body scheme drives a cable end by translation only: a torsional End A on a + ! rod fixed to a body (here bending-pinned, which that scheme otherwise takes) is refused + CALL refused('Body (staggered)', '1 arm Body1 0 0 -10 0 0 -20 4 -', [brow], & + 'a torsional END CONNECTION on a body or rod needs bodyScheme monolithic', 'staggered bodyScheme', & + 'Pinned') + ! written anchor first onto a Pinned rod, the line is turned around and meets the rod's own + ! refusal (not "two moving ends") + CALL refused_rows('anchor-first Pinned', ['1 arm Pinned 0 0 -30 0 0 -40 4 -'], '1 2 R1B -', 1.0_wp, & + 'on the end of ROD 1 (pinned) is not supported: a free or pinned rod is axisymmetric') + ! a line between two Fixed rods (a J-tube to a J-tube): End B is a rod end + CALL refused_rows('two Fixed', [CHARACTER(48) :: '1 arm Fixed 0 0 -30 0 0 -40 4 -', & + '2 arm Fixed 0 0 -140.01 0 0 -150.01 4 -'], '1 R1B R2A -', -1.0_wp, & + 'torsional END CONNECTIONS require a finite-EI line with Fixed End B; line 1 ends (End B) '// & + 'on a rod end: a line between two rods is not supported in this build') + END SUBROUTINE check_refusals + + SUBROUTINE refused_rows(label, rod_rows, line_row, ez_z, needle) + !! A vertical line between z = -40 and -140.01 twisted by 90 deg (Ez = (0, 0, ez_z) at both + !! ends) on the given rods and LINES row (the Fixed point 2 at the bottom): the deck stops + !! with the message needle. + CHARACTER(*), INTENT(IN) :: label, rod_rows(:), line_row, needle + REAL(wp), INTENT(IN) :: ez_z + CHARACTER(256) :: ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + ca = '1 A Rigid '//TRIM(vec([0.0_wp, 0.0_wp, ez_z]))//' Rigid 1 0 0 0' + cb = '1 B Rigid '//TRIM(vec([0.0_wp, 0.0_wp, ez_z]))//' Rigid 1 0 0 90' + CALL write_deck('trod_ref.dat', [CHARACTER(8) ::], rod_rows, ['2 Fixed 0.0 0.0 -140.01 0 0 0 0'], line_row, & + '100.0 40', [ca, cb], [CHARACTER(32) :: '0.1 dtM', '1.0 TMax'], [CHARACTER(8) :: 'Torq1N1']) + CALL run_deck('trod_ref.dat', 'trod_ref', ok, em) + WRITE (*, '(A,A,A,A)') 'refusal on a ', label, ' rod line: ', TRIM(em) + CALL require(.NOT. ok .AND. INDEX(em, needle) > 0, '3: a torsional line on a '//label//' rod is refused '// & + 'by name (got: '//TRIM(em)//')') + END SUBROUTINE refused_rows + + SUBROUTINE refused(label, rod_row, bodies, needle, extra, bend_a) + !! A vertical rod (End B at z = -40, or the body rods' at -40 in global axes) holding a + !! vertical line twisted by 90 deg: the deck stops with the message needle. extra: one more + !! OPTIONS row; bend_a: End A's bending connection (default Rigid). + CHARACTER(*), INTENT(IN) :: label, rod_row, bodies(:), needle + CHARACTER(*), INTENT(IN), OPTIONAL :: extra, bend_a + REAL(wp), PARAMETER :: AX(3) = [0.0_wp, 0.0_wp, -1.0_wp], NX(3) = [1.0_wp, 0.0_wp, 0.0_wp] + CHARACTER(64), PARAMETER :: ROW_A = '2 Fixed 0.0 0.0 -140.01 0 0 0 0' + CHARACTER(256) :: ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 0' + IF (PRESENT(bend_a)) ca = '1 A '//bend_a//' '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 0' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 90' + IF (PRESENT(extra)) THEN + CALL write_deck('trod_ref.dat', bodies, [rod_row], [ROW_A], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(32) :: '0.1 dtM', '1.0 TMax', 'deck bodyIC', extra], [CHARACTER(8) :: 'Torq1N1']) + ELSE + CALL write_deck('trod_ref.dat', bodies, [rod_row], [ROW_A], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(32) :: '0.1 dtM', '1.0 TMax', 'deck bodyIC'], [CHARACTER(8) :: 'Torq1N1']) + END IF + CALL run_deck('trod_ref.dat', 'trod_ref', ok, em) + WRITE (*, '(A,A,A,A)') 'refusal on a ', label, ' rod: ', TRIM(em) + CALL require(.NOT. ok .AND. INDEX(em, needle) > 0, '3: a torsional End A on a '//label//' rod is refused '// & + 'by name (got: '//TRIM(em)//')') + END SUBROUTINE refused + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_one_end_rod() + !! Gate 4, one restrained end: the gate 1 J-tube line with GJ|K, free in torsion at one end. + CHARACTER(16), PARAMETER :: OUTS(3) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1'] + REAL(wp), PARAMETER :: AX(3) = [0.48_wp, 0.36_wp, -0.8_wp], NX(3) = [0.6_wp, -0.8_wp, 0.0_wp] + REAL(wp), PARAMETER :: LN = 100.0_wp, KC = 4.0e5_wp + CHARACTER(160) :: bare_type + REAL(wp) :: pa(3), pb(3), anchor(3), tw_ref, v(4), vp(4), e_tw(2), e_m(2), e_route(2) + CHARACTER(256) :: rrow, prow, arow, ca(2), cb(2) + CHARACTER(24), PARAMETER :: LABEL(2) = [CHARACTER(24) :: 'End B free', 'End A (rod end) free'] + LOGICAL :: ok + CHARACTER(512) :: em + INTEGER :: iv + bare_type = neutral_type + WRITE (neutral_type, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4|4.0e5 1.0 1.0e-12 0.0 0.0 0.0 0.0' + pa = [0.0_wp, 0.0_wp, -30.0_wp] + pb = pa + 10.0_wp*AX + anchor = pb + (LN*1.0001_wp)*AX + rrow = '1 arm Fixed '//TRIM(vec(pa))//' '//TRIM(vec(pb))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + WRITE (prow, '(A,A,A)') '1 Coupled ', TRIM(vec(pb)), ' 0 0 0 0' + ! the free end turns by the stretch's -(K/GJ) dl relative to the restrained one + tw_ref = -(KC/GJ)*(LN*1.0e-4_wp)*180.0_wp/PI + ca(1) = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb(1) = '1 B Rigid '//TRIM(vec(AX))//' Free '//TRIM(vec(NX))//' 0' + ca(2) = '1 A Rigid '//TRIM(vec(AX))//' Free '//TRIM(vec(NX))//' 0' + cb(2) = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + DO iv = 1, 2 + CALL write_deck('trod_oe.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca(iv), cb(iv)], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_oe.dat', 'trod_oe', ok, em) + CALL require(ok, '4: a line restrained at one end ('//TRIM(LABEL(iv))//') on a Fixed rod runs with its twist '// & + 'channels: '//TRIM(em)) + e_tw(iv) = 1.0_wp + e_m(iv) = 1.0_wp + e_route(iv) = 1.0_wp + IF (.NOT. ok) CYCLE + CALL read_row('trod_oe.out', 0, v, ok) + CALL require(ok, '4: one-end rod output readable') + e_tw(iv) = ABS(v(4) - tw_ref)/ABS(tw_ref) + ! against the torque K eps the coupling would give a section held from twisting + e_m(iv) = nan_max_abs(v(2:3))/(KC*1.0e-4_wp) + CALL write_deck('trod_oep.dat', [CHARACTER(8) ::], [CHARACTER(8) ::], [prow, arow], '1 1 2 -', '100.0 40', & + [ca(iv), cb(iv)], [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('trod_oep.dat', 'trod_oep', ok, em) + CALL require(ok, '4: the same line from a held Coupled point runs: '//TRIM(em)) + IF (ok) CALL read_row('trod_oep.out', 0, vp, ok) + IF (ok) e_route(iv) = ABS(v(4) - vp(4))/ABS(tw_ref) + WRITE (*, '(A,A,A,F12.7,A,F12.7,A,3ES10.3)') 'one end on a Fixed rod, ', TRIM(LABEL(iv)), ': Twist1 ', v(4), & + ' deg (-(K/GJ) dl ', tw_ref, '); errors twist, |torque| / K eps, vs a held Coupled point ', e_tw(iv), & + e_m(iv), e_route(iv) + END DO + neutral_type = bare_type + CALL require(MAXVAL(e_tw) <= 1.0e-6_wp, '4: the free end turns by -(K/GJ) dl on a Fixed rod end') + CALL require(MAXVAL(e_m) <= 1.0e-6_wp, '4: a line free at one end carries no torque on a Fixed rod end') + CALL require(MAXVAL(e_route) <= 1.0e-6_wp, '4: the same twist as from a held Coupled point') + END SUBROUTINE check_one_end_rod + + SUBROUTINE check_attachments_rod() + !! Gate 4, ATTACHMENTS: the gate 1 line twisted two turns with two clumps and a buoy. + CHARACTER(16), PARAMETER :: OUTS(3) = [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1'] + REAL(wp), PARAMETER :: AX(3) = [0.48_wp, 0.36_wp, -0.8_wp], NX(3) = [0.6_wp, -0.8_wp, 0.0_wp] + REAL(wp), PARAMETER :: LN = 100.0_wp + CHARACTER(48), PARAMETER :: ATTS(3) = [CHARACTER(48) :: '1 25.0 500.0 0.1 0.0 0.0', '1 50.0 50.0 0.4 0.0 0.0', & + '1 75.0 300.0 0.05 0.0 0.0'] + REAL(wp) :: pa(3), pb(3), anchor(3), m_ref, v(4), vp(4), e_route + CHARACTER(256) :: rrow, prow, arow, ca, cb + LOGICAL :: ok + CHARACTER(512) :: em + pa = [0.0_wp, 0.0_wp, -30.0_wp] + pb = pa + 10.0_wp*AX + anchor = pb + (LN*1.0001_wp)*AX + rrow = '1 arm Fixed '//TRIM(vec(pa))//' '//TRIM(vec(pb))//' 4 -' + WRITE (arow, '(A,A,A)') '2 Fixed ', TRIM(vec(anchor)), ' 0 0 0 0' + WRITE (prow, '(A,A,A)') '1 Coupled ', TRIM(vec(pb)), ' 0 0 0 0' + m_ref = GJ*4.0_wp*PI/LN + ca = '1 A Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 30' + cb = '1 B Rigid '//TRIM(vec(AX))//' Rigid '//TRIM(vec(NX))//' 750' + CALL write_deck('trod_att.dat', [CHARACTER(8) ::], [rrow], [arow], '1 R1B 2 -', '100.0 40', [ca, cb], & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS, atts=ATTS) + CALL run_deck('trod_att.dat', 'trod_att', ok, em) + CALL require(ok, '4: a rod-end line with ATTACHMENTS runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_row('trod_att.out', 0, v, ok) + CALL write_deck('trod_attp.dat', [CHARACTER(8) ::], [CHARACTER(8) ::], [prow, arow], '1 1 2 -', '100.0 40', & + [ca, cb], [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS, atts=ATTS) + CALL run_deck('trod_attp.dat', 'trod_attp', ok, em) + CALL require(ok, '4: the same line with ATTACHMENTS from a held Coupled point runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_row('trod_attp.out', 0, vp, ok) + e_route = nan_max_abs(v(2:4) - vp(2:4))/m_ref + WRITE (*, '(A,3ES15.7,A,3ES15.7,A,ES10.3)') 'ATTACHMENTS on a Fixed rod line: Torq N1/N41, Twist1 ', v(2:4), & + '; from a held Coupled point ', vp(2:4), '; difference / (GJ Phi/L) ', e_route + CALL require(e_route <= 1.0e-7_wp, '4: the rod-end line with ATTACHMENTS has the held point''s torque and twist') + CALL require(ABS(v(2)/m_ref - 1.0_wp) > 1.0e-6_wp, '4: the attachments bend the line (its torque is not GJ Phi/L)') + END SUBROUTINE check_attachments_rod + +END PROGRAM test_rod_end_torsion diff --git a/tests/test_step_allocations.f90 b/tests/test_step_allocations.f90 index df0ccab8..c20dade2 100644 --- a/tests/test_step_allocations.f90 +++ b/tests/test_step_allocations.f90 @@ -23,15 +23,21 @@ PROGRAM test_step_allocations !! committed-state outputs (CD_HFMF_SetCoupledKinematics, CD_HFMF_CalcOutput with the connection !! moment, both end forces, the energy and the torque query) are gated as well. With "nodal" !! the same cable carries the nodal twist (polar inertia and torsional damping), with its - !! 7-DOF-per-node band and the node-torque and element-twist queries. + !! 7-DOF-per-node band and the node-torque and element-twist queries; with "free" the nodal + !! twist of the same cable free in torsion at its held end (restrained at the coupled end only). !! !! With "current_grid" the gate runs the evaluation of a MoorDyn-C current grid (Currents 2 and !! 5) that every standalone step makes at every node: CD_Current_Grid_Velocity, and the gradient !! of the EI = 0 static tangent (CD_Current_Grid_Gradient), at points inside and outside a !! sheared grid and at times before, inside and past its last sample. !! + !! With "motion_roll" or "motion_vessel" the gate runs the standalone driver's march of a mixed + !! EI = 0 + finite-EI deck with the deck's prescribed motion (CD_AGG_MotionKinematics, then + !! CD_AGG_Step_Moving with the roll column or with the vessel orientation and rates): a straight + !! line restrained in torsion whose End A rolls about its axis, beside an EI = 0 chain. + !! !! Usage: test_step_allocations [ranges] - !! test_step_allocations torsion | nodal | current_grid + !! test_step_allocations torsion | nodal | free | current_grid | motion_roll | motion_vessel USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_LONG_LONG USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -48,7 +54,8 @@ PROGRAM test_step_allocations CD_AGG_NFluidNodes, CD_AGG_NumChannels, CD_AGG_GetMovingPointMesh, & CD_AGG_Snapshot, CD_AGG_SetFluidFields, CD_AGG_Step_Moving, & CD_AGG_CalcOutput, CD_AGG_EvalChannel, CD_AGG_End, & - CD_AGG_Range_Sample + CD_AGG_Range_Sample, CD_AGG_UpdateStates_Moving, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations IMPLICIT NONE INTERFACE FUNCTION cd_test_allocation_count() BIND(C, NAME='cd_test_allocation_count') RESULT(n) @@ -74,13 +81,17 @@ END SUBROUTINE cd_test_allocation_counting IF (COMMAND_ARGUMENT_COUNT() == 1) THEN CALL GET_COMMAND_ARGUMENT(1, arg) - IF (TRIM(arg) == 'current_grid') THEN + SELECT CASE (TRIM(arg)) + CASE ('torsion', 'nodal', 'free') + CALL torsion_gate(TRIM(arg) /= 'torsion', TRIM(arg) == 'free') + CASE ('current_grid') CALL current_grid_gate() - STOP - END IF - IF (TRIM(arg) /= 'torsion' .AND. TRIM(arg) /= 'nodal') & - ERROR STOP 'a single argument must be "torsion", "nodal" or "current_grid"' - CALL torsion_gate(TRIM(arg) == 'nodal') + CASE ('motion_roll', 'motion_vessel') + CALL motion_gate(TRIM(arg) == 'motion_vessel') + CASE DEFAULT + ERROR STOP 'a single argument must be "torsion", "nodal", "free", "current_grid", "motion_roll" or '// & + '"motion_vessel"' + END SELECT STOP END IF IF (COMMAND_ARGUMENT_COUNT() /= 3 .AND. COMMAND_ARGUMENT_COUNT() /= 4) THEN @@ -184,10 +195,10 @@ SUBROUTINE march(first_step, count, counted) END DO END SUBROUTINE march - SUBROUTINE torsion_gate(nodal) + SUBROUTINE torsion_gate(nodal, free_end) !! Zero heap allocation in CD_HFMF_UpdateStates of a cable with condensed torsion, or with the - !! nodal twist. - LOGICAL, INTENT(IN) :: nodal + !! nodal twist (free_end: free in torsion at the held end 1). + LOGICAL, INTENT(IN) :: nodal, free_end INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDOF = 6*NN, N_WARM = 40, N_COUNT = 200 REAL(wp), PARAMETER :: LL = 10.0_wp, DTT = 0.01_wp TYPE(CD_HFMF_ModuleType) :: cab @@ -228,6 +239,7 @@ SUBROUTINE torsion_gate(nodal) tors%irn = 0.05_wp tors%bt = 0.5_wp END IF + IF (free_end) tors%end_free(1) = .TRUE. tors%has_theta = .TRUE. frame(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] frame(:, 2) = [0.0_wp, 0.0_wp, 1.0_wp] @@ -335,6 +347,127 @@ SUBROUTINE current_grid_gate() PRINT '(A)', 'PASS: no heap allocation in the current grid evaluation' END SUBROUTINE current_grid_gate + SUBROUTINE motion_gate(vessel) + !! Zero heap allocation in the standalone driver's per-step march of a mixed deck with its + !! prescribed motion: the 100 m straight neutral line of test_mixed_route_torsion, clamped and + !! restrained in torsion at both ends, End A rolled about the line axis (by a vessel, or by the + !! motionFile roll column), beside a chain on a second moving point. + LOGICAL, INTENT(IN) :: vessel + INTEGER, PARAMETER :: N_WARM = 40, N_COUNT = 160, NT = N_WARM + N_COUNT + REAL(wp), PARAMETER :: DTM = 0.05_wp, PI = 3.14159265358979323846_wp + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: mag + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), ld(:, :), o(:, :, :), w(:, :), al(:, :), roll(:) + REAL(wp) :: t, ro, dro, d2ro, om + INTEGER :: u, k, n, n_it + INTEGER(C_LONG_LONG) :: c0, n_alloc + LOGICAL :: turns, rolls, converged, stalled + ! one file root per mode: the two gates may run at once in one directory + CHARACTER(32) :: root + root = MERGE('step_alloc_motion_vessel', 'step_alloc_motion_roll ', vessel) + om = 2.0_wp*PI/10.0_wp + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NT + t = DTM*k + ro = 15.0_wp*(1.0_wp - COS(om*t)) + dro = 15.0_wp*om*SIN(om*t) + d2ro = 15.0_wp*om*om*COS(om*t) + IF (vessel) THEN + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 0 0 -50 ', ro, ' 0 0 0 0 0 ', dro*PI/180.0_wp, & + ' 0 0 0 0 0 ', d2ro*PI/180.0_wp, ' 0 0' + ELSE + WRITE (u, '(F8.3,A,ES25.16E3)') t, ' 1 0 0 -50 0 0 0 0 0 0 ', ro + WRITE (u, '(F8.3,A)') t, ' 3 0 10 -50 0 0 0 0 0 0' + END IF + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'step allocation gate: mixed deck with prescribed motion' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.01_wp*PI, ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0 0 0 0' + WRITE (u, '(A)') 'chain 0.1 50.0 1.0e9 -1.0 0.0 0 0 0 0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 '//MERGE('Vessel ', 'Coupled', vessel)//' 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '3 '//MERGE('Vessel ', 'Coupled', vessel)//' 0.0 10.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 0.0 100.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 4 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '2 chain 110.0 20' + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Rigid 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 0 1 90' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '10.0 TMax' + IF (vessel) THEN + WRITE (u, '(A)') TRIM(root)//'.txt vesselMotion' + WRITE (u, '(A)') '0|0|-50 vesselRef' + ELSE + WRITE (u, '(A)') TRIM(root)//'.txt motionFile' + END IF + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + ALLOCATE (mag) + CALL CD_AGG_Init_From_Deck(mag, TRIM(root)//'.dat', DTM, es, em, forbid_deck_ambient=.TRUE., & + run_tmax=10.0_wp, host_orientation=.TRUE., prescribed_motion=.TRUE.) + CALL check('motion deck initialization') + n = CD_AGG_NMovingPoints(mag, es, em) + CALL check('motion moving-point count') + ALLOCATE (p(3, n), v(3, n), a(3, n), ld(3, n), o(3, 3, n), w(3, n), al(3, n), roll(n)) + CALL CD_AGG_GetMovingPointMesh(mag, p, v, a, ld, es, em) + CALL check('motion initial mesh') + CALL CD_AGG_MotionKinematics(mag, 1, p, v, a, o, w, al, roll, turns, rolls, es, em) + CALL check('motion row 1') + IF (turns .EQV. rolls) ERROR STOP 'the motion gate drives neither or both frame inputs' + CALL CD_AGG_UpdateStates_Moving(mag, p, v, a, es, em) + CALL check('motion row 1 transfer') + CALL CD_AGG_Refresh_Accelerations(mag, es, em) + CALL check('motion row 1 accelerations') + n_alloc = 0 + DO k = 1, NT + c0 = cd_test_allocation_count() + IF (k > N_WARM) CALL cd_test_allocation_counting(1_C_INT) + CALL CD_AGG_MotionKinematics(mag, k + 1, p, v, a, o, w, al, roll, turns, rolls, es, em) + IF (es == 0) THEN + IF (turns) THEN + CALL CD_AGG_Step_Moving(mag, DTM, p, v, a, converged, stalled, n_it, es, em, t_committed=DTM*k, & + orientation=o, angular_velocity=w, angular_acceleration=al) + ELSE + CALL CD_AGG_Step_Moving(mag, DTM, p, v, a, converged, stalled, n_it, es, em, t_committed=DTM*k, roll=roll) + END IF + END IF + CALL cd_test_allocation_counting(0_C_INT) + CALL check('motion step') + IF (.NOT. converged .OR. stalled) ERROR STOP 'motion step did not converge' + n_alloc = n_alloc + (cd_test_allocation_count() - c0) + END DO + CALL CD_AGG_End(mag, es, em) + PRINT '(A,I0,A,I0,A)', 'mixed deck with '//MERGE('vessel motion', 'roll column ', vessel)//': ', N_COUNT, & + ' counted steps, ', n_alloc, ' heap allocations in the steps' + IF (n_alloc /= 0) THEN + PRINT '(A)', 'FAIL: the prescribed-motion march of a mixed deck allocated after warm-up' + ERROR STOP 1 + END IF + PRINT '(A)', 'PASS: no heap allocation in the prescribed-motion march of a mixed deck after warm-up' + END SUBROUTINE motion_gate + SUBROUTINE check(stage) CHARACTER(*), INTENT(IN) :: stage diff --git a/tests/test_torsion_deck.f90 b/tests/test_torsion_deck.f90 index c20f5ceb..d06cfff3 100644 --- a/tests/test_torsion_deck.f90 +++ b/tests/test_torsion_deck.f90 @@ -7,8 +7,9 @@ !> pretwist: Torq = GJ Phi / L at every node, Twist = 720 deg, TwistN linear from !> End A; torsional end springs add their compliance; !> 2. backward compatibility: the same deck with Free torsion columns (any normal), or with one -!> end restrained only, writes the same .out bytes as the 6-column rows; Rigid, Infinity, -!> Inf and a quoted "Rigid" are one restraint; +!> end restrained only on a 10-column LINE TYPES row (no GJ, so its torsion is not solved), +!> writes the same .out bytes as the 6-column rows; Rigid, Infinity, Inf and a quoted +!> "Rigid" are one restraint; !> 3. a pretwist sweep to three turns on a sagging clamped line: the torque grows in equal !> steps (no 2 pi slip) and Twist follows the pretwist; !> 4. body torque return: a massive Rigid6 body (attitude rolled, pitched and yawed) holding a @@ -845,8 +846,8 @@ SUBROUTINE expect_error(label, path, root, needle) END SUBROUTINE expect_error SUBROUTINE check_one_end_two_moving() - !! One restrained end is ignored before the torsion rules: on a line with two moving ends - !! (Coupled to Free, dynamic) the one-end row gets exactly the verdict of the six-column rows, + !! One restrained end on a line with two moving ends (Coupled to Free, dynamic) is not solved + !! in torsion (it is noted): the one-end row gets exactly the verdict of the six-column rows, !! not the torsion rule "two moving ends". LOGICAL :: ok0, ok1 CHARACTER(512) :: em0, em1 @@ -926,7 +927,8 @@ SUBROUTINE check_errors() CALL straight_deck('tdeck_e8.dat', 'Pinned 1 0 0 Rigid 0 0 1 0', 'Pinned 1 0 0 Free 0 0 1 0', & [CHARACTER(16) :: 'FairTen1'], tei0) CALL expect_error('torsion on an EI = 0 line is named', 'tdeck_e8.dat', 'tdeck_e8', 'require a finite-EI line') - CALL straight_deck('tdeck_e9.dat', 'Rigid 1 0 0 Rigid 0 0 1 0', 'Rigid 1 0 0 Free 0 0 1 720', OUTS) + ! (a line restrained at one end only is solved in torsion: test_torsion_one_end) + CALL straight_deck('tdeck_e9.dat', 'Rigid 1 0 0 Free 0 0 1 0', 'Rigid 1 0 0 Free 0 0 1 720', OUTS) CALL expect_error('a torque channel on a line without torsion is named', 'tdeck_e9.dat', 'tdeck_e9', & 'carries no torque') CALL write_deck('tdeck_e10.dat', [neutral_type], no_rows, & @@ -968,9 +970,9 @@ SUBROUTINE check_errors() [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 cab 100.0 40'], & [CHARACTER(96) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 90'], & [CHARACTER(24) :: '0.1 dtM'], [CHARACTER(16) :: 'FairTen1']) - ! a caller that does not pass the fairlead orientation (the C API, the standalone mixed - ! route) is refused by name; one that does (the OpenFAST and FAST.Farm shells) builds the - ! line with its torsion + ! a caller that does not pass the fairlead orientation (the C API) is refused by name; one + ! that does (the OpenFAST and FAST.Farm shells, the standalone mixed route) builds the line + ! with its torsion CALL CD_Init_Deck_Aggregate('tdeck_e12.dat', 0.1_wp, agg, es, em) CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'needs a host that turns its fairlead frame') > 0, & 'an aggregate caller without orientations refuses torsion by name (got: '//TRIM(em)//')') @@ -1021,8 +1023,9 @@ SUBROUTINE write_lines(path, rows) END SUBROUTINE write_lines SUBROUTINE check_scope_refusals() - !! 6 (continued). Torsion outside its scope stops by name: End A on a rod end and End A on a - !! Point3 body; a torsional line carrying ATTACHMENTS solves (test_torsion_attachments). + !! 6 (continued). Torsion outside its scope stops by name: End A on a pinned rod (a Fixed rod + !! end is supported, test_rod_end_torsion) and End A on a Point3 body; a torsional line + !! carrying ATTACHMENTS solves (test_torsion_attachments). CHARACTER(120) :: tail(9), ty(4) ty(1) = '--- LINE TYPES ---' ty(2) = 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' @@ -1042,14 +1045,15 @@ SUBROUTINE check_scope_refusals() 'Name Diam Mass Cd Ca CdEnd CaEnd', '(-) (m) (kg/m) (-) (-) (-) (-)', & 'arm 0.6 400.0 1.0 1.0 0.0 0.0', '--- RODS ---', & 'ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs', & - '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)', '1 arm Fixed 0 0 -40 0 0 -50 4 -', & + '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)', '1 arm Pinned 0 0 -40 0 0 -50 4 -', & '--- POINTS ---', 'ID Type X Y Z Mass Vol CdA Ca', '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)', & '2 Fixed 100.0 0.0 -50.0 0 0 0 0', '--- LINES ---', 'ID NodeA NodeB Outputs', '(-) (-) (-) (-)', & '1 R1B 2 -', tail(1:4), '--- END CONNECTIONS ---', & 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist', & '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)', '1 A Rigid 0 0 -1 Rigid 1 0 0 0', & '1 B Rigid 1 0 0 Rigid 0 0 1 0', tail(5:9)]) - CALL expect_error('a torsional end on a rod is named', 'tdeck_s1.dat', 'tdeck_s1', 'on a rod end is not supported') + CALL expect_error('a torsional end on a pinned rod is named', 'tdeck_s1.dat', 'tdeck_s1', & + 'on the end of ROD 1 (pinned) is not supported') ! End A on a Point3 body CALL write_lines('tdeck_s2.dat', [CHARACTER(120) :: 'torsion scope', ty, '--- BODIES ---', & 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca', & diff --git a/tests/test_torsion_one_end.f90 b/tests/test_torsion_one_end.f90 new file mode 100644 index 00000000..6f902cbc --- /dev/null +++ b/tests/test_torsion_one_end.f90 @@ -0,0 +1,1001 @@ +! File: tests/test_torsion_one_end.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_torsion_one_end + !! Gates of a finite-EI line restrained in torsion at one end only, its other end free to twist + !! (END CONNECTIONS TorsStiffness Free there, or no row): the free end carries no torque and + !! turns with the twist of the line. + !! M modes and waves of the cubic-Hermite dynamics: a straight taut 10 m line (GJ 80 N m2, + !! Irn 0.5 kg m, 20 elements, clamped in bending, both end positions held), rigid in + !! torsion at one end and free at the other, the free end at internal end 2 (deck End A) + !! and at internal end 1 (deck End B) in turn: + !! M1 released from a twist (the restrained end's frame turned by 0.2 rad over a quarter + !! period, then held), the free end rings at the quarter-wave frequencies of the + !! clamped-free continuum, omega_n = (2n - 1) pi/(2L) sqrt(GJ/Irn), n = 1, 2 (the peaks + !! of its Hann-windowed spectrum, 0.4 % and 1 %); + !! M2 driven in roll A sin(Omega t) at the restrained end, Omega = omega_1/2 and + !! 3 omega_1/2 (kL = pi/4, 3 pi/4): the free end rolls with the continuum's A/cos kL + !! (in antiphase above the first mode) and the restrained end's support reacts with + !! GJ A k tan kL (1 %, the Fourier components at Omega); the free end's support takes + !! no torque; + !! M3 a snapshot of the driven run, restored, continues bit-identically. + !! C torque-tension coupling on the deck (standalone driver): a straight neutral cable (EA + !! 1e7 N, GJ|K 5e4 N m2|4e5 N m) of 99 m held 100 m apart, restrained in torsion at one end: + !! C1 statics, End A free, End B free, and End A without an END CONNECTIONS row (End B an + !! elastic restraint): the stretch twists the line by -(K/GJ) sum (l_e - l0_e) = -8 rad + !! (Twist1, half of it at mid-line, Twist1N41 = Twist1), no torque anywhere, and the + !! tension (EA - K^2/GJ) eps of a section free to twist; + !! C2 a march moving End A 0.1 m away over 20 s (polar inertia negligible, Irn 1e-9): the + !! free end, the moving End A or the anchored End B, turns with the stretch at every + !! step, Twist1 = -(K/GJ)(l(t) - l0), and the tension follows (EA - K^2/GJ) eps(t); + !! D torsional inertia on the deck: the 100 m line (GJ 5e4 N m2, Irn 1 kg m) restrained at + !! End A, free at End B, End A rolled A sin(Omega t) by the motionFile roll column at + !! Omega = omega_1/4 (kL = pi/8): the Fourier components at Omega of Twist1, Torq1N1 and + !! Torq1N41 are the continuum's, A (1/cos kL - 1) and GJ times its mean twist rate over the + !! end elements (the free end's element carries 1.3 % of the driven end's torque); + !! A the coupled aggregate (End A host-driven, host_orientation): the C1 line free at End A + !! keeps its static twist and no torque while the platform rolls about the line axis (the + !! roll does not reach a free end), with no axial moment on the platform; the D line + !! restrained at End A rolled by the platform gives D's continuum response; + !! N a line restrained at one end whose LINE TYPES row gives no GJ (10 columns) keeps the + !! meaning of the 6-column rows: its twist channels are refused with the reason; a solved + !! line's restrained Pretwist beyond 1000 turns is refused by name. + !! T ATTACHMENTS on a line free at one end (the torsion stage after the attachment polish, + !! on the polished mesh): + !! T1 statics: the C1 cable hung vertically (99 m between points 100 m apart) carrying three + !! clumps and buoys of net weights w_k at nodes n_k, free at End A and at End B in turn. + !! The line stays straight and its section is free to twist, so each element carries + !! the tension T_e = T_A - sum_(n_k <= e) w_k and the strain T_e/(EA - K^2/GJ), with + !! sum_e l0 eps_e = H - L0: T_A = [(EA - K^2/GJ)(H - L0)/l0 + sum_k w_k (NE + 1 - n_k)]/NE. + !! The free end turns by Twist1 = -(K/GJ)(H - L0) whatever the weights, with no torque + !! and the tensions T_A, T_A - sum w_k; the mid-line node by -(K/GJ) sum_(e<=20) l0 eps_e + !! (0.8 % beyond the uniform strain's half) within 1e-3: the shared nodal tangent of + !! the cubic-Hermite elements spreads each tension step over its two elements, a + !! first-order mesh error (3.9e-4, 1.9e-4, 9.6e-5 at 40, 80, 160 elements); + !! T2 dynamics: the D roll of the restrained End A, the line taut (99.9 m over the span), + !! with three neutral modules (their mass is translational only, so the torsional + !! response is D's continuum over the 99.9 m). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & + CD_HTORS_OK + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_EvalChannel, CD_AGG_End, & + CD_AGG_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCableDynType, CD_HermiteCable_Dyn_Init, & + CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_End, & + CD_HermiteCable_Dyn_Set_EndConnection, CD_HermiteCable_Dyn_Set_Torsion, & + CD_HermiteCable_Dyn_Set_Torsion_Drive, & + CD_HermiteCable_Dyn_EndConnection_Moment, CD_HermiteCable_Dyn_Snapshot, & + CD_HermiteCable_Dyn_Restore, CD_HCDYN_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, RHOW = 1025.0_wp, DEG = PI/180.0_wp + ! the deck cable of gates C, D, A: EA 1e7 N, GJ 5e4 N m2 and, under coupling, K 4e5 N m + REAL(wp), PARAMETER :: EA_D = 1.0e7_wp, GJ_D = 5.0e4_wp, K_D = 4.0e5_wp, SPAN = 100.0_wp, L0_D = 99.0_wp + REAL(wp), PARAMETER :: LL = 10.0_wp, EA = 1.0e5_wp, EI = 100.0_wp, GJ = 80.0_wp, RHOA = 1.0_wp, IRN = 0.5_wp + INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDOF = 6*NN + INTEGER :: nfail = 0, kfree, mom_sign(2) = 0 + + DO kfree = 2, 1, -1 + CALL check_modes(kfree) + CALL check_driven(kfree, 0.5_wp) + CALL check_driven(kfree, 1.5_wp) + END DO + CALL check_restore() + CALL check_deck_statics() + CALL check_deck_stretch() + CALL check_deck_inertia() + CALL check_aggregate() + CALL check_not_solved() + CALL check_attachments_statics() + CALL check_attachments_inertia() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: one-end torsion gates' + +CONTAINS + + INCLUDE 'nan_max_abs.inc' + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (cond) RETURN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//TRIM(label) + END SUBROUTINE require + + CHARACTER(5) FUNCTION end_name(kf) RESULT(s) + !! The deck end of internal end kf (internal end 1 is End B, end 2 End A). + INTEGER, INTENT(IN) :: kf + s = MERGE('End B', 'End A', kf == 1) + END FUNCTION end_name + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE build_line(m, kf, ok) + !! The straight line along +x (node 1 at the origin), clamped in bending at both ends (end + !! positions held), rigid in torsion at internal end 3 - kf and free at internal end kf; both + !! end frames (+x, +z); rho_inf 1 (no numerical dissipation). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: kf + LOGICAL, INTENT(OUT) :: ok + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), l0(NE), g(NDOF), raw + INTEGER :: k, es + CHARACTER(300) :: em + l0 = LL/REAL(NE, wp) + q = 0.0_wp + DO k = 1, NN + q(6*k - 5) = LL*REAL(k - 1, wp)/REAL(NE, wp) + q(6*k - 2) = 1.0_wp + END DO + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(RHOA, k=1, NE)], [(0.0_wp, k=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, 1.0_wp, es, em) + ok = es == CD_HCDYN_OK + CALL require(ok, 'init: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL CD_HermiteCable_Dyn_Set_EndConnection(m, [0.0_wp, 0.0_wp], & + RESHAPE([1.0_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], [3, 2]), & + es, em, connection_mode=[CD_ENDCONN_RIGID, CD_ENDCONN_RIGID]) + ok = es == CD_HCDYN_OK + CALL require(ok, 'end connections: '//TRIM(em)) + IF (.NOT. ok) RETURN + tors%active = .TRUE. + tors%ends = frames(0.0_wp) + tors%end_free(kf) = .TRUE. + ALLOCATE (tors%gj(NE), tors%irn(NE)) + tors%gj = GJ + tors%irn = IRN + CALL CD_HermiteTorsion_Line(q, l0, tors%ends, raw, g, es, em) + CALL require(es == CD_HTORS_OK, 'seed twist evaluates: '//TRIM(em)) + tors%theta = CD_HermiteTorsion_Unwrap(raw, 0.0_wp) + tors%has_theta = .TRUE. + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + ok = es == CD_HCDYN_OK .AND. m%tw_active + CALL require(ok, 'one-end torsion installs the nodal twist ('//end_name(kf)//' free): '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL require(m%torsion%torque == 0.0_wp, 'one-end torsion: no condensed torque') + END SUBROUTINE build_line + + FUNCTION frames(ang) RESULT(ends) + !! Both end frames (+x, +z), the restrained end's turned by ang about +x by the caller. + REAL(wp), INTENT(IN) :: ang + REAL(wp) :: ends(3, 4) + ends(:, 1) = [1.0_wp, 0.0_wp, 0.0_wp] + ends(:, 2) = [0.0_wp, -SIN(ang), COS(ang)] + ends(:, 3) = [1.0_wp, 0.0_wp, 0.0_wp] + ends(:, 4) = [0.0_wp, -SIN(ang), COS(ang)] + END FUNCTION frames + + SUBROUTINE drive_step(m, kf, ang, dt, ok) + !! One step with the restrained end's frame turned to ang about +x (the free end's held). + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: kf + REAL(wp), INTENT(IN) :: ang, dt + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: ends(3, 4), turned(3, 4) + INTEGER :: es, kr + CHARACTER(300) :: em + kr = 3 - kf + ends = frames(0.0_wp) + turned = frames(ang) + ends(:, 2*kr - 1:2*kr) = turned(:, 2*kr - 1:2*kr) + CALL CD_HermiteCable_Dyn_Set_Torsion_Drive(m, ends, 0.0_wp, es, em) + IF (es == CD_HCDYN_OK) CALL CD_HermiteCable_Dyn_Step(m, dt, 40, 1.0e-11_wp, es, em) + ok = es == CD_HCDYN_OK + IF (.NOT. ok) WRITE (*, '(A)') ' step: '//TRIM(em) + END SUBROUTINE drive_step + + REAL(wp) FUNCTION free_roll(m, kf) RESULT(r) + !! The roll of the free end's section about +x: its twist angle against its director, which + !! the straight, unmoving line keeps fixed (no transport). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: m + INTEGER, INTENT(IN) :: kf + r = m%tw_phi(MERGE(1, NN, kf == 1)) + END FUNCTION free_roll + + REAL(wp) FUNCTION axial_moment(m, node) RESULT(mx) + !! The axial (x) component of the line's moment on the support of end node node. + TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: m + INTEGER, INTENT(IN) :: node + REAL(wp) :: mom(3) + INTEGER :: es + CHARACTER(300) :: em + CALL CD_HermiteCable_Dyn_EndConnection_Moment(m, node, mom, es, em) + CALL require(es == CD_HCDYN_OK, 'end moment: '//TRIM(em)) + mx = mom(1) + END FUNCTION axial_moment + + REAL(wp) FUNCTION ramp(t, tr) RESULT(s) + !! C2 quintic from 0 at t = 0 to 1 at t = tr. + REAL(wp), INTENT(IN) :: t, tr + REAL(wp) :: x + x = MIN(MAX(t/tr, 0.0_wp), 1.0_wp) + s = x**3*(10.0_wp - 15.0_wp*x + 6.0_wp*x**2) + END FUNCTION ramp + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_modes(kf) + !! M1: released from a twist, the free end rings at the clamped-free frequencies. + INTEGER, INTENT(IN) :: kf + REAL(wp), PARAMETER :: AMP = 0.2_wp + INTEGER, PARAMETER :: NPP = 200, NPER = 40 + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: c, om1, dt, tr, t, ang, err(2), peak(2) + REAL(wp), ALLOCATABLE :: sig(:), ts(:) + INTEGER :: k, n, nrec, nstep + LOGICAL :: ok + c = SQRT(GJ/IRN) + om1 = 0.5_wp*PI*c/LL + dt = 2.0_wp*PI/om1/REAL(NPP, wp) + tr = 0.25_wp*2.0_wp*PI/om1 + CALL build_line(m, kf, ok) + IF (.NOT. ok) RETURN + nstep = NPER*NPP + NINT(tr/dt) + ALLOCATE (sig(nstep), ts(nstep)) + nrec = 0 + DO k = 1, nstep + t = dt*REAL(k, wp) + ang = AMP*ramp(t, tr) + CALL drive_step(m, kf, ang, dt, ok) + CALL require(ok, 'M1 ('//end_name(kf)//' free): step') + IF (.NOT. ok) EXIT + IF (t > tr) THEN + nrec = nrec + 1 + sig(nrec) = free_roll(m, kf) - AMP + ts(nrec) = t + END IF + END DO + IF (ok) THEN + DO n = 1, 2 + peak(n) = spectrum_peak(sig(1:nrec), ts(1:nrec), REAL(2*n - 1, wp)*om1) + err(n) = peak(n)/(REAL(2*n - 1, wp)*om1) - 1.0_wp + END DO + WRITE (*, '(A,A,A,2F10.5,A,2F10.5,A,2ES10.2)') 'M1 ', end_name(kf), ' free: ring-down peaks ', peak, & + ' rad/s, quarter-wave ', om1, 3.0_wp*om1, ' rad/s, errors ', err + CALL require(ABS(err(1)) <= 4.0e-3_wp, 'M1 ('//end_name(kf)//' free): the first mode is the quarter wave') + CALL require(ABS(err(2)) <= 1.0e-2_wp, 'M1 ('//end_name(kf)//' free): the second mode is three quarter waves') + END IF + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_modes + + REAL(wp) FUNCTION spectrum_peak(x, t, om0) RESULT(om_pk) + !! The frequency of the largest Hann-windowed Fourier amplitude of x(t) within 15 % of om0. + REAL(wp), INTENT(IN) :: x(:), t(:), om0 + INTEGER, PARAMETER :: NGRID = 3001 + INTEGER :: i, j, n + REAL(wp) :: om, w, re, im, amp, best, t0, span + n = SIZE(x) + t0 = t(1) + span = t(n) - t0 + best = -1.0_wp + om_pk = om0 + DO j = 1, NGRID + om = om0*(0.85_wp + 0.3_wp*REAL(j - 1, wp)/REAL(NGRID - 1, wp)) + re = 0.0_wp + im = 0.0_wp + DO i = 1, n + w = 0.5_wp - 0.5_wp*COS(2.0_wp*PI*(t(i) - t0)/span) + re = re + w*x(i)*COS(om*(t(i) - t0)) + im = im + w*x(i)*SIN(om*(t(i) - t0)) + END DO + amp = re*re + im*im + IF (amp > best) THEN + best = amp + om_pk = om + END IF + END DO + END FUNCTION spectrum_peak + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_driven(kf, ratio) + !! M2: the restrained end rolled A sin(Omega t) (amplitude ramped in over eight periods), + !! Omega = ratio omega_1. Over six periods after one more, the Fourier components at Omega + !! (orthogonal there to the free modes the ramp leaves ringing, omega_1 and 3 omega_1) of the + !! free end's roll and of the restrained support's axial reaction are the continuum's: + !! A/cos kL (in phase below the first mode, in antiphase above it) and GJ A k tan kL, the + !! latter with a sign the same at both frequencies. + INTEGER, INTENT(IN) :: kf + REAL(wp), INTENT(IN) :: ratio + REAL(wp), PARAMETER :: AMP = 0.2_wp + INTEGER, PARAMETER :: NPER_RAMP = 8, NPER_MEAS = 6, NPP = 200 + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: c, om, dt, t, ramp_t, kw, fmax, roll_ref, mom_ref, e_roll, e_mom, s, co + REAL(wp) :: rs, rc, ms, mc, a_roll, a_mom, mf + INTEGER :: k, node_r, node_f, k0 + LOGICAL :: ok + CHARACTER(8) :: lab + c = SQRT(GJ/IRN) + om = ratio*0.5_wp*PI*c/LL + dt = 2.0_wp*PI/om/REAL(NPP, wp) + WRITE (lab, '(F4.2)') ratio + CALL build_line(m, kf, ok) + IF (.NOT. ok) RETURN + node_r = MERGE(NN, 1, kf == 1) + node_f = MERGE(1, NN, kf == 1) + ramp_t = REAL(NPER_RAMP, wp)*2.0_wp*PI/om + k0 = (NPER_RAMP + 1)*NPP + rs = 0.0_wp + rc = 0.0_wp + ms = 0.0_wp + mc = 0.0_wp + fmax = 0.0_wp + DO k = 1, k0 + NPER_MEAS*NPP + t = dt*REAL(k, wp) + CALL drive_step(m, kf, AMP*ramp(t, ramp_t)*SIN(om*t), dt, ok) + CALL require(ok, 'M2 ('//end_name(kf)//' free, Omega/omega_1 = '//TRIM(lab)//'): step') + IF (.NOT. ok) EXIT + IF (k > k0) THEN + s = SIN(om*t) + co = COS(om*t) + rs = rs + free_roll(m, kf)*s + rc = rc + free_roll(m, kf)*co + ms = ms + axial_moment(m, node_r)*s + mc = mc + axial_moment(m, node_r)*co + mf = axial_moment(m, node_f) + fmax = MAX(fmax, ABS(mf)) + END IF + END DO + IF (ok) THEN + rs = 2.0_wp*rs/REAL(NPER_MEAS*NPP, wp) + rc = 2.0_wp*rc/REAL(NPER_MEAS*NPP, wp) + ms = 2.0_wp*ms/REAL(NPER_MEAS*NPP, wp) + mc = 2.0_wp*mc/REAL(NPER_MEAS*NPP, wp) + kw = om/c + roll_ref = AMP/COS(kw*LL) + mom_ref = GJ*AMP*kw*TAN(kw*LL) + a_roll = rs + a_mom = ms + e_roll = a_roll/roll_ref - 1.0_wp + e_mom = ABS(a_mom/mom_ref) - 1.0_wp + WRITE (*, '(A,A,A,F4.2,A,2ES13.5,A,2ES13.5,A,2ES10.2,A,2ES9.2,A,ES9.2)') 'M2 ', end_name(kf), & + ' free, Omega/omega_1 = ', ratio, ': free-end roll and driven torque at Omega ', a_roll, a_mom, & + ' continuum ', roll_ref, mom_ref, ' errors ', e_roll, e_mom, '; quadrature ', rc/roll_ref, mc/mom_ref, & + '; free-end axial moment ', fmax + CALL require(ABS(e_roll) <= 1.0e-2_wp .AND. ABS(rc) <= 1.0e-2_wp*ABS(roll_ref), & + 'M2 ('//end_name(kf)//' free, '//TRIM(lab)//'): the free end rolls by A/cos kL') + CALL require(ABS(e_mom) <= 1.0e-2_wp .AND. ABS(mc) <= 1.0e-2_wp*ABS(mom_ref), & + 'M2 ('//end_name(kf)//' free, '//TRIM(lab)//'): the restrained end reacts with GJ A k tan kL') + IF (mom_sign(kf) == 0) THEN + mom_sign(kf) = NINT(SIGN(1.0_wp, a_mom/mom_ref)) + ELSE + CALL require(mom_sign(kf) == NINT(SIGN(1.0_wp, a_mom/mom_ref)), 'M2 ('//end_name(kf)//' free, '// & + TRIM(lab)//'): the reaction turns sign with tan kL across the first mode') + END IF + CALL require(fmax <= 1.0e-9_wp*ABS(mom_ref), 'M2 ('//end_name(kf)//' free, '//TRIM(lab)// & + '): the free end transmits no torque') + END IF + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_driven + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_restore() + !! M3: the driven run of the End A free line: 300 steps, snapshot, 100 more; restored, the + !! same 100 steps are bit-identical. + TYPE(CD_HermiteCableDynType) :: m + REAL(wp) :: dt, om, qref(NDOF), pref(NN) + INTEGER :: k, es + LOGICAL :: ok + CHARACTER(300) :: em + om = 0.5_wp*0.5_wp*PI*SQRT(GJ/IRN)/LL + dt = 2.0_wp*PI/om/200.0_wp + CALL build_line(m, 2, ok) + IF (.NOT. ok) RETURN + DO k = 1, 300 + CALL drive_step(m, 2, 0.2_wp*ramp(dt*k, 50.0_wp*dt)*SIN(om*dt*k), dt, ok) + IF (.NOT. ok) EXIT + END DO + CALL CD_HermiteCable_Dyn_Snapshot(m, es, em) + CALL require(ok .AND. es == CD_HCDYN_OK, 'M3: snapshot: '//TRIM(em)) + DO k = 301, 400 + CALL drive_step(m, 2, 0.2_wp*SIN(om*dt*k), dt, ok) + IF (.NOT. ok) EXIT + END DO + qref = m%q + pref = m%tw_phi + CALL CD_HermiteCable_Dyn_Restore(m, es, em) + CALL require(es == CD_HCDYN_OK, 'M3: restore: '//TRIM(em)) + DO k = 301, 400 + CALL drive_step(m, 2, 0.2_wp*SIN(om*dt*k), dt, ok) + IF (.NOT. ok) EXIT + END DO + CALL require(ok .AND. ALL(bits(m%q) == bits(qref)) .AND. ALL(bits(m%tw_phi) == bits(pref)), & + 'M3: the restored one-end run continues bit-identically') + WRITE (*, '(A,ES13.5,A)') 'M3 restore: free-end roll ', pref(NN), ' rad, restored run identical' + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_restore + + ! ------------------------------------------------------------------------------------------ + ! deck gates + ! ------------------------------------------------------------------------------------------ + CHARACTER(160) FUNCTION type_row(gj_col, irn) RESULT(row) + !! The neutral 0.2 m LINE TYPES row (mass rhoW pi d^2/4, EA 1e7, EI 1e6, GAs 1e8) with the GJ + !! column gj_col and the polar inertia irn. + CHARACTER(*), INTENT(IN) :: gj_col + REAL(wp), INTENT(IN) :: irn + WRITE (row, '(A,ES24.16,A,ES12.5,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 1.0e8 '// & + TRIM(gj_col)//' 1.0 ', irn, ' 0.0 0.0 0.0 0.0' + END FUNCTION type_row + + SUBROUTINE write_deck(path, trow, conns, length, options, outs, ten_cols, atts, end_b) + !! The straight cable along +x from a Coupled End A (0, 0, -50) to a Fixed End B (100, 0, -50) + !! (or end_b), 40 elements over length, LINE TYPES row trow (14 columns, or 10 with ten_cols), + !! END CONNECTIONS rows conns (none when empty), ATTACHMENTS rows atts, then options and outs. + CHARACTER(*), INTENT(IN) :: path, trow, conns(:), options(:), outs(:) + REAL(wp), INTENT(IN) :: length + LOGICAL, INTENT(IN), OPTIONAL :: ten_cols + CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + REAL(wp), INTENT(IN), OPTIONAL :: end_b(3) + INTEGER :: u, i + LOGICAL :: ten + ten = .FALSE. + IF (PRESENT(ten_cols)) ten = ten_cols + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'one-end torsion gate' + WRITE (u, '(A)') '--- LINE TYPES ---' + IF (ten) THEN + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + ELSE + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + END IF + WRITE (u, '(A)') TRIM(trow) + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + IF (PRESENT(end_b)) THEN + WRITE (u, '(A,3ES24.16,A)') '2 Fixed ', end_b, ' 0 0 0 0' + ELSE + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0 0 0 0 0' + END IF + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A,F10.4,A)') '1 cab ', length, ' 40' + IF (PRESENT(atts)) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca' + WRITE (u, '(A)') '(-) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(atts) + WRITE (u, '(A)') TRIM(atts(i)) + END DO + END IF + IF (SIZE(conns) > 0) THEN + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + DO i = 1, SIZE(conns) + WRITE (u, '(A)') TRIM(conns(i)) + END DO + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run_deck(path, root, ok, em) + CHARACTER(*), INTENT(IN) :: path, root + LOGICAL, INTENT(OUT) :: ok + CHARACTER(*), INTENT(OUT) :: em + LOGICAL :: conv + INTEGER :: es + CALL CD_Run_Deck_Driver(path, root, conv, es, em) + ok = es == CD_DECKDRV_OK .AND. conv + END SUBROUTINE run_deck + + SUBROUTINE read_out(path, ncol, rows, nrow) + !! Every data row of a driver .out file (time first, then ncol - 1 channels). + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: ncol + REAL(wp), ALLOCATABLE, INTENT(OUT) :: rows(:, :) + INTEGER, INTENT(OUT) :: nrow + REAL(wp), ALLOCATABLE :: tmp(:, :) + REAL(wp) :: v(ncol) + INTEGER :: u, ios + CHARACTER(4096) :: buf + nrow = 0 + ALLOCATE (rows(ncol, 64)) + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + DO + READ (u, *, IOSTAT=ios) v + IF (ios /= 0) EXIT + nrow = nrow + 1 + IF (nrow > SIZE(rows, 2)) THEN + ALLOCATE (tmp(ncol, 2*SIZE(rows, 2))) + tmp(:, 1:nrow - 1) = rows(:, 1:nrow - 1) + CALL MOVE_ALLOC(tmp, rows) + END IF + rows(:, nrow) = v + END DO + CLOSE (u) + END SUBROUTINE read_out + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_deck_statics() + !! C1: the static coupling twist of a line free at one end. + CHARACTER(16), PARAMETER :: OUTS(8) = [CHARACTER(16) :: 'FairTen1', 'Torq1N1', 'Torq1N21', 'Torq1N41', & + 'Twist1N21', 'Twist1N41', 'Twist1', 'Ten1N21'] + CHARACTER(48) :: conns(2, 3) + CHARACTER(24), PARAMETER :: LABEL(3) = [CHARACTER(24) :: 'End A free', 'End B free', 'End A without a row'] + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: eps, t_ref, tw_ref, e_t, e_tw, e_m + INTEGER :: iv, nrow, nconn + LOGICAL :: ok + CHARACTER(512) :: em + conns(:, 1) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1', '1 B Rigid 1 0 0 Rigid 0 0 1 30'] + conns(:, 2) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 -30', '1 B Rigid 1 0 0 Free 0 0 1'] + conns(:, 3) = [CHARACTER(48) :: '1 B Rigid 1 0 0 1.0e5 0 0 1 10', ''] + eps = SPAN/L0_D - 1.0_wp + t_ref = (EA_D - K_D**2/GJ_D)*eps + tw_ref = -(K_D/GJ_D)*(SPAN - L0_D)/DEG + DO iv = 1, 3 + nconn = MERGE(1, 2, iv == 3) + CALL write_deck('t1e_static.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), conns(1:nconn, iv), L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], OUTS) + CALL run_deck('t1e_static.dat', 't1e_static', ok, em) + CALL require(ok, 'C1 ('//TRIM(LABEL(iv))//'): the static deck runs with its twist channels: '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL read_out('t1e_static.out', 9, rows, nrow) + CALL require(nrow == 1, 'C1: one static row') + IF (nrow < 1) CYCLE + e_t = MAX(ABS(rows(2, 1) - t_ref), ABS(rows(9, 1) - t_ref))/t_ref + e_tw = MAX(ABS(rows(8, 1) - tw_ref), ABS(rows(7, 1) - tw_ref), ABS(rows(6, 1) - 0.5_wp*tw_ref))/ABS(tw_ref) + e_m = nan_max_abs(rows(3:5, 1)) + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,ES14.7,A,ES14.7,A,3ES10.2)') 'C1 ', TRIM(LABEL(iv)), ': Twist1 ', & + rows(8, 1), ' deg (expected ', tw_ref, '), FairTen1 ', rows(2, 1), ' N (expected ', t_ref, & + '); errors twist, tension, |torque| ', e_tw, e_t, e_m + CALL require(e_tw <= 1.0e-6_wp, 'C1 ('//TRIM(LABEL(iv))//'): the stretch twists the free line by -(K/GJ) dl') + CALL require(e_t <= 1.0e-6_wp, 'C1 ('//TRIM(LABEL(iv))//'): the tension is (EA - K^2/GJ) eps') + CALL require(e_m <= 1.0e-6_wp, 'C1 ('//TRIM(LABEL(iv))//'): no static torque') + END DO + END SUBROUTINE check_deck_statics + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE stretch_motion(path) + !! End A held at its place, moved by -DX s(t) along x (s a C2 quintic over 20 s), then held. + CHARACTER(*), INTENT(IN) :: path + INTEGER, PARAMETER :: NSTEP = 500 + REAL(wp), PARAMETER :: TR = 20.0_wp, DTM = 0.05_wp, DX = 0.1_wp + REAL(wp) :: t, tau, s, sd, sdd + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az' + DO k = 0, NSTEP + t = DTM*REAL(k, wp) + tau = MIN(t/TR, 1.0_wp) + s = 10.0_wp*tau**3 - 15.0_wp*tau**4 + 6.0_wp*tau**5 + sd = (30.0_wp*tau**2 - 60.0_wp*tau**3 + 30.0_wp*tau**4)/TR + sdd = (60.0_wp*tau - 180.0_wp*tau**2 + 120.0_wp*tau**3)/TR**2 + IF (t > TR) THEN + sd = 0.0_wp + sdd = 0.0_wp + END IF + WRITE (u, '(ES16.8,A,ES16.8,A,ES16.8,A,ES16.8,A)') t, ' 1 ', -DX*s, ' 0.0 -50.0 ', -DX*sd, ' 0 0 ', -DX*sdd, & + ' 0 0' + END DO + CLOSE (u) + END SUBROUTINE stretch_motion + + SUBROUTINE check_deck_stretch() + !! C2: the free end turns with the stretch at every step of the march. + REAL(wp), PARAMETER :: TR = 20.0_wp, DX = 0.1_wp + CHARACTER(48) :: conns(2, 2) + CHARACTER(24), PARAMETER :: LABEL(2) = [CHARACTER(24) :: 'End A free', 'End B free'] + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: tau, s, dl, e_tw, e_t + INTEGER :: iv, k, nrow + LOGICAL :: ok + CHARACTER(512) :: em + conns(:, 1) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1', '1 B Rigid 1 0 0 Rigid 0 0 1 0'] + conns(:, 2) = [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'] + CALL stretch_motion('t1e_stretch.txt') + DO iv = 1, 2 + CALL write_deck('t1e_stretch.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), conns(:, iv), L0_D, & + [CHARACTER(32) :: '0.05 dtM', '25.0 TMax', 't1e_stretch.txt motionFile'], & + [CHARACTER(16) :: 'FairTen1', 'Twist1']) + CALL run_deck('t1e_stretch.dat', 't1e_stretch', ok, em) + CALL require(ok, 'C2 ('//TRIM(LABEL(iv))//'): the stretching march runs: '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL read_out('t1e_stretch.out', 3, rows, nrow) + CALL require(nrow == 501, 'C2: one row per step') + e_tw = 0.0_wp + e_t = 0.0_wp + DO k = 1, nrow + tau = MIN(rows(1, k)/TR, 1.0_wp) + s = 10.0_wp*tau**3 - 15.0_wp*tau**4 + 6.0_wp*tau**5 + dl = SPAN + DX*s - L0_D + e_tw = MAX(e_tw, ABS(rows(3, k) + (K_D/GJ_D)*dl/DEG)/((K_D/GJ_D)*dl/DEG)) + e_t = MAX(e_t, ABS(rows(2, k) - (EA_D - K_D**2/GJ_D)*dl/L0_D)/((EA_D - K_D**2/GJ_D)*dl/L0_D)) + END DO + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,2ES10.2)') 'C2 ', TRIM(LABEL(iv)), ': Twist1 from ', rows(3, 1), & + ' to ', rows(3, nrow), ' deg; largest errors twist, tension ', e_tw, e_t + CALL require(e_tw <= 1.0e-6_wp, 'C2 ('//TRIM(LABEL(iv))//'): the free end turns with the stretch at every step') + ! (the axial inertia of the ramp, about 3e-5 of the tension, included) + CALL require(e_t <= 1.0e-4_wp, 'C2 ('//TRIM(LABEL(iv))//'): the tension is (EA - K^2/GJ) eps(t)') + END DO + END SUBROUTINE check_deck_stretch + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE inertia_expect(amp, kw, len, ne_d, tw_amp, mt_a, mt_b) + !! The continuum's response at Omega to a roll amp sin(Omega t) of the restrained End A of a + !! line free at End B, theta(s) = amp cos(k (L - s))/cos(kL) (s from End A): the twist of End + !! B relative to End A, and GJ times the mean twist rate over the End A and End B elements + !! (an end node's torque is its element's). + REAL(wp), INTENT(IN) :: amp, kw, len + INTEGER, INTENT(IN) :: ne_d + REAL(wp), INTENT(OUT) :: tw_amp, mt_a, mt_b + REAL(wp) :: h + h = len/REAL(ne_d, wp) + tw_amp = amp*(1.0_wp/COS(kw*len) - 1.0_wp) + mt_a = GJ_D*amp*(COS(kw*(len - h)) - COS(kw*len))/(h*COS(kw*len)) + mt_b = GJ_D*amp*(1.0_wp - COS(kw*h))/(h*COS(kw*len)) + END SUBROUTINE inertia_expect + + SUBROUTINE check_deck_inertia() + !! D: the motionFile roll of the restrained End A spins the line, whose free End B follows. + REAL(wp), PARAMETER :: IRN_D = 1.0_wp, AMP = 0.1_wp + INTEGER, PARAMETER :: NPP = 120, NPER_RAMP = 8, NPER_MEAS = 4 + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: c, om, dt, t, kw, tw_ref, ma_ref, mb_ref, proj(3), e(3) + INTEGER :: u, k, nrow, k0, nstep + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(64) :: opt(3) + c = SQRT(GJ_D/IRN_D) + om = 0.25_wp*0.5_wp*PI*c/SPAN + dt = 2.0_wp*PI/om/REAL(NPP, wp) + nstep = (NPER_RAMP + 1 + NPER_MEAS)*NPP + OPEN (NEWUNIT=u, FILE='t1e_roll.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az roll' + DO k = 0, nstep + t = dt*REAL(k, wp) + WRITE (u, '(ES24.16,A,ES24.16)') t, ' 1 0.0 0.0 -50.0 0 0 0 0 0 0 ', & + AMP*ramp(t, REAL(NPER_RAMP, wp)*2.0_wp*PI/om)*SIN(om*t)/DEG + END DO + CLOSE (u) + WRITE (opt(1), '(ES24.16,A)') dt, ' dtM' + WRITE (opt(2), '(ES24.16,A)') dt*REAL(nstep, wp), ' TMax' + opt(3) = 't1e_roll.txt motionFile' + CALL write_deck('t1e_roll.dat', type_row('5.0e4', IRN_D), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], SPAN, opt, & + [CHARACTER(16) :: 'Twist1', 'Torq1N1', 'Torq1N41']) + CALL run_deck('t1e_roll.dat', 't1e_roll', ok, em) + CALL require(ok, 'D: the rolling march runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_out('t1e_roll.out', 4, rows, nrow) + CALL require(nrow == nstep + 1, 'D: one row per step') + IF (nrow /= nstep + 1) RETURN + k0 = (NPER_RAMP + 1)*NPP + 1 + proj = 0.0_wp + DO k = k0 + 1, nrow + proj = proj + rows(2:4, k)*SIN(om*rows(1, k)) + END DO + proj = 2.0_wp*proj/REAL(NPER_MEAS*NPP, wp) + kw = om/c + CALL inertia_expect(AMP, kw, SPAN, 40, tw_ref, ma_ref, mb_ref) + ! Twist1 in degrees + e(1) = proj(1)*DEG/tw_ref - 1.0_wp + e(2) = proj(2)/ma_ref - 1.0_wp + e(3) = proj(3)/mb_ref - 1.0_wp + WRITE (*, '(A,3ES13.5,A,3ES13.5,A,3ES10.2)') 'D roll of the restrained End A (kL = pi/8): Twist1, Torq1N1, '// & + 'Torq1N41 at Omega ', proj(1)*DEG, proj(2:3), ' continuum ', tw_ref, ma_ref, mb_ref, ' errors ', e + CALL require(ABS(e(1)) <= 1.0e-2_wp, 'D: the free End B follows the roll with the continuum''s twist') + CALL require(ABS(e(2)) <= 1.0e-2_wp, 'D: the restrained End A carries the continuum''s inertial torque') + CALL require(ABS(e(3)) <= 3.0e-2_wp, 'D: the free End B''s element carries the continuum''s small torque') + END SUBROUTINE check_deck_inertia + + ! ------------------------------------------------------------------------------------------ + FUNCTION roll_dcm(phi) RESULT(r) + !! OpenFAST mesh orientation (global to local) of a roll phi about +x. + REAL(wp), INTENT(IN) :: phi + REAL(wp) :: r(3, 3) + r = 0.0_wp + r(1, 1) = 1.0_wp + r(2, 2) = COS(phi) + r(2, 3) = SIN(phi) + r(3, 2) = -SIN(phi) + r(3, 3) = COS(phi) + END FUNCTION roll_dcm + + SUBROUTINE check_aggregate() + !! A: the coupled aggregate, End A on the platform (host orientation). + REAL(wp), PARAMETER :: IRN_D = 1.0_wp, AMP = 0.1_wp, DT_A = 0.05_wp, RATE = 60.0_wp*PI/180.0_wp + INTEGER, PARAMETER :: NPP = 120, NPER_RAMP = 8, NPER_MEAS = 4 + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp) :: pos(3, 1), vel(3, 1), acc(3, 1), load(3, 1), moment(3, 1), orient(3, 3, 1), omega(3, 1) + REAL(wp) :: alpha(3, 1), tw0, tw, ta, tb, werr, merr, c, om, dt, t, ang, kw, tw_ref, ma_ref, mb_ref, proj(3), e(3) + REAL(wp) :: s, sd, sdd, tr + INTEGER :: es, ni, k, k0, nstep + LOGICAL :: cv, st, ok + CHARACTER(512) :: em + ! A1: the C1 line free at End A, the platform rolling at 60 deg/s + CALL write_deck('t1e_agg1.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1', '1 B Rigid 1 0 0 Rigid 0 0 1 0'], L0_D, & + [CHARACTER(16) :: '0.05 dtM'], [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1']) + CALL CD_AGG_Init_From_Deck(agg, 't1e_agg1.dat', DT_A, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'A1: the line free at End A builds on the aggregate: '//TRIM(em)) + IF (ok) THEN + CALL agg_channels(agg, ta, tb, tw0) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = RATE + werr = 0.0_wp + merr = 0.0_wp + DO k = 1, 10 + orient(:, :, 1) = roll_dcm(RATE*DT_A*k) + CALL CD_AGG_Step_Moving(agg, DT_A, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'A1: the rolling step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + CALL CD_AGG_CalcOutput(agg, es, em) + CALL agg_channels(agg, ta, tb, tw) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, moment=moment) + werr = MAX(werr, ABS(tw - tw0)) + merr = MAX(merr, ABS(ta), ABS(tb), ABS(moment(1, 1))) + IF (k == 10) WRITE (*, '(A,3ES12.4)') ' A1 last step: Torq1N1, Torq1N41, axial moment ', ta, tb, moment(1, 1) + END DO + WRITE (*, '(A,F12.5,A,ES10.2,A,ES10.2,A)') 'A1 aggregate, End A free, platform roll 30 deg: Twist1 ', tw0, & + ' deg, change ', werr, ' deg; torques and axial fairlead moment ', merr, ' N m' + CALL require(ABS(tw0 + (K_D/GJ_D)*(SPAN - L0_D)/DEG) <= 1.0e-6_wp*ABS(tw0), & + 'A1: the static coupling twist on the aggregate') + CALL require(werr <= 1.0e-6_wp, 'A1: the platform roll does not twist a line free at End A') + ! (against the torque GJ phi/L the roll would put into a line restrained at both ends) + CALL require(merr <= 1.0e-6_wp*GJ_D*RATE*DT_A*10.0_wp/SPAN, 'A1: no torque, and no axial moment on the platform') + CALL CD_AGG_End(agg, es, em) + END IF + ! A2: the D line restrained at End A, rolled by the platform + c = SQRT(GJ_D/IRN_D) + om = 0.25_wp*0.5_wp*PI*c/SPAN + dt = 2.0_wp*PI/om/REAL(NPP, wp) + tr = REAL(NPER_RAMP, wp)*2.0_wp*PI/om + CALL write_deck('t1e_agg2.dat', type_row('5.0e4', IRN_D), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], SPAN, & + [CHARACTER(16) :: '0.05 dtM'], [CHARACTER(16) :: 'Torq1N1', 'Torq1N41', 'Twist1']) + CALL CD_AGG_Init_From_Deck(agg, 't1e_agg2.dat', dt, es, em, host_orientation=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, 'A2: the line free at End B builds on the aggregate: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em, orientation=orient) + nstep = (NPER_RAMP + 1 + NPER_MEAS)*NPP + k0 = (NPER_RAMP + 1)*NPP + proj = 0.0_wp + DO k = 1, nstep + t = dt*REAL(k, wp) + ! the roll AMP s(t) sin(Omega t) with its rate and acceleration (s the quintic ramp) + CALL ramp_derivs(t, tr, s, sd, sdd) + ang = AMP*s*SIN(om*t) + orient(:, :, 1) = roll_dcm(ang) + omega = 0.0_wp + alpha = 0.0_wp + omega(1, 1) = AMP*(sd*SIN(om*t) + s*om*COS(om*t)) + alpha(1, 1) = AMP*(sdd*SIN(om*t) + 2.0_wp*sd*om*COS(om*t) - s*om*om*SIN(om*t)) + CALL CD_AGG_Step_Moving(agg, dt, pos, vel, acc, cv, st, ni, es, em, orientation=orient, & + angular_velocity=omega, angular_acceleration=alpha) + CALL require(es == CD_AGG_OK .AND. cv, 'A2: the rolling step converges: '//TRIM(em)) + IF (es /= CD_AGG_OK) EXIT + IF (k > k0) THEN + CALL CD_AGG_CalcOutput(agg, es, em) + CALL agg_channels(agg, ta, tb, tw) + proj = proj + [tw, ta, tb]*SIN(om*t) + END IF + END DO + IF (es == CD_AGG_OK) THEN + proj = 2.0_wp*proj/REAL(NPER_MEAS*NPP, wp) + kw = om/c + CALL inertia_expect(AMP, kw, SPAN, 40, tw_ref, ma_ref, mb_ref) + e(1) = proj(1)*DEG/tw_ref - 1.0_wp + e(2) = proj(2)/ma_ref - 1.0_wp + e(3) = proj(3)/mb_ref - 1.0_wp + WRITE (*, '(A,3ES13.5,A,3ES10.2)') 'A2 aggregate, platform roll of the restrained End A: Twist1, Torq1N1, '// & + 'Torq1N41 at Omega ', proj(1)*DEG, proj(2:3), ' errors against the continuum ', e + CALL require(ABS(e(1)) <= 1.0e-2_wp, 'A2: the free End B follows the platform roll') + CALL require(ABS(e(2)) <= 1.0e-2_wp, 'A2: the fairlead End A carries the continuum''s inertial torque') + CALL require(ABS(e(3)) <= 3.0e-2_wp, 'A2: the free End B''s element carries the continuum''s small torque') + END IF + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE check_aggregate + + SUBROUTINE ramp_derivs(t, tr, s, sd, sdd) + !! The quintic ramp of ramp() and its first two time derivatives. + REAL(wp), INTENT(IN) :: t, tr + REAL(wp), INTENT(OUT) :: s, sd, sdd + REAL(wp) :: x + x = MIN(MAX(t/tr, 0.0_wp), 1.0_wp) + s = x**3*(10.0_wp - 15.0_wp*x + 6.0_wp*x**2) + sd = 0.0_wp + sdd = 0.0_wp + IF (t < tr) THEN + sd = 30.0_wp*x**2*(1.0_wp - x)**2/tr + sdd = 60.0_wp*x*(1.0_wp - x)*(1.0_wp - 2.0_wp*x)/tr**2 + END IF + END SUBROUTINE ramp_derivs + + SUBROUTINE agg_channels(agg, torq_a, torq_b, twist) + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + REAL(wp), INTENT(OUT) :: torq_a, torq_b, twist + INTEGER :: es + CHARACTER(256) :: em + CALL CD_AGG_EvalChannel(agg, 1, torq_a, es, em) + CALL require(es == CD_AGG_OK, 'Torq1N1 evaluates: '//TRIM(em)) + CALL CD_AGG_EvalChannel(agg, 2, torq_b, es, em) + CALL require(es == CD_AGG_OK, 'Torq1N41 evaluates: '//TRIM(em)) + CALL CD_AGG_EvalChannel(agg, 3, twist, es, em) + CALL require(es == CD_AGG_OK, 'Twist1 evaluates: '//TRIM(em)) + END SUBROUTINE agg_channels + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_not_solved() + !! N: a 10-column LINE TYPES row (no GJ) with one restrained end: the twist channel is refused + !! with the reason, and without it the deck runs as before. + LOGICAL :: ok + CHARACTER(512) :: em + CALL write_deck('t1e_n.dat', 'cab 0.2 60.0 1.0e9 0.0 1.0e5 0.0 0.0 0.0 0.0', & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], [CHARACTER(16) :: 'FairTen1', 'Twist1'], & + ten_cols=.TRUE.) + CALL run_deck('t1e_n.dat', 't1e_n', ok, em) + CALL require(.NOT. ok .AND. INDEX(em, 'restrained at one end only and its torsion is not solved') > 0 .AND. & + INDEX(em, 'give no GJ') > 0, 'N: the twist channel of a line not solved in torsion is refused '// & + 'with the reason (got: '//TRIM(em)//')') + CALL write_deck('t1e_n.dat', 'cab 0.2 60.0 1.0e9 0.0 1.0e5 0.0 0.0 0.0 0.0', & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], [CHARACTER(16) :: 'FairTen1'], ten_cols=.TRUE.) + CALL run_deck('t1e_n.dat', 't1e_n', ok, em) + CALL require(ok, 'N: without the twist channel the deck runs: '//TRIM(em)) + ! a solved line's imposed twist, its restrained end's Pretwist, is held within 1000 turns + CALL write_deck('t1e_n2.dat', type_row('5.0e4', 1.0_wp), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Free 0 0 1 0', '1 B Rigid 1 0 0 Rigid 0 0 1 4.0e5'], L0_D, & + [CHARACTER(16) :: '0.1 dtM', '0.0 TMax'], [CHARACTER(16) :: 'Twist1']) + CALL run_deck('t1e_n2.dat', 't1e_n2', ok, em) + CALL require(.NOT. ok .AND. INDEX(em, 'the Pretwist of its restrained End B = 4.00000E+05 deg exceeds 1000 '// & + 'turns') > 0, 'N: a restrained Pretwist beyond 1000 turns is named (got: '// & + TRIM(em)//')') + END SUBROUTINE check_not_solved + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_attachments_statics() + !! T1: the static coupling twist of a vertical line free at one end carrying attachments. + INTEGER, PARAMETER :: NE_D = 40, NATT = 3, NODE(NATT) = [11, 21, 31] + REAL(wp), PARAMETER :: MASS(NATT) = [2000.0_wp, 100.0_wp, 800.0_wp], VOL(NATT) = [0.5_wp, 1.0_wp, 0.2_wp] + CHARACTER(16), PARAMETER :: OUTS(7) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'Torq1N1', 'Torq1N41', & + 'Twist1N21', 'Twist1', 'Twist1N41'] + CHARACTER(48) :: conns(2, 2), atts(NATT) + CHARACTER(24), PARAMETER :: LABEL(2) = [CHARACTER(24) :: 'End A free', 'End B free'] + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: w(NATT), l0, ea_eff, t_a, t_e, tw_ref, tw_mid, tw_mid0, e_tw, e_mid, e_t, e_m + INTEGER :: iv, k, e, nrow + LOGICAL :: ok + CHARACTER(512) :: em + l0 = L0_D/REAL(NE_D, wp) + w = (MASS - RHOW*VOL)*9.80665_wp + DO k = 1, NATT + WRITE (atts(k), '(A,F12.6,F10.2,F8.3,A)') '1 ', REAL(NODE(k) - 1, wp)*l0, MASS(k), VOL(k), ' 0.0 0.0' + END DO + ! the element tensions from End A down, their strains and the twists + ea_eff = EA_D - K_D**2/GJ_D + t_a = ea_eff*(SPAN - L0_D)/l0 + DO k = 1, NATT + t_a = t_a + w(k)*REAL(NE_D + 1 - NODE(k), wp) + END DO + t_a = t_a/REAL(NE_D, wp) + tw_ref = -(K_D/GJ_D)*(SPAN - L0_D)/DEG + tw_mid = 0.0_wp + DO e = 1, 20 + t_e = t_a - SUM(w, MASK=NODE <= e) + tw_mid = tw_mid - (K_D/GJ_D)*l0*t_e/ea_eff + END DO + tw_mid = tw_mid/DEG + tw_mid0 = 0.5_wp*tw_ref + conns(:, 1) = [CHARACTER(48) :: '1 A Rigid 0 0 -1 Free 1 0 0', '1 B Rigid 0 0 -1 Rigid 1 0 0 30'] + conns(:, 2) = [CHARACTER(48) :: '1 A Rigid 0 0 -1 Rigid 1 0 0 -30', '1 B Rigid 0 0 -1 Free 1 0 0'] + DO iv = 1, 2 + CALL write_deck('t1e_att.dat', type_row('5.0e4|4.0e5', 1.0e-9_wp), conns(:, iv), L0_D, & + [CHARACTER(16) :: '200.0 WtrDpth', '0.1 dtM', '0.0 TMax'], OUTS, atts=atts, & + end_b=[0.0_wp, 0.0_wp, -50.0_wp - SPAN]) + CALL run_deck('t1e_att.dat', 't1e_att', ok, em) + CALL require(ok, 'T1 ('//TRIM(LABEL(iv))//'): the deck with attachments runs with its twist channels: '//TRIM(em)) + IF (.NOT. ok) CYCLE + CALL read_out('t1e_att.out', 8, rows, nrow) + CALL require(nrow == 1, 'T1: one static row') + IF (nrow < 1) CYCLE + e_tw = MAX(ABS(rows(7, 1) - tw_ref), ABS(rows(8, 1) - tw_ref))/ABS(tw_ref) + e_mid = ABS(rows(6, 1) - tw_mid)/ABS(tw_mid) + e_t = MAX(ABS(rows(2, 1) - t_a), ABS(rows(3, 1) - (t_a - SUM(w))))/t_a + e_m = nan_max_abs(rows(4:5, 1)) + WRITE (*, '(A,A,A,F12.5,A,F12.5,A,F12.5,A,F12.5,A,F12.5,A,4ES10.2)') 'T1 ', TRIM(LABEL(iv)), ': Twist1 ', & + rows(7, 1), ' deg (expected ', tw_ref, '), Twist1N21 ', rows(6, 1), ' (expected ', tw_mid, & + '; uniform strain ', tw_mid0, '); errors twist, mid twist, tensions, |torque| ', e_tw, e_mid, e_t, e_m + CALL require(e_tw <= 1.0e-6_wp, 'T1 ('//TRIM(LABEL(iv))//'): the free end turns by -(K/GJ) dl with the modules') + CALL require(e_mid <= 1.0e-3_wp, 'T1 ('//TRIM(LABEL(iv))//'): the mid-line twist follows the module tensions') + CALL require(e_t <= 1.0e-6_wp, 'T1 ('//TRIM(LABEL(iv))//'): the end tensions carry the module weights') + CALL require(e_m <= 1.0e-6_wp, 'T1 ('//TRIM(LABEL(iv))//'): no static torque') + END DO + END SUBROUTINE check_attachments_statics + + SUBROUTINE check_attachments_inertia() + !! T2: the D roll of the restrained End A with three neutral modules (mass rhoW V, no drag), the + !! line taut (an attachment polish of the slack-free D line does not converge, with or without + !! torsion). + REAL(wp), PARAMETER :: IRN_D = 1.0_wp, AMP = 0.1_wp, LEN_T = 99.9_wp + INTEGER, PARAMETER :: NPP = 120, NPER_RAMP = 8, NPER_MEAS = 4 + REAL(wp), ALLOCATABLE :: rows(:, :) + REAL(wp) :: c, om, dt, t, kw, tw_ref, ma_ref, mb_ref, proj(3), e(3) + INTEGER :: u, k, nrow, k0, nstep + LOGICAL :: ok + CHARACTER(512) :: em + CHARACTER(64) :: opt(3) + c = SQRT(GJ_D/IRN_D) + om = 0.25_wp*0.5_wp*PI*c/SPAN + dt = 2.0_wp*PI/om/REAL(NPP, wp) + nstep = (NPER_RAMP + 1 + NPER_MEAS)*NPP + OPEN (NEWUNIT=u, FILE='t1e_att_roll.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az roll' + DO k = 0, nstep + t = dt*REAL(k, wp) + WRITE (u, '(ES24.16,A,ES24.16)') t, ' 1 0.0 0.0 -50.0 0 0 0 0 0 0 ', & + AMP*ramp(t, REAL(NPER_RAMP, wp)*2.0_wp*PI/om)*SIN(om*t)/DEG + END DO + CLOSE (u) + WRITE (opt(1), '(ES24.16,A)') dt, ' dtM' + WRITE (opt(2), '(ES24.16,A)') dt*REAL(nstep, wp), ' TMax' + opt(3) = 't1e_att_roll.txt motionFile' + CALL write_deck('t1e_att_roll.dat', type_row('5.0e4', IRN_D), & + [CHARACTER(48) :: '1 A Rigid 1 0 0 Rigid 0 0 1 0', '1 B Rigid 1 0 0 Free 0 0 1'], LEN_T, opt, & + [CHARACTER(16) :: 'Twist1', 'Torq1N1', 'Torq1N41'], & + atts=[CHARACTER(48) :: '1 25.0 512.5 0.5 0.0 0.0', '1 50.0 1025.0 1.0 0.0 0.0', & + '1 75.0 205.0 0.2 0.0 0.0']) + CALL run_deck('t1e_att_roll.dat', 't1e_att_roll', ok, em) + CALL require(ok, 'T2: the rolling march with neutral modules runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_out('t1e_att_roll.out', 4, rows, nrow) + CALL require(nrow == nstep + 1, 'T2: one row per step') + IF (nrow /= nstep + 1) RETURN + k0 = (NPER_RAMP + 1)*NPP + 1 + proj = 0.0_wp + DO k = k0 + 1, nrow + proj = proj + rows(2:4, k)*SIN(om*rows(1, k)) + END DO + proj = 2.0_wp*proj/REAL(NPER_MEAS*NPP, wp) + kw = om/c + CALL inertia_expect(AMP, kw, LEN_T, 40, tw_ref, ma_ref, mb_ref) + e(1) = proj(1)*DEG/tw_ref - 1.0_wp + e(2) = proj(2)/ma_ref - 1.0_wp + e(3) = proj(3)/mb_ref - 1.0_wp + WRITE (*, '(A,3ES13.5,A,3ES13.5,A,3ES10.2)') 'T2 roll with neutral modules (kL = pi/8): Twist1, Torq1N1, '// & + 'Torq1N41 at Omega ', proj(1)*DEG, proj(2:3), ' continuum ', tw_ref, ma_ref, mb_ref, ' errors ', e + CALL require(ABS(e(1)) <= 1.0e-2_wp, 'T2: the free End B follows the roll with the continuum''s twist') + CALL require(ABS(e(2)) <= 1.0e-2_wp, 'T2: the restrained End A carries the continuum''s inertial torque') + CALL require(ABS(e(3)) <= 3.0e-2_wp, 'T2: the free End B''s element carries the continuum''s small torque') + END SUBROUTINE check_attachments_inertia + + ELEMENTAL INTEGER(8) FUNCTION bits(x) + REAL(wp), INTENT(IN) :: x + bits = TRANSFER(x, 0_8) + END FUNCTION bits + +END PROGRAM test_torsion_one_end diff --git a/validation/scripts/openfast_lin_torsion.py b/validation/scripts/openfast_lin_torsion.py index 6efbe120..7b29f051 100644 --- a/validation/scripts/openfast_lin_torsion.py +++ b/validation/scripts/openfast_lin_torsion.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 """OpenFAST linearisation of finite-EI lines restrained in torsion (CompMooring = 5). -Two decks, each linearised once at t = 0 in the case of openfast_lin_ab.py (the IEA-15MW +Three decks, each linearised once at t = 0 in the case of openfast_lin_ab.py (the IEA-15MW UMaine model, platform DOFs only, still water, OutFmt ES24.15E3, module-level output), with the deck below as the only mooring: @@ -36,10 +36,19 @@ >= 1 % of it within twice that. The operating-point moment about d must equal the static Torq1N1. + 3. The straight line of 1 restrained in torsion at End A only, End B free to twist: the free + end's angle is a state; the torsional modes of A are the clamped-free ones, against the + continuum's quarter-wave (2n - 1) pi/(2L) sqrt(GJ/Irn) within x^2/6, x = (2n - 1) pi/(4N), + and the lumped chain's 2 sqrt(GJ/Irn)/h sin(x); the roll stiffness about the line axis + vanishes (the platform turns the line as a whole), against the feedthrough GJ/l_e. + Measured (the 0.4.0 module): the three torsional modes are the lumped chain's to 5e-14 and the continuum's within -1.6e-4, -6.6e-4, -1.5e-3; the straight line's roll stiffness is GJ/L to 1.5e-14 (feedthrough D alone 25 000 = GJ/l_e); the twisted lazy wave matches its static -solutions to 4.9e-4 (the moment about d per unit rotation 82.4268 / 82.4263 N m/rad, 5.9e-6). +solutions to 4.9e-4 (the moment about d per unit rotation 82.4268 / 82.4263 N m/rad, 5.9e-6); +the line free at End B has 100 twist states, its modes are the clamped-free chain's to 2.5e-13 +and lie 4.1e-5, 3.7e-4, 1.0e-3 below the quarter-wave, and its roll stiffness is 0 against the +feedthrough 25 000. An executable without twist states refuses both decks at initialisation ("formal OpenFAST linearization of a line restrained in torsion is not supported"); with the twist angles held the straight line's roll stiffness would be the end element's GJ/l_e, 50 times GJ/L. @@ -70,7 +79,7 @@ IRN_STRAIGHT = 2.0 -def straight_deck() -> str: +def straight_deck(tors_b: str = "Rigid") -> str: mass = RHOW * 0.25 * np.pi * 0.2**2 return "\n".join([ "--------------------- CableDyn Input File ------------------------------------", @@ -96,7 +105,7 @@ def straight_deck() -> str: "LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist", "(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)", "1 A Pinned 0 0 -1 Rigid 1 0 0 0", - "1 B Pinned 0 0 -1 Rigid 1 0 0 0", + f"1 B Pinned 0 0 -1 {tors_b} 1 0 0 0", "--------------------- OPTIONS -----------------------------------------------", "0.025 dtM - CableDyn time step (s)", "--------------------- OUTPUTS -----------------------------------------------", @@ -286,6 +295,43 @@ def gate_straight(args: argparse.Namespace, case: Path) -> list[str]: return fails +def gate_straight_free(args: argparse.Namespace, case: Path) -> list[str]: + mod = lin_case(args, case, "tors_straight_free", straight_deck("Free")) + fails = [] + labels = [ab_label(s) for s in state_labels(case / "Main_lin_tors_straight_free.1.CD.lin", mod["n_x"])] + tw = np.array(["twist" in s for s in labels]) + print(f"straight line free at End B: {mod['n_x']} states, {int(tw.sum())} twist") + if int(tw.sum()) != 2 * N_STRAIGHT: + fails.append("the free end's angle is not a state") + ev, vec = np.linalg.eig(mod["A"]) + share = np.sum(np.abs(vec[tw, :])**2, axis=0) / np.sum(np.abs(vec)**2, axis=0) + pick = (ev.imag > 1e-9) & (share > 0.999) + w = np.sort(np.abs(ev[pick])) + h = L_STRAIGHT / N_STRAIGHT + c = np.sqrt(GJ / IRN_STRAIGHT) + worst_c = worst_d = 0.0 + if len(w) < 3: + ab.die(f"found {len(w)} torsional modes of the line free at End B, expected at least 3") + for n in (1, 2, 3): + x = (2 * n - 1) * np.pi / (4 * N_STRAIGHT) + wc = (2 * n - 1) * np.pi / (2 * L_STRAIGHT) * c + wd = 2.0 / h * c * np.sin(x) + ec, ed = w[n - 1] / wc - 1.0, w[n - 1] / wd - 1.0 + bound = 1.2 * x**2 / 6.0 + 1e-6 + print(f" torsional mode {n}: {w[n - 1] / (2 * np.pi):.8f} Hz; quarter-wave {wc / (2 * np.pi):.8f} " + f"({ec:+.3e}, bound {bound:.2e}); clamped-free chain {wd / (2 * np.pi):.8f} ({ed:+.3e})") + worst_c = max(worst_c, abs(ec) / bound) + worst_d = max(worst_d, abs(ed)) + if worst_c > 1.0 or worst_d > 1e-6: + fails.append("the torsional modes of A differ from the clamped-free ones") + K, Dft = reduced_6x6(mod) + print(f" roll stiffness about the line axis -(D - C A^-1 B) = {K[5, 5]:.3e} N m/rad (GJ/L = " + f"{GJ / L_STRAIGHT:.3e}); feedthrough -D = {Dft[5, 5]:.6e} (GJ/l_e = {GJ / h:.6e})") + if abs(K[5, 5]) > 1e-6 * GJ / L_STRAIGHT: + fails.append("the line free at End B has a roll stiffness") + return fails + + def state_labels(path: Path, n_x: int) -> list[str]: text = path.read_text().splitlines() out: list[str] = [] @@ -404,7 +450,7 @@ def main() -> None: if not args.driver.is_file(): ab.die(f"driver not found: {args.driver}") case = args.case_dir - fails = gate_straight(args, case) + gate_lazy_wave(args, case) + fails = gate_straight(args, case) + gate_straight_free(args, case) + gate_lazy_wave(args, case) if fails: ab.die("; ".join(fails)) print("PASS") From 357f9eb9c24ce8d6facf6c3fda275be9ebe584b8 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 14:04:19 +0900 Subject: [PATCH 26/51] feat(cable): finite-EI lines with two moving ends, between two floaters or two objects, TURBINES rows turning both end frames (#75) A finite-EI (cubic-Hermite) line may now have two moving ends: End B on a Coupled/Vessel point (a cable shared by two floaters, a FAST.Farm shared line), standalone, in OpenFAST, FAST.Farm and the C API, and End B on a Rigid6 body point or a rod end on the standalone multibody march (a cable between two objects). Both ends are driven, carry END CONNECTIONS and torsion, and return their loads to their hosts or objects. Base: dev e992e9f (#74); the series is rebased onto it from 6195432 (#71), past #72, #73 and #74. - HFMF boundary: a second driven end at internal node 1 (moving_b), with its own parent frame, end connection and torsion frame (the frames of both ends turn with their parents), its mirror block in the restart state, and a held End B (at rest, target equal to the committed position in either frame) that steps exactly as a Fixed End B. - Standalone: motionFile, vesselMotion/vesselRAO, TURBINES rows and the roll column drive End B as End A; Phi = Pretwist(B) - Pretwist(A) - roll(A) - roll(B), the roll of an end free in torsion twisting nothing. TURBINES decks start each end's Ez/Nx in its turbine's PtfmInit axes and turn both frames with the rows' rotations, as FAST.Farm does. - Aggregate, OpenFAST, FAST.Farm, C API: End B on a moving column of its own (cable_col_b), the turbine map, host orientations at both ends, CableDyn_GetCoupledLayout with the End B blocks; OpenFAST linearisation of such a cable fails closed (the linearisation of torsion from #73 stays for every other line). On the standalone mixed deck the roll columns of both ends twist the line. - Multibody march: End B's attachment, frames and loads (cab_*_b); the monolithic step re-steps a cable between two objects at every outer iteration and couples both objects' junction coordinates through its finite-difference end-to-end stiffness in the one Newton matrix; the static passes balance both objects on the cubic-Hermite end loads, accelerated by Anderson mixing (a stiff EI 1e6 clamped cable between two unequal moored bodies, out of their plane: 8 passes either direction, where the plain passes diverged); the staggered scheme takes pinned ends. 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, so the result does not depend on the line's direction. A partitioned coupling was measured and not taken: on a stiff taut cable (EA 1e8 N) between 200 kg bodies at dtM 0.05 s it needed 9.2 mean outer iterations and 300 step halvings over 100 steps, the joint form 3.9 and none. An End B on a Free/Connect point, a Point3 buoy or a Coupled/Vessel point stays refused there by name. - Validation (native and the Python mirror): END CONNECTIONS and torsion admit those End B points; staticsFriction asLaid is refused on a moving End B. Where it meets the torsion routes of #73/#74 (one restrained end, torsion on Fixed and `Body` rod ends, prescribed motion on the mixed deck): - check_torsion_line is the union of both scopes. Two cases neither solves are refused by name, natively and in deck_file.py: torsion at an End B on a rod end, and a rod End A restrained in torsion with a moving End B. A bending END CONNECTION takes any End B that holds a frame (ROD_END_B_NOTE is gone). - The restrained end decides, not any torsion on the line (line_torsion_at_a/line_torsion_at_b): connected_end, cab_clamp_b, the End B staggered refusal, the static pass tolerance and pinned-end skip, the roll columns, and the torsion turn limit of both bodies (an end free in torsion is not limited). clamp_object_frame takes the Fixed-rod normal of the end it frames; `Rod` connection moments include End B. - Mixed deck: build_aggregate_motion now follows the two-ends moving-set order (End A columns, then End B columns) and cable_two_ends imposes Phi_0 - roll(A) - roll(B). Before, a deck whose End B point came first was refused and otherwise the roll did not twist the line (gate 8 below). - test_cable_between_bodies D: a Fixed-to-rod-end line and its reversal now write one output, since #74 turns a Fixed-to-rod line around as dev turns a Fixed-to-body line. Result changes: - The finite-EI compatibility (Cosserat) deck route is retired. Only three test decks reached it, all refusals or a run-only smoke; on four shared-line decks it failed to converge (three) or reached a static FairTen of -6.1e8 N (one), and the Hermite route runs all four. Decks with a line between two moving points now run on the Hermite route. - A torsion frame at a bending-pinned body or rod End A is refused on bodyScheme staggered (it ran with the frame held still and could spin the body through +-180 deg); the monolithic scheme turns it with the body. - Standalone TURBINES decks: an end on a `Turbine` point takes Ez and Nx in the turbine's axes (turned by PtfmInit) and its frames turn with the TURBINES rows. Decks whose turbines start rotated or whose rows rotate, with end connections or torsion, change: on a clamped line twisted 90 deg between turbines rolling 10 deg in opposite senses the end torque at 1 s is 613.6 N m (788.1 N m before), tensions within 5e-7. No example uses TURBINES rows. Gates: - tests/test_two_moving_ends: a held Coupled End B writes the Fixed End B's files byte for byte (also at a 37 deg chord heading and in the modes); a symmetric cable whose ends move apart stays mirror-symmetric (4e-11 m); a rigid translation keeps the end loads (4e-5 N of 1.6e4 N); End B driven equals the reversed line driven at End A (1e-3 N; turning clamped End B 2e-5 N, 4e-7 N m); equal rolls keep the torque (3e-6 N m), opposite rolls change it by GJ (2 phi)/L (5e-6 N m); restarts bit-identical; FAST.Farm aggregate vs standalone: shared line 7e-3 N of 1.9e4 N, yawed turbines with torsion 7.6e-9, rolling turbines 3.4e-8 in every channel. - tests/test_cable_between_bodies: two mirrored bodies stay mirror images (monolithic clamped and staggered pinned, to the output precision); a body joined to a 1e15 kg body equals the body-to-Fixed line of the established route to 8e-9 (clamped, and twisted 90 deg); two free bodies with no external load keep the total linear momentum to 3e-5 and the energy to 0.2 %; a 90 deg twist returns equal and opposite torques GJ Phi/L (sum below 2e-10 N m); a moored pair starts balanced and stays at rest, its connection moments turning it from the pinned pitch; the stiff unequal pair converges forward and reversed to one equilibrium the still dynamics hold, and with its passes limited fails closed naming the line; either direction of a Fixed-point-to-rod-end cable gives the same output, and an End B on a fixed rod's end is the Fixed End B; a body-to-rod-end cable runs; refusals name their cause (the staggered torsion End A included). - tests/test_mixed_route_torsion gate 8: a line twisted 90 deg between two Coupled points beside a chain, both ends rolled by the roll column: rolled oppositely the twist stays 90 deg exactly (torque GJ Phi/L to 3.4e-6 N m); rolled equally 15 deg it is 90 - 2 roll to 5.0e-7 deg (4.7e-6 N m; the old code 30 deg and 262 N m); End B's point listed first gives the same figures (the old code refused the deck). - tests/test_rod_end_torsion, python/tests/test_deck_native_parity: the End B rod-end refusal and the shared staggered message. - Python validator: mirrors the march's End B refusals, the staggered refusal of a connected or torsional end at either end, and the two new torsion refusals. - C API and Python: host rotations at both end frames, the coupled layout driven through the documented host recipe, the asLaid mirror. Commits: the two-moving-ends commits rebased one by one, the three multibody commits (a finite-EI line between two objects, its review fixes, the Python mirror) as one with the torsion-route integration, then the Intel ifx #5151 continuation fix and the mixed-deck roll fix with gate 8. Two fixes from the checked Debug CI job: - `end_b_at_rest` no longer indexes `pdof_b` when End B is not driven (Fortran does not short-circuit `moving_b .AND. .NOT. end_b_at_rest(...)`; Release read a stray value it then discarded, Debug stopped on it). - A rod numbered as a body is no longer one of the body's attachment points (also in 0.3.0): 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 both. New gate `body_rod_numbering`: the same deck with the arm rod numbered 1 and 3 now writes identical outputs; before, 200 of 203 rows differed (arm pitch 172 deg, body pitch 1.06 deg, a leg tension 3.0 kN in 1 s). The 25 tests the Debug job failed and the new gate pass on a local checked Debug build. Full ctest (341/341) and pytest (python/tests and tests with the native driver: 2179 passed, 75 skipped) pass; ruff check/format and mypy clean (the three numpy-stub notes dev already has aside), pre-commit clean, docs build with warnings as errors, no symbol both in a PUBLIC list and declared PUBLIC. A/B against the reference driver: 53 of 53 examples byte-identical. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 66 +- CMakeLists.txt | 33 +- doc/api_reference.md | 6 +- doc/capabilities.rst | 16 +- doc/capi.rst | 9 +- doc/driver_format.md | 145 +- doc/file_formats.rst | 11 +- doc/openfast.rst | 17 +- doc/options.rst | 14 +- doc/outputs.rst | 37 +- doc/solver_paths.rst | 6 +- doc/standalone_driver.rst | 8 +- doc/theory.rst | 3 +- doc/troubleshooting.rst | 73 +- python/cabledyn/deck_file.py | 248 +- python/cabledyn/model.py | 6 +- python/tests/test_deck_file.py | 84 +- python/tests/test_deck_native_parity.py | 93 +- python/tests/test_host_rotation.py | 37 +- python/tests/test_two_moving_ends_capi.py | 104 + src/CableDyn_CAPI.f90 | 12 +- src/CableDyn_DeckDriver.f90 | 3118 +++++++++------------ src/CableDyn_HermiteCableDynamic.f90 | 26 +- src/CableDyn_OpenFAST_Aggregate.f90 | 180 +- src/CableDyn_OpenFAST_HermiteFMF.f90 | 612 +++- src/openfast/CableDyn_OF.f90 | 8 + tests/test_anchor_uplift.py | 20 +- tests/test_body_rod_numbering.py | 131 + tests/test_cable_between_bodies.f90 | 876 ++++++ tests/test_deck_driver.f90 | 6 +- tests/test_mixed_route_torsion.f90 | 76 + tests/test_rod_end_torsion.f90 | 7 +- tests/test_static_friction_as_laid.py | 8 +- tests/test_two_moving_ends.f90 | 1513 ++++++++++ 34 files changed, 5523 insertions(+), 2086 deletions(-) create mode 100644 python/tests/test_two_moving_ends_capi.py create mode 100644 tests/test_body_rod_numbering.py create mode 100644 tests/test_cable_between_bodies.f90 create mode 100644 tests/test_two_moving_ends.f90 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 From 1a8a6068eb767a3950e34bbcc2ca8741eb342995 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 15:21:47 +0900 Subject: [PATCH 27/51] ci(wheels): build the macOS wheel on the macOS 15 runner (#76) GitHub retires the `macos-14` runner image on 2 November 2026, and its scheduled brownouts already cancel the `wheels / macos` job (#73, #74, #75: "Cancelled after 1s", annotated as a macOS 14 brownout, actions/runner-images#13518). - `.github/workflows/wheels.yml`: the macOS wheel builds on `macos-15` with `MACOSX_DEPLOYMENT_TARGET=15.0`, the oldest macOS its Homebrew gfortran and OpenBLAS bottles support there, so delocate accepts the bundled libraries. The wheel tag becomes `macosx_15_0_arm64` (0.3.0: `macosx_14_0_arm64`). - The installation page, the README and the CHANGELOG (`Changed`) say the macOS wheel needs macOS 15 or newer on Apple silicon; on macOS 14, build from source. No code change. Docs build with warnings as errors locally; the `wheels / macos` job of this PR is the build and smoke test of the new wheel. Signed-off-by: Jae Hoon Seo --- .github/workflows/wheels.yml | 4 ++-- CHANGELOG.md | 3 +++ README.md | 2 +- doc/installation.rst | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index b0eb5a50..91588793 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -96,7 +96,7 @@ jobs: if-no-files-found: error macos: - runs-on: macos-14 + runs-on: macos-15 steps: - name: Check out CableDyn uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -112,7 +112,7 @@ jobs: # deployment target is the runner's macOS, the oldest the Homebrew libraries support. CIBW_BEFORE_ALL_MACOS: brew install gcc openblas CIBW_ENVIRONMENT_MACOS: >- - MACOSX_DEPLOYMENT_TARGET=14.0 + MACOSX_DEPLOYMENT_TARGET=15.0 FC=gfortran CMAKE_PREFIX_PATH=$(brew --prefix openblas) CIBW_TEST_COMMAND: >- diff --git a/CHANGELOG.md b/CHANGELOG.md index 03ce9a44..60775dd9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -280,6 +280,9 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Changed +- The macOS wheel needs macOS 15 or newer on Apple silicon (0.3.0: macOS 14). It is built on + the macOS 15 runner, as GitHub retires the macOS 14 runner image on 2 November 2026, and its + Homebrew gfortran and OpenBLAS support no older macOS. On macOS 14, build from source. - With a `motionFile` or `vesselMotion`, the single-line finite-EI route writes `.static.out` before it installs the first motion row, so the file holds the static solve; before, it showed the fairlead already moved to row 1. A deck whose row 1 is off the deck fairlead changes diff --git a/README.md b/README.md index cafb45b1..caa9e719 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ a named error rather than running approximately. 4. Optionally, script runs from Python. The package on PyPI carries the solver library and the driver (wheels for Windows x64 and Linux x86-64 with an AVX2 - processor, and macOS on Apple silicon), so nothing else is needed. A relative + processor, and macOS 15 or newer on Apple silicon), so nothing else is needed. A relative output root is resolved against the deck's folder, so this run writes `examples\wd0050.out`: diff --git a/doc/installation.rst b/doc/installation.rst index 77c5f1cc..bad8fb6c 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -171,7 +171,7 @@ Install it from PyPI (Python 3.10 or newer; NumPy is the only required dependenc This installs the ``cabledyn`` package and four console commands: ``cabledyn-run``, ``cabledyn-deck``, ``cabledyn-study``, and ``cabledyn-post``. The wheels for Windows x64 and -Linux x86-64 (both for processors with AVX2) and for macOS on Apple silicon carry the solver: +Linux x86-64 (both for processors with AVX2) and for macOS 15 or newer on Apple silicon carry the solver: the CableDyn shared library and the standalone driver, so the package runs decks without the release executables. On another platform pip builds from the source distribution, which needs a Fortran compiler and LAPACK. From e760bc6043ec789802019505b99ab8b97aaafd11 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Sat, 31 Oct 2026 18:27:42 +0900 Subject: [PATCH 28/51] fix(statics): the static start above the surface, in sheared currents, on lines as long as their span and on bodies with pinned cables (#77) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## What changed Six accuracy items from the open list, rebased onto dev (#73 torsion linearisation, control and modal analysis, #74 torsion on the mixed deck, at one end and on a rod end, #75 lines with two moving ends, #76), one commit that closes where they meet dev's newer routes, and four fixes from an independent review. - **Dry weight of an `EI = 0` line above the surface.** With a seabed the march gives the part of a line above the still-water level its dry weight; the static start kept its buoyancy. `CD_Static_Line_Equilibrium` now carries the dry part as a fixed point on the wetted lengths. A chain hung from 5 m above the surface starts in the march's equilibrium (holds to 1e-10; before 1e-3 of its fairlead load in the first step), and the coupled and standalone starts agree to 1.4e-8 (before 2.4e-4). - **The same dry weight in the force balance of `Connect`/`Free` points, bodies and rods** (`solve_body_equilibrium_core`, its warm and cold line solves, the new `CD_Static_Line_Dry_Load`). A 50 t `Connect` point hung by two chains from 10 m above the surface holds its position over 2 s (before it sank 1.1e-2 m). An `EI = 0` chain between two moving objects across the surface, a body point 5 m above it and a `Connect` clump, holds both (before 5.5e-3 m). In that balance a finite-EI line, carried without its bending stiffness, now takes its dry weight with or without a seabed, as its cubic-Hermite cable does: a body with a light pinned cable 5 m above the surface on a deck without a seabed holds its heave to 7e-6 m (before 2.8e-3 m). - **`ATTACHMENTS` above the surface.** The march loads an attachment above the free surface with its weight alone, while the attachment polish and the torsion stage after it kept its buoyancy. Each solve now takes every attachment's load for the side of the surface its node is on, and the final solve is repeated until no attachment changes side. A 500 kg, 0.2 m³ module 3 m above the surface held the fairlead load over 1 s to the output's 8 digits, restrained in torsion as well (before it moved by up to 6.1e-2). An attachment carried above and below the surface on alternate solves (a net-buoyant module that would float, which a point attachment cannot represent) fails closed, and the message leads with that attachment's index, Mass and Volume. - **A pinned cable with `ATTACHMENTS` in the body static balance.** The object solve left a bending-pinned End A free in torsion to its cable without bending stiffness, which carries no attachments. Such a line now takes the static passes of a connected end. On a moored body with a 2 t clump on a pinned cable the body holds its pose (before it drifted by up to 2.9e-2 m and 0.20 deg in 5 s). - **Current gradient in the finite-EI static tangent.** A depth profile is sampled at the node elevations and a current grid at the node positions, so the drag moves with the nodes. The Newton tangent now carries that: the drag tangent matches central differences to 4e-10 to 1.7e-9 (before 5e-2 to 0.2), also at the twisted equilibrium of a line restrained in torsion with `GJ|K` (4.3e-10, before 5.4e-2). The equilibria do not change beyond the solver tolerance; Newton converges faster in strong shear (16 instead of 23 iterations). - **Force-scale floor for a finite-EI line as long as its span.** The static start of a neutral line whose length equals its span failed with neutral or drag-area `ATTACHMENTS`: the polish stalled at the round-off of the axial forces. For a line whose chord is at least its length, the convergence scale now includes that floor over the tolerance, as on the `EI = 0` path. Such lines now start straight and unloaded, also between two moving ends, restrained in torsion at both ends or at End A only, and with a chord 1e-8 longer than the line (0.1 N to 2.2e-7 N). All of these failed on dev. - Docs: the linearisation at an accelerating coupled point (`doc/openfast.rst`, `VALIDATION.md`), and the carry spin of a held end section, measured and left out (`doc/theory.rst`; the modal analysis and the OpenFAST linearisation of #73 leave it out as well). ## Review fixes - **The attachment with no static side is named** (`attachment_static_polish`, `torsion_after_attachments`): a 200 kg, 2 m³ module 50 m along a slack cable stopped with only "the homotopy stopped at load fraction 0.625000"; every later failure now leads with the attachment that crossed the surface (`static_dry_weight` 9). On dev the same deck ran with the module 4.5 m above the surface and its buoyancy kept. - **A pinned cable with `ATTACHMENTS` on a `Point3` buoy** is refused by the existing `Point3` message instead of an END CONNECTIONS message for a deck without that row (`line_attachments` 10). - **The body passes of a pinned cable with `ATTACHMENTS` are Anderson-mixed**, as the passes of a line between two objects are: on a spar rod with a 1500 kg clump on a pinned cable the plain passes diverged (end-load change 2.9 of the force scale after 60) and the deck stopped; they now converge in 26 and the rod holds to 8 digits over 3 s (`line_attachments` 11). - **Every bending-pinned finite-EI line on a Rigid6 body or a rod end takes the (mixed) passes**, with or without attachments: the stand-in without bending stiffness put a spar rod's start 5.7e-2 m off equilibrium (7e-2 m drift and a 2.3 % leg tension change in 3 s); it now holds to 8 digits after 4 passes (`line_attachments` 12; before 1.8e-4 m in 0.1 s). This changes the static start of user decks with a pinned finite-EI cable on a free body or rod by the bending share of the end force; no example deck has one. - **Body passes that do not hinge on round-off** (after the Linux Release job failed `line_attachments` 11 with no convergence in 60 passes, where Windows took 26): the core solve's stand-in cable now carries the line's `ATTACHMENTS` smeared as net weight, as the Hermite statics smear them, so the passes correct only the lumped, surface-side, drag and bending differences (the whole 15 kN clump load before); a failed pass set is repeated once on the stand-in without attachments; and the Anderson column-drop bound is 1e-6 instead of 1e-10 (a pinned end's residual spans fewer directions than the history, so later columns were round-off with coefficients near 1e12). Gate 11 converges in 6 passes, geometrically. New gate 13: the same deck with a leg anchor moved 1 ulp either way gives the same rod pose to 1e-9 m in 6 passes each (before 26, no convergence after 60, 26). Across a 45-deck sweep of rod and body decks (clump mass, cable length, rod mass, start offsets, 1-ulp and 1e-14 m moves) 42 converge, 34 before; the two-object decks are unchanged. Gates 11 and 12 march at `dtM` 0.002 s, because the explicit coupling of a cable to a free rod on this branch is unstable at 0.01 s (fixed separately in the next PR). - Known and left: the as-laid friction reference still takes an attachment's net in-water weight, which matters only where the seabed rises above `z = 0`. ## Rebase notes - Conflicts were only in `CHANGELOG.md` (entries kept side by side), `doc/openfast.rst` (the torsion linearisation paragraph of #73 kept, and the zero-frequency paragraph replaced by this branch's operating-point version) and `doc/theory.rst` (the carry-spin paragraph placed before #74's free-end section). The source files merged cleanly. `cached_line_solve`, `prepare_line` and `warm_line_solve` sit on #75's two-ends object solve unchanged: the line cache already treats both ends alike. - The carry-spin commit message no longer says the modal analysis refuses torsion. ## Gates - `static_dry_weight` 1-8: gates 1-5 as before. Gate 6: a module above the surface, plain and restrained in torsion (0; before 6.1e-2), and a submerged module as guard. Gate 7: a pinned cable above the surface on a body without a seabed (7e-6 m; before 2.8e-3 m). Gate 8: an `EI = 0` chain between a body above the surface and a `Connect` point (0; before 5.5e-3 m). - `line_attachments` 8 (continued) and 9: two moving ends, torsion at one or both ends, and a chord above the length, each of which failed on dev; the pinned cable with a clump on a moored body (1e-9 m; before 2.9e-2 m). - `hermite_static_current_gradient` 1-5, `nodal_twist_dynamic` (carry spin). ## Checks - Full ctest (Release): 344 of 344 pass (also after the review fixes; base now dev 1a8a606, #76 touched only CI and docs). On the checked Debug build (`-fcheck=all`) the added and touched tests and their neighbours pass, 12 of 12: `static_dry_weight`, `line_attachments`, `hermite_static_current_gradient`, `nodal_twist_dynamic`, `hermite_cable_static`, `hermite_torsion_static`, `torsion_attachments`, `torsion_one_end`, `rod_end_torsion`, `clamped_cable_ends`, `cable_between_bodies`, `bodies_rods`. - pytest `python/tests` and `tests`, with the native parity tests on (`CABLEDYN_TEST_DRIVER`): 2179 passed, 75 skipped. - ruff check and format are clean. Strict mypy shows only dev's 3 numpy-stub notes. pre-commit and Sphinx `-W` are clean, and no symbol is both in a `PUBLIC` list and declared `PUBLIC`. - Example A/B against dev 357f9eb: 53 of 53 identical. No example has a line or attachment above the water, a finite-EI line in a profile or grid current, a line as long as its span, or a pinned cable with `ATTACHMENTS` on a body. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 70 +- CMakeLists.txt | 11 + VALIDATION.md | 17 + doc/driver_format.md | 18 +- doc/openfast.rst | 16 +- doc/theory.rst | 89 ++- doc/troubleshooting.rst | 7 + src/CableDyn_DeckDriver.f90 | 610 ++++++++++++---- src/CableDyn_HermiteCableStatic.f90 | 56 +- src/CableDyn_Model.f90 | 40 +- src/CableDyn_Static.f90 | 169 ++++- .../test_hermite_static_current_gradient.f90 | 233 +++++++ tests/test_line_attachments.f90 | 589 +++++++++++++++- tests/test_nodal_twist_dynamic.f90 | 88 +++ tests/test_static_dry_weight.f90 | 656 ++++++++++++++++++ 15 files changed, 2487 insertions(+), 182 deletions(-) create mode 100644 tests/test_hermite_static_current_gradient.f90 create mode 100644 tests/test_static_dry_weight.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 60775dd9..83ac53d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,8 +123,12 @@ All notable changes to CableDyn are recorded in this file. The format follows velocities, with `A`, `B`, `C` and `D` by central differences of the accelerations solved at the perturbed state. On the UMaine chains the stiffness `D - C A^-1 B` matches MoorDyn-F's to 0.1 % and the lowest nine line-mode frequencies to 0.3 %; with a lazy-wave power cable every coupled - point matches the deck's own static solutions to 3e-4, also with a hang-off spring. A cable - end connection with a numeric stiffness now linearises. The viscoelastic slow-branch stretch + point matches the deck's own static solutions to 3e-4, also with a hang-off spring. The + reduction is the static stiffness at an operating point whose coupled points do not + accelerate: the coupled load includes the line's inertia, so at the accelerating `t = 0` + platform the lazy wave's force per unit rotation reads 1.2 % off, and 2.7e-4 with the platform + DOFs disabled (`doc/openfast.rst`). A cable end connection with a numeric stiffness now + linearises. The viscoelastic slow-branch stretch and the Syrope slow strain are first-order states, so the reduction gives these ropes' relaxed static stiffness (each matches its deck's static solutions to 7e-5; held, they would read the chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end @@ -357,6 +361,68 @@ All notable changes to CableDyn are recorded in this file. The format follows 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. +- The static start of a neutral finite-EI line whose length equals its span (straight at zero + strain, so with neither weight nor tension) failed with neutral `ATTACHMENTS` or with + attachments that only carry a drag area: the attachment polish stalled at the round-off of the + axial forces, 7.6e-8 N, against a tolerance of 1e-8 times the solver's 1 N force floor, at + every load step. For a line whose chord is at least its length the force scale of the + convergence test now includes that round-off floor over the tolerance + (`16 eps max(EA/L0) |x| / tol`, as on the `EI = 0` path), so these lines start straight and + unloaded, also between two moving ends, restrained in torsion at one or both ends, and with a + chord 1e-8 longer than the line (its 0.1 N tension to 2.2e-7 N); slack lines and lines that + carry weight or tension above the floor are unchanged. +- The Newton tangent of the finite-EI static solve in a depth-profile current or a current grid + carries the current's gradient: the drag samples the current at the node positions, so it moves + with them. The drag part of the tangent now matches central differences of the residual to + 8e-10 (before off by 5e-2 to 0.2 in sheared profiles). Newton takes up to a third fewer + iterations on a light cable in a strong shear (16 instead of 23); the equilibria are unchanged + within the solver tolerance. +- The static start of an `EI = 0` line held above the still-water level kept the buoyancy of its + dry part, while the march (with `WtrDpth` or a bathymetry) gives that part its dry weight. The + start was not the march's equilibrium: a chain hung from 5 m above the surface onto the + seabed moved by 1e-3 of its fairlead load in the first step, and the coupled start differed + from the standalone one by 2.4e-4. The static solve now carries the dry weight (a fixed point + on the wetted lengths): the start holds to 1e-10, the two routes agree to 1.4e-8, and a + vertical chain's end loads sum to its weight to 1.5e-8 (before 1.4 % low). The force balance + of `Connect` and `Free` points and free bodies and rods takes the same dry weight: a 50 t + `Connect` point hung by two chains from 10 m above the surface holds its position to the + output's 8 digits over 2 s (before it sank 1.1e-2 m). There a finite-EI line, carried without + its bending stiffness, takes its dry weight with or without a seabed, as its cubic-Hermite + cable does: a stiff body with a light cable pinned 5 m above the surface on a deck without a + seabed holds its heave to 7e-6 m over 3 s (before it moved 2.8e-3 m), and an `EI = 0` chain + between that body 5 m above the surface and a `Connect` clump holds both to the output's 8 + digits (before 5.5e-3 m). Lines below the surface are unchanged. +- `ATTACHMENTS` above the still-water level kept their buoyancy in the static start of a + finite-EI line, while the march loads them with their weight alone. A 500 kg, 0.2 m^3 module + 3 m above the surface on a cable hung from 5 m above it moved the fairlead load by up to + 6.1 % in the first second, and as much on the same cable restrained in torsion. The + attachment polish and the torsion stage after it now give each attachment the load of its side + of the surface (a fixed point that repeats the solve until none changes side); both starts + hold to the output's 8 digits. An attachment that its weight in air takes below the surface + and its weight in water above it (a net-buoyant module that would float) has no static + position and fails closed, naming the attachment that crossed the surface. +- A bending-pinned finite-EI line with `ATTACHMENTS` from a Rigid6 body or a rod end left its + attachments out of the body static balance, which carries such a line as a cable without + bending stiffness: on a moored body with a 2 t clump 50 m along a pinned cable the body started + at the pose of the line without the clump and drifted by up to 2.9e-2 m and 0.20 deg in 5 s. + Such a line now takes the static passes of a connected end, which balance the body on the + cubic-Hermite cable's end loads; the body holds its pose to the output's 8 digits. Their + passes are Anderson-mixed, as those of a line between two objects, and the core cable of the + passes carries the line's `ATTACHMENTS` smeared, so the passes correct only the lumped, + side-of-the-surface and bending differences: on a free spar rod with a 1500 kg clump on a cable + pinned at its upper end the plain passes on a core cable without the clump diverged (the deck + stopped), and Anderson-mixed ones converged in 26 passes or stopped by round-off (a 1-ulp + change of an anchor coordinate; the Linux build stopped). They now converge in 6, the same + for those 1-ulp changes, and the rod holds its pose to 8 digits. The mixing drops history + columns that add less than 1e-6 of a new direction (1e-10 before), which had let round-off + columns drive the mixed loads to 1e6 N. Across a sweep of the rod deck (clump 0 to 4 t, cable + 50 to 70 m, rod mass, clump position, start offsets, 1-ulp changes) 42 of 45 decks converge + (34 before), the three left with no stable equilibrium found on either core cable. +- A bending-pinned finite-EI line on a Rigid6 body or a rod end without `ATTACHMENTS` was left to + the body static solve's cable without bending stiffness, whose end force lacks the bending's + share: a free spar rod with a 55 m pinned cable (EI 2e4 N m^2) started 5.7e-2 m off its + equilibrium, drifted 7e-2 m in 3 s and moved a leg tension by 2.3 %. Such a line now takes the + static passes too (4 here); the rod holds its pose to the output's 8 digits. - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index d414303a..87526527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -663,6 +663,13 @@ target_link_libraries(test_hermite_cable_static PRIVATE cabledyn_core) add_test(NAME hermite_cable_static COMMAND test_hermite_cable_static) set_tests_properties(hermite_cable_static PROPERTIES LABELS "fortran;unit;static") +# Finite-EI static tangent of a depth-profile current: the profile's vertical gradient in the drag +# tangent, against central differences of the residual +add_executable(test_hermite_static_current_gradient tests/test_hermite_static_current_gradient.f90) +target_link_libraries(test_hermite_static_current_gradient PRIVATE cabledyn_core) +add_test(NAME hermite_static_current_gradient COMMAND test_hermite_static_current_gradient) +set_tests_properties(hermite_static_current_gradient PROPERTIES LABELS "fortran;unit;static;hermite") + # Finite-EI mesh-resolution diagnosis: h*kappa peak / curvature-jump / contact-island metrics # and the power-of-two refinement recommendation -- the preflight trigger for the adaptive mesh # policy. Synthetic controlled profiles + fail-closed validation. @@ -1201,6 +1208,10 @@ target_link_libraries(test_flagship_compression_note PRIVATE cabledyn_core) add_test(NAME flagship_compression_note COMMAND test_flagship_compression_note ${CMAKE_SOURCE_DIR}/examples/iea15mw_umaine_mixed_cabledyn.dat) set_tests_properties(flagship_compression_note PROPERTIES LABELS "fortran;integration;static;contact") +add_executable(test_static_dry_weight tests/test_static_dry_weight.f90) +target_link_libraries(test_static_dry_weight PRIVATE cabledyn_core) +add_test(NAME static_dry_weight COMMAND test_static_dry_weight WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(static_dry_weight PROPERTIES LABELS "fortran;integration;static;openfast") add_executable(test_viv_kernels tests/test_viv_kernels.f90) target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) diff --git a/VALIDATION.md b/VALIDATION.md index c6c0594e..f0ce65de 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -392,6 +392,23 @@ scripts, results, and source provenance are in lazy-wave power cable (positions and tangents of its free nodes, and their rates). Every coupled point's linearised stiffness equals central differences of the deck's own static solutions to ≤3.3e-4, the cable's 36.0 / 2.62 / 38.5 N/m included, and also with a 5e4 N·m/rad hang-off spring. + With that spring, the t = 0 linearisation's force per unit rotation reads 1.2 % below the static + solutions out of plane (Fy per x-rotation 2.583 against 2.614 N/rad). In plane it is 0.08 % and + 0.32 % off (Fx and Fz per y-rotation). The cause is the operating point, not the `.lin` + matrices. A probe that differentiates the core's acceleration recompute as `lin_eval` does + reproduces `A`, `B`, `C` and `D` to 1e-8. The platform starts out of balance, so at t = 0 the + fairlead accelerates at (−0.019, 0, −0.016) m/s². The cable's coupled load is its support + reaction, which includes the inertia `−M(q) a` of the line, and turning the end tangent changes + that reaction while the fairlead accelerates. With this acceleration prescribed, the probe + reproduces the rotation columns to 2e-5 (2.5826 N/rad). With the platform DOFs disabled in + ElastoDyn, the coupled point does not accelerate. The OpenFAST reduction is then symmetric, + and it matches the static solutions, Richardson-extrapolated over 0.125° and 0.25° rotations, + in plane to 1.1e-5 (Fx per y-rotation 33.8954 / 33.8952 N/rad) and out of plane to 2.7e-4 + (2.6149 / 2.6142 N/rad). The out-of-plane residue is the O(h²) truncation of the 1 µm state + step on the soft sideways mode of the frictionless laid tail. In the probe it falls to 2.6e-5 + at a 0.3 µm step and grows to 2.9e-2 at 10 µm, and the sway translation column shows the same + residue. The moments per unit translation carry no inertia, so they match the static solutions + at either operating point. Two step sizes had to be small. A millimetre position step lifted the cable's grounded nodes out of their 0.3 mm seabed penetration on one side of the difference, and a 5 cm coupled-point step slackened the chain's last element. Each halved a stiffness (the cable's sway stiffness read 242 diff --git a/doc/driver_format.md b/doc/driver_format.md index 7cd9dc7d..ed01706b 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -421,9 +421,12 @@ connection moment at every connected end, and at both ends of a cable between tw Static initial condition: the static solve moves the free bodies, the free rods, the pinned rods (two rotations about the pin, the pin force on the parent body) and the `Free`/`Connect` points -together. A finite-EI line enters it with its axial stiffness and weight, without its bending -stiffness (a note names the line); its own shape is then solved with the bending stiffness at -the equilibrium end positions. +together. A finite-EI line enters it with its axial stiffness and weight (its part above the +surface with its dry weight), without its bending stiffness (a note names the line); its own +shape is then solved with the bending stiffness at the equilibrium end positions. A line +connected (clamped, elastic or restrained in torsion) at a body or rod end, a line between two +objects, and a bending-pinned line on a Rigid6 body or a rod end are balanced on their +cubic-Hermite end loads in static passes. **OpenFAST `CompMooring = 5` (aggregate route):** finite-EI cables run on the cubic-Hermite path: lazy-wave statics and generalised-α dynamics driven by the coupled fairlead, including platform @@ -1027,12 +1030,13 @@ Behaviour: A deck current (a `current` row, uniform or profile, or a MoorDyn-C `Currents` field at `t = 0`, sampled at the attachment node) loads the attachments in the static initial condition with the same drag law at rest, so a run in a current starts in equilibrium. - An attachment above the free surface carries its weight only. Attachments have no seabed - contact of their own; the node's contact acts on the line. + An attachment above the free surface carries its weight only, in the static initial condition + too. Attachments have no seabed contact of their own; the node's contact acts on the line. - The static equilibrium is solved first with each attachment's net weight spread over the two elements at its node, then carried to the discrete loads by continuation. The current drag - depends on the node's position and line direction, so the final solve is repeated until the - node positions change by less than 1e-9 m. On a line restrained in torsion the torsion stage + depends on the node's position and line direction, and the weight on the side of the surface + an attachment is on, so the final solve is repeated until the node positions change by less + than 1e-9 m and no attachment changes side. On a line restrained in torsion the torsion stage (the imposed twist) follows on the discrete equilibrium, with the attachments' net weights and drag as nodal loads (the drag again to a fixed point), so a run starts in the twisted equilibrium. An attachment adds no polar inertia to the line's twist. diff --git a/doc/openfast.rst b/doc/openfast.rst index a2b56410..c8259a5d 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -484,8 +484,20 @@ turn of an end frame or connection direction is nonlinear); a run without linear operating point, such as the still-water start, they lie on the linearised surface, while at a moving one the accelerations and the end-frame rates of the last step enter them. -The zero-frequency reduction ``D − C A⁻¹ B`` is the static mooring stiffness. It agrees with -MoorDyn-F and with CableDyn's own static solutions (:doc:`validation`). Quadratic drag has no +The zero-frequency reduction ``D − C A⁻¹ B`` is the static mooring stiffness at an operating point +whose coupled points do not accelerate. It agrees with MoorDyn-F and with CableDyn's own static +solutions (:doc:`validation`). A cable's coupled load is its support reaction, which includes the +inertia ``−M(q) a`` of the line, and the mass moves with the configuration: the added mass turns +with each element, and the end tangent's mass couples to the fairlead. At a coupled-point +acceleration ``a`` the force rows therefore also carry the configuration derivative of that +inertial reaction. The rotation columns, which turn the end tangent, show it most. An OpenFAST run +generally starts out of balance, so its platform accelerates at ``t = 0``. On the lazy-wave cable of +the mixed example, held by a 5e4 N·m/rad hang-off spring, a fairlead acceleration of 0.025 m/s² +moves the force per unit rotation by 1.2 % out of plane and by 0.08–0.32 % in plane. The translation +columns and the moments per unit translation stay within 3e-4 of the static solutions. At zero +acceleration the rotation columns match them too, to 2.7e-4 out of plane and 1.1e-5 in plane. +Compare a reduction with static solutions only at an operating point whose coupled points do not +accelerate, for example with the platform degrees of freedom disabled. Quadratic drag has no slope at rest, so the 0.1 m/s step gives its equivalent linear damping at that velocity amplitude. CableDyn integrates the drag over the element, and a one-node step then gives about half of MoorDyn-F's lumped value. diff --git a/doc/theory.rst b/doc/theory.rst index 2bc324c6..9be55fbb 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -545,6 +545,34 @@ order, End B, and :math:`\Phi` at End A), so a turn of the frame enters the end reference twist through the same solid angles. A turn of an end frame by more than :math:`\pi/2` about the line within one step is refused, and the step is cut. +The held end section turns with its frame. Its spin about the tangent, relative to the +time-parallel reference, is the frame's angular velocity projected by the derivative of the end +element's reference twist with respect to the frame's rotation. Its polar inertia (half the end +element's) carries the kinetic energy of that spin and loads the frame through the reaction +moment. A bending-pinned or elastic end lets the end tangent :math:`\mathbf{t}` move off the +director :math:`\mathbf{d}`, and the section's director, the frame's normal carried by the +smallest rotation :math:`G(\mathbf{d} \to \mathbf{t})`, then spins about :math:`\mathbf{t}` as +well: + +.. math:: + + c = \frac{(\mathbf{t} \times \mathbf{d})\cdot\dot{\mathbf{t}}}{1 + \mathbf{d}\cdot\mathbf{t}}, + \qquad \lvert c\rvert \le \tan\tfrac{\theta}{2}\,\lvert\dot{\mathbf{t}}\rvert , + +with :math:`\theta` the end bend angle. The model leaves this carry spin out of the kinetic +energy, out of the line's equations of motion and out of the reaction moment alike, so the +three stay consistent: with the end frames held, the energy without the carry spin keeps the +same band at a polar inertia of 0.02 and of 1 kg m. Including the spin would give the end tangent +a configuration-dependent rank-one polar mass :math:`I\,\nabla c\,\nabla c^{\mathsf T}` with its +gyroscopic velocity terms. Its kinetic energy :math:`\tfrac12 I c^2` is of order +:math:`(d^2/2l^2)\tan^2(\theta/2)` of the end element's translational kinetic energy (section +diameter :math:`d`, element length :math:`l`). The test suite measures it on a 10 m line pinned +in bending and rigid in torsion at both ends, twisted by 4 rad and swinging with a 13° end bend +angle: 6e-8 of the peak kinetic energy at :math:`I_{rn} = 0.02` kg m and 4e-6 at an extreme +1 kg m, against the step's own energy band of 6e-3 at :math:`\rho_\infty = 1`. The modal analysis +and the OpenFAST linearisation take the same lumped polar mass on the angles, with a held end's +angle not a coordinate, so they leave the carry spin out too. + .. _theory-free-end: **A free end.** A line restrained in torsion at one end only has its other end free to twist: @@ -1520,6 +1548,22 @@ beyond a :math:`10^{-6}` relative round-off band; a slack element reports zero t A line with no admissible equilibrium fails closed, naming the line, the seeds and stages tried, and the reason. +With a seabed (``WtrDpth`` or a bathymetry) the march gives the part of a line above the +still-water level its dry weight, through the recovery load of *Buoyancy and wetting* above, and +the static start does the same. The recovery depends on the wetted lengths, so the line is +solved again with the recovery of the last solution as a constant load until its nodes move by +less than :math:`10^{-9}` m. This fixed point contracts at the ratio of the recovery's stiffness +:math:`\rho g A/\sin\theta` (:math:`\theta` the inclination at the surface) to the line's own, +a few :math:`10^{-3}` for a hanging chain. A chain hung from 5 m above the surface then starts in +the equilibrium its march holds, and the coupled and standalone starts agree; with its buoyancy +kept above the surface it moved by :math:`10^{-3}` of its fairlead load in the first step. A line +wholly below the surface has no recovery and is solved once. Without a seabed the march, and so +the static start, keeps the buoyancy everywhere (the driver warns about a line end above the +surface then). The force balance of ``Connect`` and ``Free`` points and of free bodies and rods +below takes its lines with the same dry weight, so these objects start balanced against the march +too; a finite-EI line, which enters it without its bending stiffness, takes its dry weight there +with or without a seabed, as its cubic-Hermite cable does. + A steady current (uniform, or a depth profile sampled at each node's own elevation as in the march) enters the static equilibrium as Morison drag on the line at rest, so the out-of-plane offset is part of the initial condition. ``Connect`` and ``Free`` points are then placed at @@ -1722,7 +1766,13 @@ the current itself; the element fluid velocity is the mean of the current at its as in the dynamics). The drag follows the line and is not a potential force: it is carried along the stiffness continuation frozen at the last accepted configuration, then converged at full stiffness by a fixed-point iteration on the frozen drag and a final Newton solve with -the configuration-dependent drag and its Jacobian. If the frozen-drag continuation fails, the +the configuration-dependent drag and its Jacobian. A depth profile is sampled at the node +elevations and a current grid at the node positions, so the drag moves with the nodes through the +current too; the Jacobian carries it as the drag's derivative with respect to the fluid velocity, +:math:`-(\partial\mathbf{f}/\partial\dot{\mathbf{r}}_a + \partial\mathbf{f}/\partial +\dot{\mathbf{r}}_b)`, times the element velocity's gradient +:math:`\tfrac12\,\mathbf{R}^{\mathsf T}(\partial\mathbf{U}/\partial\mathbf{x})\,\mathbf{R}` at each +node (:math:`\mathbf{R}` the turn of the solve frame). If the frozen-drag continuation fails, the still-water equilibrium is found first and the drag is brought in by load steps. A load step that stalls hands over to a pseudo-arclength continuation in the drag fraction :math:`\lambda`: each corrector solves the bordered system @@ -1805,7 +1855,15 @@ The fallback and the dynamic Hermite path use fallback hierarchies are tried before a direct cold solve; every attempt uses the same physical inputs and tolerance; - a **dimensionless per-DOF residual norm**, with tangent-DOF residuals divided by the nodal - tributary length. + tributary length. The force scale is the largest of 1 N, the line's weight, the applied nodal + loads, and, for a line held at both ends whose chord is at least its length, the tension the + chord implies and the round-off floor of the axial forces over the tolerance, + :math:`16\,\epsilon\,\max(EA/L_0)\max(\lvert x\rvert, L_0)/\text{tol}` with + :math:`\lvert x\rvert` the largest coordinate (the floor of the ``EI = 0`` path). A neutral line + of the length of its span, straight at zero strain, carries neither weight nor tension, and + without the floor its residual could not meet the tolerance: its attachment polish stalled at + 7.6e-8 N against :math:`10^{-8}` N. A slack weightless line keeps its scale, so its round-off + stall on the straight compressed strut fails over to the weight continuation above. The static tolerance is :math:`\min(10^{-6},\ \text{tol}_\text{dyn})`, where :math:`\text{tol}_\text{dyn}` is the dynamic Newton tolerance, so the dynamics start from an @@ -2719,7 +2777,19 @@ whose frame rolls with it. The static solve carries the cable first without bending; passes then add the difference between the cubic-Hermite cable's end force and that surrogate, and the Hermite connection moment, at the previous pass's pose, until these loads change by less than :math:`10^{-7}` of the force scale. At the -fixed point the object balances the Hermite cable exactly. +fixed point the object balances the Hermite cable exactly. A bending-pinned end carries no +moment, but the surrogate gives its end force without the share of the bending, which on a soft +object is not small (a free spar rod with a pinned 55 m cable of :math:`EI = 2\times10^4` N m\ :sup:`2` +started 5.7 cm off its equilibrium), and with the line's ``ATTACHMENTS`` only smeared: on a +Rigid6 body or a rod end such a line takes the passes too, Anderson-mixed. The surrogate carries +the attachments' net weight smeared over the elements beside their nodes, as the smeared start of +the Hermite statics, so the passes correct only the lumped, side-of-the-surface, drag and bending +differences; a surrogate without them left the passes a heavy clump's whole load, whose change +with the object's pose its end stiffness did not see, and the passes converged or stopped by +round-off. Should the passes fail on that surrogate, they are repeated once on the surrogate +without the attachments. The mixing drops history columns that add less than :math:`10^{-6}` of +a new direction, which keeps its least-squares fit well conditioned when the residuals span fewer +directions than the history. **End connections (Hermite lines).** A line end may carry an isotropic rotational spring with potential :math:`U = \tfrac{1}{2}k\,\theta^2`, where :math:`\theta` is the angle between the end @@ -2799,10 +2869,17 @@ with the fluid velocity :math:`\mathbf{u}` and acceleration :math:`\dot{\mathbf{ the relative velocity :math:`\mathbf{w} = \mathbf{u} - \dot{\mathbf{r}}_j` split normal and along the nodal tangent :math:`\mathbf{m}_j/\lvert\mathbf{m}_j\rvert` (the line's Morison law with :math:`C_dA = C_{d,n} d` and :math:`C_dA_x = \pi C_{d,t} d`). The drag enters the velocity tangent -and, through :math:`\mathbf{m}_j`, the position tangent exactly. The statics start from the +and, through :math:`\mathbf{m}_j`, the position tangent exactly. Above the free surface an +attachment carries its weight :math:`-m g\,\mathbf{e}_z` alone. The statics start from the equilibrium with the net weight smeared over the node's two elements and continue to the lumped -load in warm-started Newton solves; in a deck current the drag at rest is added and the final -solve is repeated with the drag of its own solution until the nodes stop moving. The load moves +load in warm-started Newton solves; in a deck current the drag at rest is added, each solve takes +every attachment's load on the side of the still-water level its node is on, and the final +solve is repeated with the loads of its own solution until the nodes stop moving and no +attachment changes side (an attachment that its weight in air takes below the surface and its +weight in water above it has no static position, and the solve fails closed, naming the +attachment that crossed the surface). Before, an attachment above the surface +kept its buoyancy in the statics: a 500 kg, 0.2 m\ :sup:`3` module 3 m above it moved the +fairlead load by up to 6.1 % in the first second of the march. The load moves in eighths; a step whose damped Newton solve does not converge is repeated from the last converged state with pseudo-transient continuation and then with a residual-merit line search, and is halved (down to 1/1024) when neither converges. A halved step doubles again (up to 1/8) diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 36aee8f9..8c590c8b 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -624,6 +624,13 @@ but a few geometries are genuinely hard: reported in the note ``... was reached after a failed Newton solve ... and passed the acceptance checks of the smeared state``. Check that the deck with the modules replaced by the equivalent smeared buoyancy section solves; if it does, the discrete layout itself is the difficulty. + ``... attachment of the line (Mass ..., Volume ...) crossed the still-water level ...`` + means the solves carried that attachment across the surface, where the dynamics drops its + buoyancy: its weight in air takes it below the surface and its weight in water above it, so a + point attachment has no static position there (the dynamics would bob it there). It is a + net-buoyant module that would float, or a module whose node lies nearer the surface than the + deflection its buoyancy gives the line. The message of the failed solve follows it. Move it + along the line or change its ``Mass`` or ``Volume``. - **A cold start at full load.** The static solve continues the load in stages; if you have hand-tuned a case into a bad basin, remove the tuning and let the default continuation run from the catenary/arch seed. diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 24401cab..2141712b 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -37,7 +37,7 @@ MODULE CableDyn_DeckDriver CD_Assemble_Cable_Tangent_Force_Banded_Free USE CableDyn_Static, ONLY: CableSolverConfig, CableCurrentLoad, CD_StaticLineReport, CD_Static_Line_Equilibrium, & CD_Static_Line_End_Forces, CD_Static_Anchor_Seabed_Tolerance, CD_Static_Cable_Solve, & - CD_STATIC_OK, CD_STATIC_BADINPUT, & + CD_Static_Line_Dry_Load, CD_STATIC_OK, CD_STATIC_BADINPUT, & CD_STATIC_FRICTION_AS_LAID, CD_STATIC_FRICTION_NONE USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & CD_Bathymetry_Is_Initialized, CD_Bathymetry_Floor, & @@ -3440,32 +3440,37 @@ END SUBROUTINE torsion_note SUBROUTINE torsion_after_attachments(est, emt) !! The torsion stage of a line with ATTACHMENTS, on its discrete equilibrium (after the - !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes and, - !! in a deck current, their drag at the twisted state as nodal loads. The drag depends on - !! the node's position and line tangent, so the stage is repeated, each time a fresh torsion - !! solve from the last state, with the drag of the last solution until the solution stops - !! moving (fixed point, as in attachment_static_polish). + !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes (-m g + !! e_z above the still-water level, attachment_static_weight) and, in a deck current, their + !! drag at the twisted state as nodal loads. The drag depends on the node's position and + !! line tangent, and the weight on the side of the surface, so the stage is repeated, each + !! time a fresh torsion solve from the last state, with the loads of the last solution until + !! the solution stops moving and no attachment changes side (fixed point, as in + !! attachment_static_polish). INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt INTEGER, PARAMETER :: MAX_FIXED_POINT = 60 REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), q_prev(:), q_polished(:) + LOGICAL, ALLOCATABLE :: att_dry(:), att_dry_now(:) LOGICAL :: has_drag - INTEGER :: k, fp + INTEGER :: fp, k_cross + ! the first attachment a pass moved across the still-water level, which names a failure of + ! the stage after it (as in attachment_static_polish) + CHARACTER(512) :: cause + CHARACTER(64) :: mv est = CD_DECKDRV_OK + k_cross = 0 + cause = '' emt = '' ! every pass starts from the polished, untwisted discrete state (a pass from the last twisted ! state would first relax it, and a writhe a buckling descent left could put Theta_0 a turn ! away, on another branch) q_polished = q_static - ALLOCATE (f_att(SIZE(q_static)), f_drag(SIZE(q_static))) - f_att = CD_ZERO - DO k = 1, SIZE(att_node) - f_att(6*(att_node(k) - 1) + 3) = f_att(6*(att_node(k) - 1) + 3) - & - (ln%att(2, k) - opts%rhoW*ln%att(3, k))*opts%g - END DO + ALLOCATE (f_att(SIZE(q_static)), f_drag(SIZE(q_static)), att_dry(SIZE(att_node)), att_dry_now(SIZE(att_node))) has_drag = opts%has_current .AND. ANY(ln%att(4, :) > CD_ZERO .OR. ln%att(6, :) > CD_ZERO) DO fp = 1, MAX_FIXED_POINT + CALL attachment_static_weight(q_static, att_node, ln%att, opts, f_att, att_dry) f_drag = CD_ZERO IF (has_drag) THEN CALL attachment_static_drag(q_static, att_node, ln%att, opts, frame_cs, f_drag, est, emt) @@ -3477,13 +3482,35 @@ SUBROUTINE torsion_after_attachments(est, emt) q_prev = q_static q_static = q_polished CALL torsion_stage(est, emt, f_att + f_drag) - IF (est /= CD_DECKDRV_OK) RETURN + IF (est /= CD_DECKDRV_OK) THEN + IF (k_cross > 0) emt = TRIM(cause)//'; '//TRIM(emt) + RETURN + END IF + ! an attachment the twist moved across the still-water level: once more, with its weight on + ! its new side + CALL attachment_static_weight(q_static, att_node, ln%att, opts, f_att, att_dry_now) + IF (.NOT. ALL(att_dry_now .EQV. att_dry)) THEN + IF (k_cross == 0) THEN + k_cross = FINDLOC(att_dry_now .NEQV. att_dry, .TRUE., DIM=1) + WRITE (mv, '(ES9.3,A,ES9.3)') ln%att(2, k_cross), ' kg, Volume ', ln%att(3, k_cross) + cause = 'finite-EI torsion static solve with discrete ATTACHMENTS: attachment '// & + TRIM(int_to_str(k_cross))//' of the line (Mass '//TRIM(ADJUSTL(mv))//' m^3) crossed the '// & + 'still-water level, where the dynamics drops its buoyancy; a point attachment that its weight '// & + 'in air takes below the surface and its weight in water above it has no static position (move '// & + 'it along the line or change its Mass or Volume)' + END IF + CYCLE + END IF IF (.NOT. has_drag) RETURN IF (MAXVAL(ABS(q_static - q_prev)) <= FIXED_POINT_TOL) RETURN END DO est = CD_DECKDRV_SOLVEFAIL - emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment current drag did not '// & - 'settle to a fixed point' + IF (ALL(att_dry_now .EQV. att_dry)) THEN + emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment current drag did not '// & + 'settle to a fixed point' + ELSE + emt = cause + END IF END SUBROUTINE torsion_after_attachments SUBROUTINE twisted_attachment_checks(est, emt) @@ -5121,11 +5148,14 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att opts, tol, ErrStat, ErrMsg, bathymetry, cur_obj, fell_back) !! Homotopy from the smeared-attachment equilibrium q to the discrete one: in warm-started !! Newton solves the element weights move from w_smear to w_bare while the lumped nodal - !! forces -(m - rho V) g e_z and, in a deck current, the attachment current drag grow from + !! forces -(m - rho V) g e_z (-m g e_z for an attachment above the still-water level, + !! attachment_static_weight) and, in a deck current, the attachment current drag grow from !! zero to full, with the contact, dry-buoyancy, end-connection and line current terms of !! the builder's static problem. The drag depends on the node's position (profile current, - !! current grid) and line tangent, so the full-load solve is repeated with the drag of the - !! last solution until the solution stops moving (fixed point). + !! current grid) and line tangent, and the weight on the side of the surface the node is on, + !! so each solve takes them at its incoming state and the full-load solve is repeated with + !! those of the last solution until the solution stops moving and no attachment changes + !! side (fixed point). !! !! The load fraction advances in steps of 1/NSTEP. A step whose damped Newton solve does !! not converge is repeated from the last converged state with pseudo-transient @@ -5169,8 +5199,14 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), dry(:), knnode(:), wl(:), q_out(:), curv(:) REAL(wp) :: lam, lam_done, dlam, res, change - INTEGER :: i, k, ne, fp, n_failed, n_ok, grow_after + INTEGER :: i, ne, fp, n_failed, n_ok, grow_after LOGICAL :: has_drag, converged, newton_failed, grown + ! which attachments are above the still-water level: in the state the last solve took its + ! loads at, and in the state it returned + LOGICAL, ALLOCATABLE :: att_dry(:), att_dry_now(:) + ! the first attachment a solve moved across the still-water level (0: none), which names a + ! failure of the polish after it + INTEGER :: k_cross ! The damped Newton failure of the first failed solve, and of the last one. CHARACTER(1024) :: first_msg, last_msg CHARACTER(48) :: step_buf, lam_buf @@ -5183,10 +5219,9 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att n_failed = 0 ne = SIZE(l0) ALLOCATE (f_att(6*(ne + 1)), f_drag(6*(ne + 1)), dry(ne), q_out(SIZE(q)), curv(ne + 1)) - f_att = CD_ZERO - DO k = 1, SIZE(node) - f_att(6*(node(k) - 1) + 3) = f_att(6*(node(k) - 1) + 3) - (att(2, k) - opts%rhoW*att(3, k))*opts%g - END DO + ALLOCATE (att_dry(SIZE(node)), att_dry_now(SIZE(node))) + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry) + k_cross = 0 has_drag = opts%has_current .AND. ANY(att(4, :) > CD_ZERO .OR. att(6, :) > CD_ZERO) dry = opts%rhoW*opts%g*QUARTER_PI*diam**2 IF (contact_enabled) THEN @@ -5228,30 +5263,67 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att WRITE (lam_buf, '(F8.6)') lam_done IF (dlam < MIN_STEP) THEN WRITE (step_buf, '(ES9.2)') MIN_STEP - CALL fail_solve(ErrStat, ErrMsg, TRIM(first_msg)//'; the homotopy stopped at load fraction '// & - TRIM(ADJUSTL(lam_buf))//', where load steps down to '//TRIM(ADJUSTL(step_buf))// & - ' did not converge either') + CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(first_msg)//'; the homotopy stopped at '// & + 'load fraction '//TRIM(ADJUSTL(lam_buf))//', where load steps down to '// & + TRIM(ADJUSTL(step_buf))//' did not converge either') ELSE WRITE (step_buf, '(I0)') MAX_FAILED_STEPS - CALL fail_solve(ErrStat, ErrMsg, TRIM(first_msg)//'; the homotopy stopped at load fraction '// & - TRIM(ADJUSTL(lam_buf))//' after '//TRIM(step_buf)//' load steps had failed') + CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(first_msg)//'; the homotopy stopped at '// & + 'load fraction '//TRIM(ADJUSTL(lam_buf))//' after '//TRIM(step_buf)// & + ' load steps had failed') END IF RETURN END IF END IF END DO - IF (.NOT. has_drag) RETURN + ! An attachment whose node the last solve moved across the still-water level was loaded with + ! the weight of the other side: the full-load solve is repeated (below) until none does. A + ! line below the surface (or wholly above it) without attachment drag is done. + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry_now) + IF (.NOT. has_drag .AND. ALL(att_dry_now .EQV. att_dry)) RETURN DO fp = 1, MAX_FIXED_POINT CALL solve_with(CD_ONE, converged, change) IF (ErrStat /= CD_DECKDRV_OK) RETURN IF (.NOT. converged) THEN - CALL fail_solve(ErrStat, ErrMsg, TRIM(last_msg)//' (attachment current drag fixed point)'); RETURN + CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(last_msg)// & + ' (attachment current drag and surface fixed point)') + RETURN END IF - IF (change <= FIXED_POINT_TOL) RETURN + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry_now) + ! the weight is constant on either side of the surface: with no attachment changing side the + ! solve took the weights of its own solution, and without drag it is the equilibrium + IF (ALL(att_dry_now .EQV. att_dry) .AND. (.NOT. has_drag .OR. change <= FIXED_POINT_TOL)) RETURN END DO - CALL fail_solve(ErrStat, ErrMsg, 'finite-EI static solve with discrete ATTACHMENTS: the attachment '// & - 'current drag did not settle to a fixed point') + IF (ALL(att_dry_now .EQV. att_dry)) THEN + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI static solve with discrete ATTACHMENTS: the attachment '// & + 'current drag did not settle to a fixed point') + ELSE + IF (k_cross == 0) k_cross = FINDLOC(att_dry_now .NEQV. att_dry, .TRUE., DIM=1) + CALL fail_solve(ErrStat, ErrMsg, surface_note('')) + END IF CONTAINS + FUNCTION surface_note(sep) RESULT(msg) + !! The cause of a failed polish in which a solve moved an attachment across the still-water + !! level (k_cross; empty without one), followed by sep: a point attachment that its weight + !! in air takes below the surface and its weight in water above it (a net-buoyant module + !! that would float, or any module whose node lies nearer the surface than the deflection + !! its buoyancy rho V g gives the line) has no static position. Without this the failure + !! read as a homotopy that stopped (a 200 kg, 2 m^3 module on a slack cable, which the + !! solves carried above and below the surface in turn). + CHARACTER(*), INTENT(IN) :: sep + CHARACTER(:), ALLOCATABLE :: msg + CHARACTER(64) :: mv + msg = '' + IF (k_cross < 1) RETURN + WRITE (mv, '(ES9.3,A,ES9.3)') att(2, k_cross), ' kg, Volume ', att(3, k_cross) + msg = 'finite-EI static solve with discrete ATTACHMENTS: attachment '//TRIM(int_to_str(k_cross))// & + ' of the line (Mass '//TRIM(ADJUSTL(mv))//' m^3) crossed the still-water level, where the '// & + 'dynamics drops its buoyancy; a point attachment that its weight in air takes below the surface '// & + 'and its weight in water above it has no static position (move it along the line or change its '// & + 'Mass or Volume)' + msg = msg//sep + END FUNCTION surface_note + SUBROUTINE solve_with(scale, ok, dq_max) !! One warm-started solve at load fraction scale, with the attachment current drag !! evaluated on the incoming state: the damped Newton iteration and, when it does not @@ -5269,6 +5341,12 @@ SUBROUTINE solve_with(scale, ok, dq_max) CHARACTER(48) :: num_buf ok = .FALSE. max_it = [MERGE(NEWTON_RETRY_ITER, 200, newton_failed), 200, 200] + ! the attachments' weights on the side of the surface of the incoming state (the first one the + ! last solve moved across the surface is recorded for the failure message) + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry_now) + IF (k_cross == 0 .AND. .NOT. ALL(att_dry_now .EQV. att_dry)) & + k_cross = FINDLOC(att_dry_now .NEQV. att_dry, .TRUE., DIM=1) + att_dry = att_dry_now f_drag = CD_ZERO IF (has_drag) THEN CALL attachment_static_drag(q, node, att, opts, frame_cs, f_drag, es, em) @@ -5360,6 +5438,34 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM END DO END SUBROUTINE attachment_static_drag + SUBROUTINE attachment_static_weight(q, node, att, opts, f, dry) + !! The attachments' weight at rest as nodal loads (f, the generalized load vector of the + !! cable solve, set here): -(m - rho V) g e_z at the node of an attachment at or below the + !! still-water level and -m g e_z above it, as the dynamics loads it (attachment_residual of + !! the cubic-Hermite model: above the free surface its weight only, no buoyancy, and no drag, + !! which attachment_static_drag skips there too). Without it the static start kept the + !! buoyancy of an attachment above the surface: a 500 kg, 0.2 m^3 module 3 m above it on a + !! cable hung from 5 m above the surface moved the fairlead load by up to 6.1 % in the first + !! second. + !! dry(k): attachment k is above the surface in q. + REAL(wp), INTENT(IN) :: q(:), att(:, :) + INTEGER, INTENT(IN) :: node(:) + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(OUT) :: f(:) + LOGICAL, INTENT(OUT) :: dry(:) + INTEGER :: k, base + f = CD_ZERO + DO k = 1, SIZE(node) + base = 6*(node(k) - 1) + dry(k) = q(base + 3) > CD_ZERO + IF (dry(k)) THEN + f(base + 3) = f(base + 3) - att(2, k)*opts%g + ELSE + f(base + 3) = f(base + 3) - (att(2, k) - opts%rhoW*att(3, k))*opts%g + END IF + END DO + END SUBROUTINE attachment_static_weight + PURE INTEGER FUNCTION bending_refine_scale(l0, ei, w) RESULT(scale) !! The power-of-two refinement factor (at most CD_HC_REFINE_CAP, and at most !! REFINED_MAX_ELEMENTS elements after it) that brings every element of a finite-EI mesh to @@ -11259,8 +11365,10 @@ END SUBROUTINE solve_point_equilibrium SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) !! Standard-output WARNINGS (never failures) for admissible but non-physical or - !! questionable inputs: a line end above the still-water level (the line is modelled - !! fully submerged), a line type that sinks into the penalty seabed by more than its + !! questionable inputs: an EI = 0 line end above the still-water level on a deck without a + !! seabed (the line is then modelled fully submerged; with WtrDpth or a bathymetry, and on + !! a finite-EI line, the part above the surface carries its dry weight), a line type that + !! sinks into the penalty seabed by more than its !! diameter (kBot too soft for its submerged weight), a slack anchored line that hangs !! below its anchor on a deck with no seabed (reported after the static solve by !! warn_line_below_anchor), and a line with fewer than three segments (a straight @@ -11272,14 +11380,23 @@ SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) TYPE(DeckOptions), INTENT(IN) :: opts INTEGER :: i, j, k, nseg REAL(wp) :: w, pen + LOGICAL :: dry_weight CHARACTER(32) :: b1, b2 DO i = 1, SIZE(lines) + ! the line's model carries the dry weight above the surface: a finite-EI line always, an + ! EI = 0 line with a seabed (its buoyancy recovery) + dry_weight = opts%has_wtrdpth .OR. opts%has_bathymetry_file + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(i)%id) CYCLE + IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE + IF (types(sections(j)%ltype)%ei > CD_ZERO) dry_weight = .TRUE. + END DO DO k = 1, 2 IF (k == 1) j = find_point(points, lines(i)%nodeA) IF (k == 2) j = find_point(points, lines(i)%nodeB) IF (j < 1) CYCLE - IF (points(j)%pos(3) > CD_ZERO) THEN + IF (points(j)%pos(3) > CD_ZERO .AND. .NOT. dry_weight) THEN WRITE (b1, '(ES10.3)') points(j)%pos(3) WRITE (output_unit, '(A)') ' WARNING: LINE '//TRIM(int_to_str(lines(i)%id))//' end POINT '// & TRIM(int_to_str(points(j)%id))//' is above the still-water level (z = '//TRIM(ADJUSTL(b1))// & @@ -11885,6 +12002,9 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg INTEGER, ALLOCATABLE :: conn(:, :) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mpl(:), diam(:), w(:), load(:, :), f_ext(:) REAL(wp), ALLOCATABLE :: kn(:) + ! the dry part's weight (with a seabed, as the dynamic model's buoyancy recovery): the + ! waterline per node and the recovery load of the solution + REAL(wp), ALLOCATABLE :: dry_wl(:), f_dry(:) REAL(wp) :: anchor(3), fairlead(3), force_a(3), force_b(3) INTEGER :: ne, n_dof, i, j, ns, es CHARACTER(1024) :: em @@ -11998,28 +12118,43 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg cur%elem_cdn = cur%elem_cdn(ne:1:-1) cur%elem_cdt = cur%elem_cdt(ne:1:-1) END IF + ALLOCATE (f_dry(n_dof)) + f_dry = CD_ZERO IF (PRESENT(bathymetry) .OR. opts%has_wtrdpth) THEN CALL CD_Nodal_Seabed_Stiffness(opts%kbot, diam, l0, kn, es, em) IF (es /= CD_LINE_OK) THEN CALL fail(ErrStat, ErrMsg, 'seabed stiffness: '//TRIM(em)); RETURN END IF + ! the line's model has a seabed and so the buoyancy recovery of its dry part + ! (init_deck_models_from_parsed): the part above the still-water level takes its dry + ! weight here too, so that the static-only start is the dynamic route's + ALLOCATE (dry_wl(ne + 1)) + dry_wl = CD_ZERO END IF IF (PRESENT(bathymetry)) THEN IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_kn=kn, bathymetry=bathymetry, current=cur) + report, es, em, seabed_kn=kn, bathymetry=bathymetry, current=cur, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_kn=kn, bathymetry=bathymetry) + report, es, em, seabed_kn=kn, bathymetry=bathymetry, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) END IF ELSE IF (opts%has_wtrdpth) THEN IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, current=cur) + report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, current=cur, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn) + report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) END IF ELSE IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & @@ -12045,6 +12180,8 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg CALL fail_solve(ErrStat, ErrMsg, 'tension recovery: '//TRIM(em)); RETURN END IF IF (PRESENT(end_ten) .OR. PRESENT(end_force)) THEN + ! the equilibrium's external load: the submerged weight and the dry part's recovery + f_ext = f_ext + f_dry IF (PRESENT(bathymetry) .AND. opts%has_current) THEN CALL CD_Static_Line_End_Forces(q, conn, l0, ea, f_ext, .TRUE., force_a, force_b, es, em, & seabed_kn=kn, bathymetry=bathymetry, current=cur) @@ -25950,7 +26087,8 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l !! = -K_c, mapped to the object unknowns through the attachment arms, plus the moment of !! the end force under a rotation of the arm. The objects' own loads (no lines, cheap) are !! differentiated by central differences. The line's steady-current drag stiffness is not in - !! K_c; the residual is exact, so it only slows convergence in a current. A line exactly at + !! K_c, nor the stiffness of its dry part's weight above the still-water level (with a seabed, + !! cached_line_solve); the residual is exact, so they only slow convergence. A line exactly at !! its slack/taut kink has no one-sided stiffness: when the analytic Newton system is !! singular or its step fails, the iteration falls back to a central-difference Jacobian of !! the full residual (warm-started line solves per column). Newton steps in a trust region @@ -26011,6 +26149,10 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l INTEGER, ALLOCATABLE :: conn(:, :) REAL(wp), ALLOCATABLE :: l0(:), ea(:), w(:), f_ext(:), kn(:), q(:), s(:) REAL(wp), ALLOCATABLE :: dia(:), cdn(:), cdt(:) + ! with a seabed, the dry part's weight above the still-water level (as the dynamic model's + ! buoyancy recovery): the element diameters and the waterline per node (unallocated: the + ! line keeps its buoyancy everywhere) + REAL(wp), ALLOCATABLE :: dry_d(:), dry_wl(:) REAL(wp) :: anchor(3) = CD_ZERO, fairlead(3) = CD_ZERO REAL(wp) :: ef(3, 2) = CD_ZERO, kc(6, 6) = CD_ZERO END TYPE @@ -27154,6 +27296,18 @@ SUBROUTINE prepare_line(jl, es_out, em_out) IF (es_l /= 0) THEN CALL fail(es_out, em_out, 'submerged weight: '//TRIM(em_l)); RETURN END IF + ! A finite-EI line's ATTACHMENTS, smeared over the elements beside their nodes with their + ! net weight (m - rho V) g, as in the smeared start of its cubic-Hermite statics: the cable + ! of the body passes (solve_body_equilibrium) carries them, so their correction is only the + ! bending's share and the difference of the lumped, side-of-the-surface and drag loads. + IF (ALLOCATED(lines(jl)%att)) THEN + BLOCK + INTEGER, ALLOCATABLE :: anode(:) + REAL(wp) :: aoff + CALL attachment_nodes(lc(jl)%l0, lines(jl)%att(1, :), anode, aoff) + CALL smear_attachments(lc(jl)%w, lc(jl)%l0, anode, lines(jl)%att, opts%rhoW, opts%g) + END BLOCK + END IF DO ii = 1, ne load(:, ii) = [CD_ZERO, CD_ZERO, -lc(jl)%w(ii)] END DO @@ -27188,6 +27342,17 @@ SUBROUTINE prepare_line(jl, es_out, em_out) CALL fail(es_out, em_out, 'seabed stiffness: '//TRIM(em_l)); RETURN END IF END IF + ! The part above the still-water level takes its dry weight here, as in solve_one_line, + ! where the line's own model gives it that weight, so that the objects start balanced + ! against the loads the march applies: an EI = 0 line with a seabed (its model's buoyancy + ! recovery, init_deck_models_from_parsed) and a finite-EI line always (its cubic-Hermite + ! cable's dry buoyancy, with or without a seabed). Without a seabed this surrogate of a + ! finite-EI line kept its buoyancy above the surface, while its cable did not. + IF (PRESENT(bathymetry) .OR. opts%has_wtrdpth .OR. line_is_finite_ei(lines(jl), types, sections)) THEN + lc(jl)%dry_d = diam + ALLOCATE (lc(jl)%dry_wl(ne + 1)) + lc(jl)%dry_wl = CD_ZERO + END IF lc(jl)%ready = .TRUE. END SUBROUTINE prepare_line @@ -27204,14 +27369,14 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) CHARACTER(*), INTENT(OUT) :: em_out LOGICAL, INTENT(IN), OPTIONAL :: want_k LOGICAL, INTENT(OUT), OPTIONAL :: k_ok - TYPE(CableSolverConfig) :: cfg, cfg_w + TYPE(CableSolverConfig) :: cfg TYPE(CD_StaticLineReport) :: report TYPE(CableCurrentLoad), ALLOCATABLE :: curp - REAL(wp), ALLOCATABLE :: zf, q0(:), q(:), tq(:) + REAL(wp), ALLOCATABLE :: zf, q0(:), q(:), f_dry(:), f_prev(:), q_prev(:) REAL(wp) :: c_old(3), c_new(3), rot_w(3, 3), sc_w REAL(wp) :: anchor(3), fairlead(3), fa(3), fb(3) - INTEGER :: nn, ii, es_l, nit - LOGICAL :: conv, stalled, at_floor + INTEGER :: nn, ii, es_l, kd + LOGICAL :: conv CHARACTER(1024) :: em_l es_out = CD_DECKDRV_OK @@ -27266,37 +27431,53 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) END DO q0(1:3) = anchor q0(3*nn - 2:3*nn) = fairlead - ! (a) plain Newton with the compression-capable law, accepted when no element is - ! compressed beyond the 1e-6 round-off band (every element taut: it is then the - ! tension-only equilibrium), as the cold initializer's first stage accepts it - CALL CD_Static_Cable_Solve(q0, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., lc(jl)%f_ext, & - [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg, q, conv, stalled, at_floor, nit, & - es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & - bathymetry=bathymetry) - IF (es_l /= CD_STATIC_OK) conv = .FALSE. - IF (conv) conv = ALL(IEEE_IS_FINITE(q)) - IF (conv) THEN - ALLOCATE (tq(nn - 1)) - CALL CD_Compute_Cable_Tension(RESHAPE(q, [3, nn]), lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., tq, & - es_l, em_l) - conv = es_l == 0 - IF (conv) conv = MINVAL(tq) >= -1.0e-6_wp*MAX(MAXVAL(ABS(tq)), TINY(CD_ONE)) - END IF - IF (.NOT. conv) THEN - ! (b) the exact tension-only law (a slack run), Levenberg-Marquardt, short budget - cfg_w%max_iter = 10 - CALL CD_Static_Cable_Solve(q0, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .TRUE., lc(jl)%f_ext, & - [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg_w, q, conv, stalled, at_floor, nit, & - es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & - bathymetry=bathymetry, regularized=.TRUE.) + ALLOCATE (f_dry(3*nn)) + f_dry = CD_ZERO + CALL warm_line_solve(jl, q0, lc(jl)%f_ext, zf, curp, q, conv) + ! With the dry part's weight (a line above the still-water level), the warm solve is + ! repeated with the recovery of the last solution as a constant load until the nodes move + ! by less than 1e-9 m or the recovery changes by less than 1e-10 of the largest nodal + ! load, as CD_Static_Line_Equilibrium iterates it; f_dry is then the recovery the + ! returned shape was solved with. A line wholly below the surface is solved once. + IF (conv .AND. ALLOCATED(lc(jl)%dry_d)) THEN + CALL CD_Static_Line_Dry_Load(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%dry_wl, opts%rhoW, opts%g, lc(jl)%dry_d, & + f_dry, es_l, em_l) IF (es_l /= CD_STATIC_OK) conv = .FALSE. - IF (conv) conv = ALL(IEEE_IS_FINITE(q)) + IF (conv .AND. ANY(f_dry /= CD_ZERO)) THEN + conv = .FALSE. + DO kd = 1, 50 + q_prev = q + f_prev = f_dry + CALL warm_line_solve(jl, q_prev, lc(jl)%f_ext + f_prev, zf, curp, q, conv) + IF (.NOT. conv) EXIT + CALL CD_Static_Line_Dry_Load(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%dry_wl, opts%rhoW, opts%g, & + lc(jl)%dry_d, f_dry, es_l, em_l) + IF (es_l /= CD_STATIC_OK) THEN + conv = .FALSE. + EXIT + END IF + conv = MAXVAL(ABS(q - q_prev)) <= 1.0e-9_wp .OR. & + MAXVAL(ABS(f_dry - f_prev)) <= 1.0e-10_wp*MAXVAL(ABS(lc(jl)%f_ext)) + IF (conv) EXIT + END DO + f_dry = f_prev + END IF END IF END IF IF (.NOT. conv) THEN - CALL CD_Static_Line_Equilibrium(anchor, fairlead, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%w, & - lc(jl)%f_ext, cfg, .TRUE., q, conv, report, es_l, em_l, seabed_z_floor=zf, & - seabed_kn=lc(jl)%kn, bathymetry=bathymetry, current=curp) + IF (.NOT. ALLOCATED(f_dry)) ALLOCATE (f_dry(3*nn)) + f_dry = CD_ZERO + IF (ALLOCATED(lc(jl)%dry_d)) THEN + CALL CD_Static_Line_Equilibrium(anchor, fairlead, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%w, & + lc(jl)%f_ext, cfg, .TRUE., q, conv, report, es_l, em_l, seabed_z_floor=zf, & + seabed_kn=lc(jl)%kn, bathymetry=bathymetry, current=curp, & + dry_waterline_z=lc(jl)%dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=lc(jl)%dry_d, dry_load=f_dry) + ELSE + CALL CD_Static_Line_Equilibrium(anchor, fairlead, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%w, & + lc(jl)%f_ext, cfg, .TRUE., q, conv, report, es_l, em_l, seabed_z_floor=zf, & + seabed_kn=lc(jl)%kn, bathymetry=bathymetry, current=curp) + END IF IF (es_l /= CD_STATIC_OK) THEN CALL fail(es_out, em_out, 'static equilibrium: line '//TRIM(int_to_str(lines(jl)%id))// & ' static solve rejected the input: '//TRIM(em_l)); RETURN @@ -27308,8 +27489,9 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) RETURN END IF END IF - CALL CD_Static_Line_End_Forces(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%f_ext, .TRUE., fa, fb, es_l, & - em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, bathymetry=bathymetry, & + ! the equilibrium's external load: the submerged weight and the dry part's recovery + CALL CD_Static_Line_End_Forces(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%f_ext + f_dry, .TRUE., fa, fb, & + es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, bathymetry=bathymetry, & current=curp) IF (es_l /= 0 .OR. .NOT. (ALL(IEEE_IS_FINITE(fa)) .AND. ALL(IEEE_IS_FINITE(fb)))) THEN CALL fail_solve(es_out, em_out, 'static equilibrium: line '//TRIM(int_to_str(lines(jl)%id))// & @@ -27329,6 +27511,49 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) END IF END SUBROUTINE cached_line_solve + SUBROUTINE warm_line_solve(jl, qs, fl, zf, curp, q, conv) + !! One warm solve of line jl from the seed qs (both ends held) under the constant load fl + !! (cached_line_solve): q the shape, conv whether it was accepted. + INTEGER, INTENT(IN) :: jl + REAL(wp), INTENT(IN) :: qs(:), fl(:) + REAL(wp), ALLOCATABLE, INTENT(IN) :: zf + TYPE(CableCurrentLoad), ALLOCATABLE, INTENT(IN) :: curp + REAL(wp), INTENT(OUT) :: q(:) + LOGICAL, INTENT(OUT) :: conv + TYPE(CableSolverConfig) :: cfg, cfg_w + REAL(wp), ALLOCATABLE :: tq(:) + INTEGER :: nn, es_l, nit + LOGICAL :: stalled, at_floor + CHARACTER(1024) :: em_l + nn = lc(jl)%nn + ! (a) plain Newton with the compression-capable law, accepted when no element is + ! compressed beyond the 1e-6 round-off band (every element taut: it is then the + ! tension-only equilibrium), as the cold initializer's first stage accepts it + CALL CD_Static_Cable_Solve(qs, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., fl, & + [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg, q, conv, stalled, at_floor, nit, & + es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & + bathymetry=bathymetry) + IF (es_l /= CD_STATIC_OK) conv = .FALSE. + IF (conv) conv = ALL(IEEE_IS_FINITE(q)) + IF (conv) THEN + ALLOCATE (tq(nn - 1)) + CALL CD_Compute_Cable_Tension(RESHAPE(q, [3, nn]), lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., tq, & + es_l, em_l) + conv = es_l == 0 + IF (conv) conv = MINVAL(tq) >= -1.0e-6_wp*MAX(MAXVAL(ABS(tq)), TINY(CD_ONE)) + END IF + IF (.NOT. conv) THEN + ! (b) the exact tension-only law (a slack run), Levenberg-Marquardt, short budget + cfg_w%max_iter = 10 + CALL CD_Static_Cable_Solve(qs, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .TRUE., fl, & + [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg_w, q, conv, stalled, at_floor, nit, & + es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & + bathymetry=bathymetry, regularized=.TRUE.) + IF (es_l /= CD_STATIC_OK) conv = .FALSE. + IF (conv) conv = ALL(IEEE_IS_FINITE(q)) + END IF + END SUBROUTINE warm_line_solve + SUBROUTINE condensed_end_stiffness(jl, zf, ok) !! lc(jl)%kc: the static tangent of line jl at its stored shape condensed onto its end !! nodes, K_c = K_ee - K_ei K_ii^-1 K_ie (end 1 = node 1 = End B, end 2 = the last node = @@ -27487,7 +27712,20 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, !! the finite-EI lines whose End A is clamped (Rigid) or elastically connected to a body or a !! rod. The core solve carries a finite-EI line as a cable without bending stiffness; for a !! connected End A the bending changes the end force and adds the connection moment, which - !! the object must carry. Each pass solves the core with extra loads on the End A points: the + !! the object must carry. A bending-pinned End A carries no moment, but the core's cable gives + !! its end force without the bending's share, which on a soft object is not small (a free spar + !! rod on four taut legs with a 55 m cable, EI 2e4 N m^2, pinned at its upper end: the rod + !! started 5.7e-2 m off its equilibrium, its top drifted 7e-2 m in 3 s and a leg tension moved + !! by 2.3 %), and its ATTACHMENTS only smeared, without their lumped, side-of-the-surface and + !! drag loads (a 2 t clump 50 m along a pinned cable from a moored body, which the core's + !! cable once left out: the body started at the pose of the line without it and drifted by up + !! to 2.9e-2 m and 0.20 deg in 5 s). Such a line on a Rigid6 body or a rod end takes the passes + !! too. The core's cable carries a line's ATTACHMENTS smeared, so the passes correct only the + !! differences: without them the correction was the clump's whole load, which the core's end + !! stiffness did not see, and on a free spar rod with a 1500 kg clump the passes converged in + !! 26 or stopped, by round-off; with them in 6. Should the passes fail on that cable, they are + !! repeated once on the core cable without the ATTACHMENTS. Each pass solves the core with + !! extra loads on the End A points: the !! difference between the cubic-Hermite cable's static end force (bending, the connection !! direction turned with the object) and the core's own end force of that line, and the !! Hermite connection moment, both evaluated at the previous pass's equilibrium. The passes @@ -27507,7 +27745,8 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, !! (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. + !! overshoot), and so does a deck with a bending-pinned line listed for its ATTACHMENTS; a + !! deck without either keeps the plain passes. TYPE(DeckLineType), INTENT(IN) :: types(:) TYPE(DeckBody), INTENT(INOUT) :: bodies(:) TYPE(DeckRodType), INTENT(IN) :: rod_types(:) @@ -27522,7 +27761,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, LOGICAL, INTENT(IN), OPTIONAL :: points_only REAL(wp), INTENT(OUT), OPTIONAL :: jac_check_err INTEGER, PARAMETER :: MAX_PASS = 60, ANDERSON_DEPTH = 6 - REAL(wp), PARAMETER :: PASS_TOL = 1.0e-7_wp, PASS_TOL_TORSION = 1.0e-10_wp + REAL(wp), PARAMETER :: PASS_TOL = 1.0e-7_wp, PASS_TOL_TORSION = 1.0e-10_wp, ANDERSON_DROP = 1.0e-6_wp TYPE(DeckBody), ALLOCATABLE :: bodies0(:) TYPE(DeckRod), ALLOCATABLE :: rods0(:) TYPE(DeckPoint), ALLOCATABLE :: points0(:) @@ -27535,6 +27774,13 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, REAL(wp), ALLOCATABLE :: new_km(:, :, :), new_rot(:, :, :), fsb(:, :) INTEGER :: j, pa, e, pass, ncl, eworst, pb, ne, nb LOGICAL :: only_points, held + ! the passes are Anderson-mixed (lines between two objects, pinned lines with ATTACHMENTS) + LOGICAL :: mix + ! the lines the core solve carries (lines_core: with or without their ATTACHMENTS), the + ! attempt of the passes, and the failure of the first + TYPE(DeckLine), ALLOCATABLE :: lines_core(:) + INTEGER :: attempt, n_attempt, first_stat + CHARACTER(1024) :: first_msg REAL(wp) :: scale, change, pass_tol_eff CHARACTER(24) :: b1 @@ -27556,9 +27802,14 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, CYCLE END IF END IF - IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) CYCLE + ! a bending-pinned End A free in torsion takes the passes on a Rigid6 body or a rod end (a + ! finite-EI end on a Point3 buoy is refused by name after this solve; the passes, which turn + ! a body frame, would refuse it as a clamped end instead) pa = find_point(points, lines(j)%nodeA) IF (pa < 1) CYCLE + IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) THEN + IF (point_on_point3_body(points(pa), bodies)) CYCLE + END IF IF (starts_with(TRIM(points(pa)%ptype), 'body')) THEN cl = [cl, j] ELSE IF (is_rod_point_type(points(pa)%ptype)) THEN @@ -27609,82 +27860,131 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, 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, 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_eff - bodies = bodies0 - rods = rods0 - points = points0 - ! the torque stiffness only with torsion: without it the core's arithmetic is exactly that - ! of a deck before torsion existed (no zero-stiffness correction, signed zeros kept) - 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, & - 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, end_force_b=fsb) + ! The passes of a bending-pinned line are Anderson-mixed, as those of the lines between two + ! objects: on the core cable without its ATTACHMENTS (the second attempt below) the + ! correction is the attachments' whole load, which turns with the object as the heavier or + ! lighter cable does and not as the core's, and the plain passes overshoot without bound on + ! a soft object (a free spar rod with a 1500 kg clump 25 m along a pinned cable from its upper + ! end: the end-load change grew to 2.9 of the force scale in 60 passes). + mix = nb > 0 + DO e = 1, ncl + IF (lines(cl(e))%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(cl(e)))) & + mix = .TRUE. + END DO + IF (mix) ALLOCATE (and_x(6*ne, ANDERSON_DEPTH + 1), and_f(6*ne, ANDERSON_DEPTH + 1)) + ! The core carries a finite-EI line's ATTACHMENTS smeared (prepare_line). Should the passes + ! fail on that cable (its equilibrium of the object unstable or not found, or the passes not + ! converging), they are repeated once on the core cable without them, whose correction is the + ! attachments' whole load: that solve keeps the object balanced by its lines without the + ! attachments' load, where a heavy clump on a slack cable from a free spar rod tilted the + ! rod's balance on the smeared cable past its stability test. + lines_core = lines + n_attempt = 1 + IF (ANY([(ALLOCATED(lines(eline(e))%att), e=1, ne)])) n_attempt = 2 + first_stat = CD_DECKDRV_OK + first_msg = '' + DO attempt = 1, n_attempt + IF (attempt == 2) THEN + first_stat = ErrStat + first_msg = ErrMsg + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + DO j = 1, SIZE(lines_core) + IF (ALLOCATED(lines_core(j)%att)) DEALLOCATE (lines_core(j)%att) + END DO + n_and = 0 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 - 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))) + ext_fm = CD_ZERO + ext_km = CD_ZERO + ext_rot = CD_ZERO + 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_eff + bodies = bodies0 + rods = rods0 + points = points0 + ! the torque stiffness only with torsion: without it the core's arithmetic is exactly that + ! of a deck before torsion existed (no zero-stiffness correction, signed zeros kept) + IF (pass_tol_eff < PASS_TOL) THEN + CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines_core, 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, end_force_b=fsb) ELSE - CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e)) + CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines_core, sections, opts, & + ErrStat, ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, & + end_force_a=fs, quiet=pass > 1, skipped=held, end_force_b=fsb) + END IF + IF (ErrStat /= CD_DECKDRV_OK) EXIT + ! 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 + 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) EXIT + 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 + IF (ErrStat /= CD_DECKDRV_OK) EXIT + change = MAXVAL(ABS(new_fm - ext_fm)) + eworst = MAXLOC(MAXVAL(ABS(new_fm - ext_fm), DIM=1), DIM=1) + ext_km = new_km + ext_rot = new_rot + IF (change <= pass_tol_eff*scale) THEN + ext_fm = new_fm + EXIT + END IF + IF (mix) THEN + CALL anderson_next(ext_fm, new_fm) + ELSE + ext_fm = new_fm + END IF + END DO + IF (ErrStat == CD_DECKDRV_OK) THEN + IF (change <= pass_tol_eff*scale) EXIT + WRITE (b1, '(ES10.3)') change/scale + IF (nb == 0) THEN + CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the END CONNECTION or ATTACHMENTS '// & + '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 - 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_km = new_km - ext_rot = new_rot - 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 + IF (attempt == n_attempt) THEN + ! both failed: the failure on the cable that carries the attachments + IF (attempt == 2) THEN + ErrStat = first_stat + ErrMsg = first_msg + END IF + RETURN END IF END DO - IF (change > pass_tol_eff*scale) THEN - WRITE (b1, '(ES10.3)') change/scale - 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 - IF (nb == 0) THEN + IF (nb == 0 .AND. ANY([(lines(cl(e))%endconn_mode(1) == CD_ENDCONN_PINNED .AND. & + .NOT. line_torsion_at_a(lines(cl(e))), e=1, ncl)])) THEN + ! a bending-pinned line among them (its bending share of the end force, its ATTACHMENTS) + WRITE (output_unit, '(A)') ' Initial conditions: the end loads (bending, connection moments, torsion, '// & + 'ATTACHMENTS) of '//TRIM(int_to_str(ncl))//' finite-EI line end(s) on bodies and rods balanced in '// & + TRIM(int_to_str(pass))//' static pass(es).' + ELSE 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).' @@ -27701,8 +28001,14 @@ SUBROUTINE anderson_next(x, g) !! 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. + !! modified Gram-Schmidt on dF; a column that adds no new direction, its part normal to the + !! kept ones below ANDERSON_DROP of its length, is dropped. A residual that grows tenfold + !! over the last one restarts the mixing from the plain pass. The drop bound keeps the fit + !! well conditioned: residuals that span fewer directions than the history (a pinned end's + !! moment rows are zero, its force acts in the line's plane) leave the later columns a + !! normal part of round-off size, and with a bound of 1e-10 their coefficients reached + !! 1e12, so the mixed loads jumped by 1e6 N and the passes converged or stopped by 1 ulp of + !! an anchor coordinate (a free spar rod with a 1500 kg clump on a pinned cable). 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) @@ -27739,7 +28045,7 @@ SUBROUTINE anderson_next(x, g) 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 + IF (NORM2(dfi) <= ANDERSON_DROP*nrm) CYCLE kept = kept + 1 rr(kept, kept) = NORM2(dfi) q(:, kept) = dfi/rr(kept, kept) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index f4eac2af..40b1dd63 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -49,7 +49,8 @@ MODULE CableDyn_HermiteCableStatic CD_Bathymetry_Rotate_Curvature USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK - USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_Velocity, CD_HYDRO_OK + USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_Velocity, & + CD_Current_Profile_Gradient, CD_Current_Grid_Gradient, 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, & @@ -917,6 +918,27 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ IF (.NOT. (ANY(freemask(1:3)) .OR. ANY(freemask(6*(nn - 1) + 1:6*(nn - 1) + 3))) .AND. ALL(EA > CD_ZERO)) THEN chord = NORM2(q(6*(nn - 1) + 1:6*(nn - 1) + 3) - q(1:3)) IF (chord > SUM(l0)) fscale = MAX(fscale, (chord/SUM(l0) - CD_ONE)*SUM(l0)/SUM(l0/EA)) + ! The round-off floor of the residual itself, for a line whose chord is at least its + ! length. The axial force is formed from coordinate differences, so a nodal force carries + ! a round-off of about eps max(EA/l0) |x| (|x| the largest coordinate; the EI = 0 path's + ! floor is 16 eps max(EA/L0) max(|q|, L0)), and the residual can fall no lower. The scale + ! keeps tol x fscale at 16 times that floor. A neutral line whose length equals its span, + ! straight at zero strain, carries neither weight nor tension and otherwise met the 1 N + ! floor of the scale: under neutral attachments its polish stalled at ||R|| = 7.6e-8 N + ! against tol x 1 N = 1e-8 N (EA 1e7, 2.5 m elements, |x| = 100 m) and failed at every load + ! step. A slack line keeps its scale: a weightless one can stall at that floor on its straight + ! compressed strut, a saddle, and is solved by the weight continuation that accepts the + ! floor on its bowed equilibrium (light_line_route of the deck driver). + IF (chord >= (CD_ONE - 1.0e-9_wp)*SUM(l0) .AND. tol > CD_ZERO) THEN + BLOCK + REAL(wp) :: xmax + xmax = MAXVAL(l0) + DO i = 1, nn + xmax = MAX(xmax, MAXVAL(ABS(q(6*(i - 1) + 1:6*(i - 1) + 3)))) + END DO + fscale = MAX(fscale, 16.0_wp*EPSILON(CD_ONE)*MAXVAL(EA/l0)*xmax/tol) + END BLOCK + END IF END IF ! Buoyancy load continuation. A net-buoyant section (w < 0, e.g. a lazy-wave buoyancy @@ -2954,14 +2976,16 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, !! Steady-current drag on one element at rest: the load fd(12) (f_ext) and, when !! want_jac, its position Jacobian, both scaled by current%load_factor. The element !! fluid velocity is the mean of the current at its two nodes, rotated into the solve - !! frame. + !! frame. A depth profile is sampled at the nodes' elevations and a current grid at their + !! positions, so the current moves with them: the Jacobian carries that dependence too + !! (below). TYPE(CD_HermiteStaticCurrentType), INTENT(IN) :: current REAL(wp), INTENT(IN) :: qe(12), l0e, d, cn, ct LOGICAL, INTENT(IN) :: want_jac REAL(wp), INTENT(OUT) :: fd(12), djq(12, 12) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: ve(12), djv(12, 12), ua(3), ub(3), ug(3), ul(3) + REAL(wp) :: ve(12), djv(12, 12), ua(3), ub(3), ug(3), ul(3), ga(3, 3), gb(3, 3), dfdu(12, 3), rot(3, 3) INTEGER :: es CHARACTER(200) :: em ErrStat = CD_HCSTAT_OK @@ -3002,6 +3026,32 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCSTAT_NOCONVERGE; ErrMsg = TRIM(em); RETURN END IF + IF (want_jac .AND. (ALLOCATED(current%grid) .OR. ALLOCATED(current%profile_z))) THEN + ! The current at the nodes moves with them. The element fluid velocity is + ! u = R^T (U(x_a) + U(x_b))/2, with R the turn of frame_cs (global = R solve frame, z + ! alone) and x = R (x_l + origin) the global node position (a profile reads only z), so + ! du/dx_l,a = R^T G_a R / 2 with G = dU/dx the field's gradient at the node. The drag sees + ! u - v(s), and a uniform velocity c of the element is the nodal velocity [c, 0, c, 0] + ! (its tangent rates zero: the Hermite shape functions of the two positions sum to one), + ! so d fd/du = -(djv(:, 1:3) + djv(:, 7:9)) and d fd/dx_l,a = d fd/du du/dx_l,a. Without + ! it a sheared current entered the Newton tangent as if it were uniform. + IF (ALLOCATED(current%grid)) THEN + CALL CD_Current_Grid_Gradient(current%grid, global_position(qe(1:3)), 0.0_wp, ga, es, em) + IF (es == CD_HYDRO_OK) CALL CD_Current_Grid_Gradient(current%grid, global_position(qe(7:9)), 0.0_wp, gb, & + es, em) + IF (es /= CD_HYDRO_OK) THEN + ErrStat = CD_HCSTAT_NOCONVERGE; ErrMsg = TRIM(em); RETURN + END IF + ELSE + CALL CD_Current_Profile_Gradient(qe(3), current%profile_z, current%profile_velocity, ga) + CALL CD_Current_Profile_Gradient(qe(9), current%profile_z, current%profile_velocity, gb) + END IF + rot = RESHAPE([current%frame_cs(1), current%frame_cs(2), CD_ZERO, -current%frame_cs(2), current%frame_cs(1), & + CD_ZERO, CD_ZERO, CD_ZERO, CD_ONE], [3, 3]) + dfdu = -(djv(:, 1:3) + djv(:, 7:9)) + djq(:, 1:3) = djq(:, 1:3) + 0.5_wp*MATMUL(dfdu, MATMUL(TRANSPOSE(rot), MATMUL(ga, rot))) + djq(:, 7:9) = djq(:, 7:9) + 0.5_wp*MATMUL(dfdu, MATMUL(TRANSPOSE(rot), MATMUL(gb, rot))) + END IF fd = current%load_factor*fd IF (want_jac) djq = current%load_factor*djq diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 02038957..d81f086c 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -1563,6 +1563,9 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra INTEGER, ALLOCATABLE :: elem_conn(:, :), fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mass_per_length(:), diameter(:) REAL(wp), ALLOCATABLE :: weight(:), elem_load(:, :), f_ext(:), q_static(:), v0(:) + ! the waterline and diameters of the dry part's weight in the static start (unallocated: + ! the static start keeps the buoyancy everywhere, as a model without buoyancy recovery) + REAL(wp), ALLOCATABLE :: dry_wl(:), dry_d(:) INTEGER :: n_elem, n_dof, e, es, istat, fr_policy LOGICAL :: dyn_to, friction_static REAL(wp) :: laid_az, laid_t @@ -1713,6 +1716,23 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL fail(ErrStat, ErrMsg, 'line model lay_azimuth must be finite') RETURN END IF + ! The dynamic model's buoyancy recovery gives the part of the line above the waterline its + ! dry weight; the static start does the same (CD_Static_Line_Equilibrium), so that a line + ! held above the surface starts in the equilibrium its march holds. + IF (PRESENT(buoyancy_waterline_z) .AND. PRESENT(buoyancy_rho) .AND. PRESENT(buoyancy_gravity)) THEN + IF (SIZE(buoyancy_waterline_z) == n_dof/3) THEN + IF (PRESENT(buoyancy_diameter_elem)) THEN + IF (SIZE(buoyancy_diameter_elem) == n_elem .AND. .NOT. PRESENT(buoyancy_diameter)) THEN + dry_wl = buoyancy_waterline_z + dry_d = buoyancy_diameter_elem + END IF + ELSE IF (PRESENT(buoyancy_diameter)) THEN + dry_wl = buoyancy_waterline_z + ALLOCATE (dry_d(n_elem)) + dry_d = buoyancy_diameter + END IF + END IF + END IF friction_static = .FALSE. IF (use_seabed .AND. use_seabed_friction) friction_static = seabed_mu > CD_ZERO .AND. & fr_policy == CD_STATIC_FRICTION_AS_LAID @@ -1770,7 +1790,9 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra IF (seabed_mu > CD_ZERO) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & - seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors) + seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, dry_gravity=buoyancy_gravity, & + dry_diameter=dry_d) IF (es /= CD_STATIC_OK .OR. .NOT. converged) THEN ErrStat = CD_MODEL_SOLVEFAIL ErrMsg = 'CableDyn_Model: still-water reference of the seabed friction failed: '//TRIM(em)// & @@ -1827,11 +1849,15 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & seabed_kn=seabed_kn, bathymetry=bathymetry, current=cur, & - load_factors=load_factors) + load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, dry_gravity=buoyancy_gravity, & + dry_diameter=dry_d) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & - seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors) + seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, dry_gravity=buoyancy_gravity, & + dry_diameter=dry_d) END IF IF (es /= CD_STATIC_OK) THEN ErrStat = CD_MODEL_SOLVEFAIL @@ -1859,12 +1885,16 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, & dyn_to, q_sw, conv_sw, report_sw, es, em, & seabed_z_floor=seabed_z_floor, seabed_kn=seabed_kn, & - bathymetry=bathymetry, current=cur_sw, load_factors=load_factors) + bathymetry=bathymetry, current=cur_sw, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, & + dry_gravity=buoyancy_gravity, dry_diameter=dry_d) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, & dyn_to, q_sw, conv_sw, report_sw, es, em, & seabed_z_floor=seabed_z_floor, seabed_kn=seabed_kn, & - bathymetry=bathymetry, load_factors=load_factors) + bathymetry=bathymetry, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, & + dry_gravity=buoyancy_gravity, dry_diameter=dry_d) END IF IF (es == CD_STATIC_OK .AND. conv_sw) THEN IF (ALLOCATED(cur%friction_ref)) THEN diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index a64d2849..6fd697ba 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -34,7 +34,7 @@ MODULE CableDyn_Static CD_Bathymetry_Floor_Gradient, CD_BATHY_OK USE CableDyn_Hydro, ONLY: CD_Cable_Morison_Drag_Force, CD_Morison_Drag_Element_Load, CD_Current_Profile_Velocity, & CD_CurrentGridType, CD_Current_Grid_Velocity, CD_Current_Grid_Gradient, & - CD_Current_Profile_Gradient, CD_HYDRO_OK + CD_Current_Profile_Gradient, CD_Buoyancy_Recovery_Element_Force, CD_HYDRO_OK USE CableDyn_Linalg, ONLY: CD_Solve_Banded USE CableDyn_Mesh, ONLY: CD_Partition_Free_Dofs USE CableDyn_Catenary, ONLY: CD_Catenary_Seed, CD_CAT_OK @@ -48,6 +48,7 @@ MODULE CableDyn_Static PUBLIC :: CD_Static_Cable_Solve_Continuation PUBLIC :: CD_Static_Line_Equilibrium PUBLIC :: CD_Static_Line_End_Forces + PUBLIC :: CD_Static_Line_Dry_Load PUBLIC :: CD_Static_Anchor_Seabed_Tolerance PUBLIC :: CD_Static_Friction_Anchors PUBLIC :: CD_Static_As_Laid_Reference @@ -1623,9 +1624,169 @@ END FUNCTION CD_Static_Anchor_Seabed_Tolerance SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, cfg, tension_only, & q, converged, report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, & - bathymetry, current, load_factors) + bathymetry, current, load_factors, dry_waterline_z, dry_rho, dry_gravity, & + dry_diameter, dry_load) !! Robust static equilibrium of one EI=0 line held at both ends: the single initializer - !! shared by the static-only deck route and the dynamic-model initial condition. + !! shared by the static-only deck route and the dynamic-model initial condition (see + !! line_equilibrium for the seeds and solver stages). + !! + !! f_ext is the submerged weight, full buoyancy everywhere. With the dry-part arguments + !! (dry_waterline_z per node, dry_rho, dry_gravity, dry_diameter per element) the part of + !! the line above its waterline carries its dry weight, as in the dynamic model's buoyancy + !! recovery (CD_Buoyancy_Recovery_Element_Force): each element straddling or above the + !! waterline gives back the buoyancy -(1 - f) rho g (pi/4) d^2 l0 / 2 at each of its nodes, + !! f its submerged fraction. A line held above the surface (a fairlead on deck) then starts + !! in the equilibrium the march holds; without them its dry part kept its buoyancy, and a + !! chain hung 5 m above the surface jumped by 1e-3 of its fairlead load in the first step. + !! The recovery load depends on the wetted lengths, so the solve is repeated with the + !! recovery of the last solution as a constant load until the nodes move by less than + !! DRY_TOL or the recovery changes by less than DRY_REL of the largest nodal load, below + !! what the solver's own residual tolerance resolves (a fixed point: it contracts at the + !! ratio of the recovery's stiffness rho g A / sin(inclination) to the line's own, a few + !! 1e-3 for a hanging chain). A fully submerged + !! line has no recovery and is solved once, unchanged. A fixed point that does not settle in + !! DRY_MAX solves (a line floating at the surface, whose dry weight is its whole restoring) + !! returns converged = .FALSE. with the reason. dry_load (optional) returns the recovery + !! load at the solution, zero without the dry-part arguments: f_ext + dry_load is the + !! external load of the equilibrium (its end forces, CD_Static_Line_End_Forces). + REAL(wp), INTENT(IN) :: anchor(3), fairlead(3) + INTEGER, INTENT(IN) :: elem_conn(:, :) + REAL(wp), INTENT(IN) :: l0(:), ea(:), weight(:), f_ext(:) + TYPE(CableSolverConfig), INTENT(IN) :: cfg + LOGICAL, INTENT(IN) :: tension_only + REAL(wp), INTENT(OUT) :: q(:) + LOGICAL, INTENT(OUT) :: converged + TYPE(CD_StaticLineReport), INTENT(OUT) :: report + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: seabed_z_floor + REAL(wp), INTENT(IN), OPTIONAL :: seabed_kn(:) + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + TYPE(CableCurrentLoad), INTENT(IN), OPTIONAL :: current + REAL(wp), INTENT(IN), OPTIONAL :: load_factors(:) + REAL(wp), INTENT(IN), OPTIONAL :: dry_waterline_z(:), dry_rho, dry_gravity, dry_diameter(:) + REAL(wp), INTENT(OUT), OPTIONAL :: dry_load(:) + ! fixed-point tolerances on the node positions [m] and on the recovery load (relative to + ! the largest nodal load), and the solve budget + REAL(wp), PARAMETER :: DRY_TOL = 1.0e-9_wp, DRY_REL = 1.0e-10_wp + INTEGER, PARAMETER :: DRY_MAX = 50 + REAL(wp), ALLOCATABLE :: f_dry(:), q_prev(:), f_prev(:) + REAL(wp) :: change, f_scale + INTEGER :: k, n_it + CHARACTER(64) :: num + + IF (PRESENT(dry_load)) dry_load = CD_ZERO + CALL line_equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, cfg, tension_only, q, converged, & + report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, bathymetry, current, load_factors) + IF (.NOT. (PRESENT(dry_waterline_z) .AND. PRESENT(dry_rho) .AND. PRESENT(dry_gravity) .AND. & + PRESENT(dry_diameter))) RETURN + IF (ErrStat /= CD_STATIC_OK .OR. .NOT. converged) RETURN + IF (SIZE(dry_waterline_z) /= SIZE(q)/3 .OR. SIZE(dry_diameter) /= SIZE(l0) .OR. & + (PRESENT(dry_load) .AND. SIZE(f_ext) /= SIZE(q))) THEN + CALL fail(ErrStat, ErrMsg, 'line equilibrium: dry_waterline_z (n_nodes) / dry_diameter (n_elem) shapes') + converged = .FALSE. + RETURN + END IF + IF (PRESENT(dry_load)) THEN + IF (SIZE(dry_load) /= SIZE(q)) THEN + CALL fail(ErrStat, ErrMsg, 'line equilibrium: dry_load must have shape (3 n_nodes)') + converged = .FALSE. + RETURN + END IF + END IF + ALLOCATE (f_dry(SIZE(q)), q_prev(SIZE(q)), f_prev(SIZE(q))) + CALL dry_recovery(q, f_dry) + IF (ErrStat /= CD_STATIC_OK) RETURN + ! fully submerged: no recovery, the solution stands as solved + IF (ALL(f_dry == CD_ZERO)) RETURN + f_scale = MAXVAL(ABS(f_ext)) + n_it = report%n_iter + DO k = 1, DRY_MAX + q_prev = q + f_prev = f_dry + CALL line_equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext + f_dry, cfg, tension_only, q, & + converged, report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, bathymetry, current, & + load_factors) + n_it = n_it + report%n_iter + report%n_iter = n_it + IF (ErrStat /= CD_STATIC_OK) RETURN + IF (.NOT. converged) THEN + report%message = 'with the dry weight above the waterline: '//TRIM(report%message) + RETURN + END IF + change = MAXVAL(ABS(q - q_prev)) + CALL dry_recovery(q, f_dry) + IF (ErrStat /= CD_STATIC_OK) RETURN + IF (change <= DRY_TOL .OR. MAXVAL(ABS(f_dry - f_prev)) <= DRY_REL*f_scale) THEN + ! the recovery the returned state was solved with (its end forces balance it exactly) + IF (PRESENT(dry_load)) dry_load = f_prev + RETURN + END IF + END DO + converged = .FALSE. + WRITE (num, '(ES9.2)') change + report%message = 'the dry weight above the waterline did not settle to a fixed point (the nodes still move '// & + TRIM(ADJUSTL(num))//' m per solve): a line floating at the surface is outside the EI = 0 '// & + 'static start' + + CONTAINS + + SUBROUTINE dry_recovery(qs, f) + !! The buoyancy recovery of the dry part of every element in state qs. + REAL(wp), INTENT(IN) :: qs(:) + REAL(wp), INTENT(OUT) :: f(:) + INTEGER :: es + CHARACTER(1024) :: em + CALL CD_Static_Line_Dry_Load(qs, elem_conn, l0, dry_waterline_z, dry_rho, dry_gravity, dry_diameter, f, es, em) + IF (es /= CD_STATIC_OK) THEN + CALL fail(ErrStat, ErrMsg, 'line equilibrium: '//TRIM(em)) + converged = .FALSE. + END IF + END SUBROUTINE dry_recovery + END SUBROUTINE CD_Static_Line_Equilibrium + + SUBROUTINE CD_Static_Line_Dry_Load(q, elem_conn, l0, waterline_z, rho, gravity, diameter, f, ErrStat, ErrMsg) + !! The dry part's weight of an EI = 0 line in state q (3 n_nodes), as the dynamic model's + !! buoyancy recovery gives it (CD_Buoyancy_Recovery_Element_Force): each element straddling + !! or above the waterline (waterline_z per node) gives back the buoyancy + !! -(1 - f) rho g (pi/4) d^2 l0 / 2 at each of its nodes, f its submerged fraction + !! (diameter per element). f is exactly zero for a line wholly below its waterline. + REAL(wp), INTENT(IN) :: q(:) + INTEGER, INTENT(IN) :: elem_conn(:, :) + REAL(wp), INTENT(IN) :: l0(:), waterline_z(:), rho, gravity, diameter(:) + REAL(wp), INTENT(OUT) :: f(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: fe(6) + INTEGER :: e, a, b, es + CHARACTER(1024) :: em + ErrStat = CD_STATIC_OK + ErrMsg = '' + f = CD_ZERO + IF (SIZE(waterline_z) /= SIZE(q)/3 .OR. SIZE(diameter) /= SIZE(l0) .OR. SIZE(f) /= SIZE(q) .OR. & + SIZE(elem_conn, 2) /= SIZE(l0)) THEN + CALL fail(ErrStat, ErrMsg, 'dry-part buoyancy: waterline_z (n_nodes) / diameter (n_elem) / f shapes') + RETURN + END IF + DO e = 1, SIZE(l0) + a = elem_conn(1, e) + b = elem_conn(2, e) + CALL CD_Buoyancy_Recovery_Element_Force(q(3*a - 2:3*a), q(3*b - 2:3*b), l0(e), waterline_z(a), & + waterline_z(b), rho, diameter(e), gravity, fe, es, em) + IF (es /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'dry-part buoyancy: '//TRIM(em)) + RETURN + END IF + f(3*a - 2:3*a) = f(3*a - 2:3*a) + fe(1:3) + f(3*b - 2:3*b) = f(3*b - 2:3*b) + fe(4:6) + END DO + END SUBROUTINE CD_Static_Line_Dry_Load + + SUBROUTINE line_equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, cfg, tension_only, & + q, converged, report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, & + bathymetry, current, load_factors) + !! Robust static equilibrium of one EI=0 line held at both ends under the constant load + !! f_ext (CD_Static_Line_Equilibrium adds the dry part above the waterline). !! !! Node 1 is the anchor and node n the fairlead (both held); weight is the signed !! submerged weight per unit length of each element (downward positive) used by the seeds, @@ -2355,7 +2516,7 @@ SUBROUTINE seabed_slope_along(x, y, hd, g) IF (es_g == CD_BATHY_OK) g = gx*hd(1) + gy*hd(2) END SUBROUTINE seabed_slope_along - END SUBROUTINE CD_Static_Line_Equilibrium + END SUBROUTINE line_equilibrium SUBROUTINE polyline_seed(anchor, fairlead, l0, has_seabed, z_floor, q) !! Positions-only seed that never compresses a line longer than its chord: the nodes are diff --git a/tests/test_hermite_static_current_gradient.f90 b/tests/test_hermite_static_current_gradient.f90 new file mode 100644 index 00000000..ca0cba1e --- /dev/null +++ b/tests/test_hermite_static_current_gradient.f90 @@ -0,0 +1,233 @@ +! File: tests/test_hermite_static_current_gradient.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_static_current_gradient + !! The finite-EI static tangent of a depth-profile current: the drag samples the profile at + !! the node elevations, so it moves with the nodes, and the Newton tangent carries that + !! dependence (the current's vertical gradient times the drag's velocity derivative). On a + !! 260 m cable (60 elements, EA 4.69e8 N, EI 1.99e4 N m^2, 157.8 N/m) hung between + !! (0, 0, -20) and (200, 0, -150) m, in three sheared currents at their static equilibrium: + !! 1. the drag part of the solver's tangent (the tangent with the current less the tangent + !! without it, both from CD_HermiteCable_Static_Solve at the same state) against central + !! differences of the drag part of its residual, over the vertical position columns where + !! the profile enters: within 1e-5 (measured 4e-10 to 8e-10; without the gradient term it + !! was off by 5.4e-2, 6.7e-2 and 0.20 in the three currents); + !! 2. the Newton iterations from the still-water equilibrium to the current's at tol 1e-8, + !! printed (7/5/6 before, 7/5/5 with the gradient), the equilibria within the solver + !! tolerance of the previous ones. + !! A fourth current is a grid (MoorDyn-C Currents 2 and 5) varying along x, y and z, sampled in a + !! solve frame turned by 30 deg about z and shifted from the global origin, where the gradient + !! enters every position column as R^T (dU/dx) R / 2: gate 1 over all the free position + !! columns (measured 1.7e-9; without the gradient term 3.9e-2). + !! A fifth case restrains the cable in torsion at both ends (GJ 1e5 N m^2 with the torque-tension + !! coupling K/GJ = 0.02, ends pinned in bending, a quarter turn) in the cross-flow shear of case 1. + !! The twisted solve assembles the drag and its tangent in the same residual as the untwisted one + !! (its condensed-torsion Newton system and stability test add the torque's terms to it), so the + !! gate is the twisted solve's convergence, stable, with a torque, and gate 1 at its twisted, out + !! of plane equilibrium (the solver returns no tangent with torsion: the drag part is evaluated + !! there without it), over the vertical columns. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HermiteStaticCurrentType, CD_HCSTAT_OK + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED + USE CableDyn_Hydro, ONLY: CD_CurrentGridType + IMPLICIT NONE + INTEGER, PARAMETER :: NE = 60, NN = NE + 1, NDOF = 6*NN, KL = 11, KU = 11, LDAB = 2*KL + KU + 1 + REAL(wp), PARAMETER :: LEN = 260.0_wp, PI = 3.14159265358979323846_wp + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(NDOF), q_sw(NDOF), q(NDOF), curv(NN), res, s + REAL(wp) :: a(3), b(3) + INTEGER :: it, es, i, k, icase, nfail + INTEGER, ALLOCATABLE :: fixed(:) + CHARACTER(1024) :: em + TYPE(CD_HermiteStaticCurrentType) :: cur + ! case 5: the torsion of the twisted solve and its end directions + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: tdir(3, 2) + + nfail = 0 + l0 = LEN/NE + EA = 4.69e8_wp + EI = 1.99e4_wp + w = 157.8_wp + a = [0.0_wp, 0.0_wp, -20.0_wp] + b = [200.0_wp, 0.0_wp, -150.0_wp] + DO i = 1, NN + s = REAL(i - 1, wp)/NE + seed(6*(i - 1) + 1:6*(i - 1) + 3) = a + s*(b - a) + [0.0_wp, 0.0_wp, -240.0_wp*s*(1.0_wp - s)] + END DO + DO i = 1, NN + k = MIN(NE, i) + seed(6*(i - 1) + 4:6*(i - 1) + 6) = (seed(6*k + 1:6*k + 3) - seed(6*(k - 1) + 1:6*(k - 1) + 3))/l0(1) + END DO + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed, -1.0e4_wp, 0.0_wp, 10, 400, 1.0e-10_wp, 0.7_wp, & + q_sw, curv, res, it, es, em) + CALL check(es == CD_HCSTAT_OK, 'still-water equilibrium: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) ERROR STOP 1 + + DO icase = 1, 4 + CALL set_current(icase) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, q_sw, fixed, -1.0e4_wp, 0.0_wp, 1, 400, 1.0e-8_wp, 1.0_wp, & + q, curv, res, it, es, em, current=cur) + CALL check(es == CD_HCSTAT_OK, 'equilibrium in the current: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) CYCLE + WRITE (*, '(A,I0,A,I0,A,ES10.2,A,3F12.6)') ' case ', icase, ': Newton iterations from still water ', it, & + ', residual ', res, ', mid-span node ', q(6*(NE/2) + 1:6*(NE/2) + 3) + CALL check_drag_tangent(icase, q) + END DO + + ! 5. restrained in torsion (GJ|K), a quarter turn, in the cross-flow shear of case 1 + IF (ALLOCATED(cur%grid)) DEALLOCATE (cur%grid) + cur%frame_cs = [1.0_wp, 0.0_wp] + cur%origin = [0.0_wp, 0.0_wp] + CALL set_current(1) + tdir(:, 1) = q_sw(4:6)/NORM2(q_sw(4:6)) + tdir(:, 2) = q_sw(NDOF - 2:NDOF)/NORM2(q_sw(NDOF - 2:NDOF)) + tors%active = .TRUE. + ALLOCATE (tors%gj(NE), tors%couple(NE)) + tors%gj = 1.0e5_wp + tors%couple = 0.02_wp + tors%phi = 0.5_wp*PI + tors%ends(:, 1) = tdir(:, 1) + tors%ends(:, 2) = [0.0_wp, 1.0_wp, 0.0_wp] + tors%ends(:, 3) = tdir(:, 2) + tors%ends(:, 4) = [0.0_wp, 1.0_wp, 0.0_wp] + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, q_sw, fixed, -1.0e4_wp, 0.0_wp, 1, 400, 1.0e-8_wp, 1.0_wp, & + q, curv, res, it, es, em, current=cur, endconn_stiffness=[0.0_wp, 0.0_wp], & + endconn_direction=tdir, endconn_mode=[CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], & + torsion=tors) + CALL check(es == CD_HCSTAT_OK, 'twisted equilibrium in the current: '//TRIM(em)) + IF (es == CD_HCSTAT_OK) THEN + WRITE (*, '(A,I0,A,ES10.2,A,ES12.5,A,L1)') ' case 5 (torsion): Newton iterations ', it, ', residual ', res, & + ', torque ', tors%torque, ' N m, stable ', tors%stable + CALL check(ABS(tors%torque) > 1.0e2_wp, 'the twisted line carries a torque') + CALL check(tors%stable, 'the twisted equilibrium in the current is stable') + CALL check_drag_tangent(5, q) + END IF + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAILED: ', nfail, ' check(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: finite-EI static tangent of a depth-profile current' + +CONTAINS + + SUBROUTINE check(ok, what) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: what + IF (ok) RETURN + WRITE (*, '(2A)') ' FAIL: ', what + nfail = nfail + 1 + END SUBROUTINE check + + SUBROUTINE set_current(icase) + !! 1: cross-flow shear, 0 at -150 m to 1.2 m/s at the surface; 2: in-plane shear reversing + !! with depth; 3: oblique, strongly sheared near the surface and held above -10 m; 4: a grid + !! varying along x, y and z in a solve frame turned by 30 deg and shifted by (40, -25) m. + INTEGER, INTENT(IN) :: icase + INTEGER :: ix, iy, iz + cur%rho = 1025.0_wp + cur%waterline_z = 0.0_wp + cur%arc_end = [LEN] + cur%diam = [0.16_wp] + cur%cdn = [1.2_wp] + cur%cdt = [0.1_wp] + SELECT CASE (icase) + CASE (1) + cur%profile_z = [-150.0_wp, 0.0_wp] + cur%profile_velocity = RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.2_wp, 0.0_wp], [3, 2]) + CASE (2) + cur%profile_z = [-150.0_wp, -60.0_wp, 0.0_wp] + cur%profile_velocity = RESHAPE([-0.6_wp, 0.0_wp, 0.0_wp, 0.2_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], & + [3, 3]) + CASE (3) + cur%profile_z = [-150.0_wp, -40.0_wp, -10.0_wp] + cur%profile_velocity = RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.3_wp, 0.3_wp, 0.0_wp, 1.0_wp, 1.5_wp, 0.0_wp], & + [3, 3]) + CASE (4) + IF (ALLOCATED(cur%profile_z)) DEALLOCATE (cur%profile_z, cur%profile_velocity) + ALLOCATE (cur%grid) + cur%grid%x = [-100.0_wp, 50.0_wp, 150.0_wp, 300.0_wp] + cur%grid%y = [-200.0_wp, 0.0_wp, 200.0_wp] + cur%grid%z = [-200.0_wp, -100.0_wp, -50.0_wp, 0.0_wp] + cur%grid%nt = 1 + ALLOCATE (cur%grid%velocity(3, 4, 3, 4, 1)) + DO iz = 1, 4 + DO iy = 1, 3 + DO ix = 1, 4 + cur%grid%velocity(:, ix, iy, iz, 1) = [0.3_wp + 0.002_wp*cur%grid%x(ix) + 0.004_wp*cur%grid%z(iz), & + 0.5_wp + 0.004_wp*cur%grid%z(iz) - 0.001_wp*cur%grid%y(iy), & + 0.0002_wp*cur%grid%x(ix)] + END DO + END DO + END DO + cur%frame_cs = [COS(PI/6.0_wp), SIN(PI/6.0_wp)] + cur%origin = [40.0_wp, -25.0_wp] + END SELECT + END SUBROUTINE set_current + + SUBROUTINE evaluate(qx, with_current, r, ab) + !! The solver's residual and banded tangent at qx (no Newton update: tol = HUGE). + REAL(wp), INTENT(IN) :: qx(NDOF) + LOGICAL, INTENT(IN) :: with_current + REAL(wp), INTENT(OUT) :: r(NDOF), ab(LDAB, NDOF) + REAL(wp) :: qd(NDOF), cd(NN), rr + INTEGER :: itx, esx + CHARACTER(512) :: emx + IF (with_current) THEN + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, -1.0e4_wp, 0.0_wp, 1, 1, HUGE(1.0_wp), 1.0_wp, & + qd, cd, rr, itx, esx, emx, current=cur, residual_out=r, tangent_out=ab) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, -1.0e4_wp, 0.0_wp, 1, 1, HUGE(1.0_wp), 1.0_wp, & + qd, cd, rr, itx, esx, emx, residual_out=r, tangent_out=ab) + END IF + CALL check(esx == CD_HCSTAT_OK, 'residual and tangent evaluation: '//TRIM(emx)) + END SUBROUTINE evaluate + + SUBROUTINE check_drag_tangent(icase, qs) + !! 1: the drag part of the tangent against central differences of the drag part of the + !! residual, over the free vertical position columns. + INTEGER, INTENT(IN) :: icase + REAL(wp), INTENT(IN) :: qs(NDOF) + REAL(wp), PARAMETER :: H = 1.0e-5_wp + REAL(wp) :: rc(NDOF), rs(NDOF), abc(LDAB, NDOF), abs_(LDAB, NDOF), dum(LDAB, NDOF), qp(NDOF) + REAL(wp) :: rp(NDOF), rm(NDOF), col_fd(NDOF), col_an(NDOF), num, den + INTEGER :: j, node, ii, jj + CALL evaluate(qs, .TRUE., rc, abc) + CALL evaluate(qs, .FALSE., rs, abs_) + num = 0.0_wp + den = 0.0_wp + DO jj = 1, MERGE(3*(NE - 1), NE - 1, icase == 4) + IF (icase == 4) THEN + node = 2 + (jj - 1)/3 + j = 6*(node - 1) + 1 + MOD(jj - 1, 3) + ELSE + node = jj + 1 + j = 6*(node - 1) + 3 + END IF + qp = qs + qp(j) = qs(j) + H + CALL evaluate(qp, .TRUE., rc, dum) + CALL evaluate(qp, .FALSE., rs, dum) + rp = rc - rs + qp(j) = qs(j) - H + CALL evaluate(qp, .TRUE., rc, dum) + CALL evaluate(qp, .FALSE., rs, dum) + rm = rc - rs + col_fd = (rp - rm)/(2.0_wp*H) + col_an = 0.0_wp + DO ii = MAX(1, j - KU), MIN(NDOF, j + KL) + col_an(ii) = abc(KL + KU + 1 + ii - j, j) - abs_(KL + KU + 1 + ii - j, j) + END DO + DO ii = 1, NDOF + IF (ANY(fixed == ii)) CYCLE + num = num + (col_an(ii) - col_fd(ii))**2 + den = den + col_fd(ii)**2 + END DO + END DO + WRITE (*, '(A,I0,A,A,ES10.3)') ' case ', icase, ': drag tangent vs central differences, ', & + MERGE('position columns:', 'vertical columns:', icase == 4), SQRT(num/den) + CALL check(SQRT(num/den) <= 1.0e-5_wp, 'the drag tangent carries the current''s vertical gradient') + END SUBROUTINE check_drag_tangent +END PROGRAM test_hermite_static_current_gradient diff --git a/tests/test_line_attachments.f90 b/tests/test_line_attachments.f90 index 9795d5ea..c69dcfe7 100644 --- a/tests/test_line_attachments.f90 +++ b/tests/test_line_attachments.f90 @@ -20,8 +20,53 @@ PROGRAM test_line_attachments !! 7. Acceptance of a fallback attachment state (CD_Attachment_Discrete_Verdict): a slope !! jump beside an attachment node passes the kink limit; the same bend away from it, a !! compressed state under tensile_safety and an unstable state fail closed by name. + !! 8. A neutral line whose length equals its span (straight at zero strain, no weight, no + !! tension) with neutral modules (m = rho V) or with a drag area alone, pinned or clamped: + !! the static start converges and stays straight and unloaded (fairlead tension below + !! 1e-3 N). Its residual sits at the round-off floor of the axial forces, about + !! eps max(EA/l0) |x| = 9e-8 N here, above tol x 1 N, where the polish stalled at every + !! load step; the convergence scale now keeps tol x scale at 16 times that floor. Heavy + !! modules on the same line (which carry it into tension) still solve. Restrained in + !! torsion (GJ 5e4 N m^2, a quarter turn at End B), the neutral-module line carries the + !! torque GJ Phi / L to 1e-6. The same with End B on a Coupled point (two moving ends): + !! neutral modules and a drag area alone stay unloaded, the line restrained in torsion at + !! both ends carries GJ Phi / L to 1e-6, and a span 1e-8 longer than the line (two moving + !! ends whose chord exceeds the length, a 0.1 N tension that the tension bound of the + !! convergence scale alone put below the floor) carries EA (chord / L - 1) to 2e-6 N + !! (measured 2.2e-7 N). Restrained in torsion at End A only (End B free in torsion), the + !! line starts untwisted. Each of these failed in the polish before the floor. + !! 9. A bending-pinned cable from a moored body (a keel point, 45 deg towards a Fixed anchor) + !! carrying a 2 t clump 50 m along it, with and without its END CONNECTIONS row: the body + !! static solve balances the body on the cubic-Hermite cable's end loads (the passes of the + !! connected ends), so the body holds its static pose over 5 s of the march to 1e-5 m and + !! 1e-4 deg (measured 0, the output's 8 digits). The cable without bending stiffness that + !! the body solve otherwise takes for a pinned line does not carry the clump: the body + !! started at the pose of the line without it and drifted by up to 2.9e-2 m and 0.20 deg. + !! 10. The pinned cable with the clump of case 9 from a Point3 buoy, where a finite-EI end is not + !! supported: the deck is refused by that name. Before, the body passes of case 9 took the + !! line and refused it as a clamped or elastic END CONNECTION on a body that is not Rigid6, + !! which the deck does not have. + !! 11. A free buoyant spar rod (10 m, 1 m diameter) on four taut legs with a finite-EI cable + !! pinned at its upper end carrying a 1500 kg clump 25 m along it; bodyIC static: the body + !! static passes converge (6, on the core cable that carries the clump smeared) and the rod + !! holds its static pose over 0.3 s of the march (dtM 0.002 s) to 1e-6 m (measured 0) and + !! the leg tensions to 1e-5 (measured 3e-7). Before, the plain passes diverged (end-load + !! change 2.9 of the force scale after 60 passes) and the deck stopped. + !! 12. The spar rod of case 11 with the cable and no clump: the bending share of the pinned + !! cable's end force is in the rod's static balance too, so the rod holds its pose over + !! 0.3 s to 1e-6 m (measured 0) and its leg tensions to 1e-5 (measured 0). Before, the + !! body passes left a pinned line without ATTACHMENTS to the core's cable without bending + !! stiffness: the rod started 5.7e-2 m off its equilibrium and its top moved 1.8e-4 m in 0.1 s + !! (dtM 0.01 s; 7e-2 m and a 2.3 % leg tension change in 3 s with the implicit object + !! coupling). + !! 13. The static start of case 11 does not hinge on round-off: with the anchor of a leg moved + !! by 1 ulp either way (x = 25 m -+ 3.6e-15 m) the passes converge to the same rod pose to + !! 1e-9 m (measured 0) in at most 10 passes (measured 6). Before, the Anderson fit kept + !! columns of round-off size and the passes converged in 26, or ran out after 60 (the + !! relative end-load change 1.5) or turned the rod over, by that 1 ulp. USE CableDyn_Precision, ONLY: wp - USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Attachment_Discrete_Verdict + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Attachment_Discrete_Verdict, & + CD_Body_Static_Pass_Limit USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & CD_AGG_UpdateStates_Moving, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & @@ -47,6 +92,13 @@ PROGRAM test_line_attachments CALL case_grammar() CALL case_coupled() CALL case_fallback_verdict() + CALL case_zero_strain() + CALL case_zero_strain_moving() + CALL case_pinned_body_clump() + CALL case_pinned_point3_clump() + CALL case_pinned_rod_clump(.TRUE.) + CALL case_pinned_rod_clump(.FALSE.) + CALL case_pinned_rod_roundoff() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -58,6 +110,541 @@ PROGRAM test_line_attachments INCLUDE 'nan_max_abs.inc' + SUBROUTINE case_zero_strain() + !! 8: a 100 m neutral line (Diam 0.2 m, mass rho pi d^2/4, EA 1e7, EI 1e6) between a Coupled + !! point and a Fixed one 100 m apart, 40 elements, TMax 0, with three modules at 25 m pitch. + CHARACTER(160) :: trow + ! the module rows: neutral (m = rho V), a drag area alone, heavy + CHARACTER(*), PARAMETER :: ROW1 = '1 25.0:25.0:75.0 102.5 0.1 0.0 0.0 0.0' + CHARACTER(*), PARAMETER :: ROW2 = '1 25.0:25.0:75.0 0.0 0.0 0.1 0.0 0.0' + CHARACTER(*), PARAMETER :: ROW3 = '1 25.0:25.0:75.0 200.0 0.1 0.0 0.0 0.0' + CHARACTER(64) :: rows(3) + CHARACTER(16) :: label(3) + REAL(wp), ALLOCATABLE :: d(:, :) + INTEGER :: k, iend, u, nrow + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(32) :: root + rows = [CHARACTER(64) :: ROW1, ROW2, ROW3] + label = [CHARACTER(16) :: 'neutral modules', 'drag area alone', 'heavy modules'] + WRITE (trow, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 0.0 0.0 0.0 0.0' + DO iend = 1, 2 + DO k = 1, 3 + WRITE (root, '(A,I0,A,I0)') 'att_span_', k, '_', iend + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'neutral line of the length of its span with attachments' + 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)') TRIM(trow) + 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 -50.0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.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)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') TRIM(rows(k)) + IF (iend == 2) THEN + 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 Rigid 1 0 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0' + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--------------------- END ----------------------------------------------------' + CLOSE (u) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '8 '//TRIM(label(k))//MERGE(' (clamped)', ' (pinned) ', iend == 2)// & + ': the static start of a line as long as its span converges: '//TRIM(msg)) + IF (.NOT. ok) CYCLE + CALL read_out(TRIM(root)//'.out', d, nrow, 2) + CALL require(nrow >= 1, '8 '//TRIM(label(k))//': static row written') + IF (nrow < 1) CYCLE + WRITE (*, '(A,A,A,ES12.4,A)') ' 8 ', TRIM(label(k)), MERGE(' (clamped)', ' (pinned) ', iend == 2), & + d(2, 1), ' N fairlead tension' + IF (k < 3) CALL require(ABS(d(2, 1)) < 1.0e-3_wp, '8 '//TRIM(label(k))//': the line stays unloaded') + IF (k == 3) CALL require(d(2, 1) > 1.0e3_wp, '8 heavy modules: the line is carried into tension') + END DO + END DO + ! restrained in torsion, pinned in bending, a quarter turn at End B + WRITE (trow, '(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' + root = 'att_span_torsion' + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'neutral line of the length of its span with neutral attachments, restrained in torsion' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(trow) + 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 -50.0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.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)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') TRIM(rows(1)) + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Pinned 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Pinned 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.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') '--------------------- END ----------------------------------------------------' + CLOSE (u) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '8 torsion: the static start of a line as long as its span converges: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out(TRIM(root)//'.out', d, nrow, 3) + CALL require(nrow >= 1, '8 torsion: static row written') + IF (nrow < 1) RETURN + WRITE (*, '(A,ES16.8,A,ES16.8,A)') ' 8 torsion: torque ', d(3, 1), ' N m, GJ Phi / L ', & + 5.0e4_wp*0.5_wp*PI/100.0_wp, ' N m' + CALL require(ABS(d(3, 1) - 5.0e4_wp*0.5_wp*PI/100.0_wp) <= 1.0e-6_wp*5.0e4_wp*0.5_wp*PI/100.0_wp, & + '8 torsion: the straight line carries GJ Phi / L') + END SUBROUTINE case_zero_strain + + SUBROUTINE case_zero_strain_moving() + !! 8 (continued): the line of case 8 with End B on a Coupled point (two moving ends), and + !! restrained in torsion at End A only. + CHARACTER(*), PARAMETER :: NEUTRAL = '1 25.0:25.0:75.0 102.5 0.1 0.0 0.0 0.0' + CHARACTER(*), PARAMETER :: DRAG = '1 25.0:25.0:75.0 0.0 0.0 0.1 0.0 0.0' + CHARACTER(*), PARAMETER :: TORS_HDR = 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + CHARACTER(*), PARAMETER :: TORS_UNITS = '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: chord, ten + INTEGER :: nrow + LOGICAL :: ok + ! two moving ends: neutral modules, a drag area alone + CALL span_deck('att_span_b1', 'Coupled', '100.0', NEUTRAL, .FALSE., [CHARACTER(64) ::], ['FairTen1']) + CALL span_run('att_span_b1', 'two moving ends, neutral modules', 2, d, nrow, ok) + IF (ok) CALL require(ABS(d(2, 1)) < 1.0e-3_wp, '8 two moving ends, neutral modules: the line stays unloaded') + CALL span_deck('att_span_b2', 'Coupled', '100.0', DRAG, .FALSE., [CHARACTER(64) ::], ['FairTen1']) + CALL span_run('att_span_b2', 'two moving ends, drag area alone', 2, d, nrow, ok) + IF (ok) CALL require(ABS(d(2, 1)) < 1.0e-3_wp, '8 two moving ends, drag area alone: the line stays unloaded') + ! two moving ends whose chord exceeds the length by 1e-8: tension EA (chord/L - 1) = 0.1 N + CALL span_deck('att_span_b3', 'Coupled', '100.000001', NEUTRAL, .FALSE., [CHARACTER(64) ::], ['FairTen1']) + CALL span_run('att_span_b3', 'two moving ends, chord above the length', 2, d, nrow, ok) + IF (ok) THEN + chord = 100.000001_wp + ten = 1.0e7_wp*(chord/100.0_wp - 1.0_wp) + WRITE (*, '(A,ES16.8,A,ES16.8,A)') ' 8 two moving ends, chord above the length: tension ', d(2, 1), & + ' N, EA (chord/L - 1) ', ten, ' N' + CALL require(ABS(d(2, 1) - ten) <= 2.0e-6_wp, '8 two moving ends, chord above the length: EA (chord/L - 1)') + END IF + ! two moving ends restrained in torsion at both ends, a quarter turn at End B + CALL span_deck('att_span_b4', 'Coupled', '100.0', NEUTRAL, .TRUE., & + [CHARACTER(80) :: TORS_HDR, TORS_UNITS, '1 A Pinned 1 0 0 Rigid 0 0 1 0', & + '1 B Pinned 1 0 0 Rigid 0 0 1 90'], ['FairTen1', 'Torq1N1 ']) + CALL span_run('att_span_b4', 'two moving ends, torsion', 3, d, nrow, ok) + IF (ok) THEN + WRITE (*, '(A,ES16.8,A,ES16.8,A)') ' 8 two moving ends, torsion: torque ', d(3, 1), ' N m, GJ Phi / L ', & + 5.0e4_wp*0.5_wp*PI/100.0_wp, ' N m' + CALL require(ABS(d(3, 1) - 5.0e4_wp*0.5_wp*PI/100.0_wp) <= 1.0e-6_wp*5.0e4_wp*0.5_wp*PI/100.0_wp, & + '8 two moving ends, torsion: the straight line carries GJ Phi / L') + END IF + ! restrained in torsion at End A only + CALL span_deck('att_span_b5', 'Fixed', '100.0', NEUTRAL, .TRUE., & + [CHARACTER(80) :: TORS_HDR, TORS_UNITS, '1 A Pinned 1 0 0 Rigid 0 0 1 0', & + '1 B Pinned 1 0 0 Free 0 0 1 0'], ['FairTen1', 'Twist1 ']) + CALL span_run('att_span_b5', 'torsion at End A only', 3, d, nrow, ok) + IF (ok) THEN + WRITE (*, '(A,ES12.4,A,ES12.4,A)') ' 8 torsion at End A only: tension ', d(2, 1), ' N, twist ', d(3, 1), ' deg' + CALL require(ABS(d(2, 1)) < 1.0e-3_wp .AND. ABS(d(3, 1)) < 1.0e-6_wp, & + '8 torsion at End A only: the line starts straight, unloaded and untwisted') + END IF + END SUBROUTINE case_zero_strain_moving + + SUBROUTINE span_deck(root, end_b_type, end_b_x, att_row, torsion, endconn_rows, outputs) + !! The neutral 100 m line of case 8 (40 elements, TMax 0) from a Coupled End A at + !! (0, 0, -50) m to End B of type end_b_type at (end_b_x, 0, -50) m, with one ATTACHMENTS row; + !! torsion: the line type with GJ 5e4 N m^2 (and its END CONNECTIONS rows). + CHARACTER(*), INTENT(IN) :: root, end_b_type, end_b_x, att_row + LOGICAL, INTENT(IN) :: torsion + CHARACTER(*), INTENT(IN) :: endconn_rows(:), outputs(:) + CHARACTER(160) :: trow + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=root//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'neutral line of the length of its span with attachments' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + IF (torsion) THEN + WRITE (trow, '(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)') '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) (-) (-) (-) (-)' + ELSE + WRITE (trow, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 0.0 0.0 0.0 0.0' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + END IF + WRITE (u, '(A)') TRIM(trow) + 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 -50.0' + WRITE (u, '(A)') '2 '//end_b_type//' '//end_b_x//' 0.0 -50.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)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') att_row + IF (SIZE(endconn_rows) > 0) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + DO i = 1, SIZE(endconn_rows) + WRITE (u, '(A)') TRIM(endconn_rows(i)) + END DO + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + DO i = 1, SIZE(outputs) + WRITE (u, '(A)') TRIM(outputs(i)) + END DO + WRITE (u, '(A)') '--------------------- END ----------------------------------------------------' + CLOSE (u) + END SUBROUTINE span_deck + + SUBROUTINE span_run(root, label, ncol, d, nrow, ok) + !! Run a span_deck deck and read its static row (ncol columns, time first). + CHARACTER(*), INTENT(IN) :: root, label + INTEGER, INTENT(IN) :: ncol + REAL(wp), ALLOCATABLE, INTENT(OUT) :: d(:, :) + INTEGER, INTENT(OUT) :: nrow + LOGICAL, INTENT(OUT) :: ok + CHARACTER(1024) :: msg + nrow = 0 + CALL run(root//'.dat', root, ok, msg) + CALL require(ok, '8 '//label//': the static start of a line as long as its span converges: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out(root//'.out', d, nrow, ncol) + ok = nrow >= 1 + CALL require(ok, '8 '//label//': static row written') + IF (ok) WRITE (*, '(A,A,A,ES12.4,A)') ' 8 ', label, ': ', d(2, 1), ' N fairlead tension' + END SUBROUTINE span_run + + SUBROUTINE case_pinned_body_clump() + !! 9: a buoyant body (hydrostatic C44 = C55 = 2e6 N m/rad) on three EI = 0 legs, with a + !! finite-EI cable from its keel point at 45 deg towards a Fixed anchor, pinned in bending at + !! the body, carrying a 2 t clump 50 m along it; bodyIC static, 5 s of the march (dtM 0.05 s). + INTEGER :: u, k, nrow + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: dpos, dpitch + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(32) :: root + DO k = 1, 2 + root = MERGE('att_body_pin_row', 'att_body_pin ', k == 1) + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned cable with a clump on a moored body' + 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 2.0e4 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 0 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)') '--- 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 40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -20.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -20.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body1 0.0 0.0 -3.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 8 -' + 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 cab 100.0 50' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '4 50.0 2000.0 0.0 0.0 0.0' + IF (k == 1) THEN + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '4 A Pinned -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, '(A)') '5.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px' + WRITE (u, '(A)') 'Body1Pz' + WRITE (u, '(A)') 'Body1Ry' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '9 '//TRIM(root)//': runs: '//TRIM(msg)) + IF (.NOT. ok) CYCLE + CALL read_out(TRIM(root)//'.out', d, nrow, 4) + CALL require(nrow >= 101, '9 '//TRIM(root)//': 5 s written') + IF (nrow < 101) CYCLE + dpos = MAXVAL(ABS(d(2:3, 1:nrow) - SPREAD(d(2:3, 1), 2, nrow))) + dpitch = MAXVAL(ABS(d(4, 1:nrow) - d(4, 1))) + WRITE (*, '(A,A,A,ES10.3,A,ES10.3,A)') ' 9 ', TRIM(root), ': body drift over 5 s ', dpos, ' m, pitch ', & + dpitch, ' deg' + CALL require(dpos <= 1.0e-5_wp .AND. dpitch <= 1.0e-4_wp, & + '9 '//TRIM(root)//': the clump on a pinned cable is in the body''s static balance') + END DO + END SUBROUTINE case_pinned_body_clump + + SUBROUTINE case_pinned_point3_clump() + !! 10: a Point3 buoy (2 t, 10 m^3) on an EI = 0 leg, with the finite-EI cable of case 9 pinned + !! at it carrying the 2 t clump; bodyIC static. + INTEGER :: u + LOGICAL :: ok + CHARACTER(1024) :: msg + OPEN (NEWUNIT=u, FILE='att_point3_pin.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned cable with a clump on a Point3 buoy' + 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 2.0e4 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 Point3 0 0 -20 0 0 0 2.0e3 10.0 0.0 0.0 0.0 8.0 0.5 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 Body1 0.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 60.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -60.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '4 1 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 105.0 20' + WRITE (u, '(A)') '4 cab 110.0 50' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '4 50.0 2000.0 0.0 0.0 0.0' + 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, '(A)') '1.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point1Pz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run('att_point3_pin.dat', 'att_point3_pin', ok, msg) + WRITE (*, '(2A)') ' 10 pinned cable on a Point3 buoy: ', TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'Point3 buoy is not supported') > 0, & + '10 pinned cable with a clump on a Point3 buoy: refused by that name') + END SUBROUTINE case_pinned_point3_clump + + SUBROUTINE case_pinned_rod_clump(clump) + !! 11 (clump) and 12: 0.3 s of the march of pinned_rod_deck (dtM 0.002 s, which the explicit + !! coupling of the cable to the rod on this route needs to stay stable). + LOGICAL, INTENT(IN) :: clump + INTEGER :: nrow + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: dpos, dten + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(16) :: root, gate + root = MERGE('att_rod_pin ', 'att_rod_pin_no', clump) + gate = MERGE('11 with a clump', '12 alone ', clump) + CALL pinned_rod_deck(TRIM(root), clump, '25.0', '0.002', '0.3') + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, TRIM(gate)//', a pinned cable on a free rod: runs: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out(TRIM(root)//'.out', d, nrow, 6) + CALL require(nrow >= 151, TRIM(gate)//', a pinned cable on a free rod: the run written') + IF (nrow < 151) RETURN + dpos = MAXVAL(ABS(d(2:3, 1:nrow) - SPREAD(d(2:3, 1), 2, nrow))) + dten = MAXVAL(ABS(d(4:6, 1:nrow) - SPREAD(d(4:6, 1), 2, nrow))/SPREAD(ABS(d(4:6, 1)), 2, nrow)) + WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') ' ', TRIM(gate), ', a pinned cable on a free rod: rod top drift ', dpos, & + ' m, rel. leg tension ', dten + CALL require(dpos <= 1.0e-6_wp .AND. dten <= 1.0e-5_wp, & + TRIM(gate)//', a pinned cable on a free rod: the rod starts in the march''s equilibrium') + END SUBROUTINE case_pinned_rod_clump + + SUBROUTINE case_pinned_rod_roundoff() + !! 13: the static start of case 11 with leg anchor x = 25 m and 1 ulp either side of it. + CHARACTER(*), PARAMETER :: X3(3) = ['25.0 ', '24.999999999999996', '25.000000000000004'] + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: p0(2), dmax + INTEGER :: k, nrow + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(24) :: root + dmax = 0.0_wp + p0 = 0.0_wp + nrow = 0 + ok = .FALSE. + ! at most 10 passes + CALL CD_Body_Static_Pass_Limit(10) + DO k = 1, 3 + WRITE (root, '(A,I0)') 'att_rod_ulp', k + CALL pinned_rod_deck(TRIM(root), .TRUE., TRIM(X3(k)), '0.01', '0.0') + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '13 '//TRIM(root)//' (anchor x '//TRIM(X3(k))//'): the static start converges: '//TRIM(msg)) + IF (.NOT. ok) EXIT + CALL read_out(TRIM(root)//'.out', d, nrow, 6) + CALL require(nrow >= 1, '13 '//TRIM(root)//': static row written') + IF (nrow < 1) EXIT + IF (k == 1) p0 = d(2:3, 1) + dmax = MAX(dmax, MAXVAL(ABS(d(2:3, 1) - p0))) + END DO + CALL CD_Body_Static_Pass_Limit(0) + IF (.NOT. ok .OR. nrow < 1) RETURN + WRITE (*, '(A,ES10.3,A)') ' 13 anchor moved by 1 ulp: rod pose change ', dmax, ' m' + CALL require(dmax <= 1.0e-9_wp, '13 anchor moved by 1 ulp: the same static start') + END SUBROUTINE case_pinned_rod_roundoff + + SUBROUTINE pinned_rod_deck(root, clump, x3, dtm, tmax) + !! The spar rod from z = -30 m to -20 m in 50 m of water, two legs from each end (the first + !! to an anchor at x = x3), the cable from its upper end towards a Fixed point at + !! (-40, 0, -50) m, a 1500 kg clump 25 m along it with clump. + CHARACTER(*), INTENT(IN) :: root, x3, dtm, tmax + LOGICAL, INTENT(IN) :: clump + INTEGER :: u + OPEN (NEWUNIT=u, FILE=root//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned cable with a clump on a free spar rod' + 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.10 10.0 2.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.20 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0' + 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 300.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 0.0 0.0 -30.0 0.0 0.0 -20.0 1 -' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Rod1A 0.0 0.0 -30.0 0 0 0 0' + WRITE (u, '(A)') '2 Rod1B 0.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '3 Fixed '//x3//' 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -25.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed 0.0 30.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed 0.0 -30.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '7 Fixed -40.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 3 -' + WRITE (u, '(A)') '2 1 4 -' + WRITE (u, '(A)') '3 2 5 -' + WRITE (u, '(A)') '4 2 6 -' + WRITE (u, '(A)') '5 2 7 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 31.95 16' + WRITE (u, '(A)') '2 poly 31.95 16' + WRITE (u, '(A)') '3 poly 42.40 20' + WRITE (u, '(A)') '4 poly 42.40 20' + WRITE (u, '(A)') '5 cab 55.0 40' + IF (clump) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '5 25.0 1500.0 0.0 0.0 0.0' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') dtm//' dtM' + WRITE (u, '(A)') tmax//' TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point2px' + WRITE (u, '(A)') 'Point2pz' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') 'FairTen2' + WRITE (u, '(A)') 'FairTen3' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE pinned_rod_deck + SUBROUTINE case_fallback_verdict() !! A straight 10 m line on 1 m elements whose tangent at node 6 is turned by 0.6 rad: the !! two elements beside node 6 carry h*kappa of about 2.3, beyond the kink limit 0.7, as the diff --git a/tests/test_nodal_twist_dynamic.f90 b/tests/test_nodal_twist_dynamic.f90 index f4caa2fd..0a6bcf08 100644 --- a/tests/test_nodal_twist_dynamic.f90 +++ b/tests/test_nodal_twist_dynamic.f90 @@ -21,6 +21,12 @@ PROGRAM test_nodal_twist_dynamic !! (with the polar part) + elastic (with the twist) stays within the band of the line !! without torsion; a parent rolling the clamped line's end frame at a steady rate puts !! the continuum's polar kinetic energy into it, the held end section's spin included; + !! a line pinned in bending and rigid in torsion at both ends, twisted and swinging (13 deg + !! end bend angle): the spin c = (t x d).dt/dt / (1 + d.t) of the end section that the + !! carry G(d -> t) adds as the end tangent t moves, which the model leaves out of the + !! kinetic energy, the line's equations and the reaction alike (theory, Nodal twist), + !! carries at most 4e-6 of the peak kinetic energy with an extreme Irn = 1 kg m (6e-8 at + !! 0.02 kg m), below the step's own energy band; !! R restart: a rolling, torsionally damped run restored from a snapshot, and one rebuilt !! from the checkpoint mirror, continue bit-identically. USE CableDyn_Precision, ONLY: wp @@ -53,6 +59,7 @@ PROGRAM test_nodal_twist_dynamic CALL check_frame_damping() CALL check_energy() CALL check_frame_energy() + CALL check_pinned_energy() CALL check_restart() IF (nfail > 0) THEN @@ -580,6 +587,87 @@ SUBROUTINE check_frame_energy() CALL CD_HFMF_End(cab) END SUBROUTINE check_frame_energy + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_pinned_energy() + REAL(wp) :: band_lo, band_hi + CALL check_pinned_carry(0.02_wp, 1.0e-6_wp, band_lo) + CALL check_pinned_carry(1.0_wp, 1.0e-5_wp, band_hi) + CALL require(ABS(band_hi - band_lo) <= 0.05_wp*band_lo, & + 'E pinned: the energy band does not depend on the held sections'' polar inertia') + END SUBROUTINE check_pinned_energy + + SUBROUTINE check_pinned_carry(irn, bound, band) + !! E: the straight line pinned in bending and rigid in torsion at both ends (no gravity, no + !! fluid, rho_inf = 1), twisted by 4 rad and released with the first pinned bending mode's + !! velocity, 6 m/s at mid-span, for ten periods. Each step evaluates, from the end tangents + !! m and their rates, the spin c = (t x d).dt/dt / (1 + d.t) of the carry G(d -> t) at both + !! ends (d the end director +x) and the kinetic energy 1/2 I c^2 of the held end sections + !! (I = Irn l0/2) that the model omits; its largest value against the peak kinetic energy + !! must stay below bound. band: (max - min) of kinetic + elastic over E0. + REAL(wp), INTENT(IN) :: irn, bound + REAL(wp), INTENT(OUT) :: band + TYPE(CD_HermiteCableDynType) :: m + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), l0(NE), s, ke, se, e0, emax, emin, ke_max, tc, tc_max, th_max, dt, mm(3), mv(3), t(3) + REAL(wp) :: td(3), c + INTEGER :: k, es, iend, b + CHARACTER(300) :: em + l0 = LL/REAL(NE, wp) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(RHOA, k=1, NE)], [(0.0_wp, k=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, 1.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'E pinned: init: '//TRIM(em)) + CALL torsion_of(q, 4.0_wp, tors, irn, 0.0_wp) + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + CALL require(es == CD_HCDYN_OK, 'E pinned: torsion: '//TRIM(em)) + band = HUGE(1.0_wp) + IF (es /= CD_HCDYN_OK) RETURN + DO k = 1, NN + s = LL*REAL(k - 1, wp)/REAL(NE, wp) + m%v(6*k - 4) = 6.0_wp*SIN(PI*s/LL) + m%v(6*k - 1) = 6.0_wp*(PI/LL)*COS(PI*s/LL) + END DO + dt = 2.0_wp*PI/(PI*PI*SQRT(EI/(RHOA*LL**4)))/400.0_wp + CALL CD_HermiteCable_Dyn_Energy(m, ke, se, es, em) + e0 = ke + se + emax = e0 + emin = e0 + ke_max = ke + tc_max = 0.0_wp + th_max = 0.0_wp + DO k = 1, 4000 + CALL CD_HermiteCable_Dyn_Step(m, dt, 40, 1.0e-11_wp, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'E pinned: step: '//TRIM(em)) + EXIT + END IF + CALL CD_HermiteCable_Dyn_Energy(m, ke, se, es, em) + emax = nan_max_abs([emax, ke + se]) + emin = MIN(emin, ke + se) + ke_max = MAX(ke_max, ke) + tc = 0.0_wp + DO iend = 1, 2 + b = MERGE(3, 6*(NN - 1) + 3, iend == 1) + mm = m%q(b + 1:b + 3) + mv = m%v(b + 1:b + 3) + t = mm/NORM2(mm) + td = (mv - DOT_PRODUCT(t, mv)*t)/NORM2(mm) + ! (t x d) . td with d = +x: (0, t3, -t2) . td + c = (t(3)*td(2) - t(2)*td(3))/(1.0_wp + t(1)) + tc = tc + 0.25_wp*irn*l0(1)*c*c + th_max = MAX(th_max, ACOS(MIN(1.0_wp, t(1)))) + END DO + tc_max = MAX(tc_max, tc) + END DO + WRITE (*, '(A,ES9.2,A,F5.1,A,ES10.3,A,ES10.3)') 'E pinned, Irn ', irn, ' kg m: end bend angle up to ', & + th_max*180.0_wp/PI, ' deg; omitted carry-spin energy / peak kinetic energy ', tc_max/ke_max, & + ', energy band / E0 ', (emax - emin)/e0 + CALL require(tc_max <= bound*ke_max, 'E pinned: the end sections'' carry spin holds a negligible energy') + CALL require(th_max > 0.2_wp, 'E pinned: the end tangents swing off their directors') + band = (emax - emin)/e0 + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_pinned_carry + ! ------------------------------------------------------------------------------------------ SUBROUTINE check_restart() !! R: 150 steps, snapshot, 100 more; restore and redo the 100: identical. A fresh module diff --git a/tests/test_static_dry_weight.f90 b/tests/test_static_dry_weight.f90 new file mode 100644 index 00000000..178e9c99 --- /dev/null +++ b/tests/test_static_dry_weight.f90 @@ -0,0 +1,656 @@ +! File: tests/test_static_dry_weight.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_static_dry_weight + !! The static start of an EI = 0 line held above the still-water level gives the part above + !! the surface its dry weight, as the dynamic model's buoyancy recovery does, on the + !! standalone and the coupled route alike (CD_Static_Line_Equilibrium with the dry-part + !! arguments). Gates: + !! 1. A vertical chain hung from 10 m above the surface to a point 90 m below it (99.9 m, + !! taut): the vertical loads of its two ends sum to its weight, w_sub times the wet + !! length plus the dry weight per metre times the dry length (the dry length 10 m over + !! the stretch of the top element), to 1e-6 (measured 1.5e-8). With the buoyancy kept + !! above the surface the sum read 1.4e-2 low. + !! 2. A chain hung 5 m above the surface onto a 200 m seabed (850 m, grounded tail): the + !! coupled aggregate's static start gives the standalone driver's fairlead load to the + !! driver's 8 output digits, 2e-7 (measured 1.4e-8; before 2.4e-4: the coupled load was + !! the dynamic reaction of a start that was not the equilibrium of the dynamics, whose + !! buoyancy recovery gives the dry part its dry weight). + !! 3. The same chain held still on the coupled route for 1 s (40 steps of 0.025 s): the + !! fairlead load stays at its static value to 1e-7 (measured 1e-10; before it moved by + !! 9.7e-4 in the first step and by 1.4e-3 at 1 s, ringing about the heavier + !! equilibrium). + !! 4. A finite-EI cable hung 5 m above the surface (its statics already carry the dry + !! weight): coupled and standalone starts agree to 2e-7 (measured 7e-8; a guard). + !! 5. A 50 t Connect point hung by two chains from Fixed points 10 m above the surface on a + !! 300 m seabed: the point's force balance (the static object solve, its warm line solves + !! included) carries the dry weight too, so the point holds its static position over 2 s + !! of the march to 1e-4 m, the output's 8 digits (measured 0), and the fairlead tension to + !! 1e-6 (measured 0). With the dry weight only in the line starts the point sank 1.1e-2 m + !! and the tension moved by 9.6e-4. + !! 6. A finite-EI cable hung from 5 m above the surface carrying a module (500 kg, 0.2 m^3) + !! 2 m along it, above the surface, which the dynamics loads with its weight alone (no + !! buoyancy, no drag), held still for 1 s (dtM 0.01 s): the fairlead load stays at its + !! static value to 1e-7 (measured 0, the output's 8 digits); before, the static start gave + !! the module its buoyancy and the load moved by up to 6.1e-2 (Fz -44269 to -46272 N at + !! 1 s). The same cable restrained in torsion at both ends (GJ 1e4 N m^2, a quarter turn, + !! the torsion stage after the attachment polish): the same, measured 0, before 6.1e-2. A + !! module 30 m along the line, under water, keeps its net weight: the guard of both + !! (measured 0). + !! 7. A stiff body (C44 = C55 = 2e8 N m/rad) on three EI = 0 legs, with a light finite-EI cable + !! (EI 100 N m^2, whose bending changes its end force little) pinned at a body point 5 m + !! above the surface, on a deck without a seabed: the body static solve gives the cable's + !! part above the surface its dry weight, as its cubic-Hermite cable has it, so the body + !! holds its heave over 3 s to 1e-4 m (measured 7e-6 m); before the solve kept the buoyancy + !! of that part (the cable's EI = 0 surrogate took the dry weight only with a seabed) and the + !! body's heave moved by 2.8e-3 m. + !! 8. An EI = 0 chain between two moving objects across the surface: from a body point 5 m above + !! it (the stiff body of gate 7) to a 3 t Connect clump that a second chain holds to an + !! anchor, WtrDpth 100 m. The object solve moves the body and the point together, the chain + !! solved with its dry part between them: both hold their static positions over 3 s of the + !! march to 1e-4 m (measured 0); with the buoyancy kept above the surface (dev before the + !! dry-weight fix) they moved by 5.5e-3 m. + !! 9. A net-buoyant module (200 kg, 2 m^3) 50 m along a slack finite-EI cable from 20 m below + !! the surface: in water it lifts its node 4.5 m above the surface, where the dynamics gives + !! it its weight alone, which sinks it: a point attachment has no static position there. + !! The static start fails closed and its message names the attachment that crossed the + !! still-water level. Before, the solves carried the module above and below the surface in + !! turn until a load step failed, and the message read as a homotopy that stopped (dev + !! started the module 4.5 m above the surface with its buoyancy and ran). + !! A deck whose lines are all submerged is solved once, bit-identically (the example A/B). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_NMovingPoints, CD_AGG_CalcOutput, CD_AGG_Step_Moving, CD_AGG_End, & + CD_AGG_OK + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: G = 9.80665_wp, RHOW = 1025.0_wp, PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: D_CHAIN = 0.333_wp, M_CHAIN = 685.0_wp, EA_CHAIN = 3.27e9_wp + INTEGER :: nfail + REAL(wp) :: f_drv(3), f_agg(3), f2(3), w_dry, w_sub, l_dry, eps_top, w_true, err, dmax + + nfail = 0 + w_dry = M_CHAIN*G + w_sub = w_dry - RHOW*G*0.25_wp*PI*D_CHAIN**2 + + ! 1. vertical chain across the surface + CALL write_deck('dry_vertical.dat', 'main 0.333 685.00 3.27e9 -1.0 0.0 2.0 0.4 0.82 0.27', & + '0.0 0.0 10.0', '0.0 0.0 -90.0', '1 main 99.9 100', 200.0_wp) + CALL driver_forces('dry_vertical', f_drv, f2) + ! the dry length: 10 m of the top element's stretch (the tension varies by 0.1 % over it) + eps_top = -f_drv(3)/EA_CHAIN + l_dry = 10.0_wp/(1.0_wp + eps_top) + w_true = w_sub*(99.9_wp - l_dry) + w_dry*l_dry + err = ABS(f_drv(3) + f2(3) + w_true)/w_true + WRITE (*, '(A,ES12.4,A,ES12.4,A,ES10.2)') ' vertical chain: sum of the end loads ', -(f_drv(3) + f2(3)), & + ' N, weight ', w_true, ' N, rel. error ', err + WRITE (*, '(A,ES10.2)') ' (buoyancy kept above the surface would read it low by ', & + (w_dry - w_sub)*l_dry/w_true + CALL check(err <= 1.0e-6_wp, 'vertical chain: the end loads carry the dry weight above the surface') + + ! 2. and 3. chain from 5 m above the surface onto the seabed + CALL write_deck('dry_chain.dat', 'main 0.333 685.00 3.27e9 -1.0 0.0 2.0 0.4 0.82 0.27', & + '-58.0 0.0 5.0', '-837.6 0.0 -200.0', '1 main 850.0 50', 200.0_wp) + CALL driver_forces('dry_chain', f_drv, f2) + CALL coupled_force('dry_chain.dat', 40, f_agg, dmax) + err = MAXVAL(ABS(f_agg - f_drv))/NORM2(f_drv) + WRITE (*, '(A,3ES16.8)') ' chain, standalone fairlead load ', f_drv + WRITE (*, '(A,3ES16.8,A,ES10.2)') ' chain, coupled fairlead load ', f_agg, ' rel. ', err + CALL check(err <= 2.0e-7_wp, 'chain above the surface: coupled and standalone static starts agree') + WRITE (*, '(A,ES10.2)') ' chain held still 1 s on the coupled route: largest rel. load change ', dmax + CALL check(dmax <= 1.0e-7_wp, 'chain above the surface: the static start is the equilibrium of the march') + + ! 4. finite-EI cable from 5 m above the surface + CALL write_deck('dry_cable.dat', 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0', & + '30.0 0.0 5.0', '500.0 0.0 -200.0', '1 bare 600.0 240', 200.0_wp) + CALL driver_forces('dry_cable', f_drv, f2) + CALL coupled_force('dry_cable.dat', 0, f_agg, dmax) + err = MAXVAL(ABS(f_agg - f_drv))/NORM2(f_drv) + WRITE (*, '(A,ES10.2)') ' finite-EI cable above the surface: coupled vs standalone rel. ', err + CALL check(err <= 2.0e-7_wp, 'finite-EI cable above the surface: coupled and standalone static starts agree') + + ! 5. a Connect point between two chains held above the surface + CALL connect_point_drift(err, dmax) + WRITE (*, '(A,ES10.2,A,ES10.2)') ' Connect point held 2 s: largest vertical drift ', dmax, & + ' m, largest rel. fairlead tension change ', err + CALL check(dmax <= 1.0e-4_wp, 'Connect point above the surface: its static position is the equilibrium of the march') + CALL check(err <= 1.0e-6_wp, 'Connect point above the surface: the fairlead tension holds its static value') + + ! 6. an attachment above the surface, untwisted and restrained in torsion; under water, the guard + CALL attachment_hold('dry_att', '1 2.0 500.0 0.2 0.0 0.0', .FALSE., err) + WRITE (*, '(A,ES10.2)') ' module above the surface, held 1 s: largest rel. fairlead load change ', err + CALL check(err <= 1.0e-7_wp, 'module above the surface: the static start is the equilibrium of the march') + CALL attachment_hold('dry_att_tors', '1 2.0 500.0 0.2 0.0 0.0', .TRUE., err) + WRITE (*, '(A,ES10.2)') ' module above the surface, torsion, held 1 s: largest rel. fairlead load change ', err + CALL check(err <= 1.0e-7_wp, 'module above the surface, torsion: the static start is the equilibrium of the march') + CALL attachment_hold('wet_att', '1 30.0 500.0 0.2 0.0 0.0', .FALSE., err) + WRITE (*, '(A,ES10.2)') ' module under water, held 1 s: largest rel. fairlead load change ', err + CALL check(err <= 1.0e-7_wp, 'module under water: the static start is the equilibrium of the march') + + ! 7. a pinned finite-EI cable above the surface on a body, no seabed + CALL body_cable_heave(dmax) + WRITE (*, '(A,ES10.2,A)') ' body with a pinned cable above the surface, no seabed: largest heave change ', dmax, ' m' + CALL check(dmax <= 1.0e-4_wp, 'pinned cable above the surface on a body: the body static balance carries its '// & + 'dry weight') + + ! 8. an EI = 0 chain between a body above the surface and a Connect point + CALL two_objects_drift(dmax) + WRITE (*, '(A,ES10.2,A)') ' chain between a body above the surface and a Connect point: largest drift ', dmax, ' m' + CALL check(dmax <= 1.0e-4_wp, 'chain between two moving objects across the surface: both start in the march''s '// & + 'equilibrium') + + ! 9. a module that would float: no static position, failed by name + CALL floating_module() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAILED: ', nfail, ' check(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: static dry weight above the surface' + +CONTAINS + + SUBROUTINE check(ok, what) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: what + IF (ok) THEN + WRITE (*, '(2A)') ' ok: ', what + ELSE + WRITE (*, '(2A)') ' FAIL: ', what + nfail = nfail + 1 + END IF + END SUBROUTINE check + + SUBROUTINE write_deck(path, type_row, pa, pb, section_row, depth) + !! One line from a Coupled point pa (End A) to a Fixed point pb; the standalone static start + !! at TMax = 0, the time step for the coupled route. + CHARACTER(*), INTENT(IN) :: path, type_row, pa, pb, section_row + REAL(wp), INTENT(IN) :: depth + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'test_static_dry_weight: a line held above the still-water level' + 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)') type_row + WRITE (u, '(A)') '--------------------- POINTS ------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled '//pa + WRITE (u, '(A)') '2 Fixed '//pb + 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)') section_row + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.025 dtM' + WRITE (u, '(F8.2,A)') depth, ' WtrDpth' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') '"Point1Fx"' + WRITE (u, '(A)') '"Point1Fy"' + WRITE (u, '(A)') '"Point1Fz"' + WRITE (u, '(A)') '"Point2Fx"' + WRITE (u, '(A)') '"Point2Fy"' + WRITE (u, '(A)') '"Point2Fz"' + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE driver_forces(root, fa, fb) + !! The standalone static start (TMax = 0): the loads on points 1 and 2 (the t = 0 row). + CHARACTER(*), INTENT(IN) :: root + REAL(wp), INTENT(OUT) :: fa(3), fb(3) + LOGICAL :: conv + INTEGER :: es, u, ios + CHARACTER(1024) :: em + CHARACTER(4096) :: line + REAL(wp) :: t + fa = 0.0_wp + fb = 0.0_wp + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, root//': standalone static start: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='old', ACTION='read') + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) t, fa, fb + EXIT + END DO + CLOSE (u) + END SUBROUTINE driver_forces + + SUBROUTINE connect_point_drift(ten_rel, dz_max) + !! Gate 5: two 240 m chains from Fixed points at (-+200, 0, 10) m to a Connect point (50 t, + !! 2 m^3) at (0, 0, -100) m, WtrDpth 300 m, held 2 s (dtM 0.01 s). ten_rel: the largest change + !! of FairTen1 over its t = 0 value, relative; dz_max: the largest change of the point's z [m]. + REAL(wp), INTENT(OUT) :: ten_rel, dz_max + INTEGER :: u, ios, es + LOGICAL :: conv + REAL(wp) :: row(4), t0, z0 + CHARACTER(1024) :: em + CHARACTER(4096) :: line + LOGICAL :: first + ten_rel = HUGE(1.0_wp) + dz_max = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE='dry_connect.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'test_static_dry_weight: a Connect point between two chains held above the surface' + 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)') 'chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') '--------------------- POINTS ------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Fixed -200.0 0.0 10.0 0 0 0 0' + WRITE (u, '(A)') '2 Connect 0.0 0.0 -100.0 50000.0 2.0 0 0' + WRITE (u, '(A)') '3 Fixed 200.0 0.0 10.0 0 0 0 0' + WRITE (u, '(A)') '--------------------- LINES -------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS ----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 chain 240.0 30' + WRITE (u, '(A)') '2 chain 240.0 30' + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + 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.01 dtM' + WRITE (u, '(A)') '2.0 TMax' + WRITE (u, '(A)') '300.0 WtrDpth' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') '"FairTen1"' + WRITE (u, '(A)') '"Point2px"' + WRITE (u, '(A)') '"Point2pz"' + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_connect.dat', 'dry_connect', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'dry_connect: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_connect.out', STATUS='old', ACTION='read') + first = .TRUE. + t0 = 0.0_wp + z0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + t0 = row(2) + z0 = row(4) + ten_rel = 0.0_wp + dz_max = 0.0_wp + first = .FALSE. + END IF + ten_rel = MAX(ten_rel, ABS(row(2) - t0)/t0) + dz_max = MAX(dz_max, ABS(row(4) - z0)) + END DO + CLOSE (u) + END SUBROUTINE connect_point_drift + + SUBROUTINE attachment_hold(root, att_row, torsion, dmax_rel) + !! Gate 6: a 600 m finite-EI cable (240 elements) from a Coupled point at (30, 0, 5) m to a + !! Fixed one at (500, 0, -200) m on a 200 m seabed with one ATTACHMENTS row, held 1 s (dtM + !! 0.01 s); torsion: restrained at both ends, a quarter turn at End B. dmax_rel: the largest + !! change of the fairlead load over its t = 0 value, relative. + CHARACTER(*), INTENT(IN) :: root, att_row + LOGICAL, INTENT(IN) :: torsion + REAL(wp), INTENT(OUT) :: dmax_rel + INTEGER :: u, ios, es + LOGICAL :: conv, first + REAL(wp) :: row(3), f0(2) + CHARACTER(1024) :: em + CHARACTER(4096) :: line + dmax_rel = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE=root//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'test_static_dry_weight: a module above the still-water level' + 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)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.0e4 1.0 0.1 1.2 0.1 1.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)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0' + END IF + WRITE (u, '(A)') '--------------------- POINTS ------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 30.0 0.0 5.0' + WRITE (u, '(A)') '2 Fixed 500.0 0.0 -200.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 600.0 240' + WRITE (u, '(A)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') att_row + IF (torsion) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Pinned 0.7071067811865476 0 -0.7071067811865476 Rigid 0 1 0 0' + WRITE (u, '(A)') '1 B Pinned 1 0 0 Rigid 0 1 0 90' + END IF + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') '1.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') '"Point1Fx"' + WRITE (u, '(A)') '"Point1Fz"' + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, root//': run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='old', ACTION='read') + first = .TRUE. + f0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + f0 = row(2:3) + dmax_rel = 0.0_wp + first = .FALSE. + END IF + dmax_rel = MAX(dmax_rel, NORM2(row(2:3) - f0)/NORM2(f0)) + END DO + CLOSE (u) + END SUBROUTINE attachment_hold + + SUBROUTINE body_cable_heave(dz_max) + !! Gate 7: a body at z = -3 m on three 103 m polyester legs to anchors at -100 m, with a + !! 120 m finite-EI cable (EI 100 N m^2, 60 elements) pinned at the body point (0, 0, 8) m (5 m + !! above the surface) towards a Fixed point at (-40, 0, -100) m, no seabed, bodyIC static, + !! 3 s of the march (dtM 0.05 s). dz_max: the largest change of the body's heave [m]. + REAL(wp), INTENT(OUT) :: dz_max + INTEGER :: u, ios, es + LOGICAL :: conv, first + REAL(wp) :: row(4), z0 + CHARACTER(1024) :: em + CHARACTER(4096) :: line + dz_max = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE='dry_body_cable.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') 'test_static_dry_weight: a pinned finite-EI cable above the surface on a body, no seabed' + 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 1.0e2 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 0 0 -3 0 0 0 2.0e4 40.0 0.0 2.0e8 2.0e8 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 40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -20.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -20.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body1 0.0 0.0 8.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 103.0 20' + WRITE (u, '(A)') '2 poly 103.0 20' + WRITE (u, '(A)') '3 poly 103.0 20' + WRITE (u, '(A)') '4 cab 120.0 60' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '3.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px' + WRITE (u, '(A)') 'Body1Pz' + WRITE (u, '(A)') 'Body1Ry' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_body_cable.dat', 'dry_body_cable', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'dry_body_cable: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_body_cable.out', STATUS='old', ACTION='read') + first = .TRUE. + z0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + z0 = row(3) + dz_max = 0.0_wp + first = .FALSE. + END IF + dz_max = MAX(dz_max, ABS(row(3) - z0)) + END DO + CLOSE (u) + END SUBROUTINE body_cable_heave + + SUBROUTINE floating_module() + !! Gate 9: a 160 m finite-EI cable (80 elements) from a Coupled point at (0, 0, -20) m to a + !! Fixed one at (100, 0, -50) m on a 50 m seabed, a 200 kg, 2 m^3 module 50 m along it. + INTEGER :: u, es + LOGICAL :: conv + CHARACTER(1024) :: em + OPEN (NEWUNIT=u, FILE='dry_float.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') 'test_static_dry_weight: a net-buoyant module that would float' + 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.16 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 -20.0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.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 160.0 80' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '1 50.0 200.0 2.0 0.0 0.0 0.0' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '0.1 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point1Fz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_float.dat', 'dry_float', conv, es, em) + WRITE (*, '(2A)') ' module that would float: ', TRIM(em) + CALL check(es /= CD_DECKDRV_OK, 'module that would float: the static start fails closed') + CALL check(INDEX(em, 'attachment 1 of the line') > 0 .AND. INDEX(em, 'crossed the still-water level') > 0, & + 'module that would float: the failure names the attachment that crossed the surface') + END SUBROUTINE floating_module + + SUBROUTINE two_objects_drift(dmax) + !! Gate 8: the body of gate 7, a 65 m chain (EI = 0, 30 segments) from its point (0, 0, 8) m to + !! a Connect point (3 t) at (-30, 0, -50) m, and an 85 m chain from there to a Fixed point at + !! (-90, 0, -100) m, WtrDpth 100 m, bodyIC static, 3 s of the march (dtM 0.02 s). dmax: the + !! largest change of the body's x and z and the point's z [m]. + REAL(wp), INTENT(OUT) :: dmax + INTEGER :: u, ios, es + LOGICAL :: conv, first + REAL(wp) :: row(4), r0(3) + CHARACTER(1024) :: em + CHARACTER(4096) :: line + dmax = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE='dry_two_objects.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') 'test_static_dry_weight: an EI = 0 chain between a body above the surface and a Connect point' + 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)') 'chain 0.1 60.0 8.0e8 -1.0 0.0 1.2 0.4 1.0 0.5' + 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 0 0 -3 0 0 0 2.0e4 40.0 0.0 2.0e8 2.0e8 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 40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -20.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -20.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body1 0.0 0.0 8.0 0 0 0 0' + WRITE (u, '(A)') '8 Connect -30.0 0.0 -50.0 3000.0 0.0 0 0' + WRITE (u, '(A)') '9 Fixed -90.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 8 -' + WRITE (u, '(A)') '5 8 9 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 103.0 20' + WRITE (u, '(A)') '2 poly 103.0 20' + WRITE (u, '(A)') '3 poly 103.0 20' + WRITE (u, '(A)') '4 chain 65.0 30' + WRITE (u, '(A)') '5 chain 85.0 30' + 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.02 dtM' + WRITE (u, '(A)') '3.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px' + WRITE (u, '(A)') 'Body1Pz' + WRITE (u, '(A)') 'Point8pz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_two_objects.dat', 'dry_two_objects', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'dry_two_objects: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_two_objects.out', STATUS='old', ACTION='read') + first = .TRUE. + r0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + r0 = row(2:4) + dmax = 0.0_wp + first = .FALSE. + END IF + dmax = MAX(dmax, MAXVAL(ABS(row(2:4) - r0))) + END DO + CLOSE (u) + END SUBROUTINE two_objects_drift + + SUBROUTINE coupled_force(path, nstep, f0, dmax_rel) + !! The coupled aggregate's static start (OpenFAST host environment): the fairlead load, and + !! the largest relative change of it over nstep still steps of 0.025 s. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: nstep + REAL(wp), INTENT(OUT) :: f0(3), dmax_rel + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), ld(:, :), p0(:, :) + INTEGER :: es, ncp, n, it + LOGICAL :: conv, stalled + CHARACTER(1024) :: em + f0 = 0.0_wp + dmax_rel = HUGE(1.0_wp) + CALL CD_AGG_Init_From_Deck(agg, path, 0.025_wp, es, em, env_gravity=G, env_rho_water=RHOW, & + env_wtrdpth=200.0_wp) + CALL check(es == CD_AGG_OK, path//': coupled static start: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ncp = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, ncp), vel(3, ncp), acc(3, ncp), ld(3, ncp), p0(3, ncp)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, ld, es, em) + f0 = ld(:, 1) + p0 = pos + vel = 0.0_wp + acc = 0.0_wp + dmax_rel = 0.0_wp + DO n = 1, nstep + CALL CD_AGG_Step_Moving(agg, 0.025_wp, p0, vel, acc, conv, stalled, it, es, em) + IF (es /= CD_AGG_OK) THEN + CALL check(.FALSE., path//': coupled still step: '//TRIM(em)) + EXIT + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + dmax_rel = MAX(dmax_rel, NORM2(ld(:, 1) - f0)/NORM2(f0)) + END DO + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE coupled_force +END PROGRAM test_static_dry_weight From 591acbc307d538e289d850935ec0db41fac60b51 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Mon, 2 Nov 2026 23:45:41 +0900 Subject: [PATCH 29/51] fix(multibody): couple a finite-EI cable pinned to a moving object implicitly (#78) ## What changed The monolithic multibody step (`bodyScheme monolithic`, the default) coupled a finite-EI cable pinned to a moving object (a Rigid6 `Body` point or a free or pinned `Rod` end, the other end held) at the Newmark predictor: the cable was stepped once per step with the predicted attachment motion and its end force was held through the outer iterations. That is an explicit, partitioned coupling. Its step amplification exceeds 1 once `K_e dt^2 / m_e` is above about 0.85 (1.5 at 1.3, 2.5 at 2), with `K_e` the cable's condensed dynamic end stiffness and `m_e` the object's effective mass along the cable. A light object on a stiff cable therefore left a balanced static start. A 3 t free rod spar with a 55 m cable (`EA` 5e8 N, 40 elements) pinned at its upper end, at `dtM` 0.01 s: - the step change of the cable tension alternated in sign and grew 2.3 times per step; - the tension rose from 11 kN past 1 MN in 0.7 s; - the rod end moved 6.3 m in 2 s. The start was not at fault. It is a stable equilibrium of the march: - the same deck with an `EI = 0` cable stays at rest to 1e-10 m; - with the cable clamped (`Rigid`, already coupled implicitly) it stays at rest to 1e-7 m; - the staggered scheme holds it. **The fix.** In `src/CableDyn_DeckDriver.f90`, every cable with an end on an object the march moves now sets `cab_imp`. This covers pinned or connected ends, End A or End B, bodies and free or pinned rods. Such a cable is re-stepped at every outer iteration with its end stiffness in the Newton matrix, as clamped cables and cables between two objects already were. A cable with no moving end is still stepped once. The staggered scheme and the OpenFAST and C-API routes are unchanged. **Docs.** - `doc/driver_format.md`: the multibody route bullet. - `doc/theory.rst`: the monolithic scheme paragraph, now with the stability criterion of the old coupling, and the clamped-cable paragraph. - `CHANGELOG.md`: an `[Unreleased]` Fixed entry. The #75 Added entry no longer says a pinned cable is "coupled at the predictor". ## Gates New CTest `pinned_cable_light_object`. On dev e760bc6, 14 of its gates fail. | Gate | dev e760bc6 | this branch | |---|---|---| | H: spar rod, cable pinned at the upper end (2 s): rod end move / tension change | 6.3 m / 161 times the start | 1e-10 m / 2.7e-8 | | H: same, in a 0.5 m/s current | 5.4 m / 472 times | 6.3e-4 m / 1.2e-4 (a slow swing of the start in the current, the same on the staggered scheme) | | H: cable pinned at the lower end | 6.5 m / 5596 times | 1.8e-10 m / 3.4e-8 | | D: cable from a fixed rod's end to the free rod (End B on the moving object) | 6.1 m / 1190 times | 2e-7 m / 9e-8 | | D: cable written from its anchor | the same output byte for byte | the same output byte for byte | | B: 4 t Rigid6 buoy with a pinned keel cable (4 s) | 0.22 m / 38 times | 1e-9 m / 3.3e-8 | | S: monolithic vs staggered, upper / lower end | 6.0 / 6.5 m apart | 1e-10 / 1.7e-10 m, tensions to 2.7e-8 / 3.4e-8 | | E: controls (`EI = 0` cable; cable clamped at upper / lower end) | at rest | at rest: 1e-10 m; 1e-7 / 3e-9 m | Gate tolerances: - 1e-5 m and 1e-5 of the tension; the positions are written to 8 digits, so 1e-6 m at the rod's depth; - 2e-3 m and 1e-3 in the current; - 1e-5 m for the staggered comparison. `line_attachments` 11 and 12 had to march at `dtM` 0.002 s on #77 because of this coupling. They are back at `dtM` 0.01 s, over 1 s instead of 0.3 s: | Gate | dev e760bc6 at `dtM` 0.01 s | this branch | |---|---|---| | 11: spar rod, pinned cable with a 1500 kg clump | 0.82 m / leg tension 13 times | 1e-7 m / 2.9e-7 | | 12: the same without the clump | 1.3 m / 4.4 times | 0 m / 3.8e-8 | Over 3 s the clump deck holds to 1.1e-6 m; dev moves it 15 m. ## Example A/B (reference driver built at e760bc6) 52 of 53 example decks are identical. `mixed_body_rods_points` changes; it is a 150 t buoy with a pinned power cable, the one example with a pinned cable on a moving object: - body surge changes by up to 3.5e-5 m (7e-6 of its 5.2 m range); - `Rod2Ry` changes by 2.3e-4 deg; - the cable top tension `FairTen8` changes by 0.6 N of 8.1 kN. The new run is the more accurate one. Against the same deck at `dtM` / 4, the body surge error falls from 3.7e-5 m to 1.6e-6 m and the pitch error from 1.1e-4 to 2.2e-5 deg. The cable tension error, 17 N, comes from the cable's own time step and does not change. The deck runs about 45 % longer (6.8 s to 9.8 s), because the cable is now stepped once per outer iteration instead of once per step. ## Checks - Full ctest (Release): 345 of 345 pass. - Checked Debug build (`-fcheck=all`, `--timeout 5400`): `pinned_cable_light_object`, `line_attachments`, `static_dry_weight`, `cable_between_bodies`, `monolithic_gates`, `clamped_cable_ends`, `body_rod_physics`, `bodies_rods` and `driver_clamped_cable_pinned_rod` pass, 9 of 9. - pytest `python/tests` and `tests`: with the native parity tests on (`CABLEDYN_TEST_DRIVER`), 2179 passed, 75 skipped. - ruff check and format are clean. Strict mypy shows only dev's 3 numpy-stub notes. - pre-commit and Sphinx `-W` are clean. `dup_public`: 0 duplicates. ## Notes - The slow drift in a current (6.3e-4 m in 2 s, 1.3e-3 m at most over 6 s, then turning back) is the same on the staggered scheme. The `EI = 0` cable in the same current holds to 1e-10 m. So it is a small static-versus-dynamic difference of the finite-EI cable in a current, not part of this coupling, and is left for the open list. - If the 45 % cost on decks with a pinned cable on a heavy body matters, the old coupling could be kept where `K_e dt^2 / m_e` is safely below 0.85. That needs estimates of `K_e` and `m_e`; this change takes the uniformly implicit coupling for robustness. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 32 +- CMakeLists.txt | 5 + doc/driver_format.md | 8 +- doc/theory.rst | 19 +- src/CableDyn_DeckDriver.f90 | 72 +++- tests/test_line_attachments.f90 | 16 +- tests/test_pinned_cable_light_object.f90 | 448 +++++++++++++++++++++++ 7 files changed, 562 insertions(+), 38 deletions(-) create mode 100644 tests/test_pinned_cable_light_object.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 83ac53d1..08fa1f6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,9 +31,8 @@ All notable changes to CableDyn are recorded in this file. The format follows 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 + halvings over 100 steps, against 3.9 and none); 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 @@ -354,6 +353,33 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Fixed +- A finite-EI cable pinned to a light moving object no longer throws it off its static start in + the monolithic multibody step. Such a cable (pinned at a Rigid6 body point or a free or pinned + rod end, the other end held) was stepped once per step with the predicted motion of its + attachment and its end force held through the iterations, an explicit coupling that diverges + once the cable's dynamic end stiffness times `dtM^2` exceeds about 0.85 of the object's mass + along the cable. It is now re-stepped at every outer iteration with its end stiffness in the + Newton matrix, as a clamped cable already was. A 3 t free rod spar with a 55 m cable (EA 5e8 N) + pinned at either rod end, at `dtM` 0.01 s: the cable tension rose from 11 kN past 1 MN in + 0.7 s and the rod end moved 6.3 to 6.5 m in 2 s (5.4 m in a current, 6.1 m with the cable from + a fixed rod's end); it now holds to 2e-10 m and 3e-8 of the tension (6e-4 m in the current, + as on the staggered scheme), and the monolithic and staggered schemes agree to 2e-10 m. With a + 1500 kg clump on that cable the rod moved 15 m in 3 s; it holds to 1.1e-6 m (`line_attachments` + 11 and 12 march at `dtM` 0.01 s again). A 4 t buoy with a pinned keel cable moved 0.22 m and + its cable tension reached 38 times its start; it now holds to 1e-9 m. Decks with a pinned cable + on a heavy body change at the accuracy of the old coupling: on the `mixed_body_rods_points` + example (150 t buoy) the body motion changes by 3.5e-5 m, its error against a run at `dtM` / 4 + falling from 3.7e-5 m to 1.6e-6 m, and the cable top tension by 0.6 N of 8.1 kN; that deck runs + about 45 % longer. +- A finite-EI cable whose End A rests on the seabed below its End B (a cable written from a seabed + termination, such as a fixed rod's end, up to a floater) takes the catenary-continuation static + route again. Its catenary seed refused the line (the fairlead, End A, must sit above the bed), + so the mesh-sequenced route alone solved it, and its branch depended on platform round-off: a + 55 m cable from a fixed rod's end on the seabed to a free spar rod solved on Windows and + reached a kinked state (max h kappa 1.96) on Linux gfortran, which failed the deck. The seed + is now laid from End A, the line seen from its other end, and its nodes put back in order. The + deck starts at the same equilibrium as before on Windows (1e-7 m, 6e-4 N), and moving the fixed + rod by 1 ulp either way or 1e-12 m up leaves the rod's start unchanged (0 m). - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 87526527..869b3af8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2214,6 +2214,11 @@ 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_pinned_cable_light_object tests/test_pinned_cable_light_object.f90) +target_link_libraries(test_pinned_cable_light_object PRIVATE cabledyn_core) +add_test(NAME pinned_cable_light_object COMMAND test_pinned_cable_light_object) +set_tests_properties(pinned_cable_light_object PROPERTIES LABELS "fortran;driver;integration;dynamic") + 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) diff --git a/doc/driver_format.md b/doc/driver_format.md index ed01706b..fba25861 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -412,10 +412,10 @@ connection moment at every connected end, and at both ends of a cable between tw 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; +- the monolithic step re-steps at every outer iteration every cable with an end, pinned or + connected, on a moving object (a Rigid6 body, a free or pinned rod), with its end stiffness in + the Newton matrix, so a light object on a stiff cable is as stable as a heavy one; 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. diff --git a/doc/theory.rst b/doc/theory.rst index 9be55fbb..12380951 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1623,7 +1623,9 @@ mesh-sequenced route described below first and this route as its fallback): declared seabed plane (flat ``WtrDpth``, or the least-squares plane of a structured bathymetry along the chord) or hung in mid-water when there is no seabed. The solve runs in the vertical plane of the chord, translated to the anchor, so a translated or rotated deck gives the same - numbers to round-off. Over a bathymetry that is not a plane along the chord (a surveyed + numbers to round-off. A line whose End A (the fairlead) rests on the seabed below its End B, + such as a cable written from a seabed termination up to a floater, is seeded from End A, the + same catenary seen from its other end, with its nodes put back in order. Over a bathymetry that is not a plane along the chord (a surveyed seabed with roughness, bumps or dips), the seed laid on the fitted plane meets the actual bed wherever the bed rises above that plane: every seed node deeper below the actual bed than its static penalty penetration (nodal submerged weight over the nodal contact stiffness @@ -2571,10 +2573,14 @@ linear spring-mass body conserved to :math:`5\times10^{-10}` at :math:`\Delta t` :math:`\rho_\infty`; observed order 2 in positions and fairlead tensions on the moored buoy and in surge, heave and pitch on the V-SP spar; gyroscopic precession of a torque-free symmetric top at second order; and an error no larger than the staggered scheme's at :math:`\Delta t` = 0.1 s and -0.05 s on the moored buoy and rod spar. A finite-EI cable pinned to its object is stepped once -per step with the attachment motion of the Newmark predictor, and its end force is held -through the iterations; a cable clamped to its object is re-stepped at every outer iteration -(*Cables clamped to bodies and rods*, below). Standalone decks with a ``motionFile``, a +0.05 s on the moored buoy and rod spar. A finite-EI cable with an end on a moving object, pinned +or clamped, is re-stepped at every outer iteration (*Cables clamped to bodies and rods*, below; +a pinned end returns no moment). Coupling a pinned cable at the predictor instead (stepped once +with the predicted end motion, its end force held through the iterations) is explicit: with +:math:`K_e` the cable's condensed dynamic end stiffness and :math:`m_e` the object's effective mass +along it at the attachment, the error grows from step to step once :math:`K_e\Delta t^2/m_e` +exceeds about 0.85, so a light rod or buoy on a stiff cable diverges from a balanced start. +Standalone decks with a ``motionFile``, a ``FAILURE`` section, or Coupled/Vessel rods, and the OpenFAST and C-API coupled routes, use the staggered scheme. @@ -2764,7 +2770,8 @@ stretch) stays free. The cable returns to the object its end force at the attach connection moment :math:`\mathbf{M}_e = \mathbf{m}\times\mathbf{g}_m`, with :math:`\mathbf{g}_m` the constraint (or spring) force on the tangent coordinates. In the monolithic step the cable is re-stepped from the step entry at every outer iteration with the -iterate's end-of-step motion, orientation, angular velocity and angular acceleration, and its +iterate's end-of-step motion, orientation, angular velocity and angular acceleration (a pinned +end, which the monolithic step couples the same way, takes the motion only), and its end force and moment load the object at the force level :math:`(1-\alpha_f)\,\mathbf{f}_{n+1} + \alpha_f\,\mathbf{f}_n`. Its condensed dynamic end stiffness with respect to the object's translation and rotation enters the Newton matrix by diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 2141712b..ec80fc40 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -988,7 +988,8 @@ MODULE CableDyn_DeckDriver ! 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). + ! (an end, pinned or connected, on an object the march moves; with both ends on objects the + ! cable 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(:) @@ -5595,7 +5596,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia INTEGER :: nnode, ne, i, es, cont_iters, polish_iters, budget_cont, cmode, k_walk ! Anchor retreats tried for a line too long for its span (see seed_walk). INTEGER, PARAMETER :: WALK_MAX_TRIES = 6 - LOGICAL :: walk_ok, fold + LOGICAL :: walk_ok, fold, rev_seed CHARACTER(1024) :: walk_msg_c REAL(wp) :: walk_d, a_seed(3) CHARACTER(1024) :: walk_msg @@ -5606,6 +5607,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia REAL(wp) :: lambda0, ratio, span(2), span_len, t, xg, yg, zf, sx, sz, sxx, sxz, xl, yl REAL(wp) :: res_cont, cont_tol, phi, penetration, zfit(NFIT), fit_misfit, fine_limit, seed_bed, anchor_bed REAL(wp), ALLOCATABLE :: pos(:), q_seed(:), q_cont(:), curv_cont(:), knnode(:), tdir(:, :), stretch(:) + REAL(wp), ALLOCATABLE :: pos_r(:), l0_r(:), ea_r(:), w_r(:) CHARACTER(1024) :: em ErrStat = CD_HCSTAT_OK @@ -5733,6 +5735,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia walk_d = CD_ZERO a_seed = a_l walk_msg = '' + rev_seed = .FALSE. seed_walk: DO k_walk = 0, WALK_MAX_TRIES IF (laid) THEN ErrStat = CD_HCSTAT_OK @@ -5780,7 +5783,33 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia seed_bed = zf END IF END IF - IF (contact_enabled) THEN + ! A fairlead (End A) on or below the seabed plane under a raised anchor (End B): a cable + ! from a seabed termination up to a floater, written from the seabed end. The catenary is + ! the same line seen from its other end, so it is seeded with the ends exchanged (End A + ! the anchor on the bed, the bed plane and its slope seen from there) and its nodes put + ! back in order. Without it the route refused the seed (the fairlead must be above the + ! bed) and left the line to the mesh-sequenced route, whose branch on such a line + ! depended on platform round-off (a kinked equilibrium on one, the cable's own on + ! another). No anchor walk follows a reversed seed. + rev_seed = contact_enabled .AND. k_walk == 0 .AND. .NOT. fold .AND. & + f_l(3) <= seed_bed + seabed_slope*span_len .AND. a_l(3) > seed_bed + IF (rev_seed) THEN + ALLOCATE (pos_r(3*nnode)) + l0_r = l0(ne:1:-1) + ea_r = ea(ne:1:-1) + w_r = w(ne:1:-1) + CALL CD_Catenary_Seed(f_l, a_seed, l0_r, ea_r, w_r, pos_r, horizontal_tension, grounded_length, es, em, & + seabed_z=seed_bed + seabed_slope*span_len, seabed_slope=-seabed_slope) + IF (es == CD_CAT_OK) THEN + DO i = 1, nnode + pos(3*(i - 1) + 1:3*i) = pos_r(3*(nnode - i) + 1:3*(nnode - i + 1)) + END DO + ELSE + ErrStat = CD_HCSTAT_NOCONVERGE + ErrMsg = 'catenary seed unavailable (the line seeded from its End A on the seabed): '//TRIM(em) + RETURN + END IF + ELSE IF (contact_enabled) THEN CALL CD_Catenary_Seed(a_seed, f_l, l0, ea, w, pos, horizontal_tension, grounded_length, es, em, & seabed_z=seed_bed, seabed_slope=seabed_slope) ELSE @@ -21530,9 +21559,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod 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 + ! attachments below: whenever either end's object moves (implicit coupling, see there) mb%cab_imp(c) = mb%cab_clamp(c) BLOCK TYPE(DeckLine) :: lnc @@ -21692,11 +21719,23 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod '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))) + ! A cable with an end on an object that the march moves couples it implicitly, pinned or + ! connected, at either end: it is re-stepped at every outer iteration with the iterate's + ! motion, its end stiffness in the Newton matrix. A pinned cable coupled at the predictor + ! instead (stepped once with the predicted attachment motion, its end force held through + ! the iterations) is a partitioned explicit coupling: the object sees the end force of the + ! predicted end position, F = -K_e x_pred, K_e the cable's condensed dynamic end stiffness + ! (the end element's EA/l_e condensed onto the inertia of the nodes behind it). On a mass + ! m_e (the object's effective mass along the cable at the attachment) that recurrence, with + ! the trapezoidal object update, has a step amplification above 1 once K_e dt^2/m_e exceeds + ! about 0.85 (1.5 at 1.3, 2.5 at 2): a light object on a stiff cable diverges whatever its + ! static balance (a 3 t free rod spar on a cable of EA 5e8 N in 1.4 m elements, dtM 0.01 s: + ! the step change of the cable tension alternated in sign and grew 2.3 times per step, the + ! tension rose from 11 kN past 1 MN and the rod top moved 6 m in 2 s). + IF (.NOT. mb%cab_imp(c)) THEN + mb%cab_imp(c) = attachment_moves(mb%cab_kind(c), mb%cab_obj(c)) + IF (mb%cab_kind_b(c) > 0) & + mb%cab_imp(c) = mb%cab_imp(c) .OR. attachment_moves(mb%cab_kind_b(c), mb%cab_obj_b(c)) IF (mb%cab_imp(c)) mb%cables(c)%tol = MIN(mb%cables(c)%tol, CLAMPED_CABLE_TOL) END IF END DO @@ -23665,12 +23704,11 @@ 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 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) + ! finite-EI cables: a cable with an end on a moving object (cab_imp: pinned or connected, + ! at either end) 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). A cable with no moving end (both ends held: on Fixed + ! points or rods fixed in place) is stepped once, its end force held DO c = 1, SIZE(mb%cables) IF (.NOT. (first .OR. mb%cab_imp(c))) CYCLE IF (.NOT. first) THEN diff --git a/tests/test_line_attachments.f90 b/tests/test_line_attachments.f90 index c69dcfe7..0d5a20dd 100644 --- a/tests/test_line_attachments.f90 +++ b/tests/test_line_attachments.f90 @@ -49,12 +49,12 @@ PROGRAM test_line_attachments !! 11. A free buoyant spar rod (10 m, 1 m diameter) on four taut legs with a finite-EI cable !! pinned at its upper end carrying a 1500 kg clump 25 m along it; bodyIC static: the body !! static passes converge (6, on the core cable that carries the clump smeared) and the rod - !! holds its static pose over 0.3 s of the march (dtM 0.002 s) to 1e-6 m (measured 0) and - !! the leg tensions to 1e-5 (measured 3e-7). Before, the plain passes diverged (end-load + !! holds its static pose over 1 s of the march (dtM 0.01 s) to 1e-6 m (measured 1e-7) and + !! the leg tensions to 1e-5 (measured 2.9e-7). Before, the plain passes diverged (end-load !! change 2.9 of the force scale after 60 passes) and the deck stopped. !! 12. The spar rod of case 11 with the cable and no clump: the bending share of the pinned !! cable's end force is in the rod's static balance too, so the rod holds its pose over - !! 0.3 s to 1e-6 m (measured 0) and its leg tensions to 1e-5 (measured 0). Before, the + !! 1 s to 1e-6 m (measured 0) and its leg tensions to 1e-5 (measured 3.8e-8). Before, the !! body passes left a pinned line without ATTACHMENTS to the core's cable without bending !! stiffness: the rod started 5.7e-2 m off its equilibrium and its top moved 1.8e-4 m in 0.1 s !! (dtM 0.01 s; 7e-2 m and a 2.3 % leg tension change in 3 s with the implicit object @@ -514,8 +514,8 @@ SUBROUTINE case_pinned_point3_clump() END SUBROUTINE case_pinned_point3_clump SUBROUTINE case_pinned_rod_clump(clump) - !! 11 (clump) and 12: 0.3 s of the march of pinned_rod_deck (dtM 0.002 s, which the explicit - !! coupling of the cable to the rod on this route needs to stay stable). + !! 11 (clump) and 12: 1 s of the march of pinned_rod_deck (dtM 0.01 s; the pinned cable is + !! coupled to the free rod implicitly, test_pinned_cable_light_object). LOGICAL, INTENT(IN) :: clump INTEGER :: nrow REAL(wp), ALLOCATABLE :: d(:, :) @@ -525,13 +525,13 @@ SUBROUTINE case_pinned_rod_clump(clump) CHARACTER(16) :: root, gate root = MERGE('att_rod_pin ', 'att_rod_pin_no', clump) gate = MERGE('11 with a clump', '12 alone ', clump) - CALL pinned_rod_deck(TRIM(root), clump, '25.0', '0.002', '0.3') + CALL pinned_rod_deck(TRIM(root), clump, '25.0', '0.01', '1.0') CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) CALL require(ok, TRIM(gate)//', a pinned cable on a free rod: runs: '//TRIM(msg)) IF (.NOT. ok) RETURN CALL read_out(TRIM(root)//'.out', d, nrow, 6) - CALL require(nrow >= 151, TRIM(gate)//', a pinned cable on a free rod: the run written') - IF (nrow < 151) RETURN + CALL require(nrow >= 101, TRIM(gate)//', a pinned cable on a free rod: the run written') + IF (nrow < 101) RETURN dpos = MAXVAL(ABS(d(2:3, 1:nrow) - SPREAD(d(2:3, 1), 2, nrow))) dten = MAXVAL(ABS(d(4:6, 1:nrow) - SPREAD(d(4:6, 1), 2, nrow))/SPREAD(ABS(d(4:6, 1)), 2, nrow)) WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') ' ', TRIM(gate), ', a pinned cable on a free rod: rod top drift ', dpos, & diff --git a/tests/test_pinned_cable_light_object.f90 b/tests/test_pinned_cable_light_object.f90 new file mode 100644 index 00000000..b92c96bb --- /dev/null +++ b/tests/test_pinned_cable_light_object.f90 @@ -0,0 +1,448 @@ +! File: tests/test_pinned_cable_light_object.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Gates of a finite-EI (cubic-Hermite) cable pinned to a light object on the standalone +!> monolithic multibody march. The deck: a 10 m, 1 m diameter buoyant free rod spar (3 t dry, +!> 8 t displaced) on four taut EI = 0 legs in 50 m of water, and a finite-EI cable (EA 5e8 N, +!> EI 2e4 N m^2, 40 elements over 55 m) pinned at a rod end and run to an anchor. The static +!> passes balance the rod on the cubic-Hermite cable, so the start is the march's equilibrium, +!> and a stable one. The monolithic step coupled such a pinned cable at the Newmark predictor +!> (stepped once with the predicted end motion, its end force held): the cable's dynamic end +!> stiffness against the rod's few tonnes made that explicit coupling unstable (K_e dt^2 / m_e +!> above about 0.85), the step change of the cable tension alternated in sign and grew 2.3 +!> times per step, and the rod fell over. A pinned cable on a moving object is now re-stepped +!> at every outer iteration with its end stiffness in the Newton matrix, as a clamped one is. +!> Positions are written to 8 digits (1e-6 m at the rod's 20 to 30 m depths). +!> H hold: the static start stays at rest over 2 s with the cable pinned at the upper and at +!> the lower rod end: rod end move at most 1e-5 m and the cable end tensions within 1e-5 of +!> the larger (measured 1e-10 and 1.8e-10 m, 2.7e-8 and 3.4e-8); in a 0.5 m/s current at +!> most 2e-3 m and 1e-3 (measured 6.3e-4 m and 1.2e-4: a slow swing of the start in the +!> current, the same on the staggered scheme). The old coupling: rod end moves of 6.3, 5.4 +!> and 6.5 m, tension changes of 161, 472 and 5596 times the start tension; +!> D the cable written from its anchor is turned around to start at the rod end and writes +!> the same output (byte for byte); a cable from a fixed rod's end to the free rod's end +!> (an End B on the moving object) holds to 1e-5 m and its tension to 1e-4 (measured 2e-7 +!> m and 9e-8; old: 6.1 m, 1190 times). That cable's End A (the fixed rod's end) lies on +!> the seabed below its End B: its catenary seed is laid from End A, the line seen from +!> its other end. Before, the catenary route refused it (fairlead on the bed) and the +!> mesh-sequenced route took over, whose branch depended on platform round-off: Linux +!> gfortran reached a kinked state (max h kappa 1.96) and failed the deck, Windows the +!> cable's equilibrium; +!> R the static start of that deck with the fixed rod moved by 1 ulp in x either way or by +!> 1e-12 m up is the same rod pose to 1e-9 m; +!> B a light Rigid6 buoy (4 t) with a pinned keel cable holds over 4 s (move at most 1e-5 m, +!> tension within 1e-5; measured 1e-9 m and 3.3e-8; old: 0.22 m, 38 times); +!> S second route: the staggered scheme, whose sub-stepped central difference resolves the +!> same coupling, gives the same rod motion (within 1e-5 m) and cable tensions (within 1e-5 +!> of the larger) as the monolithic step, the cable at the upper and at the lower rod end +!> (measured 1e-10 and 1.7e-10 m; old: 6.0 and 6.5 m apart); +!> E controls of the routes coupled implicitly before: the same deck with an EI = 0 cable +!> holds its static start to 1e-6 m, and the cable clamped (Rigid) at the upper or lower +!> rod end to 1e-5 m. +PROGRAM test_pinned_cable_light_object + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + IMPLICIT NONE + + INTEGER :: n_fail = 0 + REAL(wp) :: mv_m, ten_m + + CALL check_hold('upper', 'pcl_upper', .FALSE., 1.0e-5_wp, 1.0e-5_wp) + CALL check_hold('upper', 'pcl_current', .TRUE., 2.0e-3_wp, 1.0e-3_wp) + CALL check_hold('lower', 'pcl_lower', .FALSE., 1.0e-5_wp, 1.0e-5_wp) + CALL check_reversed() + CALL check_hold('fixrod', 'pcl_fixrod', .FALSE., 1.0e-5_wp, 1.0e-4_wp) + CALL check_fixrod_roundoff() + CALL check_buoy() + CALL check_staggered('upper', 'pcl_upper') + CALL check_staggered('lower', 'pcl_lower') + CALL check_hold('upper', 'pcl_ei0', .FALSE., 1.0e-6_wp, 1.0e-6_wp, ei0=.TRUE.) + CALL check_hold('upper', 'pcl_clamp_up', .FALSE., 1.0e-5_wp, 1.0e-4_wp, clamp='1.0') + CALL check_hold('lower', 'pcl_clamp_lo', .FALSE., 1.0e-5_wp, 1.0e-4_wp, clamp='-1.0') + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' gate(s) of a pinned cable on a light object failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: a finite-EI cable pinned to a light object (hold, direction, buoy, staggered '// & + 'route, EI = 0 and clamped controls)' + +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 + + LOGICAL FUNCTION same_text(p1, p2) RESULT(same) + !! The two files have the same lines. + CHARACTER(*), INTENT(IN) :: p1, p2 + INTEGER :: u1, u2, i1, i2 + CHARACTER(1024) :: b1, b2 + same = .FALSE. + OPEN (NEWUNIT=u1, FILE=p1, STATUS='OLD', ACTION='READ', IOSTAT=i1) + IF (i1 /= 0) RETURN + OPEN (NEWUNIT=u2, FILE=p2, STATUS='OLD', ACTION='READ', IOSTAT=i2) + IF (i2 /= 0) THEN + CLOSE (u1) + RETURN + END IF + DO + READ (u1, '(A)', IOSTAT=i1) b1 + READ (u2, '(A)', IOSTAT=i2) b2 + IF (i1 /= 0 .OR. i2 /= 0) EXIT + IF (b1 /= b2) EXIT + END DO + same = i1 < 0 .AND. i2 < 0 + CLOSE (u1) + CLOSE (u2) + END FUNCTION same_text + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE write_spar_deck(path, cable_at, current, scheme, ei0, clamp, from_anchor, rod2_a, tmax) + !! The free rod spar between z = -30 m (End A) and -20 m (End B) on four taut EI = 0 legs + !! (from End A to anchors 25 m up- and downstream, from End B to anchors 30 m to either side) + !! and the finite-EI cable (line 5, 55 m) to the anchor (-40, 0, -50): from the rod's upper + !! end (cable_at 'upper'), its lower end ('lower'), or from the end of a fixed rod at that + !! anchor to the upper end ('fixrod', End B on the free rod). current: 0.5 m/s in +X; + !! scheme: bodyScheme; ei0: the cable without bending stiffness; clamp: a Rigid End A + !! connection along the rod axis (EzZ given); from_anchor: line 5 written from the anchor; + !! rod2_a: the fixed rod's End A (default the anchor; its End B 1 m above); tmax: TMax + !! (default 2 s). + CHARACTER(*), INTENT(IN) :: path, cable_at, scheme, clamp + LOGICAL, INTENT(IN) :: current, ei0, from_anchor + REAL(wp), INTENT(IN), OPTIONAL :: rod2_a(3) + CHARACTER(*), INTENT(IN), OPTIONAL :: tmax + INTEGER :: u + CHARACTER(8) :: rod_end + REAL(wp) :: r2(3) + r2 = [-40.0_wp, 0.0_wp, -50.0_wp] + IF (PRESENT(rod2_a)) r2 = rod2_a + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'free rod spar with a finite-EI cable pinned at 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)') 'poly 0.10 10.0 2.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + IF (ei0) THEN + WRITE (u, '(A)') 'cab 0.20 60.0 5.0e8 -1.0 0.0 1.2 0.0 1.0 0.0' + ELSE + WRITE (u, '(A)') 'cab 0.20 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0' + 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 300.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 0.0 0.0 -30.0 0.0 0.0 -20.0 1 -' + IF (cable_at == 'fixrod') WRITE (u, '(A,6(ES24.16,1X),A)') '2 spar Fixed ', r2, r2 + [0.0_wp, 0.0_wp, 1.0_wp], & + ' 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 Rod1A 0.0 0.0 -30.0 0 0 0 0' + WRITE (u, '(A)') '2 Rod1B 0.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '3 Fixed 25.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -25.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed 0.0 30.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed 0.0 -30.0 -50.0 0 0 0 0' + IF (cable_at == 'fixrod') THEN + WRITE (u, '(A,3(ES24.16,1X),A)') '7 Rod2A ', r2, ' 0 0 0 0' + ELSE + WRITE (u, '(A)') '7 Fixed -40.0 0.0 -50.0 0 0 0 0' + END IF + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 3 -' + WRITE (u, '(A)') '2 1 4 -' + WRITE (u, '(A)') '3 2 5 -' + WRITE (u, '(A)') '4 2 6 -' + rod_end = MERGE('1', '2', cable_at == 'lower') + IF (from_anchor .OR. cable_at == 'fixrod') THEN + WRITE (u, '(A)') '5 7 '//TRIM(rod_end)//' -' + ELSE + WRITE (u, '(A)') '5 '//TRIM(rod_end)//' 7 -' + END IF + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 31.95 16' + WRITE (u, '(A)') '2 poly 31.95 16' + WRITE (u, '(A)') '3 poly 42.40 20' + WRITE (u, '(A)') '4 poly 42.40 20' + WRITE (u, '(A)') '5 cab 55.0 40' + IF (LEN_TRIM(clamp) > 0) THEN + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '5 A Rigid 0.0 0.0 '//TRIM(clamp) + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '0.01 dtM' + IF (PRESENT(tmax)) THEN + WRITE (u, '(A)') tmax//' TMax' + ELSE + WRITE (u, '(A)') '2.0 TMax' + END IF + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') scheme//' bodyScheme' + WRITE (u, '(A)') '0.4 rhoInf' + IF (current) WRITE (u, '(A)') 'uniform 0.5 0.0 0.0 current' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point1px Point1pz Point2px Point2pz FairTen5 AnchTen5' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_spar_deck + + SUBROUTINE spar_measures(root, mv, ten, ok) + !! The largest rod end move from the start and the largest change of the cable's end + !! tensions from their start over the run, relative to the larger start tension. + CHARACTER(*), INTENT(IN) :: root + REAL(wp), INTENT(OUT) :: mv, ten + LOGICAL, INTENT(OUT) :: ok + REAL(wp) :: rows(7, 400) + INTEGER :: n, k + CALL read_rows(TRIM(root)//'.out', rows, n, ok) + mv = HUGE(1.0_wp) + ten = HUGE(1.0_wp) + IF (.NOT. ok) RETURN + mv = 0.0_wp + ten = 0.0_wp + DO k = 1, n + mv = nan_max_abs([mv, NORM2(rows(2:3, k) - rows(2:3, 1)), NORM2(rows(4:5, k) - rows(4:5, 1))]) + ten = nan_max_abs([ten, (rows(6:7, k) - rows(6:7, 1))/MAXVAL(rows(6:7, 1))]) + END DO + END SUBROUTINE spar_measures + + SUBROUTINE check_hold(cable_at, root, current, mv_tol, ten_tol, ei0, clamp) + !! H / D / E. The spar deck (cable_at, current, ei0, clamp as in write_spar_deck) holds its + !! static start: rod end move at most mv_tol, cable tension change at most ten_tol relative. + CHARACTER(*), INTENT(IN) :: cable_at, root + LOGICAL, INTENT(IN) :: current + REAL(wp), INTENT(IN) :: mv_tol, ten_tol + LOGICAL, INTENT(IN), OPTIONAL :: ei0 + CHARACTER(*), INTENT(IN), OPTIONAL :: clamp + LOGICAL :: ok, e0 + CHARACTER(1024) :: em + CHARACTER(8) :: cl + e0 = .FALSE. + IF (PRESENT(ei0)) e0 = ei0 + cl = '' + IF (PRESENT(clamp)) cl = clamp + CALL write_spar_deck(root//'.dat', cable_at, current, 'monolithic', e0, cl, .FALSE.) + CALL run_deck(root//'.dat', root, ok, em) + CALL require(ok, root//': the spar deck runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL spar_measures(root, mv_m, ten_m, ok) + CALL require(ok, root//': output readable') + IF (.NOT. ok) RETURN + WRITE (*, '(A,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A)') root, ': rod end move ', mv_m, ' m (tol ', mv_tol, & + '), cable tension change ', ten_m, ' (tol ', ten_tol, ')' + CALL require(mv_m <= mv_tol, root//': the rod holds its static start') + CALL require(ten_m <= ten_tol, root//': the cable tension holds') + END SUBROUTINE check_hold + + SUBROUTINE check_reversed() + !! D. Line 5 written from its anchor to the upper rod end runs as the deck written from the + !! rod end (the line is turned around): the same output, byte for byte. + LOGICAL :: ok + CHARACTER(1024) :: em + CALL write_spar_deck('pcl_reversed.dat', 'upper', .FALSE., 'monolithic', .FALSE., '', .TRUE.) + CALL run_deck('pcl_reversed.dat', 'pcl_reversed', ok, em) + CALL require(ok, 'D: the reversed spar deck runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + ok = same_text('pcl_reversed.out', 'pcl_upper.out') + WRITE (*, '(A,L1)') 'D: cable written from its anchor writes the same output: ', ok + CALL require(ok, 'D: the cable written from its anchor writes the same output as from the rod end') + END SUBROUTINE check_reversed + + SUBROUTINE check_fixrod_roundoff() + !! R. The fixed-rod-to-free-rod cable of D, its End A on the seabed below End B: its static + !! start with the fixed rod moved by 1 ulp in x either way and by 1e-12 m up is the + !! same rod pose to 1e-9 m. + REAL(wp), PARAMETER :: X0 = -40.0_wp, Z0 = -50.0_wp + REAL(wp) :: r2(3, 3), rows(7, 4), p0(4), dmax + INTEGER :: k, n + LOGICAL :: ok + CHARACTER(1024) :: em + CHARACTER(24) :: root + r2(:, 1) = [NEAREST(X0, 1.0_wp), 0.0_wp, Z0] + r2(:, 2) = [NEAREST(X0, -1.0_wp), 0.0_wp, Z0] + r2(:, 3) = [X0, 0.0_wp, Z0 + 1.0e-12_wp] + CALL write_spar_deck('pcl_fixrod_r0.dat', 'fixrod', .FALSE., 'monolithic', .FALSE., '', .FALSE., tmax='0.0') + CALL run_deck('pcl_fixrod_r0.dat', 'pcl_fixrod_r0', ok, em) + CALL require(ok, 'R: the fixed-rod deck static start runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows('pcl_fixrod_r0.out', rows, n, ok) + CALL require(ok, 'R: static row written') + IF (.NOT. ok) RETURN + p0 = rows(2:5, 1) + dmax = 0.0_wp + DO k = 1, 3 + WRITE (root, '(A,I0)') 'pcl_fixrod_r', k + CALL write_spar_deck(TRIM(root)//'.dat', 'fixrod', .FALSE., 'monolithic', .FALSE., '', .FALSE., & + rod2_a=r2(:, k), tmax='0.0') + CALL run_deck(TRIM(root)//'.dat', TRIM(root), ok, em) + CALL require(ok, 'R: '//TRIM(root)//' (the fixed rod moved by round-off) runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows(TRIM(root)//'.out', rows, n, ok) + CALL require(ok, 'R: '//TRIM(root)//' static row written') + IF (.NOT. ok) RETURN + dmax = MAX(dmax, MAXVAL(ABS(rows(2:5, 1) - p0))) + END DO + WRITE (*, '(A,ES10.3,A)') 'R: fixed rod moved by 1 ulp or 1e-12 m: rod pose change ', dmax, ' m' + CALL require(dmax <= 1.0e-9_wp, 'R: the fixed rod moved by round-off gives the same static start') + END SUBROUTINE check_fixrod_roundoff + + SUBROUTINE check_staggered(cable_at, mono_root) + !! S. The spar deck (cable_at) on the staggered scheme: rod end positions within 1e-5 m and + !! the cable end tensions within 1e-5 of the larger start tension of the monolithic + !! step's (run mono_root) at every output step. + CHARACTER(*), INTENT(IN) :: cable_at, mono_root + REAL(wp) :: rm(7, 400), rs(7, 400), dp, dt_rel + INTEGER :: nm, ns, k + LOGICAL :: ok, ok2 + CHARACTER(1024) :: em + CALL write_spar_deck('pcl_stag_'//cable_at//'.dat', cable_at, .FALSE., 'staggered', .FALSE., '', .FALSE.) + CALL run_deck('pcl_stag_'//cable_at//'.dat', 'pcl_stag_'//cable_at, ok, em) + CALL require(ok, 'S: the staggered spar deck runs ('//cable_at//'): '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows(mono_root//'.out', rm, nm, ok) + CALL read_rows('pcl_stag_'//cable_at//'.out', rs, ns, ok2) + CALL require(ok .AND. ok2 .AND. nm == ns, 'S: both outputs readable with the same rows ('//cable_at//')') + IF (.NOT. (ok .AND. ok2 .AND. nm == ns)) RETURN + dp = 0.0_wp + dt_rel = 0.0_wp + DO k = 1, nm + dp = nan_max_abs([dp, rm(2:5, k) - rs(2:5, k)]) + dt_rel = nan_max_abs([dt_rel, (rm(6:7, k) - rs(6:7, k))/MAXVAL(rs(6:7, 1))]) + END DO + WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') 'S (', cable_at, '): monolithic vs staggered: rod end position ', dp, & + ' m, cable tension (relative) ', dt_rel + CALL require(dp <= 1.0e-5_wp, 'S: the monolithic and staggered rod motions agree ('//cable_at//')') + CALL require(dt_rel <= 1.0e-5_wp, 'S: the monolithic and staggered cable tensions agree ('//cable_at//')') + END SUBROUTINE check_staggered + + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_buoy() + !! B. A 4 t Rigid6 buoy (12 m^3) on three taut legs with a finite-EI cable pinned at its keel + !! point to a seabed anchor holds its static start over 4 s: body move at most 1e-5 m + !! and the cable tension within 1e-5. + INTEGER :: u, n, k + REAL(wp) :: rows(4, 500), mv, ten + LOGICAL :: ok + CHARACTER(1024) :: em + OPEN (NEWUNIT=u, FILE='pcl_buoy.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'light buoy with a finite-EI cable pinned at its keel' + 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)') 'cable 0.20 60.0 5.0e8 -1.0 2.0e4 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 0.0 0.0 0.0 0.0 0.0 0.0 4.0e3 12.0 2.84e5 2.0e6 2.0e6 24.0 0.1 2.0e4 2.0e4 1.8e4' + 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 3.0 0.0 -4.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 -1.5 2.598 -4.0 0 0 0 0' + WRITE (u, '(A)') '3 Body1 -1.5 -2.598 -4.0 0 0 0 0' + WRITE (u, '(A)') '4 Body1 0.0 0.0 -4.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed 60.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -30.0 51.962 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Fixed -30.0 -51.962 -100.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -60.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 5 -' + WRITE (u, '(A)') '2 2 6 -' + WRITE (u, '(A)') '3 3 7 -' + WRITE (u, '(A)') '4 4 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 111.4 20' + WRITE (u, '(A)') '2 poly 111.4 20' + WRITE (u, '(A)') '3 poly 111.4 20' + WRITE (u, '(A)') '4 cable 10.0 40' + WRITE (u, '(A)') '4 cable 120.0 60' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '4.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '0.4 rhoInf' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px Body1Pz FairTen4' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run_deck('pcl_buoy.dat', 'pcl_buoy', ok, em) + CALL require(ok, 'B: the buoy deck runs: '//TRIM(em)) + IF (.NOT. ok) RETURN + CALL read_rows('pcl_buoy.out', rows, n, ok) + CALL require(ok, 'B: buoy output readable') + IF (.NOT. ok) RETURN + mv = 0.0_wp + ten = 0.0_wp + DO k = 1, n + mv = nan_max_abs([mv, NORM2(rows(2:3, k) - rows(2:3, 1))]) + ten = nan_max_abs([ten, (rows(4, k) - rows(4, 1))/rows(4, 1)]) + END DO + WRITE (*, '(A,ES10.3,A,ES10.3)') 'B: light buoy, pinned keel cable: body move ', mv, & + ' m, cable tension change ', ten + CALL require(mv <= 1.0e-5_wp, 'B: the light buoy holds its static start') + CALL require(ten <= 1.0e-5_wp, 'B: the keel cable tension holds') + END SUBROUTINE check_buoy +END PROGRAM test_pinned_cable_light_object From 780708c974edd409244431c6de84ee747b17fd83 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 08:55:35 +0900 Subject: [PATCH 30/51] feat(current): deck currents on the standalone mixed EI=0 + finite-EI deck (#79) ## Summary The standalone mixed deck (`EI = 0` lines and finite-EI cables between `Fixed`/`Coupled`/`Vessel` points, run by the driver on the OpenFAST aggregate) now takes every deck current the single-line routes take: a `current` OPTION (uniform or profile), a WaterKin `CurrentMod 1` table and MoorDyn-C `Currents 1`/`2`/`5`. Until now the route refused all of them (and the aggregate also refused a deck current on any deck with a finite-EI cable). Deck waves stay refused on the mixed route, and the coupled OpenFAST/FAST.Farm route is unchanged: it keeps taking the host's field and refusing deck currents. ## Design - `CD_Init_Deck_Aggregate` / `CD_AGG_Init_From_Deck` take a new optional `deck_current` (passed only by the driver's `run_mixed_held_deck`). With it, the current refusals (`forbid_deck_ambient`, the finite-EI scope, MoorDyn-C `Currents 1/2/5`) are lifted. The refusals of `WaveKin 3/7` and deck waves stay. A deck-owned current is refused by name beside a host field (`external_fluid`), a host placement/farm/`static_current`, or bodies, rods and `Connect`/`Free` points (those decks run on the multibody or point-system march). Without `dtM` it is refused as on the single-line routes. - Statics: the static solves of the chains and the cables already take `opts` (with the static tangent gradient of a profile or grid). They now see the deck current at `t = 0`, as on the single-line routes. - Dynamics: an opaque `CD_DeckCurrentRuntimeType` (the deck options that carry the current, plus a sample workspace) is held by the aggregate. Its samplers call the single-line routes' own updaters: `update_system_line_hydro` (the system twin of `update_wave_models`) on the `EI = 0` lines and `update_hermite_deck_fluid` on the cables. Every field therefore goes through `deck_current_velocity`, as on the other routes. - `CD_AGG_Init_From_Deck` samples it at `t = 0` at the static state (the cables' first held field sets the consistent start acceleration). - `CD_AGG_Refresh_Accelerations` (the row-1 station of a motion) samples it again at `t = 0` at the installed row. - `CD_AGG_Step_Moving` samples it at `t_committed` at the step-start nodes, as the single-line marches do; `t_committed` is required. - `update_hermite_deck_fluid` takes an optional workspace, so the aggregate's march makes no heap allocation per step. The single-line routes still call it without one, unchanged. - Python `DeckFile` mirrors the change: a mixed deck accepts the currents, and refuses deck waves and `WaveKin 3/7` with the native wording. ## Validation New `mixed_route_currents` test (driver plus library): a 100 m cable and a 110 m chain, both fairleads surging 1 m from rest, in cross currents. Numbers are fractions of each channel's range, mixed route against the single-line routes. On dev every driver run of the mixed decks is refused. | Gate | Result | | --- | --- | | OPTION `uniform` / `profile`, `Currents 1/2/5`: static start | chain exact; cable 4.9e-6 / 4.3e-6 / 1.3e-6 / 9.2e-7 / 2.1e-6 (out-of-plane offset, 4 um of 0.55 m, the coupled build's static polish; still water: exact) | | March, coupled Newton controls (driver) | cable 1.0e-3 to 1.1e-3 (still water: 1.2e-3); chain 2.1e-5 uniform, exact sheared (still water: 5.4e-5, the row-1 transfer) | | March, the deck's Newton controls (library) | cable 4.9e-6 / 4.7e-6 / 9.5e-7 / 2.4e-6, the static start's difference (still water: 1.9e-8) | | Current felt | mid nodes 0.55 m / 0.56 m out of plane (uniform); chain tension history changes by 3.0e-3 | | `Currents 2` wrapping past its last sample | equal to the unrolled table bit for bit; differs from the held table by 0.39 of the chain tension range after 6 s | | Uniform field as `Currents 1` / `Currents 5` | bit for bit / static start bit for bit and march 3.9e-8 | | Correction rewind (`CD_AGG_Snapshot`, step, `CD_AGG_Restore`, step) x10, still water and `Currents 2` | bit for bit | | Refusals | deck waves, `uniform` beside `Currents 2`, current without `dtM` | Further checks: - `step_allocations_mixed_current`: 0 heap allocations in 160 steps in a `Currents 5` grid. It made 640 (4 per step) with the cables' automatic sample arrays before the workspace. - Python: a native-verdict parity test over ten mixed-deck current/wave rows; `driver_msg_mixed_current` now runs the lazy-wave deck in its current, and `driver_msg_mixed_waves` checks the waves refusal. Checks: - Release ctest: 345/345. - Checked Debug (`-fcheck=all`): 10/10 new and touched tests (`mixed_route_currents`, `step_allocations_mixed_current`, `mixed_route_torsion`, `mdc_currents`, `openfast_aggregate*`, `driver_msg_mixed*`). - pytest: 2189 passed, 75 skipped. The native mixed-route verdict test passes 10/10, and 5/10 fail against the dev driver. - ruff, strict mypy (only the 3 known errors), pre-commit, Sphinx `-W`, ifx duplicate-PUBLIC scan: 0. - Example A/B against dev: 53/53 decks identical. Docs: `driver_format.md`, `standalone_driver.rst`, `capabilities.rst`, `troubleshooting.rst`, `VALIDATION.md`, `CHANGELOG.md`. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 11 + CMakeLists.txt | 26 +- VALIDATION.md | 19 +- app/cabledyn.f90 | 17 +- doc/capabilities.rst | 9 +- doc/driver_format.md | 10 +- doc/standalone_driver.rst | 8 +- doc/troubleshooting.rst | 14 +- python/cabledyn/deck_file.py | 24 +- python/tests/test_deck_file.py | 5 +- python/tests/test_deck_native_parity.py | 90 ++- src/CableDyn_DeckDriver.f90 | 253 ++++++-- src/CableDyn_OpenFAST_Aggregate.f90 | 87 ++- tests/data/msg_mixed_waves.dat | 58 ++ tests/test_mixed_route_currents.f90 | 798 ++++++++++++++++++++++++ tests/test_step_allocations.f90 | 131 +++- 16 files changed, 1461 insertions(+), 99 deletions(-) create mode 100644 tests/data/msg_mixed_waves.dat create mode 100644 tests/test_mixed_route_currents.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index 08fa1f6a..aceb1c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,17 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- Deck currents on the standalone mixed `EI = 0` + finite-EI deck: a `current` OPTION (uniform or + profile), a WaterKin `CurrentMod 1` table and MoorDyn-C `Currents 1`/`2`/`5`, which the mixed + route refused, are taken in the static start of the chains and cables and sampled at every node + before each step with the single-line routes' updaters. Against the single-line routes on a + chain and a cable in a cross current: the static start agrees exactly for the chain and to + 4.9e-6 of the range for the cable (the coupled build's static polish), the march with the + same Newton controls to 4.9e-6 (cable) and 2.1e-5 (chain); a `Currents 2` table wrapping past + its last sample equals the unrolled table bit for bit; a uniform `Currents 1` profile and a + uniform `Currents 5` grid equal `uniform` to round-off (at most 3.9e-8); a correction rewind repeats the + step bit for bit; the march allocates nothing per step. Deck waves stay refused; the coupled + route keeps taking the host's field. - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 869b3af8..84066a67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1459,6 +1459,10 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN set_tests_properties(step_allocations_motion_roll PROPERTIES LABELS "fortran;dynamic;memory") add_test(NAME step_allocations_motion_vessel COMMAND test_step_allocations motion_vessel) set_tests_properties(step_allocations_motion_vessel PROPERTIES LABELS "fortran;dynamic;memory") + # And with the deck's own current on that march (a Currents 5 grid that varies in time). + add_test(NAME step_allocations_mixed_current COMMAND test_step_allocations mixed_current) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/step_alloc_mixed_current) + set_tests_properties(step_allocations_mixed_current PROPERTIES LABELS "fortran;dynamic;memory") # And with the nodal twist of a line free in torsion at one end. add_test(NAME step_allocations_torsion_one_end COMMAND test_step_allocations free) set_tests_properties(step_allocations_torsion_one_end PROPERTIES LABELS "fortran;dynamic;memory") @@ -2256,6 +2260,19 @@ target_link_libraries(test_mixed_route_torsion PRIVATE cabledyn_core) add_test(NAME mixed_route_torsion COMMAND test_mixed_route_torsion $) set_tests_properties(mixed_route_torsion PROPERTIES LABELS "fortran;driver;integration;dynamic") +# Deck currents on the standalone mixed route (the aggregate samples the deck current at every +# node before each step): OPTION uniform and profile and MoorDyn-C Currents 1/2/5 against the +# single-line routes, the wrap of a time-varying table, uniform writings of one field, snapshot +# and restore, and the refusals that remain (deck waves, double counting, no dtM). +add_executable(test_mixed_route_currents tests/test_mixed_route_currents.f90) +target_link_libraries(test_mixed_route_currents PRIVATE cabledyn_core) +add_test(NAME mixed_route_currents COMMAND test_mixed_route_currents $ + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/mixed_route_currents_work) +set_tests_properties(mixed_route_currents PROPERTIES LABELS "fortran;driver;integration;dynamic") +foreach(_mrc_case uni prof still wav c1 c2 c2u c2h c2d c5 c1u c5u) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/mixed_route_currents_work/${_mrc_case}) +endforeach() + 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}) @@ -2741,8 +2758,13 @@ cabledyn_msg_test(shared_line_finite_ei msg_shared_line_finite_ei.dat 1 cabledyn_msg_test(pliant_connect_end_b msg_pliant_connect_end_b.dat 1 "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" +# The standalone mixed route takes a deck current (here the static start of the lazy-wave deck) +# and refuses deck waves by name. +cabledyn_msg_test(mixed_current msg_mixed_current.dat 0 + "CableDyn mixed standalone aggregate: 3 line.s. .2 EI=0, 1 finite-EI." + "STILL WATER") +cabledyn_msg_test(mixed_waves msg_mixed_waves.dat 1 + "the deck waves OPTION is not supported for a standalone mixed EI=0/finite-EI deck;takes the deck current but evaluates no deck waves;couple the deck to OpenFAST .CompMooring = 5. with SeaState" "this coupled mode;the C API;FAST.Farm") cabledyn_msg_test(mixed_connect_coupled_cable msg_mixed_connect_coupled_cable.dat 1 "finite-EI LINE 3: a Coupled/Vessel End A .POINT 1. would need motionFile coupling to drive it;remove the Connect/Free points;held still .that route takes no motionFile either." diff --git a/VALIDATION.md b/VALIDATION.md index f0ce65de..4143f3a5 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -863,10 +863,23 @@ stop with a named error. **Standalone mixed aggregate.** `CableDyn_driver.exe` partitions and steps the same aggregate used by OpenFAST. The IEA-15 three-chain + touchdown-cable deck writes all four static profiles and a one-step `dtM=0.025 s` dynamic test with -progress/ETA. On this held-end mixed route (mixed lines without bodies, rods or -free points), `motionFile` and deck-owned waves/current stop with an error. Mixed -decks that also contain bodies, rods or free points run on the multibody march, +progress/ETA. On this mixed route (mixed lines without bodies, rods or free points) +the deck's prescribed motion (`motionFile`, `vesselMotion`; `mixed_route_torsion`) and +its current (`mixed_route_currents`, below) are marched; deck waves stop with an error. +Mixed decks that also contain bodies, rods or free points run on the multibody march, which accepts deck waves and current (`mixed_body_rods_points.dat`). +`mixed_route_currents` runs a cable (100 m, 40 elements) and a chain (110 m) surging 1 m from +rest in cross currents (OPTION `uniform` and `profile`, MoorDyn-C `Currents 1`, `2` and `5`) on +the mixed route and on their single-line routes: the static start agrees exactly for the chain +and to 4.9e-6 of each channel's range for the cable (its out-of-plane offset, 4 um of 0.55 m, at +the stopping point of the coupled build's static polish; exactly in still water); the march +differs by 1.1e-3 for the cable on the coupled Newton controls (1.2e-3 in still water too) and +keeps the static start's 4.9e-6 with the deck's; the chain agrees to 2.1e-5 (exactly in a sheared +current; the row-1 transfer, 5.4e-5 in still water). A `Currents 2` table wrapping past its last +sample equals the unrolled table bit for bit and departs from the held one by 0.39 of the chain +tension range; a uniform `Currents 1` profile equals `uniform` to round-off (0 on Windows, +3.9e-8 on Linux), a uniform `Currents 5` grid to 3.9e-8; ten correction rewinds repeat their steps bit for bit; the march of a mixed deck +in a `Currents 5` grid makes no heap allocation per step (`step_allocations_mixed_current`). ### WaterKin and SeaState modes diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 9676692b..9accf8a1 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -459,8 +459,10 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h !! motion as the standalone cubic-Hermite route does: the point rows' translations, the !! vessel's rotation (the orientation and angular rates the fairlead end connection and !! torsion frames turn with) and the motionFile roll column (the imposed twist of a line - !! restrained in torsion). Deck-owned ambient fields require separate updaters and - !! therefore remain an explicit fail-closed boundary. + !! restrained in torsion). The deck's own current (a current OPTION, a WaterKin CurrentMod 1 + !! table, MoorDyn-C Currents 1/2/5) is the aggregate's deck_current: its static solves take + !! it and every step samples it at the nodes. Deck waves remain an explicit fail-closed + !! boundary. CHARACTER(*), INTENT(IN) :: deck, root REAL(wp), INTENT(IN) :: dt, run_time LOGICAL, INTENT(IN) :: has_dt, has_run_time, has_motion, line_outputs @@ -527,13 +529,14 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h run_msg = 'CableDyn_driver: cannot allocate the mixed aggregate' EXIT mixed_run END IF - ! The aggregate is caller-driven and cannot refresh standalone wave/current - ! OPTIONS. Reject such decks by name instead of silently holding zero fluid. The driver - ! holds the line end frames or turns them with the deck's vesselMotion table + ! The aggregate is caller-driven and evaluates no deck waves: a waves OPTION is refused by + ! name instead of silently holding zero fluid. The deck's own current is the aggregate's + ! (deck_current), sampled at the nodes before every step at the step's t_committed. The + ! driver holds the line end frames or turns them with the deck's vesselMotion table ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). CALL CD_AGG_Init_From_Deck(aggregate, deck, step_dt, es, em, forbid_deck_ambient=.TRUE., & run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE., host_orientation=.TRUE., & - prescribed_motion=has_motion, static_run=nstep == 0) + prescribed_motion=has_motion, static_run=nstep == 0, deck_current=.TRUE.) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run @@ -633,7 +636,7 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h max_consecutive_miss = 0 first_miss_time = CD_ZERO last_miss_time = CD_ZERO - ! the march (no fluid sampled by the driver on this route) or, without one, finalisation + ! the march (the aggregate samples the deck current itself) or, without one, finalisation CALL CD_Profile_Enter(MERGE(CD_PROF_SOLVE, CD_PROF_FINAL, nstep > 0)) IF (nstep > 0) CALL start_standalone_progress(progress, nstep, step_dt) DO step = 1, nstep diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 7493bdf7..793046d3 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -72,8 +72,10 @@ Line and constitutive capability - Supported with route limits - a mixed deck of lines between held or coupled points only (no bodies, rods, or ``Free``/``Connect`` points) runs in OpenFAST and standalone as a static run or a dynamic - run with held ends or a ``motionFile``/``vesselMotion`` prescription, and rejects deck - waves standalone (so ``vesselRAO`` too); a mixed deck with bodies, rods, or + run with held ends or a ``motionFile``/``vesselMotion`` prescription; standalone it takes + the deck current (``current`` OPTION, WaterKin ``CurrentMod 1``, MoorDyn-C ``Currents`` + ``1``/``2``/``5``) as the single-line routes do and rejects deck waves (so ``vesselRAO`` + too); a mixed deck with bodies, rods, or ``Free``/``Connect`` points runs standalone on the multibody march, with moving objects and deck waves/current, but not with a ``motionFile`` * - Viscoelastic rope (MoorDyn ``ElasticMod`` 2/3) @@ -173,7 +175,8 @@ Loads and environment * - MoorDyn-C currents in time and space (``Currents 2``, ``Currents 5``) - Standalone only - ``current_profile_dynamic.txt`` and ``current_profile_4d.txt``, interpolated as MoorDyn-C - v2.7.1 does at every node's position and time, the static start included; see + v2.7.1 does at every node's position and time, the static start included, on every + standalone route (the mixed ``EI = 0`` + finite-EI deck too); see :ref:`moordyn-c-wavekin` * - Airy and JONSWAP waves - Supported diff --git a/doc/driver_format.md b/doc/driver_format.md index fba25861..1512b826 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -356,8 +356,14 @@ first steps differ from that route's. A static run (`TMax = 0`) of a line restra takes `False alpha_force_blend`, as on the single-line route. The run writes the common `.out` and the all-line `.static.out` tables, plus the range graph of every line with the `r` flag. -Mixed decks reject, by name, deck wave/current OPTIONS (so `vesselRAO`), WaterKin `WaveKinMod 1`, -MoorDyn-C `WaveKin 3`/`7` and `Currents 1`/`2`/`5`, and per-line `p`/`t` flags. +A mixed deck takes every deck current the single-line routes take: a `current` OPTION (uniform or +profile), a WaterKin `CurrentMod 1` table and MoorDyn-C `Currents 1`/`2`/`5`. The static start of +its `EI = 0` lines and finite-EI cables is solved in the current at `t = 0`, and before every step +the current at the step's end time is sampled at every node of the step-start state and held +over the step, as on the single-line routes and with the same field evaluation (a `Currents 2`/`5` +table that varies in time repeats past its last sample there too). Mixed decks reject, by name, +deck waves (so `vesselRAO`), WaterKin `WaveKinMod 1`, MoorDyn-C `WaveKin 3`/`7`, and per-line +`p`/`t` flags. (multibody-march)= **Multibody march** (bodies, rods, `Connect`/`Free` points, EI = 0 lines and finite-EI cables in diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index d608a667..3ca77654 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -109,9 +109,11 @@ to march held-end dynamics. A static-only mixed deck with no dynamic-only option both ``dtM`` and ``TMax``; the time-step option becomes mandatory when a positive-duration march is requested. -A mixed deck rejects deck-owned wave/current OPTIONS by name, and with them ``vesselRAO``, -which needs deck waves. A ``vesselMotion`` record moves every ``Coupled``/``Vessel`` point -rigidly with the vessel (translation and rotation of each hang-off); a ``motionFile`` gives the +A mixed deck takes the deck current (a ``current`` OPTION, a WaterKin ``CurrentMod 1`` table or +MoorDyn-C ``Currents 1``/``2``/``5``) in its static start and its march, as the single-line +routes do. It rejects deck waves by name, and with them ``vesselRAO``, which needs deck waves. +A ``vesselMotion`` record moves every ``Coupled``/``Vessel`` point rigidly with the vessel +(translation and rotation of each hang-off); a ``motionFile`` gives the rows of each point. Row 1 is installed before ``t = 0``, also with ``TMax = 0``, after the ``.static.out`` of the static solve is written. On the ``EI = 0`` lines that transfer re-derives the interior accelerations, which the ``EI = 0``-only route does not, so with row 1 off the deck diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 8c590c8b..8322bfe9 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -299,13 +299,13 @@ Model data deck (the ``EI = 0`` lines on the Coupled point directly): a host (OpenFAST ``CompMooring = 5`` or the C API) drives its Coupled points, and the standalone driver runs it with them held still (that route takes no ``motionFile`` either). - * - ``the deck current OPTION is not supported for a standalone mixed EI=0/finite-EI deck`` / - ``the deck waves OPTION ...`` - - the standalone driver runs a mixed ``EI = 0``/finite-EI deck in still water: no ambient - fluid field covers its span. Remove the ``waves``/``current`` OPTION, run a deck whose - lines are all ``EI = 0`` or all finite-EI (those standalone routes evaluate the deck waves - and current), or couple the deck to OpenFAST (``CompMooring = 5``) with SeaState, which - supplies them. + * - ``the deck waves OPTION is not supported for a standalone mixed EI=0/finite-EI deck`` / + ``the MoorDyn-C WaveKin waves are not supported for a standalone mixed EI=0/finite-EI + deck`` + - the standalone driver marches the deck current of a mixed ``EI = 0``/finite-EI deck but no + deck waves. Remove the ``waves`` OPTION (or ``WaveKin``), run a deck whose lines are all + ``EI = 0`` or all finite-EI (those standalone routes evaluate the deck waves), or couple + the deck to OpenFAST (``CompMooring = 5``) with SeaState, which supplies them. * - ``the deck current OPTION is not supported in FAST.Farm`` / ``the deck waves OPTION ...`` - the shared mooring of a FAST.Farm farm runs in still water (no fluid field spans the farm). Remove the ``waves``/``current`` OPTION. diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 8065c46a..9fb70d1a 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -3756,18 +3756,20 @@ def end_key(token: str) -> str: f"{self._label}: OPTION nModes is not supported for mixed EI=0/finite-EI " "decks; remove it or set it to 0" ) - # native run_mixed_held_deck: the standalone mixed deck runs on the aggregate in - # still water and writes the main OUTPUTS only - if ( - has_waves - or trains - or mdc_wave_kin - or (current is not None and current.values[0].lower() != "none") - or mdc_currents - ): + # native run_mixed_held_deck: the standalone mixed deck runs on the aggregate, which + # marches the deck current (a current OPTION or Currents 1/2/5, deck_current) but + # evaluates no deck waves, and writes the main OUTPUTS only + if mdc_wave_kin: + raise DeckFormatError( + f"{self._label}: the MoorDyn-C WaveKin {mdc_wave_kin} waves are not supported " + "for a standalone mixed EI=0/finite-EI deck (it takes a deck current but no " + "deck waves)" + ) + if has_waves or trains: raise DeckFormatError( - f"{self._label}: a mixed EI=0/finite-EI deck runs in still water; remove " - "the deck waves and current" + f"{self._label}: the deck waves OPTION is not supported for a standalone mixed " + "EI=0/finite-EI deck: this route takes the deck current but evaluates no deck " + "waves" ) if series_lines: raise DeckFormatError( diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 62254259..49d0dda6 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -940,9 +940,8 @@ def test_attachments_accept_an_axial_drag_area_and_a_deck_current(tmp_path): # all finite-EI lines: the deck driver takes a deck current path.write_text(text.replace("1.0e8 0.0 0.0 1.2", "1.0e8 0.0 1.0e3 1.2"), encoding="utf-8") DeckFile.read(path) - # a mixed EI=0/finite-EI deck runs on the aggregate in still water - with pytest.raises(DeckFormatError, match="runs in still water"): - DeckFile.from_text(text) + # a mixed EI=0/finite-EI deck runs on the aggregate in its current too + DeckFile.from_text(text) def test_viv_lift_flag_is_upper_case_and_standalone(): diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 2abb9c5e..55f4d6a0 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -842,17 +842,27 @@ def test_quoted_syrope_paths_reject_what_a_quote_cannot_hold(path, message): ) -def test_standalone_mixed_deck_runs_on_the_still_water_aggregate(): +def test_standalone_mixed_deck_runs_on_the_aggregate_in_its_current(): DeckFile.from_text(_MIXED) DeckFile.from_text(_edit(_MIXED, ("2 2 3 -", "2 2 3 r"))) - _rejects(_options(_MIXED, "uniform 0.5 0 0 current"), "runs in still water") - _rejects(_options(_MIXED, "airy 2 8 0 waves"), "runs in still water") + # the aggregate marches the deck current (deck_current) but evaluates no deck waves + DeckFile.from_text(_options(_MIXED, "uniform 0.5 0 0 current")) + DeckFile.from_text(_options(_MIXED, "profile -50 0.1 0 0 0 0.5 0.2 0 current")) + for mode in (1, 2, 5): + DeckFile.from_text(_options(_MIXED, f"{mode} Currents")) + _rejects(_options(_MIXED, "airy 2 8 0 waves"), "evaluates no deck waves") + _rejects(_options(_MIXED, "7 WaveKin"), "WaveKin 7 waves are not supported") + _rejects(_options(_MIXED, "uniform 0.5 0 0 current", "2 Currents"), "double-counting") + _rejects( + _edit(_options(_MIXED, "uniform 0.5 0 0 current"), ("0.1 dtM\n10.0 TMax\n", "")), + "standalone OPTION current requires dtM and TMax", + ) _rejects(_edit(_MIXED, ("2 2 3 -", "2 2 3 pt")), "writes no per-line files") # the driver marches the deck's motionFile or vesselMotion; vesselRAO needs deck waves DeckFile.from_text(_options(_MIXED, "m.txt motionFile")) DeckFile.from_text(_options(_MIXED, "v.txt vesselMotion", "0|0|0 vesselRef")) _rejects(_options(_MIXED, "r.txt vesselRAO"), "vesselRAO needs deck waves") - _rejects(_options(_MIXED, "r.txt vesselRAO", "airy 2 8 0 waves"), "runs in still water") + _rejects(_options(_MIXED, "r.txt vesselRAO", "airy 2 8 0 waves"), "evaluates no deck waves") def test_coupled_route_takes_no_motion_file_and_needs_a_line(): @@ -1710,3 +1720,75 @@ def test_model_round_trips_the_torsion_columns(): ) assert added.torsion_stiffness == 1.0e4 assert "TorsStiffness" in plain.to_text() + + +# MoorDyn-C current files of the mixed-route parity decks (written beside the deck) +_MIXED_CURRENT_FILES = { + 1: ("current_profile.txt", "steady\nz ux uy uz\n-50.0 0.1 0.05 0.0\n0.0 0.4 0.2 0.0\n"), + 2: ( + "current_profile_dynamic.txt", + "dynamic\n\n\n\n-50.0 0.0\nt ux... uy...\n0.0 0.1 0.3 0.0 0.1\n1.0 0.2 0.4 0.05 0.15\n", + ), + 5: ( + "current_profile_4d.txt", + "2 2 2 2\n-500.0 500.0\n-50.0 50.0\n-60.0 0.0\n0.0 1.0\nx y z t ux uy uz\n" + + "".join( + f"{x} {y} {z} {t} {0.1 + 0.1 * t} 0.05 0.0\n" + for t in (0.0, 1.0) + for z in (-60.0, 0.0) + for y in (-50.0, 50.0) + for x in (-500.0, 500.0) + ), + ), +} + + +@pytest.mark.skipif( + not _PARITY_DRIVER or not Path(_PARITY_DRIVER).is_file(), + reason="set CABLEDYN_TEST_DRIVER to a built native driver to run the native mixed-route parity", +) +@pytest.mark.parametrize( + "rows", + [ + ("uniform 0.5 0 0 current",), + ("profile -50 0.1 0 0 0 0.5 0.2 0 current",), + ("1 Currents",), + ("2 Currents",), + ("5 Currents",), + ("2 Currents", "uniform 0.5 0 0 current"), + ("3 Currents",), + ("airy 2 8 0 waves",), + ("7 WaveKin",), + ("no dtM", "uniform 0.5 0 0 current"), + ], +) +def test_mixed_route_currents_get_the_native_verdict(rows, tmp_path): + # the deck currents of the single-line routes run on the mixed route too; deck waves do not + text = _edit(_MIXED, ("0.1 dtM\n10.0 TMax\n", "0.1 dtM\n0.2 TMax\n")) + if rows[0] == "no dtM": + text = _edit(text, ("0.1 dtM\n0.2 TMax\n", "")) + rows = rows[1:] + text = _options(text, *rows) + for row in rows: + if row.endswith("Currents") and int(row.split()[0]) in _MIXED_CURRENT_FILES: + name, content = _MIXED_CURRENT_FILES[int(row.split()[0])] + (tmp_path / name).write_text(content, encoding="utf-8") + try: + DeckFile.from_text(text) + python_accepts = True + except DeckFormatError: + python_accepts = False + deck = tmp_path / "mixed.dat" + deck.write_text(text, encoding="utf-8") + completed = subprocess.run( + [_PARITY_DRIVER, str(deck), str(tmp_path / "mixed")], + capture_output=True, + text=True, + cwd=tmp_path, + timeout=600, + check=False, + ) + # exit code 1 is an input refusal; 0 a run and 2 a solve failure after validation + assert python_accepts == (completed.returncode != 1), completed.stdout + completed.stderr + if python_accepts: + assert "mixed standalone aggregate" in completed.stdout, completed.stdout diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index ec80fc40..d914afda 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -219,6 +219,11 @@ MODULE CableDyn_DeckDriver PUBLIC :: CD_MotionRuntimeType PUBLIC :: CD_Motion_Active, CD_Motion_NColumns, CD_Motion_Has_Rotation, CD_Motion_Has_Roll PUBLIC :: CD_Motion_Kinematics, CD_Motion_Deck_Positions, CD_Motion_End + ! Deck current of a standalone mixed deck: the aggregate samples it at every node before each + ! step with the updaters of the single-line routes (opaque; DeckOptions stays private). + PUBLIC :: CD_DeckCurrentRuntimeType + PUBLIC :: CD_Deck_Current_Active, CD_Deck_Current_Sample_System, CD_Deck_Current_Sample_Cables + PUBLIC :: CD_Deck_Current_End PUBLIC :: CD_Init_Deck_Aggregate_Rod, CD_Step_Aggregate_Rod PUBLIC :: CD_Rod_NRods, CD_Rod_Snapshot, CD_Rod_Restore, CD_Rod_End PUBLIC :: CD_Rod_MirrorSize, CD_Rod_Get_States, CD_Rod_Set_States, CD_Rod_Apply_States @@ -791,6 +796,8 @@ MODULE CableDyn_DeckDriver TYPE :: HydroUpdateWorkspace REAL(wp), ALLOCATABLE :: q(:), v(:), a(:) REAL(wp), ALLOCATABLE :: fluid_velocity(:, :), fluid_acceleration(:, :), waterline(:) + ! node positions of a finite-EI cable (update_hermite_deck_fluid with a workspace) + REAL(wp), ALLOCATABLE :: node_pos(:, :) END TYPE TYPE :: ModelOutputWorkspace @@ -1092,6 +1099,22 @@ MODULE CableDyn_DeckDriver LOGICAL, ALLOCATABLE :: col_roll(:) END TYPE + !> Opaque deck current of a standalone mixed deck, which the standalone driver marches on the + !> coupled aggregate (CD_Init_Deck_Aggregate with deck_current): the deck's current OPTION + !> (uniform or profile), WaterKin CurrentMod 1 table or MoorDyn-C Currents 1/2/5 field, as the + !> deck options that carry it, and the workspace of its samples. Before every step the + !> aggregate samples it at time t + dt at every node of the step-start state and holds it over + !> the step (CD_Deck_Current_Sample_System on the EI = 0 lines, CD_Deck_Current_Sample_Cables + !> on the finite-EI cables), with the updaters of the single-line EI = 0 and cubic-Hermite + !> routes (update_wave_models' system twin update_system_line_hydro, update_hermite_deck_fluid), + !> so every route evaluates the same field the same way (deck_current_velocity). + TYPE :: CD_DeckCurrentRuntimeType + PRIVATE + LOGICAL :: active = .FALSE. + TYPE(DeckOptions) :: opts + TYPE(HydroUpdateWorkspace) :: 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 @@ -1209,6 +1232,9 @@ MODULE CableDyn_DeckDriver ! The deck's own prescribed motion (prescribed_motion: the standalone driver), in the ! aggregate moving-set order; inactive otherwise. TYPE(CD_MotionRuntimeType) :: motion + ! The deck's own current (deck_current: the standalone driver), sampled by the facade at + ! every node before each step; inactive otherwise. + TYPE(CD_DeckCurrentRuntimeType) :: current END TYPE CONTAINS @@ -7248,7 +7274,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & range_files, host_orientation, static_current, prescribed_motion, & - static_run) + static_run, deck_current) !! Parse a MIXED deck ONCE and partition its lines into {EI=0 mooring} and !! {finite-EI cable}, returning the raw parts the OpenFAST aggregate facade wraps: !! the EI=0 mooring SYSTEM built from the mooring subset (over ALL deck points, the @@ -7267,6 +7293,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi !! a deck with a finite-EI cable, a Rigid6 body or a rod, under a host fluid field, or in !! FAST.Farm mode; a deck with a finite-EI cable that also carries Free/Connect dynamic !! points. A deck current on any other deck is a steady field applied through the lines. + !! With deck_current (the standalone driver) a deck current of every kind the standalone + !! routes take is the deck's own, on the EI = 0 lines and the finite-EI cables alike. !! Coupled finite-EI flat/structured contact and friction use the same production !! Hermite residual as the standalone route. !! ptfm_init (optional, 6): initial platform displacement [surge, sway, heave, @@ -7338,9 +7366,17 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! restrained in torsion needs no force-blended step, as on the single-line standalone route; ! a coupled host always marches. LOGICAL, INTENT(IN), OPTIONAL :: static_run + ! deck_current: the caller marches the deck's own current (the standalone driver on a mixed + ! deck of lines between Fixed/Coupled/Vessel points): a current OPTION (uniform or profile), a + ! WaterKin CurrentMod 1 table or a MoorDyn-C Currents 1/2/5 field is taken instead of refused. + ! The static solves of the EI = 0 lines and of the finite-EI cables take it at t = 0, as on + ! the single-line routes, and agg%current carries it for the facade, which samples it at + ! every node before each step (CD_Deck_Current_Sample_System/_Cables). A coupled host keeps + ! supplying its own field and passes no deck_current. + LOGICAL, INTENT(IN), OPTIONAL :: deck_current INTEGER :: nturb - LOGICAL :: host_turns, own_motion, dynamic_points, static_only + LOGICAL :: host_turns, own_motion, dynamic_points, static_only, own_current TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -7478,12 +7514,49 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 'coupled aggregate runs must use WaveKinMod 2/SEASTATE through external_fluid') RETURN END IF - IF (opts%mdc_wave_kin > 0 .OR. opts%mdc_currents > 0) THEN + own_current = .FALSE. + IF (PRESENT(deck_current)) own_current = deck_current + IF (opts%mdc_wave_kin > 0 .AND. own_current) THEN + CALL fail(ErrStat, ErrMsg, 'the MoorDyn-C WaveKin '//TRIM(int_to_str(opts%mdc_wave_kin))//' waves are '// & + 'not supported for a standalone mixed EI=0/finite-EI deck (it takes a deck current but no '// & + 'deck waves): remove WaveKin, run a deck whose lines are all EI=0 or all finite-EI, or '// & + 'couple the deck to OpenFAST (CompMooring = 5) with SeaState, which supplies the waves') + RETURN + END IF + IF ((opts%mdc_wave_kin > 0 .OR. opts%mdc_currents > 0) .AND. .NOT. own_current) THEN CALL fail(ErrStat, ErrMsg, 'the MoorDyn-C WaveKin 3/7 and Currents 1/2/5 files are not supported on the '// & - 'aggregate route (coupled runs take water kinematics from the host; standalone mixed '// & - 'EI=0/finite-EI decks reject deck water kinematics)') + 'aggregate route (coupled runs take water kinematics from the host)') RETURN END IF + ! The deck's own current (deck_current) is marched by the standalone driver over lines between + ! Fixed/Coupled/Vessel points held or moved by the deck's motion, from the deck pose: no host + ! field, placement or farm, and no body, rod or Connect/Free point (those decks run on the + ! standalone multibody or point-system march, which take the current themselves). + IF (own_current .AND. (opts%has_current .OR. opts%has_current_profile)) THEN + IF (PRESENT(external_fluid)) THEN + IF (external_fluid) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a deck-owned current (deck_current) and a '// & + 'host fluid field (external_fluid) would double-count the current'); RETURN + END IF + END IF + IF (nturb > 0 .OR. PRESENT(ptfm_init) .OR. PRESENT(coupled_positions) .OR. PRESENT(static_current)) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a deck-owned current (deck_current) is marched '// & + 'from the deck pose of a standalone deck (no host placement, farm or host current)'); RETURN + END IF + IF (deck_has_dynamic_points(points) .OR. SIZE(bodies) > 0 .OR. SIZE(rods) > 0) THEN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a deck-owned current (deck_current) drives lines '// & + 'between Fixed/Coupled/Vessel points only (bodies, rods and Connect/Free points take it on '// & + 'the standalone multibody or point-system march)'); RETURN + END IF + ! the standalone routes' clock: the current is a dynamic-deck option + IF (.NOT. opts%has_dtm) THEN + IF (opts%mdc_currents > 0) THEN + CALL fail(ErrStat, ErrMsg, 'standalone Currents '//TRIM(int_to_str(opts%mdc_currents))// & + ' requires dtM and TMax'); RETURN + END IF + CALL fail(ErrStat, ErrMsg, 'standalone OPTION current requires dtM and TMax'); RETURN + END IF + END IF IF (opts%waterkin_seastate) THEN IF (.NOT. PRESENT(external_fluid)) THEN @@ -7529,6 +7602,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (forbid_deck_ambient) THEN ! The two callers that forbid deck ambient fluid: the FAST.Farm shell (n_turbines >= 1) and ! the standalone runner of a mixed EI=0/finite-EI deck. Each gets the advice of its route. + ! The standalone runner marches the deck current itself (deck_current), so only a caller + ! without it is refused one. IF (opts%has_wave) THEN IF (nturb > 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck waves OPTION is not supported in '// & @@ -7536,22 +7611,21 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 'farm). Remove the waves OPTION'); RETURN END IF CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck waves OPTION is not supported for a '// & - 'standalone mixed EI=0/finite-EI deck: this route runs the mooring in STILL WATER, because '// & - 'no ambient fluid field covers its span. Remove the waves OPTION, run a deck whose lines are '// & + 'standalone mixed EI=0/finite-EI deck: this route takes the deck current but evaluates no '// & + 'deck waves. Remove the waves OPTION, run a deck whose lines are '// & 'all EI=0 or all finite-EI (those standalone routes evaluate the deck waves), or couple the '// & 'deck to OpenFAST (CompMooring = 5) with SeaState, which supplies the waves'); RETURN END IF - IF (opts%has_current .OR. opts%has_current_profile) THEN + IF ((opts%has_current .OR. opts%has_current_profile) .AND. .NOT. own_current) THEN IF (nturb > 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not supported in '// & 'FAST.Farm: the shared mooring of a farm runs in STILL WATER (no fluid field spans the '// & 'farm). Remove the current OPTION'); RETURN END IF - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not supported for a '// & - 'standalone mixed EI=0/finite-EI deck: this route runs the mooring in STILL WATER, because '// & - 'no ambient fluid field covers its span. Remove the current OPTION, run a deck whose lines are '// & - 'all EI=0 or all finite-EI (those standalone routes evaluate the deck current), or couple the '// & - 'deck to OpenFAST (CompMooring = 5) with SeaState, which supplies the current'); RETURN + ! (the standalone mixed route passes deck_current; this is a library caller without it) + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not marched by a '// & + 'caller that forbids deck ambient fluid without deck_current; remove the current OPTION, '// & + 'or pass deck_current to march the deck''s own current'); RETURN END IF END IF END IF @@ -7786,7 +7860,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! closed rather than silently drop the physics. A PURE mooring deck (n_fin == 0) keeps ! the full EI=0 feature set so it composes to the plain CD_FMF_Init_From_Deck system. IF (n_fin > 0) THEN - IF (opts%has_current .OR. opts%has_current_profile) THEN + ! (a deck-owned current, deck_current, reaches the cables through their held field) + IF ((opts%has_current .OR. opts%has_current_profile) .AND. .NOT. own_current) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: ambient current on a deck with a finite-EI '// & 'cable is not supported (the cable does not receive a deck-owned current)'); RETURN END IF @@ -8088,6 +8163,12 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (ErrStat /= CD_DECKDRV_OK) THEN CALL CD_End_Deck_Aggregate(agg); RETURN END IF + ! The deck's own current, sampled by the facade at every node before each step (the + ! static solves above took it at t = 0 through opts). + IF (own_current .AND. opts%has_current) THEN + agg%current%active = .TRUE. + agg%current%opts = opts + END IF ! The deck's own prescribed motion over the same moving-set order. IF (own_motion) THEN CALL build_aggregate_motion(points, lines, is_fin, opts, agg%motion, ErrStat, ErrMsg) @@ -8676,6 +8757,7 @@ SUBROUTINE CD_End_Deck_Aggregate(agg) agg%has_point3 = .FALSE. CALL CD_Range_End(agg%ranges) CALL CD_Motion_End(agg%motion) + CALL CD_Deck_Current_End(agg%current) agg%gravity = CD_ZERO agg%rho_water = CD_ZERO END SUBROUTINE CD_End_Deck_Aggregate @@ -8881,6 +8963,61 @@ SUBROUTINE CD_Motion_End(rt) rt%active = .FALSE. END SUBROUTINE CD_Motion_End + LOGICAL FUNCTION CD_Deck_Current_Active(rt) RESULT(active) + !! The aggregate carries the deck's own current (CD_Init_Deck_Aggregate deck_current). + TYPE(CD_DeckCurrentRuntimeType), INTENT(IN) :: rt + active = rt%active + END FUNCTION CD_Deck_Current_Active + + SUBROUTINE CD_Deck_Current_Sample_System(rt, system, time, ErrStat, ErrMsg, initial_condition) + !! The deck current u(x_j, time) at every node x_j of the EI = 0 system's lines, held over the + !! coming step as the drag's fluid velocity (update_system_line_hydro, the updater of the + !! standalone point-system march): before a step from t to t + dt the caller passes time = + !! t + dt and the step-start node positions, as the single-line EI = 0 march does. With + !! initial_condition (the t = 0 sample at the start state) a line whose field changed + !! re-derives its acceleration; a march-step sample keeps the committed generalised-alpha + !! acceleration. A no-op without a deck current. + TYPE(CD_DeckCurrentRuntimeType), INTENT(INOUT) :: rt + TYPE(CD_SystemType), INTENT(INOUT) :: system + REAL(wp), INTENT(IN) :: time + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: initial_condition + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (.NOT. rt%active) RETURN + CALL update_system_line_hydro(system, rt%opts, time, rt%work, ErrStat, ErrMsg, & + initial_condition=initial_condition) + END SUBROUTINE CD_Deck_Current_Sample_System + + SUBROUTINE CD_Deck_Current_Sample_Cables(rt, cables, time, ErrStat, ErrMsg) + !! The deck current u(x_j, time) at every node x_j of each finite-EI cable, installed as its + !! held fluid field over the coming step (update_hermite_deck_fluid, the updater of the + !! standalone cubic-Hermite march; time = t + dt at the step-start nodes). The first held + !! field of a cable completes its dynamic initialisation (the consistent start acceleration + !! in the current); a later one keeps the committed acceleration. A no-op without a deck + !! current. + TYPE(CD_DeckCurrentRuntimeType), INTENT(INOUT) :: rt + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) + REAL(wp), INTENT(IN) :: time + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + IF (.NOT. rt%active) RETURN + CALL update_hermite_deck_fluid(cables, rt%opts, time, ErrStat, ErrMsg, work=rt%work) + END SUBROUTINE CD_Deck_Current_Sample_Cables + + SUBROUTINE CD_Deck_Current_End(rt) + !! Release the deck current. Idempotent. + TYPE(CD_DeckCurrentRuntimeType), INTENT(INOUT) :: rt + TYPE(DeckOptions) :: none + TYPE(HydroUpdateWorkspace) :: empty + rt%opts = none + rt%work = empty + rt%active = .FALSE. + END SUBROUTINE CD_Deck_Current_End + SUBROUTINE CD_Run_Deck_Driver(deck_path, out_root, converged, ErrStat, ErrMsg) !! Parse a MoorDyn-style deck, run static IC and optional held-end dynamic march, !! write `.out`. @@ -31381,49 +31518,75 @@ SUBROUTINE apply_motion_to_hermite_cables(cables, lines, points, motion, time_in END DO END SUBROUTINE apply_motion_to_hermite_cables - SUBROUTINE update_hermite_deck_fluid(cables, opts, time, ErrStat, ErrMsg) + SUBROUTINE update_hermite_deck_fluid(cables, opts, time, ErrStat, ErrMsg, work) + !! The deck current and waves at time at every node of each cable, installed as its held + !! fluid field (CD_HFMF_Set_Held_Fluid). work (optional): the scratch of the samples, sized at + !! the first call, so a march that passes it makes no heap allocation per step. TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cables(:) TYPE(DeckOptions), INTENT(IN) :: opts REAL(wp), INTENT(IN) :: time INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: i, j, nn, es - REAL(wp) :: eta, wv(3), wa(3) - CHARACTER(1024) :: em - CHARACTER(200) :: em_k ! a per-node current or wave kinematics message (at most 160 characters) + TYPE(HydroUpdateWorkspace), INTENT(INOUT), OPTIONAL :: work + INTEGER :: i, nn + LOGICAL :: grow ErrStat = CD_DECKDRV_OK; ErrMsg = '' IF (.NOT. (opts%has_current .OR. opts%has_wave)) RETURN DO i = 1, SIZE(cables) nn = CD_HFMF_NNodes(cables(i)) - BLOCK - REAL(wp) :: xyz(3, nn), fv(3, nn), fa(3, nn), wl(nn) - CALL CD_HFMF_GetNodePositions(cables(i), xyz, es, em) - IF (es /= CD_HFMF_OK) THEN - CALL hermite_fluid_fail('node-position query', em); RETURN - END IF - fv = CD_ZERO; fa = CD_ZERO; wl = CD_ZERO - DO j = 1, nn - IF (opts%has_current) THEN - fv(:, j) = deck_current_velocity(opts, xyz(:, j), time, es, em_k) - IF (es /= CD_HYDRO_OK) THEN - CALL hermite_fluid_fail('current profile', em_k); RETURN - END IF + IF (PRESENT(work)) THEN + CALL ensure_hydro_workspace(work, 0, nn) + grow = .NOT. ALLOCATED(work%node_pos) + IF (.NOT. grow) grow = SIZE(work%node_pos, 2) < nn + IF (grow) THEN + IF (ALLOCATED(work%node_pos)) DEALLOCATE (work%node_pos) + ALLOCATE (work%node_pos(3, nn)) + END IF + CALL hermite_cable_fluid(cables(i), nn, work%node_pos(:, 1:nn), work%fluid_velocity(:, 1:nn), & + work%fluid_acceleration(:, 1:nn), work%waterline(1:nn)) + ELSE + BLOCK + REAL(wp) :: xyz(3, nn), fv(3, nn), fa(3, nn), wl(nn) + CALL hermite_cable_fluid(cables(i), nn, xyz, fv, fa, wl) + END BLOCK + END IF + IF (ErrStat /= CD_DECKDRV_OK) RETURN + END DO + CONTAINS + SUBROUTINE hermite_cable_fluid(cable, n, xyz, fv, fa, wl) + !! One cable's sample: u(x_j, time) (current plus wave velocity), the wave acceleration and + !! elevation at its node positions x_j, held as its fluid field. + TYPE(CD_HFMF_ModuleType), INTENT(INOUT) :: cable + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(OUT) :: xyz(3, n), fv(3, n), fa(3, n), wl(n) + INTEGER :: j, es + REAL(wp) :: eta, wv(3), wa(3) + CHARACTER(1024) :: em + CHARACTER(200) :: em_k ! a per-node current or wave kinematics message (at most 160 characters) + CALL CD_HFMF_GetNodePositions(cable, xyz, es, em) + IF (es /= CD_HFMF_OK) THEN + CALL hermite_fluid_fail('node-position query', em); RETURN + END IF + fv = CD_ZERO; fa = CD_ZERO; wl = CD_ZERO + DO j = 1, n + IF (opts%has_current) THEN + fv(:, j) = deck_current_velocity(opts, xyz(:, j), time, es, em_k) + IF (es /= CD_HYDRO_OK) THEN + CALL hermite_fluid_fail('current profile', em_k); RETURN END IF - IF (opts%has_wave) THEN - CALL deck_wave_kinematics(opts, xyz(1, j), xyz(2, j), xyz(3, j), time, eta, wv, wa, es, em_k) - IF (es /= CD_HYDRO_OK) THEN - CALL hermite_fluid_fail('wave kinematics', em_k); RETURN - END IF - fv(:, j) = fv(:, j) + wv; fa(:, j) = wa; wl(j) = eta + END IF + IF (opts%has_wave) THEN + CALL deck_wave_kinematics(opts, xyz(1, j), xyz(2, j), xyz(3, j), time, eta, wv, wa, es, em_k) + IF (es /= CD_HYDRO_OK) THEN + CALL hermite_fluid_fail('wave kinematics', em_k); RETURN END IF - END DO - CALL CD_HFMF_Set_Held_Fluid(cables(i), fv, fa, wl, es, em) - IF (es /= CD_HFMF_OK) THEN - CALL hermite_fluid_fail('held-field update', em); RETURN + fv(:, j) = fv(:, j) + wv; fa(:, j) = wa; wl(j) = eta END IF - END BLOCK - END DO - CONTAINS + END DO + CALL CD_HFMF_Set_Held_Fluid(cable, fv, fa, wl, es, em) + IF (es /= CD_HFMF_OK) CALL hermite_fluid_fail('held-field update', em) + END SUBROUTINE hermite_cable_fluid + SUBROUTINE hermite_fluid_fail(where, msg) CHARACTER(*), INTENT(IN) :: where, msg ErrStat = CD_DECKDRV_SOLVEFAIL diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index e8e75e9e..62d59dcb 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -86,7 +86,10 @@ MODULE CableDyn_OpenFAST_Aggregate CD_Deck_Range_Sample_Aggregate, CD_Deck_Range_Write, & CD_MotionRuntimeType, CD_Motion_Active, CD_Motion_NColumns, & CD_Motion_Has_Rotation, CD_Motion_Has_Roll, CD_Motion_Kinematics, & - CD_Motion_Deck_Positions, CD_Motion_End + CD_Motion_Deck_Positions, CD_Motion_End, & + CD_DeckCurrentRuntimeType, CD_Deck_Current_Active, & + CD_Deck_Current_Sample_System, CD_Deck_Current_Sample_Cables, & + CD_Deck_Current_End USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & CD_Get_System_Line_State, & @@ -181,6 +184,11 @@ MODULE CableDyn_OpenFAST_Aggregate REAL(wp), ALLOCATABLE :: cable_phi0(:) ! The deck's own prescribed motion (standalone mixed route; inactive for a coupled host). TYPE(CD_MotionRuntimeType) :: motion + ! The deck's own current (standalone mixed route, Init deck_current; inactive for a coupled + ! host, which supplies its field through CD_AGG_SetFluidFields): sampled at every node of the + ! EI = 0 lines and the cables at t = 0 by Init and CD_AGG_Refresh_Accelerations, and at + ! t_committed before every step (sample_deck_current). + TYPE(CD_DeckCurrentRuntimeType) :: current ! Per-cable status staging lets independent finite-EI cables advance concurrently while ! preserving deterministic, cable-order error reporting after the parallel region. INTEGER, ALLOCATABLE :: cable_stat(:) @@ -280,7 +288,8 @@ MODULE CableDyn_OpenFAST_Aggregate SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravity, env_rho_water, env_wtrdpth, & ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & - range_files, host_orientation, static_current, prescribed_motion, static_run) + range_files, host_orientation, static_current, prescribed_motion, static_run, & + deck_current) !! Build the aggregate from ONE mixed deck: partition its lines into {EI=0 mooring} !! and {finite-EI cable}, wrap the mooring subset into a CD_FMF, and own one CD_HFMF !! per cable. Same signature philosophy as CD_FMF_Init_From_Deck (host environment @@ -311,8 +320,8 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi INTEGER, INTENT(IN), OPTIONAL :: n_turbines REAL(wp), INTENT(IN), OPTIONAL :: turbine_ref_pos(:, :) REAL(wp), INTENT(IN), OPTIONAL :: farm_ptfm_init(:, :) - ! forbid_deck_ambient: the caller's documented scope is still water, so reject a - ! deck that declares its own waves/current OPTIONS (see CD_Init_Deck_Aggregate). + ! forbid_deck_ambient: the caller evaluates no deck waves (and, without deck_current, no + ! deck current), so reject a deck that declares them (see CD_Init_Deck_Aggregate). LOGICAL, INTENT(IN), OPTIONAL :: forbid_deck_ambient ! range_files: the caller writes the range graphs of the LINES flag r (CD_AGG_Range_*) LOGICAL, INTENT(IN), OPTIONAL :: range_files @@ -328,6 +337,9 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ! static_run: the caller marches no step (the standalone TMax = 0 run; see ! CD_Init_Deck_Aggregate) LOGICAL, INTENT(IN), OPTIONAL :: static_run + ! deck_current: the caller marches the deck's own current (the standalone driver; see + ! CD_Init_Deck_Aggregate): every step samples it at the nodes, at its t_committed + LOGICAL, INTENT(IN), OPTIONAL :: deck_current ! Both bundles (about 70 KB together) are built on the heap: initialisation runs on the ! thread of the calling host, whose stack size CableDyn does not choose. @@ -368,7 +380,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & range_files=range_files, host_orientation=host_orientation, & static_current=static_current, prescribed_motion=prescribed_motion, & - static_run=static_run) + static_run=static_run, deck_current=deck_current) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF @@ -503,6 +515,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi IF (ALLOCATED(parts%line_obj_index)) CALL MOVE_ALLOC(parts%line_obj_index, candidate%line_obj_index) candidate%ranges = parts%ranges candidate%motion = parts%motion + candidate%current = parts%current IF (ALLOCATED(parts%cable_points)) THEN CALL MOVE_ALLOC(parts%cable_points, candidate%cable_points) ELSE @@ -587,6 +600,16 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi CALL CD_AGG_End(candidate, es, em) RETURN END IF + ! the deck's own current at t = 0 at the static state: the EI = 0 lines re-derive their start + ! accelerations in it and the cables take it as their first held field, as the single-line + ! routes' t = 0 samples do before their march + IF (CD_Deck_Current_Active(candidate%current)) THEN + CALL sample_deck_current(candidate, CD_ZERO, .TRUE., ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) THEN + CALL CD_AGG_End(candidate, es, em) + RETURN + END IF + END IF candidate%dt = dt ! freeze the coupling step for the fixed-dt Step_Moving guard candidate%initialized = .TRUE. IF (CD_Motion_Active(candidate%motion)) THEN @@ -1087,6 +1110,13 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver 'threaded into every step' RETURN END IF + ! a deck-owned current is sampled at the end-of-step time + IF (CD_Deck_Current_Active(self%current) .AND. .NOT. PRESENT(t_committed)) THEN + ErrStat = CD_AGG_BADINPUT + ErrMsg = 'CableDyn_OpenFAST_Aggregate: a deck-owned current requires the committed time (t_committed) '// & + 'threaded into every step' + RETURN + END IF IF (.NOT. (moving_cols_ok(position, self) .AND. moving_cols_ok(velocity, self) .AND. & moving_cols_ok(acceleration, self))) THEN ErrStat = CD_AGG_BADINPUT @@ -1149,6 +1179,15 @@ SUBROUTINE CD_AGG_Step_Moving(self, dt, position, velocity, acceleration, conver END IF self%mv_roll = CD_ZERO IF (use_roll) self%mv_roll = roll + ! The deck's own current over this step: u(x_j, t + dt) at every node x_j of the step-start + ! state, held over the step on the EI = 0 lines and the cables, as the single-line EI = 0 + ! and cubic-Hermite marches sample it before their steps. It is an input of the step (a + ! function of the committed state and the clock), so a rewound or restored step samples + ! the same field again. + IF (CD_Deck_Current_Active(self%current)) THEN + CALL sample_deck_current(self, t_committed, .FALSE., ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) RETURN + END IF ! stage: snapshot every sub-object before any of them steps (multi-object only; a ! single sub-object is already atomic -- the hot mooring-only path skips this). ! A Rigid6 deck is single-subobject (ncable == 0) yet still needs staging: its branch @@ -1503,13 +1542,21 @@ SUBROUTINE CD_AGG_Refresh_Accelerations(self, ErrStat, ErrMsg) !! committed state, keeping the coupled node's prescribed acceleration !! (CD_HFMF_Refresh_Acceleration): after CD_AGG_UpdateStates_Moving installs the first row !! of a prescribed motion, so the first step does not start from the static acceleration - !! (the standalone cubic-Hermite route's row-1 station). The EI = 0 system is unchanged. + !! (the standalone cubic-Hermite route's row-1 station). The EI = 0 system is unchanged, + !! except under a deck-owned current: the row-1 station is t = 0, so the current is sampled + !! again at t = 0 at the installed row (as the single-line routes sample it after installing + !! row 1), an EI = 0 line whose field changed re-deriving its acceleration in it, before the + !! cables' refresh. TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: c, es CHARACTER(1024) :: em IF (.NOT. require_initialized(self, ErrStat, ErrMsg)) RETURN + IF (CD_Deck_Current_Active(self%current)) THEN + CALL sample_deck_current(self, CD_ZERO, .TRUE., ErrStat, ErrMsg) + IF (ErrStat /= CD_AGG_OK) RETURN + END IF DO c = 1, self%ncable CALL CD_HFMF_Refresh_Acceleration(self%cables(c), es, em) IF (es /= CD_HFMF_OK) THEN @@ -1521,6 +1568,33 @@ SUBROUTINE CD_AGG_Refresh_Accelerations(self, ErrStat, ErrMsg) ErrMsg = '' END SUBROUTINE CD_AGG_Refresh_Accelerations + SUBROUTINE sample_deck_current(self, time, initial_condition, ErrStat, ErrMsg) + !! The deck's own current at time over every node: the EI = 0 system's lines + !! (CD_Deck_Current_Sample_System; initial_condition re-derives the acceleration of a line + !! whose field changed) and the finite-EI cables (CD_Deck_Current_Sample_Cables). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: time + LOGICAL, INTENT(IN) :: initial_condition + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + INTEGER :: es + CHARACTER(1024) :: em + ErrStat = CD_AGG_OK + ErrMsg = '' + IF (self%has_sys) THEN + CALL CD_Deck_Current_Sample_System(self%current, self%sys%fast%system, time, es, em, & + initial_condition=initial_condition) + IF (es /= CD_DECKDRV_OK) THEN + CALL map_deck_status(es, em, ErrStat, ErrMsg) + RETURN + END IF + END IF + IF (self%ncable > 0) THEN + CALL CD_Deck_Current_Sample_Cables(self%current, self%cables, time, es, em) + IF (es /= CD_DECKDRV_OK) CALL map_deck_status(es, em, ErrStat, ErrMsg) + END IF + END SUBROUTINE sample_deck_current + SUBROUTINE check_motion_columns(self, ErrStat, ErrMsg) !! The prescribed-motion columns match the moving surface: one column per moving point, and !! each column's driving point at that moving point's static position (a column map that @@ -2310,6 +2384,7 @@ SUBROUTINE CD_AGG_End(self, ErrStat, ErrMsg) IF (ALLOCATED(self%mv_roll)) DEALLOCATE (self%mv_roll) IF (ALLOCATED(self%cable_phi0)) DEALLOCATE (self%cable_phi0) CALL CD_Motion_End(self%motion) + CALL CD_Deck_Current_End(self%current) IF (ALLOCATED(self%cable_stat)) DEALLOCATE (self%cable_stat) IF (ALLOCATED(self%cable_msg)) DEALLOCATE (self%cable_msg) IF (ALLOCATED(self%channels)) DEALLOCATE (self%channels) diff --git a/tests/data/msg_mixed_waves.dat b/tests/data/msg_mixed_waves.dat new file mode 100644 index 00000000..2e42b975 --- /dev/null +++ b/tests/data/msg_mixed_waves.dat @@ -0,0 +1,58 @@ +--------------------- CableDyn Input File --- +msg_mixed_waves +--------------------- LINE TYPES --- +TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +chain 0.216 286.56 1229760000 -1 0 1.37 0.64 1 0 +pc 0.16 36.7 469000000 -1 19900 1.2 0.1 1 0 +buoy 0.5 170.666793 469000000 -1 19900 1.2 0.1 1 0 +--------------------- POINTS --- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Coupled 0 0 -14 0 0 0 0 +2 Fixed 830 0 -200 0 0 0 0 +3 Fixed -415 719 -200 0 0 0 0 +4 Fixed -300 -50 -200 0 0 0 0 +--------------------- LINES --- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 1 2 - +2 1 3 - +3 1 4 - +--------------------- SECTIONS --- +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 chain 850 85 +2 chain 850 85 +3 pc 180 180 +3 buoy 80 80 +3 pc 150 150 +--------------------- OPTIONS --- +9.80665 g +1025.0 rhoW +200.0 WtrDpth +100000.0 kBot +1.0e4 cBot +0.05 dtM +0.0 TMax +airy 2 8 0 waves +--------------------- OUTPUTS --- +"FairTen1" +"AnchTen1" +"FairTen2" +"AnchTen2" +"FairTen3" +"AnchTen3" +"Point1Fx" +"Point1Fy" +"Point1Fz" +"Point2Fx" +"Point2Fy" +"Point2Fz" +"Point3Fx" +"Point3Fy" +"Point3Fz" +"Point4Fx" +"Point4Fy" +"Point4Fz" +--------------------- need this line --- diff --git a/tests/test_mixed_route_currents.f90 b/tests/test_mixed_route_currents.f90 new file mode 100644 index 00000000..8e60d849 --- /dev/null +++ b/tests/test_mixed_route_currents.f90 @@ -0,0 +1,798 @@ +! File: tests/test_mixed_route_currents.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> Deck currents on the standalone mixed route: a deck that mixes an EI = 0 chain and a finite-EI +!> cable (on separate points, without bodies, rods or Free/Connect points) runs on the coupled +!> aggregate, marched by the standalone driver (the executable given as the first argument), and +!> takes every deck current the single-line routes take. Each deck is run three ways: the cable +!> alone (the standalone cubic-Hermite route), the chain alone (the EI = 0 route) and both together +!> (the mixed route); both Coupled fairleads surge 1 m from rest (motionFile) over 10 s. +!> 1. A uniform current (0.4, 0.3, 0) m/s and a sheared profile, both across the two lines (the +!> cable along x, the chain along y), in the static start and the march: the mixed route +!> against the single-line routes, each channel to a fraction of its range, beside the same +!> comparison in still water (the route difference without a current). The static start agrees +!> within STATIC_TOL: the chain exactly, the cable to the stopping point of the coupled cable +!> build's static polish (its out-of-plane offset, the softest coordinate, by 4 um of 0.55 m; +!> in still water exactly). In the march the cable steps with the coupled Newton controls on +!> the mixed route (relative tolerance 5e-3, a fresh factor) and with the deck's on its own +!> (1e-8, a carried factor), which differ by about 1.2e-3 of the range in still water too +!> (DRIVER_CABLE_TOL); with the deck's controls given to the aggregate cable (the library +!> march of the driver's loop) the march keeps the static start's difference +!> (LIBRARY_CABLE_TOL). The chain agrees within CHAIN_TOL (exactly in a sheared current; its +!> row-1 transfer re-derives its interior accelerations on the mixed route, by 5e-5 in still +!> water). The current is felt: both mid nodes leave the vertical plane of their chord, and +!> the chain's fairlead tension history differs from the still-water run's. +!> 2. MoorDyn-C Currents 1 (a sheared current_profile.txt), Currents 2 (a sheared +!> current_profile_dynamic.txt that varies in time) and Currents 5 (a current_profile_4d.txt +!> grid that varies in x, y, z and time): the gate 1 agreement of the mixed route with the +!> single-line routes given the same file. +!> 3. The wrap of a Currents 2 table past its last sample in the march: three samples (0, 2, 4 s, +!> the first and last equal) run to 10 s repeat with period 6 s. The mixed route matches the +!> mixed route given the table unrolled to 12 s (round-off: 1e-9 of each channel's range) and +!> departs from the same table held after its last sample (beyond 6 s, by more than 1 % of the +!> chain's tension range): the march samples the wrapped field at every step. +!> 4. A uniform field written as a Currents 1 profile equals the OPTION uniform current on the +!> mixed route to GRID_TOL of each channel's range (the profile's linear interpolation between +!> equal levels is exact on some platforms and one ulp off on others, which the march carries: +!> 0 on Windows, 3.9e-8 on Linux gfortran); written as a Currents 5 grid (constant in space and time), its static +!> start bit for bit and its march to GRID_TOL of each channel's range (the round-off of the +!> grid's trilinear weights). +!> 5. The correction rewind of the aggregate (CD_AGG_Snapshot, a step, CD_AGG_Restore, the step +!> again) every 20th step, in still water and in the Currents 2 field: the repeated step samples +!> the current again from the restored state, and every channel of every step equals the march +!> without rewinds bit for bit. +!> 6. The mixed route still refuses deck waves by name, and like the single-line routes a current +!> OPTION beside Currents 2 (double-counting) and a current without dtM. +PROGRAM test_mixed_route_currents + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_GetMovingPointMesh, CD_AGG_UpdateStates_Moving, & + CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_EvalChannel, & + CD_AGG_NumChannels, CD_AGG_End, CD_AGG_MotionKinematics, & + CD_AGG_Refresh_Accelerations, CD_AGG_Snapshot, CD_AGG_Restore, CD_AGG_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, TMAX = 10.0_wp, PERIOD = 10.0_wp + INTEGER, PARAMETER :: NSTEP = 200, MAXCOL = 16, MAXROW = 400 + CHARACTER(*), PARAMETER :: CAB_T = 'cab 0.2 60.0 4.0e8 0.0 1.0e4 1.2 0.1 1.0 0.0' + CHARACTER(*), PARAMETER :: CHAIN_T = 'chain 0.1 50.0 1.0e9 -1.0 0.0 1.37 0.64 1.0 0.0' + ! the mixed deck's channels: the cable (line 1) then the chain (line 2) + CHARACTER(16), PARAMETER :: MIXED_OUTS(10) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'L1N21px', 'L1N21py', & + 'L1N21pz', 'FairTen2', 'AnchTen2', 'L2N11px', 'L2N11py', 'L2N11pz'] + CHARACTER(16), PARAMETER :: CABLE_OUTS(5) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'L1N21px', 'L1N21py', & + 'L1N21pz'] + CHARACTER(16), PARAMETER :: CHAIN_OUTS(5) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'L1N11px', 'L1N11py', & + 'L1N11pz'] + ! differences of the mixed route from the single-line routes, of each channel's range (gate 1): the + ! static start; the cable stepped with the coupled Newton controls, and with the deck's; the chain + REAL(wp), PARAMETER :: STATIC_TOL = 1.0e-5_wp, DRIVER_CABLE_TOL = 2.0e-3_wp, LIBRARY_CABLE_TOL = 1.0e-5_wp + REAL(wp), PARAMETER :: CHAIN_TOL = 1.0e-4_wp + ! round-off between two writings of one field (gates 3 and 4), of each channel's range, and of a + ! uniform field interpolated on a grid (gate 4) + REAL(wp), PARAMETER :: SAME_TOL = 1.0e-9_wp, GRID_TOL = 1.0e-7_wp + CHARACTER(1024) :: driver + INTEGER :: n_fail = 0 + + IF (COMMAND_ARGUMENT_COUNT() < 1) ERROR STOP 'usage: test_mixed_route_currents ' + CALL GET_COMMAND_ARGUMENT(1, driver) + + CALL check_option_currents() + CALL check_moordyn_c_currents() + CALL check_wrap() + CALL check_uniform_writings() + CALL check_snapshot('still/mixed.dat', '5 still water') + CALL check_snapshot('c2/mixed.dat', '5 Currents 2') + CALL check_refusals() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' mixed-route current gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: deck currents on the standalone mixed route' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + PURE SUBROUTINE smooth(amplitude, t, f, df, d2f) + !! f = F (1 - cos w t) / 2 and its rates, w = 2 pi / PERIOD: a motion from rest. + REAL(wp), INTENT(IN) :: amplitude, t + REAL(wp), INTENT(OUT) :: f, df, d2f + REAL(wp) :: w + w = 2.0_wp*PI/PERIOD + f = 0.5_wp*amplitude*(1.0_wp - COS(w*t)) + df = 0.5_wp*amplitude*w*SIN(w*t) + d2f = 0.5_wp*amplitude*w*w*COS(w*t) + END SUBROUTINE smooth + + SUBROUTINE write_motion(path, ids, ys) + !! motionFile rows of the Coupled points ids at (0, ys, -50), each surging 1 m from rest. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: ids(:) + REAL(wp), INTENT(IN) :: ys(:) + REAL(wp) :: t, x, vx, ax + INTEGER :: u, k, j + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + t = DT*k + CALL smooth(1.0_wp, t, x, vx, ax) + DO j = 1, SIZE(ids) + WRITE (u, '(F8.3,1X,I0,3ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ids(j), x, ys(j), -50.0_wp, ' ', vx, & + ' 0 0 ', ax, ' 0 0' + END DO + END DO + CLOSE (u) + END SUBROUTINE write_motion + + SUBROUTINE write_deck(path, types, points, lines, sections, options, outs) + CHARACTER(*), INTENT(IN) :: path, types(:), points(:), lines(:), sections(:), options(:), outs(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'mixed-route current 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) (-) (-) (-) (-)' + DO i = 1, SIZE(types) + WRITE (u, '(A)') TRIM(types(i)) + END DO + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + DO i = 1, SIZE(points) + WRITE (u, '(A)') TRIM(points(i)) + END DO + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + DO i = 1, SIZE(lines) + WRITE (u, '(A)') TRIM(lines(i)) + END DO + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + DO i = 1, SIZE(sections) + WRITE (u, '(A)') TRIM(sections(i)) + END DO + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + DO i = 1, SIZE(options) + WRITE (u, '(A)') TRIM(options(i)) + END DO + WRITE (u, '(A)') '--- OUTPUTS ---' + DO i = 1, SIZE(outs) + WRITE (u, '(A)') TRIM(outs(i)) + END DO + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE write_case(dir, current) + !! The three decks of a case in folder dir (ending in '/', or empty): cable.dat, a 100 m + !! finite-EI line (40 elements) from End A on the Coupled point (0, 0, -50) to a Fixed End B + !! at (95, 0, -60); chain.dat, a 110 m chain (20 segments) from (0, 20, -50) to a Fixed + !! (0, 110, -100); and mixed.dat, both on their own points. current: the deck's current rows. + CHARACTER(*), INTENT(IN) :: dir, current(:) + CHARACTER(48) :: opts(SIZE(current) + 3) + INTEGER :: i + opts(1) = '0.05 dtM' + opts(2) = '10.0 TMax' + DO i = 1, SIZE(current) + opts(2 + i) = current(i) + END DO + opts(SIZE(opts)) = 'cable_m.txt motionFile' + CALL write_motion(dir//'cable_m.txt', [1], [0.0_wp]) + CALL write_deck(dir//'cable.dat', [CHARACTER(64) :: CAB_T], & + [CHARACTER(40) :: '1 Coupled 0.0 0.0 -50.0 0 0 0 0', '2 Fixed 95.0 0.0 -60.0 0 0 0 0'], & + [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 cab 100.0 40'], opts, CABLE_OUTS) + opts(SIZE(opts)) = 'chain_m.txt motionFile' + CALL write_motion(dir//'chain_m.txt', [1], [20.0_wp]) + CALL write_deck(dir//'chain.dat', [CHARACTER(64) :: CHAIN_T], & + [CHARACTER(40) :: '1 Coupled 0.0 20.0 -50.0 0 0 0 0', '2 Fixed 0.0 110.0 -100.0 0 0 0 0'], & + [CHARACTER(16) :: '1 1 2 -'], [CHARACTER(24) :: '1 chain 110.0 20'], opts, CHAIN_OUTS) + opts(SIZE(opts)) = 'mixed_m.txt motionFile' + CALL write_motion(dir//'mixed_m.txt', [1, 3], [0.0_wp, 20.0_wp]) + CALL write_deck(dir//'mixed.dat', [CHARACTER(64) :: CAB_T, CHAIN_T], & + [CHARACTER(40) :: '1 Coupled 0.0 0.0 -50.0 0 0 0 0', '2 Fixed 95.0 0.0 -60.0 0 0 0 0', & + '3 Coupled 0.0 20.0 -50.0 0 0 0 0', '4 Fixed 0.0 110.0 -100.0 0 0 0 0'], & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + opts, MIXED_OUTS) + END SUBROUTINE write_case + + SUBROUTINE write_text(path, lines) + CHARACTER(*), INTENT(IN) :: path, lines(:) + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + DO i = 1, SIZE(lines) + WRITE (u, '(A)') TRIM(lines(i)) + END DO + CLOSE (u) + END SUBROUTINE write_text + + SUBROUTINE run_driver(deck, root, ok) + !! Run the driver executable on a deck, its stdout and stderr to .log. + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ex, cs + CALL EXECUTE_COMMAND_LINE('"'//TRIM(driver)//'" '//deck//' '//root//' > '//root//'.log 2>&1', & + WAIT=.TRUE., EXITSTAT=ex, CMDSTAT=cs) + ok = cs == 0 .AND. ex == 0 + END SUBROUTINE run_driver + + INTEGER FUNCTION driver_exit(deck, root) RESULT(ex) + CHARACTER(*), INTENT(IN) :: deck, root + INTEGER :: cs + CALL EXECUTE_COMMAND_LINE('"'//TRIM(driver)//'" '//deck//' '//root//' > '//root//'.log 2>&1', & + WAIT=.TRUE., EXITSTAT=ex, CMDSTAT=cs) + IF (cs /= 0) ex = -1 + END FUNCTION driver_exit + + LOGICAL FUNCTION log_has(root, text) RESULT(found) + CHARACTER(*), INTENT(IN) :: root, text + CHARACTER(4096) :: line + INTEGER :: u, ios + found = .FALSE. + OPEN (NEWUNIT=u, FILE=root//'.log', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (INDEX(line, text) > 0) found = .TRUE. + END DO + CLOSE (u) + END FUNCTION log_has + + SUBROUTINE read_out(path, names, vals, nrow) + !! The channel names and rows of a driver .out file (Time first). + CHARACTER(*), INTENT(IN) :: path + CHARACTER(32), INTENT(OUT) :: names(MAXCOL) + REAL(wp), INTENT(OUT) :: vals(MAXROW, MAXCOL) + INTEGER, INTENT(OUT) :: nrow + CHARACTER(4096) :: buf + INTEGER :: u, ios, ncol, k + names = '' + vals = 0.0_wp + nrow = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + READ (buf, *, IOSTAT=ios) names + ncol = 0 + DO k = 1, MAXCOL + IF (LEN_TRIM(names(k)) > 0) ncol = k + END DO + DO + IF (nrow == MAXROW) EXIT + READ (u, *, IOSTAT=ios) vals(nrow + 1, 1:ncol) + IF (ios /= 0) EXIT + nrow = nrow + 1 + END DO + CLOSE (u) + END SUBROUTINE read_out + + INTEGER FUNCTION col_of(names, name) RESULT(c) + CHARACTER(32), INTENT(IN) :: names(:) + CHARACTER(*), INTENT(IN) :: name + INTEGER :: k + c = 0 + DO k = 1, SIZE(names) + IF (TRIM(names(k)) == TRIM(name)) c = k + END DO + END FUNCTION col_of + + REAL(wp) FUNCTION range_error(a, b, n) RESULT(e) + !! max |b - a| over the rows, relative to the range max |a|. + REAL(wp), INTENT(IN) :: a(:), b(:) + INTEGER, INTENT(IN) :: n + e = MAXVAL(ABS(b(1:n) - a(1:n)))/MAX(MAXVAL(ABS(a(1:n))), TINY(1.0_wp)) + IF (.NOT. IEEE_IS_FINITE(e)) e = HUGE(1.0_wp) + END FUNCTION range_error + + SUBROUTINE run_case(dir, label, ok) + !! Run the three decks of a case (write_case) on the driver. + CHARACTER(*), INTENT(IN) :: dir, label + LOGICAL, INTENT(OUT) :: ok + LOGICAL :: ok_a, ok_b, ok_c + CALL run_driver(dir//'cable.dat', dir//'cable', ok_a) + CALL require(ok_a, label//': the cable alone runs on the standalone cubic-Hermite route') + CALL run_driver(dir//'chain.dat', dir//'chain', ok_b) + CALL require(ok_b, label//': the chain alone runs on the EI = 0 route') + CALL run_driver(dir//'mixed.dat', dir//'mixed', ok_c) + CALL require(ok_c, label//': the mixed deck runs in the current') + IF (ok_c) CALL require(log_has(dir//'mixed', 'mixed standalone aggregate'), & + label//': the mixed deck runs on the aggregate') + ok = ok_a .AND. ok_b .AND. ok_c + END SUBROUTINE run_case + + SUBROUTINE line_errors(nm, vm, nl, vl, first, outs_l, e_static, e_march) + !! The mixed route's channels MIXED_OUTS(first + 1:first + 5) against a single-line route's + !! outs_l: the largest difference at t = 0 (the static start) and over every row, each + !! relative to the channel's range max |a| on the single-line route. + CHARACTER(32), INTENT(IN) :: nm(:), nl(:) + REAL(wp), INTENT(IN) :: vm(:, :), vl(:, :) + INTEGER, INTENT(IN) :: first + CHARACTER(16), INTENT(IN) :: outs_l(5) + REAL(wp), INTENT(OUT) :: e_static, e_march + INTEGER :: k, cm, cl + REAL(wp) :: scale + e_static = 0.0_wp + e_march = 0.0_wp + DO k = 1, 5 + cm = col_of(nm, MIXED_OUTS(first + k)) + cl = col_of(nl, outs_l(k)) + IF (cm == 0 .OR. cl == 0) THEN + e_static = HUGE(1.0_wp) + e_march = HUGE(1.0_wp) + RETURN + END IF + scale = MAX(MAXVAL(ABS(vl(1:NSTEP + 1, cl))), TINY(1.0_wp)) + e_static = MAX(e_static, ABS(vm(1, cm) - vl(1, cl))/scale) + e_march = MAX(e_march, MAXVAL(ABS(vm(1:NSTEP + 1, cm) - vl(1:NSTEP + 1, cl)))/scale) + END DO + END SUBROUTINE line_errors + + SUBROUTINE compare_case(dir, label, still) + !! The mixed route (mixed.out) against the cable alone (cable.out) and the chain alone + !! (chain.out): the static row (t = 0) and every row of the march. still: a still-water case + !! (the baseline of the route difference; no out-of-plane offset to check). + CHARACTER(*), INTENT(IN) :: dir, label + LOGICAL, INTENT(IN), OPTIONAL :: still + CHARACTER(32) :: nm(MAXCOL), na(MAXCOL), nc(MAXCOL) + REAL(wp), ALLOCATABLE :: vm(:, :), va(:, :), vc(:, :) + INTEGER :: rm, ra, rc, cm, cs + REAL(wp) :: e_cable_static, e_cable, e_chain_static, e_chain + ALLOCATE (vm(MAXROW, MAXCOL), va(MAXROW, MAXCOL), vc(MAXROW, MAXCOL)) + CALL read_out(dir//'mixed.out', nm, vm, rm) + CALL read_out(dir//'cable.out', na, va, ra) + CALL read_out(dir//'chain.out', nc, vc, rc) + CALL require(rm == NSTEP + 1 .AND. ra == NSTEP + 1 .AND. rc == NSTEP + 1, label//': every route writes every row') + IF (rm /= NSTEP + 1 .OR. ra /= NSTEP + 1 .OR. rc /= NSTEP + 1) RETURN + CALL line_errors(nm, vm, na, va, 0, CABLE_OUTS, e_cable_static, e_cable) + CALL line_errors(nm, vm, nc, vc, 5, CHAIN_OUTS, e_chain_static, e_chain) + WRITE (*, '(A,A,2ES10.3,A,2ES10.3,A)') ' ', label//': driver, mixed route against single-line routes: cable ', & + e_cable_static, e_cable, ', chain ', e_chain_static, e_chain, ' (static start, march; of each channel''s range)' + CALL require(e_cable_static <= STATIC_TOL .AND. e_chain_static <= STATIC_TOL, & + label//': the static start agrees within the static tolerance') + CALL require(e_cable <= DRIVER_CABLE_TOL, label//': the cable agrees within the coupled Newton tolerance') + CALL require(e_chain <= CHAIN_TOL, label//': the chain agrees within the row-1 transfer') + ! the current is felt: both mid nodes leave the vertical plane of their chord + IF (PRESENT(still)) THEN + IF (still) RETURN + END IF + cm = col_of(nm, 'L1N21py') + cs = col_of(nm, 'L2N11px') + IF (cm > 0 .AND. cs > 0) THEN + WRITE (*, '(A,A,F8.4,A,F8.4,A)') ' ', label//': static out-of-plane offset of the mid nodes: cable ', & + vm(1, cm), ' m, chain ', vm(1, cs), ' m' + CALL require(ABS(vm(1, cm)) > 0.02_wp .AND. ABS(vm(1, cs)) > 0.02_wp, & + label//': the current pushes both lines out of the plane of their chord') + END IF + END SUBROUTINE compare_case + + SUBROUTINE march_library(dir, label) + !! The driver's march of the mixed deck (CableDyn_driver run_mixed_held_deck) through the + !! aggregate library, with the cable given the standalone route's Newton controls (the deck's + !! dynamic tolerance 1e-8, 30 iterations, the carried factor): every channel of both lines is + !! compared at every step with the single-line routes' outputs. + CHARACTER(*), INTENT(IN) :: dir, label + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp), ALLOCATABLE :: got(:, :), va(:, :), vc(:, :) + CHARACTER(32) :: na(MAXCOL), nc(MAXCOL), ng(MAXCOL) + CHARACTER(2048) :: em + INTEGER :: c, ra, rc, nch, es + REAL(wp) :: e_cable_static, e_cable, e_chain_static, e_chain + LOGICAL :: ok + ALLOCATE (agg, va(MAXROW, MAXCOL), vc(MAXROW, MAXCOL)) + CALL init_mixed(agg, dir//'mixed.dat', label, ok) + IF (.NOT. ok) RETURN + DO c = 1, agg%ncable + agg%cables(c)%tol = 1.0e-8_wp + agg%cables(c)%max_iter = 30 + agg%cables(c)%line%tangent_reuse = .TRUE. + END DO + nch = CD_AGG_NumChannels(agg) + ALLOCATE (got(MAXROW, MAXCOL)) + got = 0.0_wp + CALL march(agg, 0, NSTEP, got(1:NSTEP + 1, 1:nch), label, ok) + CALL CD_AGG_End(agg, es, em) + IF (.NOT. ok) RETURN + CALL read_out(dir//'cable.out', na, va, ra) + CALL read_out(dir//'chain.out', nc, vc, rc) + CALL require(ra == NSTEP + 1 .AND. rc == NSTEP + 1, label//': the single-line outputs are complete') + IF (ra /= NSTEP + 1 .OR. rc /= NSTEP + 1) RETURN + ng = '' + ng(1:SIZE(MIXED_OUTS)) = MIXED_OUTS + CALL line_errors(ng, got, na, va, 0, CABLE_OUTS, e_cable_static, e_cable) + CALL line_errors(ng, got, nc, vc, 5, CHAIN_OUTS, e_chain_static, e_chain) + WRITE (*, '(A,A,2ES10.3,A,2ES10.3,A)') ' ', label//': library, the standalone Newton controls: cable ', & + e_cable_static, e_cable, ', chain ', e_chain_static, e_chain, ' (static start, march; of each channel''s range)' + CALL require(e_cable <= LIBRARY_CABLE_TOL, label//': with the same Newton controls the cable reproduces the '// & + 'single-line route') + CALL require(e_chain <= CHAIN_TOL, label//': the chain reproduces the EI = 0 route') + END SUBROUTINE march_library + SUBROUTINE init_mixed(agg, deck, label, ok) + !! The aggregate as the driver's mixed route builds it, with the motion's first row installed. + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + CHARACTER(*), INTENT(IN) :: deck, label + LOGICAL, INTENT(OUT) :: ok + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :), omega(:, :), alpha(:, :) + REAL(wp), ALLOCATABLE :: roll(:) + CHARACTER(2048) :: em + INTEGER :: es, n + LOGICAL :: turns, rolls + CALL CD_AGG_Init_From_Deck(agg, deck, DT, es, em, forbid_deck_ambient=.TRUE., run_tmax=TMAX, & + range_files=.TRUE., host_orientation=.TRUE., prescribed_motion=.TRUE., & + deck_current=.TRUE.) + ok = es == CD_AGG_OK + CALL require(ok, label//': the aggregate takes the deck current: '//TRIM(em)) + IF (.NOT. ok) RETURN + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), load(3, n), orient(3, 3, n), omega(3, n), alpha(3, n), roll(n)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_MotionKinematics(agg, 1, pos, vel, acc, orient, omega, alpha, roll, turns, & + rolls, es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(agg, es, em) + ok = es == CD_AGG_OK + CALL require(ok, label//': the first motion row installs: '//TRIM(em)) + END SUBROUTINE init_mixed + + SUBROUTINE march(agg, first, last, got, label, ok) + !! Steps first + 1 .. last of the driver's loop (step 0: the outputs only), every channel + !! of every step into got(step + 1, :). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg + INTEGER, INTENT(IN) :: first, last + REAL(wp), INTENT(INOUT) :: got(:, :) + CHARACTER(*), INTENT(IN) :: label + LOGICAL, INTENT(OUT) :: ok + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), orient(:, :, :), omega(:, :), alpha(:, :), roll(:) + CHARACTER(2048) :: em + INTEGER :: es, n, step, k, n_iter + LOGICAL :: turns, rolls, conv, stalled + REAL(wp) :: v + n = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), orient(3, 3, n), omega(3, n), alpha(3, n), roll(n)) + ok = .TRUE. + DO step = first, last + IF (step > first) THEN + CALL CD_AGG_MotionKinematics(agg, step + 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + IF (es == CD_AGG_OK) CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, & + t_committed=DT*step) + IF (es /= CD_AGG_OK .OR. .NOT. conv) THEN + CALL require(.FALSE., label//': library march step: '//TRIM(em)) + ok = .FALSE. + RETURN + END IF + ELSE IF (step > 0) THEN + ! the state of step first, recorded by the march that reached it + CYCLE + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + DO k = 1, SIZE(got, 2) + CALL CD_AGG_EvalChannel(agg, k, v, es, em) + got(step + 1, k) = v + END DO + END DO + END SUBROUTINE march + + SUBROUTINE check_option_currents() + !! Gate 1. + LOGICAL :: ok + CHARACTER(32) :: nu(MAXCOL), ns(MAXCOL) + REAL(wp), ALLOCATABLE :: vu(:, :), vs(:, :) + INTEGER :: ru, rs + REAL(wp) :: change + CALL write_case('uni/', [CHARACTER(48) :: 'uniform 0.4 0.3 0 current']) + CALL run_case('uni/', '1 uniform', ok) + IF (ok) THEN + CALL compare_case('uni/', '1 uniform') + CALL march_library('uni/', '1 uniform') + END IF + CALL write_case('prof/', [CHARACTER(48) :: 'profile -200 0.1 0.05 0 0 0.6 0.4 0 current']) + CALL run_case('prof/', '1 profile', ok) + IF (ok) THEN + CALL compare_case('prof/', '1 profile') + CALL march_library('prof/', '1 profile') + END IF + ! the same mixed deck in still water: the current changes the chain's tension history + CALL write_case('still/', [CHARACTER(48) :: 'none current']) + CALL run_case('still/', '1 still water', ok) + IF (ok) THEN + CALL compare_case('still/', '1 still water', still=.TRUE.) + CALL march_library('still/', '1 still water') + END IF + ALLOCATE (vu(MAXROW, MAXCOL), vs(MAXROW, MAXCOL)) + CALL read_out('uni/mixed.out', nu, vu, ru) + CALL read_out('still/mixed.out', ns, vs, rs) + IF (ru == NSTEP + 1 .AND. rs == NSTEP + 1) THEN + change = range_error(vs(:, col_of(ns, 'FairTen2')), vu(:, col_of(nu, 'FairTen2')), rs) + WRITE (*, '(A,ES10.3,A)') ' 1 still water: the uniform current changes the chain fairlead tension by ', change, & + ' of its range' + CALL require(change > 1.0e-3_wp, '1: the mixed route applies the current to the chain') + change = MAXVAL(ABS(vs(1:rs, col_of(ns, 'L1N21py')))) + CALL require(change < 1.0e-9_wp, '1: in still water the cable stays in its plane') + ELSE + CALL require(.FALSE., '1: the still-water and uniform-current outputs are complete') + END IF + END SUBROUTINE check_option_currents + + SUBROUTINE write_c1(dir, uniform) + !! current_profile.txt: a sheared profile across both lines, or the uniform (0.4, 0.3, 0). + CHARACTER(*), INTENT(IN) :: dir + LOGICAL, INTENT(IN) :: uniform + IF (uniform) THEN + CALL write_text(dir//'current_profile.txt', [CHARACTER(40) :: 'uniform current', 'z ux uy uz', & + '-200.0 0.4 0.3 0.0', '0.0 0.4 0.3 0.0']) + ELSE + CALL write_text(dir//'current_profile.txt', [CHARACTER(40) :: 'sheared current', 'z ux uy uz', & + '-200.0 0.05 0.02 0.0', '-80.0 0.3 0.2 0.01', & + '-40.0 0.5 0.35 0.0', '0.0 0.7 0.5 0.0']) + END IF + END SUBROUTINE write_c1 + + SUBROUTINE write_c2(dir, kind) + !! current_profile_dynamic.txt at the depths -200, -80, -40, 0 m: kind 1 the three samples + !! 0, 2, 4 s (the first and last equal, so the field repeats with period 6 s past 4 s), + !! kind 2 the same table unrolled to 12 s, kind 3 the same table held from 4 s to 12 s. + CHARACTER(*), INTENT(IN) :: dir + INTEGER, INTENT(IN) :: kind + CHARACTER(*), PARAMETER :: A = ' 0.10 0.15 0.20 0.25 0.05 0.08 0.10 0.12', & + B = ' 0.40 0.50 0.60 0.70 0.30 0.35 0.40 0.45' + CHARACTER(96) :: rows(7) + INTEGER :: n + SELECT CASE (kind) + CASE (1) + rows(1:3) = [CHARACTER(96) :: '0.0'//A, '2.0'//B, '4.0'//A] + n = 3 + CASE (2) + rows = [CHARACTER(96) :: '0.0'//A, '2.0'//B, '4.0'//A, '6.0'//A, '8.0'//B, '10.0'//A, '12.0'//A] + n = 7 + CASE DEFAULT + rows(1:4) = [CHARACTER(96) :: '0.0'//A, '2.0'//B, '4.0'//A, '12.0'//A] + n = 4 + END SELECT + CALL write_text(dir//'current_profile_dynamic.txt', [CHARACTER(96) :: 'time-varying sheared current', & + 'across both lines', '', '', '-200.0 -80.0 -40.0 0.0', 't ux... uy...', rows(1:n)]) + END SUBROUTINE write_c2 + + SUBROUTINE write_c5(dir, uniform) + !! current_profile_4d.txt: x in {-10, 110}, y in {-10, 120}, z in {-210, -100, 0} and t in + !! {0, 3, 6} with u varying in each (sheared, turning across the lines and past its last + !! sample: the march to 10 s wraps it), or the uniform (0.4, 0.3, 0) at t = 0 and 1. + CHARACTER(*), INTENT(IN) :: dir + LOGICAL, INTENT(IN) :: uniform + REAL(wp), PARAMETER :: XS(2) = [-10.0_wp, 110.0_wp], YS(2) = [-10.0_wp, 120.0_wp], & + ZS(3) = [-210.0_wp, -100.0_wp, 0.0_wp], TS(3) = [0.0_wp, 3.0_wp, 6.0_wp] + INTEGER :: u, ix, iy, iz, it, nt + REAL(wp) :: ux, uy, s + OPEN (NEWUNIT=u, FILE=dir//'current_profile_4d.txt', STATUS='REPLACE', ACTION='WRITE') + nt = MERGE(2, 3, uniform) + WRITE (u, '(A,I0)') '2 2 3 ', nt + WRITE (u, '(A)') '-10.0 110.0' + WRITE (u, '(A)') '-10.0 120.0' + WRITE (u, '(A)') '-210.0 -100.0 0.0' + IF (uniform) THEN + WRITE (u, '(A)') '0.0 1.0' + ELSE + WRITE (u, '(A)') '0.0 3.0 6.0' + END IF + WRITE (u, '(A)') 'x y z t ux uy uz' + DO it = 1, nt + DO iz = 1, 3 + DO iy = 1, 2 + DO ix = 1, 2 + IF (uniform) THEN + ux = 0.4_wp + uy = 0.3_wp + ELSE + s = 1.0_wp + ZS(iz)/250.0_wp + ux = s*(0.3_wp + 0.002_wp*XS(ix) + 0.001_wp*YS(iy))*MERGE(1.0_wp, 1.6_wp, it /= 2) + uy = s*(0.2_wp + 0.001_wp*XS(ix) - 0.001_wp*YS(iy) + 0.1_wp*(it - 1)) + END IF + WRITE (u, '(4F10.3,3F12.6)') XS(ix), YS(iy), ZS(iz), MERGE(REAL(it - 1, wp), TS(it), uniform), ux, uy, & + MERGE(0.0_wp, 0.01_wp*s, uniform) + END DO + END DO + END DO + END DO + CLOSE (u) + END SUBROUTINE write_c5 + + SUBROUTINE check_moordyn_c_currents() + !! Gate 2. + LOGICAL :: ok + CALL write_case('c1/', [CHARACTER(48) :: '1 Currents']) + CALL write_c1('c1/', .FALSE.) + CALL run_case('c1/', '2 Currents 1', ok) + IF (ok) CALL compare_case('c1/', '2 Currents 1') + CALL write_case('c2/', [CHARACTER(48) :: '2 Currents']) + CALL write_c2('c2/', 1) + CALL run_case('c2/', '2 Currents 2', ok) + IF (ok) THEN + CALL compare_case('c2/', '2 Currents 2') + CALL march_library('c2/', '2 Currents 2') + END IF + CALL write_case('c5/', [CHARACTER(48) :: '5 Currents']) + CALL write_c5('c5/', .FALSE.) + CALL run_case('c5/', '2 Currents 5', ok) + IF (ok) THEN + CALL compare_case('c5/', '2 Currents 5') + CALL march_library('c5/', '2 Currents 5') + END IF + END SUBROUTINE check_moordyn_c_currents + + REAL(wp) FUNCTION outs_difference(root_a, root_b, from_row, to_row) RESULT(e) + !! max over the mixed channels and the rows from_row..to_row of |b - a| relative to each + !! channel's range in a (HUGE when an output is incomplete). + CHARACTER(*), INTENT(IN) :: root_a, root_b + INTEGER, INTENT(IN) :: from_row, to_row + CHARACTER(32) :: na(MAXCOL), nb(MAXCOL) + REAL(wp), ALLOCATABLE :: va(:, :), vb(:, :) + INTEGER :: ra, rb, k, ca, cb + REAL(wp) :: scale + ALLOCATE (va(MAXROW, MAXCOL), vb(MAXROW, MAXCOL)) + CALL read_out(root_a//'.out', na, va, ra) + CALL read_out(root_b//'.out', nb, vb, rb) + e = HUGE(1.0_wp) + IF (ra /= NSTEP + 1 .OR. rb /= NSTEP + 1) RETURN + e = 0.0_wp + DO k = 1, SIZE(MIXED_OUTS) + ca = col_of(na, MIXED_OUTS(k)) + cb = col_of(nb, MIXED_OUTS(k)) + IF (ca == 0 .OR. cb == 0) THEN + e = HUGE(1.0_wp) + RETURN + END IF + scale = MAXVAL(ABS(va(1:ra, ca))) + e = MAX(e, MAXVAL(ABS(vb(from_row:to_row, cb) - va(from_row:to_row, ca)))/MAX(scale, TINY(1.0_wp))) + END DO + END FUNCTION outs_difference + + SUBROUTINE check_wrap() + !! Gate 3: the Currents 2 table of gate 2 (c2/) against it unrolled (c2u/) and held (c2h/). + LOGICAL :: ok + REAL(wp) :: e_unrolled, e_held, e_early + CHARACTER(32) :: na(MAXCOL), nb(MAXCOL) + REAL(wp), ALLOCATABLE :: va(:, :), vb(:, :) + INTEGER :: ra, rb, c + CALL write_case('c2u/', [CHARACTER(48) :: '2 Currents']) + CALL write_c2('c2u/', 2) + CALL run_driver('c2u/mixed.dat', 'c2u/mixed', ok) + CALL require(ok, '3: the mixed deck runs with the unrolled table') + CALL write_case('c2h/', [CHARACTER(48) :: '2 Currents']) + CALL write_c2('c2h/', 3) + CALL run_driver('c2h/mixed.dat', 'c2h/mixed', ok) + CALL require(ok, '3: the mixed deck runs with the held table') + e_unrolled = outs_difference('c2/mixed', 'c2u/mixed', 1, NSTEP + 1) + ALLOCATE (va(MAXROW, MAXCOL), vb(MAXROW, MAXCOL)) + CALL read_out('c2/mixed.out', na, va, ra) + CALL read_out('c2h/mixed.out', nb, vb, rb) + e_held = 0.0_wp + e_early = HUGE(1.0_wp) + IF (ra == NSTEP + 1 .AND. rb == NSTEP + 1) THEN + c = col_of(na, 'FairTen2') + e_early = MAXVAL(ABS(vb(1:121, c) - va(1:121, c)))/(MAXVAL(va(1:ra, c)) - MINVAL(va(1:ra, c))) + e_held = MAXVAL(ABS(vb(122:rb, c) - va(122:ra, c)))/(MAXVAL(va(1:ra, c)) - MINVAL(va(1:ra, c))) + END IF + WRITE (*, '(A,ES10.3,A)') ' 3 wrap: the wrapped and the unrolled table differ by ', e_unrolled, & + ' of each channel''s range' + WRITE (*, '(A,ES10.3,A,ES10.3,A)') ' 3 wrap: the held table differs from the wrapped one by ', e_early, & + ' up to 6 s and by ', e_held, ' after it (chain tension, of its range)' + CALL require(e_unrolled <= SAME_TOL, '3: past its last sample the march takes the table repeated') + CALL require(e_early <= SAME_TOL, '3: the held table is the same field up to 6 s') + CALL require(e_held > 0.01_wp, '3: the wrap changes the march after 6 s') + END SUBROUTINE check_wrap + + SUBROUTINE check_uniform_writings() + !! Gate 4: a uniform Currents 5 grid and a uniform Currents 1 profile against OPTION uniform. + LOGICAL :: ok + REAL(wp) :: e5, e1, e5_static + CALL write_case('c5u/', [CHARACTER(48) :: '5 Currents']) + CALL write_c5('c5u/', .TRUE.) + CALL run_driver('c5u/mixed.dat', 'c5u/mixed', ok) + CALL require(ok, '4: the mixed deck runs in a uniform Currents 5 grid') + CALL write_case('c1u/', [CHARACTER(48) :: '1 Currents']) + CALL write_c1('c1u/', .TRUE.) + CALL run_driver('c1u/mixed.dat', 'c1u/mixed', ok) + CALL require(ok, '4: the mixed deck runs in a uniform Currents 1 profile') + e5 = outs_difference('uni/mixed', 'c5u/mixed', 1, NSTEP + 1) + e5_static = outs_difference('uni/mixed', 'c5u/mixed', 1, 1) + e1 = outs_difference('uni/mixed', 'c1u/mixed', 1, NSTEP + 1) + WRITE (*, '(A,ES10.3,A,ES10.3,A,ES10.3,A)') ' 4 uniform field: Currents 5 grid ', e5, ' (static start ', & + e5_static, '), Currents 1 profile ', e1, ' of each channel''s range from OPTION uniform' + ! the grid's trilinear weights and the profile's linear ones reproduce the uniform field to + ! round-off, which the march carries + CALL require(e5_static == 0.0_wp .AND. e5 <= GRID_TOL, '4: a uniform Currents 5 grid is OPTION uniform') + CALL require(e1 <= GRID_TOL, '4: a uniform Currents 1 profile is OPTION uniform') + END SUBROUTINE check_uniform_writings + + SUBROUTINE check_snapshot(deck, label) + !! Gate 5 on a mixed deck (the Newton controls of the coupled route): the correction rewind of + !! the OpenFAST shell (CD_AGG_Snapshot at the start of a step, the step, CD_AGG_Restore, the + !! step again) every 20th step of the march, against the march without rewinds. + CHARACTER(*), INTENT(IN) :: deck, label + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: a, b + REAL(wp), ALLOCATABLE :: ga(:, :), gb(:, :), gp(:, :) + INTEGER, PARAMETER :: EVERY = 20 + INTEGER :: es, nch, step, n_rewind + CHARACTER(2048) :: em + LOGICAL :: ok + REAL(wp) :: e_pre, e_post + ALLOCATE (a, b) + CALL init_mixed(a, deck, label//' uninterrupted', ok) + IF (.NOT. ok) RETURN + nch = CD_AGG_NumChannels(a) + ALLOCATE (ga(NSTEP + 1, nch), gb(NSTEP + 1, nch), gp(NSTEP + 1, nch)) + ga = 0.0_wp + gb = 0.0_wp + gp = 0.0_wp + CALL march(a, 0, NSTEP, ga, label//' uninterrupted', ok) + CALL CD_AGG_End(a, es, em) + IF (.NOT. ok) RETURN + CALL init_mixed(b, deck, label//' rewound', ok) + IF (.NOT. ok) RETURN + CALL march(b, 0, 0, gb, label//' rewound', ok) + n_rewind = 0 + DO step = 1, NSTEP + IF (MOD(step, EVERY) == 0) THEN + CALL CD_AGG_Snapshot(b, es, em) + CALL require(es == CD_AGG_OK, label//': snapshot: '//TRIM(em)) + CALL march(b, step - 1, step, gp, label//' before the rewind', ok) + IF (.NOT. ok) EXIT + CALL CD_AGG_Restore(b, es, em) + CALL require(es == CD_AGG_OK, label//': restore: '//TRIM(em)) + n_rewind = n_rewind + 1 + END IF + CALL march(b, step - 1, step, gb, label//' rewound', ok) + IF (.NOT. ok) EXIT + END DO + CALL CD_AGG_End(b, es, em) + IF (.NOT. ok) RETURN + e_pre = 0.0_wp + DO step = EVERY, NSTEP, EVERY + e_pre = MAX(e_pre, MAXVAL(ABS(gp(step + 1, :) - ga(step + 1, :)))) + END DO + e_post = MAXVAL(ABS(gb - ga)) + WRITE (*, '(A,I0,A,ES10.3,A,ES10.3)') ' '//label//': ', n_rewind, ' rewinds; largest difference from the '// & + 'march without them: the rewound steps ', e_pre, ', the march after them ', e_post + CALL require(n_rewind == NSTEP/EVERY .AND. e_pre == 0.0_wp .AND. e_post == 0.0_wp, & + label//': a step repeated after a restore is the uninterrupted march, bit for bit') + END SUBROUTINE check_snapshot + + SUBROUTINE check_refusals() + !! Gate 6. + INTEGER :: ex + LOGICAL :: named + CALL write_case('wav/', [CHARACTER(48) :: 'airy 2 8 0 waves']) + ex = driver_exit('wav/mixed.dat', 'wav/mixed') + named = log_has('wav/mixed', 'the deck waves OPTION is not supported for a standalone mixed') + CALL require(ex == 1 .AND. named, & + '6: deck waves on the mixed deck are refused by name') + CALL write_case('c2d/', [CHARACTER(48) :: '2 Currents', 'uniform 0.4 0.3 0 current']) + CALL write_c2('c2d/', 1) + ex = driver_exit('c2d/mixed.dat', 'c2d/mixed') + named = log_has('c2d/mixed', 'double-counting') + CALL require(ex == 1 .AND. named, & + '6: a current OPTION beside Currents 2 is refused as double counting') + CALL write_deck('nodt_mixed.dat', [CHARACTER(64) :: CAB_T, CHAIN_T], & + [CHARACTER(40) :: '1 Coupled 0.0 0.0 -50.0 0 0 0 0', '2 Fixed 95.0 0.0 -60.0 0 0 0 0', & + '3 Coupled 0.0 20.0 -50.0 0 0 0 0', '4 Fixed 0.0 110.0 -100.0 0 0 0 0'], & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -'], [CHARACTER(24) :: '1 cab 100.0 40', '2 chain 110.0 20'], & + [CHARACTER(48) :: 'uniform 0.4 0.3 0 current'], MIXED_OUTS) + ex = driver_exit('nodt_mixed.dat', 'nodt_mixed') + named = log_has('nodt_mixed', 'standalone OPTION current requires dtM and TMax') + CALL require(ex == 1 .AND. named, & + '6: a current without dtM is refused as on the single-line routes') + END SUBROUTINE check_refusals + +END PROGRAM test_mixed_route_currents diff --git a/tests/test_step_allocations.f90 b/tests/test_step_allocations.f90 index c20dade2..f101c1eb 100644 --- a/tests/test_step_allocations.f90 +++ b/tests/test_step_allocations.f90 @@ -36,8 +36,13 @@ PROGRAM test_step_allocations !! CD_AGG_Step_Moving with the roll column or with the vessel orientation and rates): a straight !! line restrained in torsion whose End A rolls about its axis, beside an EI = 0 chain. !! + !! With "mixed_current" the same march of a mixed deck takes the deck's own current + !! (deck_current): a MoorDyn-C Currents 5 grid that varies in space and time, sampled at every + !! node of the chain and of the finite-EI cable before each step, past its last sample too. + !! !! Usage: test_step_allocations [ranges] - !! test_step_allocations torsion | nodal | free | current_grid | motion_roll | motion_vessel + !! test_step_allocations torsion | nodal | free | current_grid | motion_roll | motion_vessel | + !! mixed_current USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_LONG_LONG USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -88,9 +93,11 @@ END SUBROUTINE cd_test_allocation_counting CALL current_grid_gate() CASE ('motion_roll', 'motion_vessel') CALL motion_gate(TRIM(arg) == 'motion_vessel') + CASE ('mixed_current') + CALL mixed_current_gate() CASE DEFAULT - ERROR STOP 'a single argument must be "torsion", "nodal", "free", "current_grid", "motion_roll" or '// & - '"motion_vessel"' + ERROR STOP 'a single argument must be "torsion", "nodal", "free", "current_grid", "motion_roll", '// & + '"motion_vessel" or "mixed_current"' END SELECT STOP END IF @@ -468,6 +475,124 @@ SUBROUTINE motion_gate(vessel) PRINT '(A)', 'PASS: no heap allocation in the prescribed-motion march of a mixed deck after warm-up' END SUBROUTINE motion_gate + SUBROUTINE mixed_current_gate() + !! Zero heap allocation in the standalone driver's per-step march of a mixed deck in its own + !! current: a sagging finite-EI line beside a chain, both fairleads surging (motionFile), in + !! a Currents 5 grid (x, y, z, t) whose last sample (6 s) the 10 s march passes. + INTEGER, PARAMETER :: N_WARM = 40, N_COUNT = 160, NT = N_WARM + N_COUNT + REAL(wp), PARAMETER :: DTM = 0.05_wp, PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: XS(2) = [-10.0_wp, 110.0_wp], YS(2) = [-10.0_wp, 120.0_wp], & + ZS(3) = [-210.0_wp, -100.0_wp, 0.0_wp], TS(3) = [0.0_wp, 3.0_wp, 6.0_wp] + CHARACTER(*), PARAMETER :: DIR = 'step_alloc_mixed_current/' + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: mag + REAL(wp), ALLOCATABLE :: p(:, :), v(:, :), a(:, :), ld(:, :), o(:, :, :), w(:, :), al(:, :), roll(:) + REAL(wp) :: t, x, vx, ax, om + INTEGER :: u, k, n, n_it, ix, iy, iz, it + INTEGER(C_LONG_LONG) :: c0, n_alloc + LOGICAL :: turns, rolls, converged, stalled + om = 2.0_wp*PI/10.0_wp + OPEN (NEWUNIT=u, FILE=DIR//'motion.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NT + t = DTM*k + x = 0.5_wp*(1.0_wp - COS(om*t)) + vx = 0.5_wp*om*SIN(om*t) + ax = 0.5_wp*om*om*COS(om*t) + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 1 ', x, ' 0 -50 ', vx, ' 0 0 ', ax, ' 0 0' + WRITE (u, '(F8.3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, ' 3 ', x, ' 20 -50 ', vx, ' 0 0 ', ax, ' 0 0' + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=DIR//'current_profile_4d.txt', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '2 2 3 3' + WRITE (u, '(A)') '-10.0 110.0' + WRITE (u, '(A)') '-10.0 120.0' + WRITE (u, '(A)') '-210.0 -100.0 0.0' + WRITE (u, '(A)') '0.0 3.0 6.0' + WRITE (u, '(A)') 'x y z t ux uy uz' + DO it = 1, 3 + DO iz = 1, 3 + DO iy = 1, 2 + DO ix = 1, 2 + WRITE (u, '(4F10.3,3F12.6)') XS(ix), YS(iy), ZS(iz), TS(it), & + (1.0_wp + ZS(iz)/250.0_wp)*(0.3_wp + 0.002_wp*XS(ix) + 0.1_wp*(it - 1)), & + (1.0_wp + ZS(iz)/250.0_wp)*(0.2_wp - 0.001_wp*YS(iy)), 0.0_wp + END DO + END DO + END DO + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=DIR//'deck.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'step allocation gate: mixed deck in its own current' + 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 4.0e8 0.0 1.0e4 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') 'chain 0.1 50.0 1.0e9 -1.0 0.0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 95.0 0.0 -60.0 0 0 0 0' + WRITE (u, '(A)') '3 Coupled 0.0 20.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 0.0 110.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 4 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '2 chain 110.0 20' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '10.0 TMax' + WRITE (u, '(A)') '5 Currents' + WRITE (u, '(A)') 'motion.txt motionFile' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + ALLOCATE (mag) + CALL CD_AGG_Init_From_Deck(mag, DIR//'deck.dat', DTM, es, em, forbid_deck_ambient=.TRUE., & + run_tmax=10.0_wp, host_orientation=.TRUE., prescribed_motion=.TRUE., & + deck_current=.TRUE.) + CALL check('current deck initialization') + n = CD_AGG_NMovingPoints(mag, es, em) + CALL check('current moving-point count') + ALLOCATE (p(3, n), v(3, n), a(3, n), ld(3, n), o(3, 3, n), w(3, n), al(3, n), roll(n)) + CALL CD_AGG_GetMovingPointMesh(mag, p, v, a, ld, es, em) + CALL check('current initial mesh') + CALL CD_AGG_MotionKinematics(mag, 1, p, v, a, o, w, al, roll, turns, rolls, es, em) + CALL check('current row 1') + CALL CD_AGG_UpdateStates_Moving(mag, p, v, a, es, em) + CALL check('current row 1 transfer') + CALL CD_AGG_Refresh_Accelerations(mag, es, em) + CALL check('current row 1 accelerations') + n_alloc = 0 + DO k = 1, NT + c0 = cd_test_allocation_count() + IF (k > N_WARM) CALL cd_test_allocation_counting(1_C_INT) + CALL CD_AGG_MotionKinematics(mag, k + 1, p, v, a, o, w, al, roll, turns, rolls, es, em) + IF (es == 0) CALL CD_AGG_Step_Moving(mag, DTM, p, v, a, converged, stalled, n_it, es, em, t_committed=DTM*k) + CALL cd_test_allocation_counting(0_C_INT) + CALL check('current step') + IF (.NOT. converged .OR. stalled) ERROR STOP 'current step did not converge' + n_alloc = n_alloc + (cd_test_allocation_count() - c0) + END DO + CALL CD_AGG_End(mag, es, em) + PRINT '(A,I0,A,I0,A)', 'mixed deck in a Currents 5 grid: ', N_COUNT, ' counted steps, ', n_alloc, & + ' heap allocations in the steps' + IF (n_alloc /= 0) THEN + PRINT '(A)', 'FAIL: the march of a mixed deck in its own current allocated after warm-up' + ERROR STOP 1 + END IF + PRINT '(A)', 'PASS: no heap allocation in the march of a mixed deck in its own current after warm-up' + END SUBROUTINE mixed_current_gate + SUBROUTINE check(stage) CHARACTER(*), INTENT(IN) :: stage From 8bbcd4e3ad61069cee783621a6522196e284e0cc Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 12:25:49 +0900 Subject: [PATCH 31/51] build: thread-safe Intel builds, value-safe floating point, openfast.exe version, faster wave kinematics (#80) ## Summary Release-build robustness for 0.4.0: separate CableDyn handles run safely from several threads under Intel ifx, every ifx build uses the value-safe floating-point model, `openfast.exe` names its real version, and the wave kinematics win back the cost of `/fp:precise`. ## Threads and the Intel run-time - **Automatic locals everywhere** (`/Qauto`, `-auto`; `-frecursive` for gfortran without OpenMP). Without OpenMP, ifx kept fixed-size local arrays and `CHARACTER` locals in static storage, so concurrent initialisations failed ("tangent assembly failed"). - **No closures as callbacks.** ifx calls internal procedures passed as arguments through trampolines on memory every thread shares; concurrent steps faulted there under every ifx option. The line step now takes a load object (`CD_Cable_Step_Loads`). The audit `thread_safe_sources` refuses closures, implicit `SAVE`, unreviewed static variables and missing flags; it fails on the old source. - **Diagnostics counts** are per system and per workspace, not process-wide tallies. - **`CableDyn_Close` no longer pauses the whole OpenMP run-time** under libiomp5/libomp. Since 0.1.0 every close called `omp_pause_resource_all` (a fix for GNU OpenMP's exit on MinGW-w64); the Intel and LLVM run-times pause every thread instead, and the next parallel region on another thread deadlocked resuming it. A non-static ifx build with OpenMP hung the threading gate 20 of 20 times; it now passes 20 of 20 with `OMP_NUM_THREADS` 1 and 4. GNU builds keep the pool join (`c_api_threads_exit` passes). - **Long names:** a failing `OPEN` of a name of about 600 characters or more ends the Intel run-time (`STATUS_STACK_BUFFER_OVERRUN`). Every user-path `OPEN` goes through `CD_Path_Openable` / `CD_Open_Read` / `CD_Open_Write` first. - Gates: `c_api_threads` (base, omp32, stress, mixed, exit) 50 of 50 under ifx and gfortran (before: every run failed under ifx), `c_api_threads_mixed` (7 decks x 4 threads), `deck_reader_io` and `driver_cli_paths` long-name cases. ## Floating point and build - `/fp:precise` (`-fp-model precise`) for every ifx build and the OpenFAST Visual Studio projects, not only the static release: the ifx default `/fp:fast` broke nine bit-identity and accuracy gates. Heap arrays above 1 MiB in every ifx build; automatic locals in the OpenFAST VS project. - A number beyond the range of the kind (e.g. `1e309`) is "not a finite number" on every compiler; core-linked C tests link through IFX in the static release. ## openfast.exe version The release patches the pinned OpenFAST v5.0.0 tree, so OpenFAST's own `git describe --dirty` stamped `v5.0.0-dirty`. The VS and CMake routes now stamp `-CableDyn-` (`v5.0.0-CableDyn-0.3.0` until the version bump), and the release smoke test fails unless `openfast.exe -v` prints exactly that. Verified on the release workflow (workflow_dispatch, artifacts only): `PASS openfast.exe identity: OpenFAST-v5.0.0-CableDyn-0.3.0`. ## Wave kinematics Block sine, cosine and exponential kernels (`CableDyn_WaveMath`) in `CD_Component_Wave_Kinematics` and `CD_Sea_Kinematics`: within 2.4 ulp (sine, cosine) and 1.12 ulp (exp) of quadruple precision over |phase| <= 1.65e6 (intrinsic fallback above), NaN propagated, IEEE semantics forced per file under GNU fast-math. Block and single-element results are bit-identical under every flag set (restart identity unaffected). Speed-ups, 1 thread: ifx `chain_two_train_sea` -33 %, line-break decks -14 %, `lazy_wave_vessel_rao` -9 %; gfortran -21 % / -9 % / 0 %. ## Checks - gfortran: ctest 348 of 348; ifx static and non-static (OpenMP): the threading gates above. - Example A/B against dev: 49 of 53 identical. `lazy_wave_vessel_rao` and `lazy_wave_bend_stiffener` differ in the last printed digit (1e-7 in `.out`); the two 1800 s line-break decks drift after about 860 s by round-off growth in the post-break transient, the same size as the gfortran-vs-ifx difference of the unchanged code. - pre-commit, Sphinx `-W`, strict mypy (dev's 3 numpy-stub notes only), no symbol both in a `PUBLIC` list and declared `PUBLIC`. Signed-off-by: Jae Hoon Seo --- .github/workflows/release-windows-static.yml | 2 + ARCHITECTURE.md | 1 + CHANGELOG.md | 76 +++++ CMakeLists.txt | 107 ++++++- DEVELOPMENT.md | 4 +- NOTICE | 6 +- RELEASE.md | 4 +- app/cabledyn.f90 | 10 +- doc/api_reference.md | 3 + doc/installation.rst | 3 +- integration/openfast/README.md | 22 +- .../integrate_openfast_vs_solution.ps1 | 42 ++- integration/openfast/openfast_build_gate.ps1 | 11 +- .../patches/0006-cabledyn-cmake.patch | 13 +- .../openfast/patches/0021-version-cmake.patch | 42 +++ .../openfast/vs-build/CableDyn.vfproj.in | 16 +- release/build_static_windows.ps1 | 20 ++ release/check_release_metadata.py | 5 + src/CableDyn_CAPI.f90 | 24 +- src/CableDyn_CosseratAssemble.f90 | 50 ++- src/CableDyn_CosseratDynamic.f90 | 67 ++-- src/CableDyn_DeckDriver.f90 | 55 ++-- src/CableDyn_Driver.f90 | 9 +- src/CableDyn_Dynamic.f90 | 159 ++++++++-- src/CableDyn_HermiteCableDynamic.f90 | 30 +- src/CableDyn_Hydro.f90 | 50 +-- src/CableDyn_Model.f90 | 187 +++++------ src/CableDyn_OpenFAST_Aggregate.f90 | 19 +- src/CableDyn_PathIO.f90 | 61 +++- src/CableDyn_RangeOutput.f90 | 3 +- src/CableDyn_System.f90 | 35 +- src/CableDyn_WaveMath.f90 | 144 +++++++++ src/CableDyn_WaveSpectra.f90 | 30 +- src/cabledyn_path.c | 52 ++- src/openfast/CableDyn_OF.f90 | 12 +- tests/check_driver_paths.cmake | 16 + tests/check_driver_profile.cmake | 4 +- tests/check_driver_profile_failure.cmake | 4 +- tests/data/c_api_free_rod.dat | 41 +++ tests/test_c_api_threads.c | 94 +++++- tests/test_core_release_regressions.f90 | 12 +- tests/test_cosserat_assemble.f90 | 13 +- tests/test_cosserat_dynamic.f90 | 14 +- tests/test_deck_reader_io.f90 | 58 +++- tests/test_documentation.py | 14 + tests/test_hermite_cable_dynamic.f90 | 31 +- tests/test_l3_lazywave_dynamic.f90 | 8 +- tests/test_of_mooring_counters.f90 | 12 +- tests/test_openfast_touchdown.f90 | 8 +- tests/test_thread_safe_sources.py | 298 ++++++++++++++++++ tests/test_wave_math.f90 | 207 ++++++++++++ 51 files changed, 1827 insertions(+), 381 deletions(-) create mode 100644 integration/openfast/patches/0021-version-cmake.patch create mode 100644 src/CableDyn_WaveMath.f90 create mode 100644 tests/data/c_api_free_rod.dat create mode 100644 tests/test_thread_safe_sources.py create mode 100644 tests/test_wave_math.f90 diff --git a/.github/workflows/release-windows-static.yml b/.github/workflows/release-windows-static.yml index 33ed671b..eea6de91 100644 --- a/.github/workflows/release-windows-static.yml +++ b/.github/workflows/release-windows-static.yml @@ -32,6 +32,8 @@ jobs: repository: OpenFAST/openfast ref: 2895884d2be01862173c88d70f86b358d2f1a50a path: openfast + # the history and tags: openfast.exe names its base by `git describe --tags` + fetch-depth: 0 persist-credentials: false - name: Check out the pinned OpenFAST regression model diff --git a/ARCHITECTURE.md b/ARCHITECTURE.md index 4493aa34..032fe55e 100644 --- a/ARCHITECTURE.md +++ b/ARCHITECTURE.md @@ -446,6 +446,7 @@ src/ CableDyn_Hydro.f90 Morison loads, Airy and JONSWAP waves, currents CableDyn_WaveSpectra.f90 spectra, spreading, and multi-train seas CableDyn_StreamWave.f90 stream-function regular nonlinear waves + CableDyn_WaveMath.f90 block sine/cosine and exponential of the wave kinematics CableDyn_Vessel.f90 vessel kinematics, 6-DOF motion, displacement RAOs CableDyn_SeabedContact.f90 C1 normal contact and stick-slip friction laws CableDyn_Bathymetry.f90 gridded bathymetry diff --git a/CHANGELOG.md b/CHANGELOG.md index aceb1c69..a102a6f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -294,6 +294,16 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Changed +- Every Intel ifx build compiles CableDyn with the value-safe floating-point model, + `/fp:precise` (`-fp-model precise` off Windows): the static Windows release and wheel, every + other CMake build and configuration with ifx (with or without OpenMP, including the core that + the OpenFAST CMake route builds, and its adapter), and every configuration of the OpenFAST + Visual Studio project. The ifx default, `/fp:fast`, reassociates sums, divides by + multiplying with the reciprocal and flushes subnormals to zero, differently at every inlined + call site, so the gates that hold two routes to the same bits failed (a zero control command + against an uncontrolled cable, a held Coupled End B against a Fixed one, a committed against a + re-derived torque), subnormal deck values read as zero and the clamped-cable elastica secant + stalled. Results of ifx builds change at round-off; gfortran builds are unchanged. - The macOS wheel needs macOS 15 or newer on Apple silicon (0.3.0: macOS 14). It is built on the macOS 15 runner, as GitHub retires the macOS 14 runner image on 2 November 2026, and its Homebrew gfortran and OpenBLAS support no older macOS. On macOS 14, build from source. @@ -336,6 +346,23 @@ All notable changes to CableDyn are recorded in this file. The format follows 0.1 s drops from 18,000 components to 1,800. On the 300 s lazy-wave case both records then run in 72 s, and every output channel's standard deviation moves by at most 0.002 %. A record with no component at or below the cut-off is refused by name. +- Waves run faster under every compiler: the wave kinematics evaluate their phase sines and cosines + and depth exponentials in blocks of plain arithmetic that vectorise under any value-safe + floating-point model (`CableDyn_WaveMath`: one argument reduction for each sine-cosine pair, + polynomials, the power of two from its bits) in place of one library call per component, which ifx + makes under `/fp:precise`. At one thread, best of five, an irregular sea runs 31 to 33 % faster + with ifx (`chain_two_train_sea` 1.83 s to 1.22 s, `chain_torsethaugen_spread` 1.64 s to 1.13 s) + and 20 to 21 % faster with gfortran (4.09 s to 3.22 s, 3.56 s to 2.86 s); the VolturnUS line-break + decks 14 % (ifx, 31.0 s to 26.8 s) and 9 % (gfortran); `lazy_wave_vessel_rao` and + `lazy_wave_bend_stiffener` 9 % with ifx and within 1 % of before with gfortran; decks without + waves run as before. This recovers about two thirds of what `/fp:precise` cost the Windows release + (`chain_two_train_sea` +83 % over `/fp:fast` before, +24 % now). The sines and cosines are within + 2.4 ulp (within 9e-26 next to their zeros) and the exponentials within 1.1 ulp of quadruple + precision, so wave decks change at round-off: 49 of the 53 example decks give identical files, two + lazy-wave decks differ by one unit in the last printed digit (7e-8 of a tension's scale), and in + the two VolturnUS line-break decks the drifting platform amplifies round-off after t = 860 s to + 0.15 to 0.21 of the anchor-2 tension's scale, as much as the gfortran and ifx builds of the + unchanged code differ by. - Coupled OpenFAST runs start from the equilibrium in SeaState's steady current (`CurrMod 1`), as standalone decks start in their `current` option, instead of from the still-water shape. The current is evaluated at SeaState's vertical grid levels for the static solves only; the @@ -391,6 +418,20 @@ All notable changes to CableDyn are recorded in this file. The format follows is now laid from End A, the line seen from its other end, and its nodes put back in order. The deck starts at the same equilibrium as before on Windows (1e-7 m, 6e-4 N), and moving the fixed rod by 1 ulp either way or 1e-12 m up leaves the rod's start unchanged (0 m). +- `CableDyn_Close` no longer pauses the OpenMP runtime of the whole process under the Intel and + LLVM OpenMP runtimes (ifx and other non-GNU builds with OpenMP). Every close called + `omp_pause_resource_all` (since 0.1.0) to join the calling thread's pool, a fix for GNU + OpenMP's process exit on MinGW-w64; libiomp5 and libomp pause the runtime of every thread + instead, so closing one handle paused the OpenMP of every other handle and of the host, and the + next parallel region on another thread deadlocked resuming it. An ifx build with OpenMP that + stepped a handle on a second thread after a close hung every time (the threading gate, 20 of + 20 runs); it now passes 20 of 20 with 1 and with 4 OpenMP threads. GNU builds keep the pool join. +- A non-static ifx build (a plain CMake build with ifx, or the core of the OpenFAST CMake route) + kept run-time-sized arrays and array temporaries on the stack, as only the static Windows + release compiled with `/heap-arrays`: the 2835-node mixed IEA-15 MW deck and a fine-mesh deck of + the statics matrix overflowed the 1 MiB stack of an MSVC-linked program. Every ifx build now + compiles with `/heap-arrays:1024` (`-heap-arrays 1024` off Windows), as the static release and + the OpenFAST Visual Studio project did; the static release is unchanged. - 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 @@ -460,6 +501,36 @@ All notable changes to CableDyn are recorded in this file. The format follows share: a free spar rod with a 55 m pinned cable (EI 2e4 N m^2) started 5.7e-2 m off its equilibrium, drifted 7e-2 m in 3 s and moved a leg tension by 2.3 %. Such a line now takes the static passes too (4 here); the rod holds its pose to the output's 8 digits. +- Diagnostic counts that concurrent models shared: the adaptive-substep fallbacks of an `EI = 0` + system and the assembly and modified-Newton counts of the finite-EI Cosserat solver were + process-wide (and lost increments without OpenMP); they are now kept per system and per solver + workspace. The count of finite-EI intervals recovered by substeps is reported only by the opt-in + run profile (`CABLEDYN_PROFILE`), whose figures stay process-wide by design; each model keeps its + own. No result changes. +- A failing `OPEN` of a file name of about 600 characters or more (the extended-length spelling of + a path beyond the Windows limit) ended an ifx-built program or the wheel's DLL with + `STATUS_STACK_BUFFER_OVERRUN` inside the Intel Fortran run-time, for example an output root in + a folder that does not exist. Every `OPEN` of a user-supplied name now first asks the system + whether the file opens (`CD_Path_Openable`) and reports the failure without attempting the + `OPEN`; the messages are unchanged. +- Concurrent steps of separate handles crashed the ifx builds with access violations: an `EI = 0` + line model passed its load and added-mass callbacks to the integrator as internal procedures, + and ifx calls such a closure through a trampoline kept in memory every thread shares, so two + threads stepping distinct models called each other's half-written trampolines (a 40-line + reproducer crashes with two threads under every ifx option). The model now hands its loads to + the integrator as an object (`CD_Cable_Step_Loads`); results are unchanged. Seven decks + stepped together on 28 threads (`c_api_threads_mixed`) failed every run before and pass 50 of + 50. +- Separate handles used on several threads at once failed in the Windows wheel and the release + binaries (Intel ifx without OpenMP): ifx kept the fixed-size local arrays and `CHARACTER` locals + of every procedure in static storage, which all threads share, so an initialisation that ran + while other handles stepped stopped with "tangent assembly failed" or "band scatter" errors + (gfortran builds were not affected: `-fopenmp` makes every local automatic). Every build now + makes local variables automatic, `/Qauto` (`-auto`) with ifx and `-frecursive` with gfortran, + which `-fopenmp` already implied, so the default gfortran build is unchanged, and so does every + configuration of the OpenFAST Visual Studio project (`LocalVariableStorage`). The release + benchmark decks run as fast or faster (0.3 to 21 %); ifx results change at round-off (with + `/fp:precise` every example is bit-identical). - 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 @@ -536,6 +607,11 @@ All notable changes to CableDyn are recorded in this file. The format follows side, or by the sign of a round-off component: in OpenFAST about half the rows of a cable in the x-z plane read 359.9x. A line whose chord heads within 45° of +X now reports its azimuths in (−180, 180], every other line in [0, 360) as before. +- The CableDyn-enabled `openfast.exe` named itself `OpenFAST-v5.0.0-dirty`: OpenFAST stamps its + version with `git describe --dirty`, and the integration patches modify the checkout. Built + through the Visual Studio solution or through CMake it now reads + `OpenFAST-v5.0.0-CableDyn-`, the describe of the unpatched OpenFAST base and + the CableDyn version, and the release build fails unless `openfast.exe -v` prints exactly that. ## [0.3.0] - 2026-10-23 diff --git a/CMakeLists.txt b/CMakeLists.txt index 84066a67..de683382 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,13 +31,8 @@ if(CABLEDYN_STATIC_WINDOWS_RELEASE) # The release executables target x86-64-v3 (CABLEDYN_TARGET_AVX2 below). set(CABLEDYN_TARGET_AVX2 ON CACHE BOOL "" FORCE) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded" CACHE STRING "" FORCE) - # Large finite-EI meshes create compiler-generated array temporaries in deeply - # nested residual/assembly calls. Keep those temporaries off the process stack; - # the released executable also receives a generous reserve below. The size - # threshold keeps run-time-sized arrays and temporaries on the heap but leaves - # compile-time-sized locals up to 1 MiB on the stack: with a bare /heap-arrays, - # IFX 2025.3 heap-allocates the host frame of every procedure with internal - # procedures and never frees it, leaking memory on each call. + # Run-time-sized arrays and array temporaries go to the heap (/heap-arrays:1024), as in + # every IFX build (below); the released executable also receives a generous reserve below. # # /Qipo: the element, hydrodynamic, and assembly kernels live in separate modules # and are called per element and per Newton iteration; without interprocedural @@ -45,7 +40,10 @@ if(CABLEDYN_STATIC_WINDOWS_RELEASE) # then holds IPO objects, so it links only through an IPO-capable IFX link (the # driver below, or the OpenFAST Release|x64 project, which enables whole-program # optimisation). - string(APPEND CMAKE_Fortran_FLAGS " /libs:static /heap-arrays:1024 /Qipo") + # + # The floating-point model is /fp:precise, as in every IFX build (below); the reference + # LAPACK is built with /fp:precise as well. + string(APPEND CMAKE_Fortran_FLAGS " /libs:static /Qipo") # CMake does not pass the compile flags to an IFX executable link on Windows. The shared # library (the Windows wheel's cabledyn.dll) links the same IPO objects, so it needs the # flag as well: without it IFX hands the intermediate objects to link.exe (LNK1107). @@ -140,6 +138,51 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") $<$:-Wall> $<$:-Wextra>) endif() +# Local variables are automatic in every procedure, whatever the OpenMP setting: separate +# models (C API handles, Python objects, FAST.Farm turbines) may step concurrently on +# several threads, and a local in static storage is shared by every thread that runs its +# procedure. Without OpenMP, IFX keeps fixed-size local arrays and CHARACTER locals in +# static storage (its default, /Qauto-scalar, makes only the numeric and LOGICAL scalars +# automatic), and gfortran moves a local array larger than -fmax-stack-var-size (64 KiB) +# there; /Qauto (-auto) and -frecursive put them on the stack (-fopenmp already implies +# -frecursive, so the default GNU build is unchanged). A value that must persist between +# calls is SAVEd explicitly. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + add_compile_options($<$:-frecursive>) +elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") + if(WIN32) + add_compile_options($<$:/Qauto>) + else() + add_compile_options($<$:-auto>) + endif() +endif() +# The value-safe floating-point model in every IFX build and configuration: /fp:precise +# (-fp-model precise off Windows), for the core, the driver, the tests, the wheel and the +# OpenFAST build of the core alike. IFX defaults to /fp:fast, which lets it reassociate sums, +# replace a division by a multiplication with the reciprocal and flush subnormals to zero, +# differently at every inlined call site. The same expression then rounds differently on two +# code paths, so the gates that hold two routes to the same bits (a zero control command and +# an uncontrolled cable, a held Coupled End B and a Fixed one, a committed and a re-derived +# torque) fail, a subnormal deck value reads as zero, and a secant iteration can stall on +# equal residuals. GNU builds keep their default, value-safe model (no -ffast-math). +# +# Run-time-sized arrays and the compiler's array temporaries on the heap, in every IFX build: +# /heap-arrays:1024 (-heap-arrays 1024 off Windows). The library runs on threads whose stack the +# host sets (1 MiB for python.exe and an MSVC-linked program: the stack_c_api and c_api_threads +# gates), and large finite-EI meshes create array temporaries in deeply nested residual and +# assembly calls; without the option a non-static IFX build overflows those stacks. The size +# threshold leaves compile-time-sized locals up to 1 MiB on the stack: with a bare /heap-arrays, +# IFX 2025.3 heap-allocates the host frame of every procedure with internal procedures and +# never frees it, leaking memory on each call. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") + if(WIN32) + add_compile_options($<$:/fp:precise> + $<$:/heap-arrays:1024>) + else() + add_compile_options("$<$:SHELL:-fp-model precise>" + "$<$:SHELL:-heap-arrays 1024>") + endif() +endif() # GNU builds on Windows (MinGW-w64): every executable gets a 64 MiB stack reserve instead of # the 2 MiB MinGW default. With OpenMP, gfortran places fixed-size local arrays on the stack # (-fopenmp implies -frecursive), and the stack depth of the OpenBLAS kernels varies with the @@ -402,6 +445,7 @@ add_library(cabledyn_obj OBJECT src/CableDyn_Assemble.f90 src/CableDyn_Loads.f90 src/CableDyn_Bathymetry.f90 + src/CableDyn_WaveMath.f90 src/CableDyn_Hydro.f90 src/CableDyn_WaveSpectra.f90 src/CableDyn_StreamWave.f90 @@ -433,6 +477,15 @@ set_target_properties(cabledyn_obj PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(cabledyn_obj PROPERTIES C_STANDARD 11 C_STANDARD_REQUIRED ON C_EXTENSIONS OFF) target_include_directories(cabledyn_obj PUBLIC "${CMAKE_Fortran_MODULE_DIRECTORY}") target_link_libraries(cabledyn_obj PUBLIC ${CABLEDYN_LAPACK}) +# The block sine, cosine and exponential of the wave kinematics (src/CableDyn_WaveMath.f90) +# round to an integer as (y + 1.5*2^52) - 1.5*2^52 and reduce the phase by pi/2 in exact parts. +# A value-unsafe floating-point model may reassociate both and fold the rounding to y, so that +# every sine, cosine and exponential is wrong by O(1). Every IFX build compiles with +# /fp:precise (-fp-model precise) already (above); a GNU build given -ffast-math (or -Ofast) +# in its flags still compiles this file with IEEE semantics. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + set_source_files_properties(src/CableDyn_WaveMath.f90 PROPERTIES COMPILE_OPTIONS "-fno-fast-math") +endif() if(CABLEDYN_HAVE_OPENBLAS_SET_NUM_THREADS) target_compile_definitions(cabledyn_obj PRIVATE CABLEDYN_HAVE_OPENBLAS_SET_NUM_THREADS=1) endif() @@ -776,6 +829,12 @@ target_link_libraries(test_hydro PRIVATE cabledyn_core) add_test(NAME hydro COMMAND test_hydro) set_tests_properties(hydro PROPERTIES LABELS "fortran;unit;hydro") +# The block sine, cosine and exponential of the wave kinematics against quadruple precision. +add_executable(test_wave_math tests/test_wave_math.f90) +target_link_libraries(test_wave_math PRIVATE cabledyn_core) +add_test(NAME wave_math COMMAND test_wave_math) +set_tests_properties(wave_math PROPERTIES LABELS "fortran;unit;hydro") + add_executable(test_cable_static tests/test_cable_static.f90) target_link_libraries(test_cable_static PRIVATE cabledyn_core) add_test(NAME cable_static COMMAND test_cable_static) @@ -1358,6 +1417,21 @@ add_test(NAME c_api_threads_stress $,1,0>) set_tests_properties(c_api_threads_stress PROPERTIES LABELS "c;unit;capi;threading" TIMEOUT 600 ENVIRONMENT "CABLEDYN_THREAD_TEST_LOOPS=5;CABLEDYN_THREAD_TEST_TIMEOUT=540") +# Concurrent steps on every per-handle route at once, 4 threads per deck, each trajectory against +# its deck's serial reference: EI = 0 chain and finite-EI cable on the coupled aggregate, +# viscoelastic and Syrope segments, a mixed EI = 0/finite-EI deck, Free points, a finite-EI +# power cable and a Free rod. Static locals or closure trampolines shared by the threads fail it. +add_test(NAME c_api_threads_mixed + COMMAND test_c_api_threads --mixed 40 + ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/host_coupling_chain_cable.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/ve_polyester_catenary_mooring.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/syrope_polyester_mooring.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/iea15mw_umaine_mixed_cabledyn.dat + ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/foam_esflowc_box_points.dat + ${CMAKE_CURRENT_SOURCE_DIR}/examples/lozon_gomaine200_power_cable.dat + ${CMAKE_CURRENT_SOURCE_DIR}/tests/data/c_api_free_rod.dat) +set_tests_properties(c_api_threads_mixed PROPERTIES LABELS "c;unit;capi;threading" TIMEOUT 600 + ENVIRONMENT "CABLEDYN_THREAD_TEST_TIMEOUT=540") if(WIN32) # Host threads that ran OpenMP teams, then an immediate process exit: MinGW-w64 # libgomp could hang in its exit handler when a pool thread was still ending. @@ -1419,6 +1493,12 @@ if(NOT WIN32) endif() # Growth bounds [MiB]: observed 0.0 MiB over 20000 C-API steps and 0.11 MiB over 1000 # aggregate steps; 2 MiB leaves room for allocator page granularity. +if(CABLEDYN_STATIC_WINDOWS_RELEASE) + # The static IFX core archive holds /Qipo objects, which only an IFX link reads (link.exe, + # the C linker, reports every CableDyn_* symbol unresolved): the C tests that link the core + # directly link through IFX there. + set_target_properties(test_c_api_raw_small_dt test_memory_growth PROPERTIES LINKER_LANGUAGE Fortran) +endif() add_test(NAME memory_growth COMMAND test_memory_growth 2 ${CMAKE_CURRENT_SOURCE_DIR}/examples/spread_3line_chain.dat 20000) set_tests_properties(memory_growth PROPERTIES LABELS "c;capi;dynamic;memory" SKIP_RETURN_CODE 77) @@ -1551,6 +1631,14 @@ if(Python3_Interpreter_FOUND) LABELS "python;unit;stack" ENVIRONMENT "${_cabledyn_python_test_environment}") + # Storage that concurrent models could share: closures, implicit SAVE, unreviewed static + # variables, and the automatic-locals flags (tests/test_thread_safe_sources.py). + add_test(NAME thread_safe_sources + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_thread_safe_sources.py) + set_tests_properties(thread_safe_sources PROPERTIES + LABELS "python;unit;threading" + ENVIRONMENT "${_cabledyn_python_test_environment}") + add_test(NAME documentation_sources COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_documentation.py) set_tests_properties(documentation_sources PROPERTIES @@ -2969,7 +3057,8 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") test_endconn_spring test_torsion_coupling test_torsion_one_end - test_two_moving_ends) + test_two_moving_ends + test_wave_math) target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) endforeach() target_compile_options(test_openfast_aggregate PRIVATE diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 2f7bfa8b..704a8b10 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -242,8 +242,8 @@ and a MinGW `FAST.Farm.exe` (`-DBUILD_FASTFARM=ON`) with the default stack stops stack overflow while ElastoDyn initialises. `openfast_build_gate.ps1` builds `openfast.exe`, runs a `CompMooring = 5` case, -checks that the CableDyn banner appears in the log, and checks that the output is -finite. +checks that the CableDyn banner appears in the log, that the executable names itself +`OpenFAST--CableDyn-`, and that the output is finite. An `openfast.exe` built this way through CMake does not embed the UTF-8 active-code-page manifest (`app/utf8_code_page.manifest`), so on Windows it may not diff --git a/NOTICE b/NOTICE index 1bcae455..b56bb457 100644 --- a/NOTICE +++ b/NOTICE @@ -22,9 +22,9 @@ OpenFAST (Apache License, Version 2.0) https://github.com/OpenFAST/openfast * integration/openfast/patches/ contains patches that MODIFY OpenFAST source - files (the root and openfast-library CMakeLists.txt; FAST_AeroMap.f90, - FAST_Funcs.f90, FAST_Mapping.f90, FAST_ModGlue.f90, FAST_Registry.txt, - FAST_Solver.f90, FAST_Subs.f90, and FAST_Types.f90 in + files (the root, openfast-library, and version CMakeLists.txt; + FAST_AeroMap.f90, FAST_Funcs.f90, FAST_Mapping.f90, FAST_ModGlue.f90, + FAST_Registry.txt, FAST_Solver.f90, FAST_Subs.f90, and FAST_Types.f90 in modules/openfast-library/src; FAST_Farm_IO.f90, FAST_Farm_Registry.txt, FAST_Farm_Subs.f90, and FAST_Farm_Types.f90 in glue-codes/fast-farm/src). The modified files remain under the Apache License, Version 2.0, and diff --git a/RELEASE.md b/RELEASE.md index ded58fe6..19dd0d58 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -102,7 +102,9 @@ solution, which still supplies the single-precision routines they do not build. The build fails if either executable imports a non-system DLL or lacks the UTF-8 active-code-page manifest (`release/check_static_windows_binary.ps1`), or if the standalone and `CompMooring = 5` smoke cases fail with a system-only `PATH` or from -a folder named in mixed scripts. +a folder named in mixed scripts. It also fails unless `openfast.exe -v` names the +executable `OpenFAST-v5.0.0-CableDyn-0.3.0`: the OpenFAST base and the CableDyn version, +never a `-dirty` describe of the patched tree. The release workflow (`.github/workflows/release-windows-static.yml`) produces exactly these assets: diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 9accf8a1..3f83766b 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -24,7 +24,7 @@ PROGRAM cabledyn CD_Classify_Dynamic_Completion, CD_DECKDRV_OK, & CD_DECKDRV_BADINPUT, CD_DECKDRV_SOLVEFAIL, CD_DECK_PATHLEN USE CableDyn_PathIO, ONLY: CD_Get_Argument, CD_Native_Path, CD_Lock_Path, CD_PATH_OK, & - CD_LOCK_ACQUIRED, CD_LOCK_HELD + CD_LOCK_ACQUIRED, CD_LOCK_HELD, CD_Open_Read, CD_Open_Write USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, & CD_AGG_NMovingPoints, CD_AGG_GetMovingPointMesh, & CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_End, & @@ -271,7 +271,7 @@ SUBROUTINE check_output_root(deck, deck_spelling, root, root_spelling) ! A probe file beside the outputs proves the directory exists and is writable. probe = root_spelling//'.write_check.tmp' INQUIRE (FILE=probe, EXIST=exists) - OPEN (NEWUNIT=unit, FILE=probe, STATUS='UNKNOWN', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, probe, ios, status='UNKNOWN') IF (ios /= 0) THEN WRITE (error_unit, '(A)') PROG//': cannot write output files at "'//root// & '" (check that the directory exists and is writable)' @@ -423,7 +423,7 @@ LOGICAL FUNCTION same_file(a, b) RESULT(same) IF (.NOT. (exists_a .AND. exists_b)) RETURN same = normalized_path(a) == normalized_path(b) IF (same) RETURN - OPEN (NEWUNIT=unit, FILE=a, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL CD_Open_Read(unit, a, ios) IF (ios /= 0) RETURN opened = .FALSE. INQUIRE (FILE=b, OPENED=opened) @@ -600,7 +600,7 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h acceleration = CD_ZERO END IF dynamic_path = TRIM(root)//'.out' - OPEN (NEWUNIT=unit, FILE=TRIM(dynamic_path), STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, TRIM(dynamic_path), ios) IF (ios /= 0) THEN run_stat = CD_DECKDRV_BADINPUT run_msg = 'CableDyn_driver: cannot open mixed dynamic output: '//TRIM(dynamic_path) @@ -726,7 +726,7 @@ LOGICAL FUNCTION deck_requests_modes(deck) RESULT(requested) REAL(wp) :: x requested = .FALSE. in_options = .FALSE. - OPEN (NEWUNIT=u, FILE=deck, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL CD_Open_Read(u, deck, ios) IF (ios /= 0) RETURN DO READ (u, '(A)', IOSTAT=ios) line diff --git a/doc/api_reference.md b/doc/api_reference.md index 29c0e844..1ab5b910 100644 --- a/doc/api_reference.md +++ b/doc/api_reference.md @@ -113,6 +113,9 @@ no deck route runs on it (a finite-EI line with two moving ends runs on the cubi spreading and multi-train seas of the standalone deck * - `CableDyn_StreamWave` - regular nonlinear waves by the stream-function (Fourier) method +* - `CableDyn_WaveMath` + - the phase sines and cosines and depth exponentials of the wave kinematics, in vectorised + blocks * - `CableDyn_Bathymetry` - the seabed elevation field * - `CableDyn_SeabedContact` diff --git a/doc/installation.rst b/doc/installation.rst index bad8fb6c..c264d5a9 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -34,7 +34,8 @@ What is on the release page * - ``openfast.exe`` - OpenFAST v5.0.0 (maintained by NLR, the National Laboratory of the Rockies, formerly NREL) with CableDyn built in as ``CompMooring = 5``; stock MoorDyn - (``CompMooring = 3``) is still available in the same binary (:doc:`openfast`) + (``CompMooring = 3``) is still available in the same binary (:doc:`openfast`). It names + itself ``OpenFAST-v5.0.0-CableDyn-0.3.0`` (``openfast.exe -v`` and the start of every run). * - ``cabledyn-0.3.0-py3-none-any.whl`` - the pure-Python package: deck editing, case generation, driver automation, result readers, fatigue and spectral post-processing (:doc:`python`) diff --git a/integration/openfast/README.md b/integration/openfast/README.md index 17373be4..74cb9fb4 100644 --- a/integration/openfast/README.md +++ b/integration/openfast/README.md @@ -16,7 +16,7 @@ this repository. | --- | --- | | `patches/*.patch` | Patch series, one file per patch; `0006` and `0016`–`0020` add new CableDyn-owned files, the others modify upstream files | | `prepare_openfast_source.ps1` | Checks the upstream revision and a clean worktree, then applies the series | -| `integrate_openfast_vs_solution.ps1` | Adds CableDyn to the Intel Fortran Visual Studio solution of the Windows release | +| `integrate_openfast_vs_solution.ps1` | Adds CableDyn to the Intel Fortran Visual Studio solution of the Windows release and sets its version string | | `vs-build/CableDyn.vfproj.in` | Visual Studio project template used by that script | | `openfast_build_gate.ps1` | Builds a configured OpenFAST tree and runs a coupled `CompMooring = 5` smoke case | @@ -48,6 +48,26 @@ For the static Windows release, pass a clean, unpatched checkout to [Installation](../../doc/installation.rst)). Its Visual Studio project compiles the CableDyn adapter with `/heap-arrays:1024`, as the static CMake build compiles the CableDyn core, so arrays whose size is known only at run time are placed on the heap rather than on the `openfast.exe` stack. +Every configuration also makes local variables automatic (`/Qauto`, as the CMake build of the +core does with every compiler): without OpenMP, ifx keeps fixed-size local arrays and `CHARACTER` +locals in static storage, which every thread shares, and the turbines of a FAST.Farm run, like +separate C API handles, may step on several threads at once. Every configuration, and the +adapter target of the CMake route, compiles with the value-safe floating-point model +(`/fp:precise`, `-fp-model precise` off Windows), as every Intel build of the core does: the +ifx default, `/fp:fast`, may reassociate sums and flush subnormals to zero. + +## Version string + +OpenFAST names its version with `git describe --dirty`, which would read `v5.0.0-dirty` on +the patched tree. A CableDyn-enabled executable names itself +`OpenFAST--CableDyn-` instead, here +`OpenFAST-v5.0.0-CableDyn-0.3.0` (printed by `openfast.exe -v` and at the start of every run). +The OpenFAST part is `git describe --tags --abbrev=8` of the checked-out commit, the +unpatched base; the CableDyn part is the project version in the CableDyn `CMakeLists.txt`. +Patch `0021` sets it in the CMake build, and `integrate_openfast_vs_solution.ps1` in the +Visual Studio solution, whose `vs-build/CreateGitVersion.bat` it replaces. Both stop unless +the base is described by a release tag (`vX.Y.Z` or `vX.Y.Z-N-g`), so the checkout +needs its tags: a `git clone` has them, a single-commit shallow fetch does not. ## License of modified files diff --git a/integration/openfast/integrate_openfast_vs_solution.ps1 b/integration/openfast/integrate_openfast_vs_solution.ps1 index af8c8acc..a440abf8 100644 --- a/integration/openfast/integrate_openfast_vs_solution.ps1 +++ b/integration/openfast/integrate_openfast_vs_solution.ps1 @@ -41,6 +41,29 @@ $LinkLibraries = @($LinkLibraries | ForEach-Object { (Resolve-Path -LiteralPath $_).Path }) +# Version stamp. The pre-build step of the VersionInfo project, vs-build\CreateGitVersion.bat, +# writes vs-build\gitVersionInfo.h from `git describe --dirty`, so a patched tree would call +# itself '-dirty'. Name the build after its OpenFAST base and the CableDyn version instead, +# '-CableDyn-'. `git describe` without --dirty describes the +# checked-out commit, the unpatched base, whether or not the patch series is applied; the +# CableDyn version is the project version of the CableDyn CMakeLists.txt. The pre-build script +# is replaced as a whole and the header written from the same string (at the end of this +# script), so a rerun leaves both unchanged. +$describeOut = & git -C $OpenFASTRoot describe --tags --abbrev=8 +if ($LASTEXITCODE -ne 0 -or $null -eq $describeOut) { + throw "git describe found no tag for the OpenFAST checkout $OpenFASTRoot (fetch its tags)" +} +$baseDescribe = "$describeOut".Trim() +if ($baseDescribe -notmatch '^v\d+\.\d+\.\d+(-\d+-g[0-9a-f]{8,})?$') { + throw "the OpenFAST base describes as '$baseDescribe', not as a release tag vX.Y.Z or vX.Y.Z-N-gHASH" +} +$cableDynCMake = Get-Content -LiteralPath (Join-Path $CableDynRoot 'CMakeLists.txt') -Raw +if ($cableDynCMake -notmatch 'project\(CableDynCore VERSION (\d+\.\d+\.\d+)') { + throw 'CableDyn project version not found in CMakeLists.txt' +} +$versionStamp = "$baseDescribe-CableDyn-$($Matches[1])" +$versionDefine = "#define GIT_VERSION_INFO '$versionStamp'" + function Escape-Xml([string]$Value) { return [Security.SecurityElement]::Escape($Value) } @@ -175,4 +198,21 @@ $settings.Encoding = New-Object Text.UTF8Encoding($false) $writer = [Xml.XmlWriter]::Create($openfastProject, $settings) try { $vf.Save($writer) } finally { $writer.Dispose() } -Write-Host 'PASS: CableDyn added to OpenFAST Visual Studio Release solution' +# The pre-build step runs in vs-build\modules; the VersionInfo project includes the header +# through GIT_INCLUDE_FILE='..\gitVersionInfo.h'. +$versionScript = @( + '@ECHO off' + 'REM Written by CableDyn integration/openfast/integrate_openfast_vs_solution.ps1: the OpenFAST' + 'REM base and the CableDyn version this executable is built from.' + ">..\gitVersionInfo.h ECHO $versionDefine" + 'EXIT /B 0' +) -join "`r`n" +[IO.File]::WriteAllText((Join-Path $OpenFASTRoot 'vs-build\CreateGitVersion.bat'), "$versionScript`r`n", + [Text.Encoding]::ASCII) +$versionHeader = Join-Path $OpenFASTRoot 'vs-build\gitVersionInfo.h' +if (-not (Test-Path -LiteralPath $versionHeader) -or + (Get-Content -LiteralPath $versionHeader -Raw) -ne "$versionDefine`r`n") { + [IO.File]::WriteAllText($versionHeader, "$versionDefine`r`n", [Text.Encoding]::ASCII) +} + +Write-Host "PASS: CableDyn added to OpenFAST Visual Studio Release solution (version $versionStamp)" diff --git a/integration/openfast/openfast_build_gate.ps1 b/integration/openfast/openfast_build_gate.ps1 index a11d7a99..c04946ba 100644 --- a/integration/openfast/openfast_build_gate.ps1 +++ b/integration/openfast/openfast_build_gate.ps1 @@ -15,7 +15,8 @@ # to openfast.exe with no errors; # 2. IDENTITY -- a coupled smoke run actually initializes the CableDyn module (the # DispNVD identity banner appears in the OpenFAST log output; a build that -# silently fell back to another mooring module fails here); +# silently fell back to another mooring module fails here), and the +# executable names itself OpenFAST--CableDyn-; # 3. RUN -- the smoke case completes (exit 0) and its .out carries finite data to the # final row (no NaN/Infinity). # @@ -192,6 +193,14 @@ Step ("run smoke (TMax = {0} s)" -f $TMax) { if ($logText -notmatch 'Running CableDyn \(') { $script:failures += 'IDENTITY: the CableDyn module banner never appeared -- CompMooring=5 did not initialize' } + # the executable names its OpenFAST base and the CableDyn version (patch 0021), never a + # '-dirty' describe of the patched tree + $cdCMake = Get-Content -LiteralPath (Join-Path $PSScriptRoot '..\..\CMakeLists.txt') -Raw + $cdVersion = [regex]::Match($cdCMake, 'project\(CableDynCore VERSION (\d+\.\d+\.\d+)').Groups[1].Value + $idPattern = '(?m)^\s*OpenFAST-v\d+\.\d+\.\d+(-\d+-g[0-9a-f]+)?-CableDyn-' + [regex]::Escape($cdVersion) + '\s*$' + if ($logText -notmatch $idPattern -or $logText -match 'OpenFAST-\S*dirty') { + $script:failures += "IDENTITY: the OpenFAST banner does not read OpenFAST--CableDyn-$cdVersion" + } } if (-not (Test-Path $outFile)) { diff --git a/integration/openfast/patches/0006-cabledyn-cmake.patch b/integration/openfast/patches/0006-cabledyn-cmake.patch index affd82eb..27e0b64f 100644 --- a/integration/openfast/patches/0006-cabledyn-cmake.patch +++ b/integration/openfast/patches/0006-cabledyn-cmake.patch @@ -1,9 +1,9 @@ diff --git a/modules/cabledyn/CMakeLists.txt b/modules/cabledyn/CMakeLists.txt new file mode 100644 -index 000000000..40f9728a6 +index 000000000..be1a9133b --- /dev/null +++ b/modules/cabledyn/CMakeLists.txt -@@ -0,0 +1,185 @@ +@@ -0,0 +1,194 @@ +# +# Copyright (C) 2026 Jae Hoon Seo, SMI Lab, Inha University +# @@ -148,6 +148,15 @@ index 000000000..40f9728a6 + ${CABLEDYN_ROOT}/src/openfast/CableDyn_Types.f90 +) +target_link_libraries(cabledynlib cabledyn_core seastlib nwtclibs) ++if (CMAKE_Fortran_COMPILER_ID STREQUAL "IntelLLVM") ++ # The value-safe floating-point model for the adapter, as the core's own build sets for ++ # every IFX build (see CableDyn's CMakeLists.txt): IFX defaults to /fp:fast. ++ if (WIN32) ++ target_compile_options(cabledynlib PRIVATE /fp:precise) ++ else() ++ target_compile_options(cabledynlib PRIVATE "SHELL:-fp-model precise") ++ endif() ++endif() +if (TARGET cabledyn_core_ep) + # the imported core cannot carry dependencies itself; the consumer orders the build + add_dependencies(cabledynlib cabledyn_core_ep) diff --git a/integration/openfast/patches/0021-version-cmake.patch b/integration/openfast/patches/0021-version-cmake.patch new file mode 100644 index 00000000..9c4afd82 --- /dev/null +++ b/integration/openfast/patches/0021-version-cmake.patch @@ -0,0 +1,42 @@ +diff --git a/modules/version/CMakeLists.txt b/modules/version/CMakeLists.txt +index 1c714c368..8a91bea44 100644 +--- a/modules/version/CMakeLists.txt ++++ b/modules/version/CMakeLists.txt +@@ -22,10 +22,34 @@ if( DEFINED GIT_DESCRIBE ) + "Version information has been set as a CMake flag. This should only used when the git-version cannot be set automatically." + ) + else() +- include(GetGitRevisionDescription) +- git_describe(GIT_DESCRIBE) ++ # CableDyn integration: the CableDyn patch series leaves the worktree modified, so the ++ # upstream `git describe --dirty` would call every CableDyn build '-dirty'. Describe ++ # the checked-out commit instead (no --dirty), which is the unpatched OpenFAST base. ++ find_package(Git QUIET) ++ if( GIT_FOUND ) ++ execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --abbrev=8 ++ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" ++ RESULT_VARIABLE _cabledyn_describe_result ++ OUTPUT_VARIABLE GIT_DESCRIBE ++ ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) ++ endif() ++ if( NOT GIT_FOUND OR NOT _cabledyn_describe_result EQUAL 0 OR ++ NOT GIT_DESCRIBE MATCHES "^v[0-9]+\\.[0-9]+\\.[0-9]+(-[0-9]+-g[0-9a-f]+)?$" ) ++ message( FATAL_ERROR ++ "The OpenFAST checkout is not described by a release tag (git describe --tags: '${GIT_DESCRIBE}'). " ++ "Fetch its tags (git fetch --tags), or set -DGIT_DESCRIBE=." ++ ) ++ endif() + endif() +-add_definitions(-DGIT_VERSION_INFO="${GIT_DESCRIBE}") ++# CableDyn integration: the executables name the CableDyn version they carry, the project ++# version of CABLEDYN_ROOT/CMakeLists.txt: '-CableDyn-'. ++file(STRINGS "${CABLEDYN_ROOT}/CMakeLists.txt" _cabledyn_project REGEX "^project\\(CableDynCore VERSION ") ++string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" _cabledyn_version "${_cabledyn_project}") ++if( NOT _cabledyn_version ) ++ message( FATAL_ERROR "No CableDyn project version in ${CABLEDYN_ROOT}/CMakeLists.txt" ) ++endif() ++set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CABLEDYN_ROOT}/CMakeLists.txt") ++add_definitions(-DGIT_VERSION_INFO="${GIT_DESCRIBE}-CableDyn-${_cabledyn_version}") + + add_library(versioninfolib STATIC + src/VersionInfo.f90 diff --git a/integration/openfast/vs-build/CableDyn.vfproj.in b/integration/openfast/vs-build/CableDyn.vfproj.in index 2b3b99c0..7f959e26 100644 --- a/integration/openfast/vs-build/CableDyn.vfproj.in +++ b/integration/openfast/vs-build/CableDyn.vfproj.in @@ -5,35 +5,35 @@ - + - + - + - + - + - + - + - + diff --git a/release/build_static_windows.ps1 b/release/build_static_windows.ps1 index 8a72f4a6..a9fa02d1 100644 --- a/release/build_static_windows.ps1 +++ b/release/build_static_windows.ps1 @@ -190,6 +190,18 @@ Invoke-StaticToolchain "cmake --build `"$cdBuild`" --target cabledyn_core cabled -OpenFASTRoot $OpenFASTRoot -CableDynRoot $CableDynRoot -CableDynBuildDir $cdBuild ` -LinkLibraries $lapackLibraries +# The identity openfast.exe must report, derived here independently of the integration script: +# the describe of the pinned OpenFAST commit (never '-dirty') and the CableDyn project version. +$ofDescribe = "$(& git -C $OpenFASTRoot describe --tags --abbrev=8)".Trim() +if ($LASTEXITCODE -ne 0 -or $ofDescribe -notmatch '^v\d+\.\d+\.\d+') { + throw "the OpenFAST checkout $OpenFASTRoot is not described by a release tag ('$ofDescribe')" +} +if ((Get-Content -LiteralPath (Join-Path $CableDynRoot 'CMakeLists.txt') -Raw) -notmatch + 'project\(CableDynCore VERSION (\d+\.\d+\.\d+)') { + throw 'CableDyn project version not found in CMakeLists.txt' +} +$expectedOpenFASTVersion = "$ofDescribe-CableDyn-$($Matches[1])" + $devenv = Join-Path $vsRoot 'Common7\IDE\devenv.com' if (-not (Test-Path -LiteralPath $devenv)) { throw "Visual Studio command-line builder not found: $devenv" } $openFastBuild = "`"$devenv`" `"$OpenFASTRoot\vs-build\OpenFAST.sln`" /Build `"Release|x64`" " + @@ -228,6 +240,14 @@ try { if ($versionRun.Text -notmatch 'Build\s+x86-64-v3') { throw "CableDyn_driver.exe is not the x86-64-v3 build with the processor check`n$($versionRun.Text)" } + # Identity gate: openfast.exe names its OpenFAST base and the CableDyn version. + $ofVersionRun = Invoke-NativeCapture $openfast @('-v') + Write-Host $ofVersionRun.Text + if ($ofVersionRun.ExitCode -ne 0 -or $ofVersionRun.Text -match 'dirty' -or + $ofVersionRun.Text -notmatch "(?m)^\s*OpenFAST-$([regex]::Escape($expectedOpenFASTVersion))\s*$") { + throw "openfast.exe -v does not report OpenFAST-$expectedOpenFASTVersion`n$($ofVersionRun.Text)" + } + Write-Host "PASS openfast.exe identity: OpenFAST-$expectedOpenFASTVersion" # On a processor without x86-64-v3 both executables stop at start with the message # (simulated here): exit 3 before any CableDyn or OpenFAST code prints. $env:CABLEDYN_CPU_GUARD_SIMULATE = 'SIMULATED-FEATURE' diff --git a/release/check_release_metadata.py b/release/check_release_metadata.py index 21c3bbbd..e3e44e8d 100644 --- a/release/check_release_metadata.py +++ b/release/check_release_metadata.py @@ -171,6 +171,11 @@ def main() -> int: "OpenFAST example banner": f"Running CableDyn (v{version}," in read( "examples/openfast/README.md" ), + # The name openfast.exe reports (release/build_static_windows.ps1 checks the binary). + "OpenFAST executable identity": all( + re.search(rf"OpenFAST-v\d+\.\d+\.\d+-CableDyn-{re.escape(version)}\b", read(name)) + for name in ("doc/installation.rst", "RELEASE.md", "integration/openfast/README.md") + ), "Python licence metadata": 'license-files = ["LICENSE"]' in read( "python/pyproject.toml" ), diff --git a/src/CableDyn_CAPI.f90 b/src/CableDyn_CAPI.f90 index 13e7451b..87e46e43 100644 --- a/src/CableDyn_CAPI.f90 +++ b/src/CableDyn_CAPI.f90 @@ -11,7 +11,7 @@ MODULE CableDyn_CAPI !! the point-system object graph used by OpenFAST-facing integrations. USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_BOOL, C_CHAR, C_DOUBLE, C_INT, C_NULL_CHAR, C_NULL_PTR, C_PTR, & C_ASSOCIATED, C_LOC, C_F_POINTER - USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64, COMPILER_VERSION USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE USE CableDyn_DeckDriver, ONLY: CD_Init_Deck_System, CD_DECKDRV_OK, CD_DECKDRV_BADINPUT, CD_DECKDRV_SOLVEFAIL, & CD_Deck_Query_dtM, CD_DECK_NAMELEN, CD_Eval_Aggregate_Channel, & @@ -1366,13 +1366,17 @@ SUBROUTINE CableDyn_Close(handle, err_stat) BIND(C, NAME='CableDyn_Close') !! it is never dereferenced or deallocated. Only a validated live handle is !! de-registered, finalized, deallocated, and nulled. !! - !! Closing a live handle also releases the OpenMP thread pool of the calling - !! thread (outside a parallel region only; the next parallel region starts a new - !! one). A pool left to the runtime is torn down when its host thread exits, and - !! its threads then end detached: a process that exits while one of them is - !! still ending can hang in the OpenMP runtime's exit handler (MinGW-w64 libgomp - !! with winpthreads). Joining the pool here means a host thread that closes its - !! handles before it ends leaves no such thread behind. + !! With GNU OpenMP (libgomp), closing a live handle also releases the OpenMP thread + !! pool of the calling thread (outside a parallel region only; the next parallel + !! region starts a new one). A pool left to the runtime is torn down when its host + !! thread exits, and its threads then end detached: a process that exits while one + !! of them is still ending can hang in the OpenMP runtime's exit handler (MinGW-w64 + !! libgomp with winpthreads). Joining the pool here means a host thread that closes + !! its handles before it ends leaves no such thread behind. The Intel and LLVM + !! runtime (libiomp5/libomp) pauses the whole process instead: one handle's Close + !! then paused the OpenMP of every other handle and of the host, and the first + !! parallel region of another thread deadlocked resuming it. Those runtimes are not + !! paused here. !$ USE OMP_LIB, ONLY: omp_pause_resource_all, omp_pause_soft TYPE(C_PTR), INTENT(INOUT) :: handle INTEGER(C_INT), INTENT(OUT) :: err_stat @@ -1380,6 +1384,8 @@ SUBROUTINE CableDyn_Close(handle, err_stat) BIND(C, NAME='CableDyn_Close') INTEGER :: es CHARACTER(CD_C_MSG_LEN) :: em !$ INTEGER :: omp_stat + ! libgomp only (see above): COMPILER_VERSION names the compiler that built this unit + LOGICAL, PARAMETER :: OMP_POOL_JOIN_ON_CLOSE = INDEX(COMPILER_VERSION(), 'GCC') > 0 err_stat = CD_C_OK IF (.NOT. C_ASSOCIATED(handle)) RETURN @@ -1401,7 +1407,7 @@ SUBROUTINE CableDyn_Close(handle, err_stat) BIND(C, NAME='CableDyn_Close') DEALLOCATE (h) handle = C_NULL_PTR ! Nonzero inside an active parallel region, where the pool is left alone. -!$ omp_stat = omp_pause_resource_all(omp_pause_soft) +!$ IF (OMP_POOL_JOIN_ON_CLOSE) omp_stat = omp_pause_resource_all(omp_pause_soft) END SUBROUTINE CableDyn_Close FUNCTION CableDyn_IsInitialized(handle) RESULT(is_initialized) BIND(C, NAME='CableDyn_IsInitialized') diff --git a/src/CableDyn_CosseratAssemble.f90 b/src/CableDyn_CosseratAssemble.f90 index 3c25f44b..3d4ff454 100644 --- a/src/CableDyn_CosseratAssemble.f90 +++ b/src/CableDyn_CosseratAssemble.f90 @@ -30,26 +30,8 @@ MODULE CableDyn_CosseratAssemble PUBLIC :: CD_Assemble_Cosserat_Internal_Force_Workspace PUBLIC :: CD_Cosserat_Free_Bandwidth, CD_Cosserat_Free_Bandwidth_Workspace PUBLIC :: CD_CosseratAssemblyWorkspace, CD_Clear_CosseratAssembly_Workspace - PUBLIC :: CD_COSASM_N_TANGENT, CD_COSASM_N_FORCE, CD_COSASM_T_TANGENT, CD_COSASM_T_FORCE PUBLIC :: CD_Reset_Cosserat_Asm_Counts - !! Diagnostic assembly counters for performance measurement: how many - !! global tangent vs internal-force assemblies have run since the last reset. - !! Incremented once per assembly call (in the serial part, not the OpenMP element - !! loop), they let a benchmark / solver attribute wall time to Newton tangent - !! builds vs residual (line-search) evaluations. Not part of any numerical result; - !! ignore in production. - !! - !! CONTRACT: these are PROCESS-GLOBAL, single-run, single-threaded instrumentation - !! -- not per-model and not synchronized. They are only meaningful for one model - !! stepped on one thread (a benchmark resets then reads them); - !! concurrent multi-model or multi-threaded stepping would interleave the counts. - !! They are diagnostics only, so a corrupted count never affects a physics result. - INTEGER, SAVE :: CD_COSASM_N_TANGENT = 0 - INTEGER, SAVE :: CD_COSASM_N_FORCE = 0 - REAL(wp), SAVE :: CD_COSASM_T_TANGENT = 0.0_wp - REAL(wp), SAVE :: CD_COSASM_T_FORCE = 0.0_wp - TYPE :: CD_CosseratAssemblyWorkspace !! Reusable scratch for finite-EI global assembly kernels. INTEGER, ALLOCATABLE :: global_to_free(:) @@ -57,6 +39,13 @@ MODULE CableDyn_CosseratAssemble REAL(wp), ALLOCATABLE :: Ke(:, :, :) INTEGER, ALLOCATABLE :: elem_es(:) CHARACTER(120), ALLOCATABLE :: elem_em(:) + ! Diagnostics of the assemblies run on this workspace since CD_Reset_Cosserat_Asm_Counts: + ! the global tangent and internal-force assemblies and their wall time, so a benchmark can + ! attribute time to Newton tangents and residual-only evaluations. They belong to the + ! workspace (one per model), so concurrent models never mix their counts, and no result + ! depends on them. + INTEGER :: n_tangent = 0, n_force = 0 + REAL(wp) :: t_tangent = 0.0_wp, t_force = 0.0_wp END TYPE CD_CosseratAssemblyWorkspace CONTAINS @@ -71,12 +60,13 @@ SUBROUTINE CD_Clear_CosseratAssembly_Workspace(work) IF (ALLOCATED(work%elem_em)) DEALLOCATE (work%elem_em) END SUBROUTINE CD_Clear_CosseratAssembly_Workspace - SUBROUTINE CD_Reset_Cosserat_Asm_Counts() - !! Zero the diagnostic assembly counters (call before a timed solve). - CD_COSASM_N_TANGENT = 0 - CD_COSASM_N_FORCE = 0 - CD_COSASM_T_TANGENT = 0.0_wp - CD_COSASM_T_FORCE = 0.0_wp + SUBROUTINE CD_Reset_Cosserat_Asm_Counts(work) + !! Zero the diagnostic assembly counters of a workspace (call before a timed solve). + TYPE(CD_CosseratAssemblyWorkspace), INTENT(INOUT) :: work + work%n_tangent = 0 + work%n_force = 0 + work%t_tangent = 0.0_wp + work%t_force = 0.0_wp END SUBROUTINE CD_Reset_Cosserat_Asm_Counts SUBROUTINE CD_Assemble_Cosserat_Tangent_Force(nodes_ref, elem_conn, ea, gas, ei, gj, q, & @@ -90,15 +80,12 @@ SUBROUTINE CD_Assemble_Cosserat_Tangent_Force(nodes_ref, elem_conn, ea, gas, ei, INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: n_nodes, n_elem, e, a, b, ndof, gmap(12), i, j, es - INTEGER(INT64) :: c0, rate REAL(wp) :: Lam0(3, 3), L0, qe(12), Kte(12, 12), finte(12) REAL(wp), ALLOCATABLE :: fe(:, :), Ke(:, :, :) INTEGER, ALLOCATABLE :: elem_es(:) CHARACTER(120), ALLOCATABLE :: elem_em(:) CHARACTER(120) :: em - CD_COSASM_N_TANGENT = CD_COSASM_N_TANGENT + 1 - CALL SYSTEM_CLOCK(c0, rate) Kt = 0.0_wp fint = 0.0_wp CALL check_inputs(nodes_ref, elem_conn, ea, gas, ei, gj, q, n_nodes, n_elem, ndof, ErrStat, ErrMsg) @@ -158,7 +145,6 @@ SUBROUTINE CD_Assemble_Cosserat_Tangent_Force(nodes_ref, elem_conn, ea, gas, ei, END DO END DO END DO - CALL add_elapsed(CD_COSASM_T_TANGENT, c0, rate) END SUBROUTINE CD_Assemble_Cosserat_Tangent_Force SUBROUTINE CD_Cosserat_Free_Bandwidth(elem_conn, n_nodes, free, kl, ku, ErrStat, ErrMsg) @@ -273,7 +259,7 @@ SUBROUTINE CD_Assemble_Cosserat_Tangent_Force_Banded_Free_Workspace(nodes_ref, e REAL(wp) :: Lam0(3, 3), L0, qe(12), Kte(12, 12), finte(12) CHARACTER(120) :: em - CD_COSASM_N_TANGENT = CD_COSASM_N_TANGENT + 1 + work%n_tangent = work%n_tangent + 1 CALL SYSTEM_CLOCK(c0, rate) Kb = 0.0_wp fint = 0.0_wp @@ -382,7 +368,7 @@ SUBROUTINE CD_Assemble_Cosserat_Tangent_Force_Banded_Free_Workspace(nodes_ref, e END DO END DO END DO - CALL add_elapsed(CD_COSASM_T_TANGENT, c0, rate) + CALL add_elapsed(work%t_tangent, c0, rate) END SUBROUTINE CD_Assemble_Cosserat_Tangent_Force_Banded_Free_Workspace SUBROUTINE CD_Assemble_Cosserat_Internal_Force(nodes_ref, elem_conn, ea, gas, ei, gj, q, & @@ -417,7 +403,7 @@ SUBROUTINE CD_Assemble_Cosserat_Internal_Force_Workspace(nodes_ref, elem_conn, e REAL(wp) :: Lam0(3, 3), L0, qe(12), finte(12) CHARACTER(120) :: em - CD_COSASM_N_FORCE = CD_COSASM_N_FORCE + 1 + work%n_force = work%n_force + 1 CALL SYSTEM_CLOCK(c0, rate) fint = 0.0_wp CALL check_inputs(nodes_ref, elem_conn, ea, gas, ei, gj, q, n_nodes, n_elem, ndof, ErrStat, ErrMsg) @@ -472,7 +458,7 @@ SUBROUTINE CD_Assemble_Cosserat_Internal_Force_Workspace(nodes_ref, elem_conn, e fint(gmap(i)) = fint(gmap(i)) + work%fe(i, e) END DO END DO - CALL add_elapsed(CD_COSASM_T_FORCE, c0, rate) + CALL add_elapsed(work%t_force, c0, rate) END SUBROUTINE CD_Assemble_Cosserat_Internal_Force_Workspace SUBROUTINE ensure_assembly_workspace(work, ndof, n_elem, need_tangent, ErrStat, ErrMsg) diff --git a/src/CableDyn_CosseratDynamic.f90 b/src/CableDyn_CosseratDynamic.f90 index 2c315ad0..9fcf6a63 100644 --- a/src/CableDyn_CosseratDynamic.f90 +++ b/src/CableDyn_CosseratDynamic.f90 @@ -40,24 +40,11 @@ MODULE CableDyn_CosseratDynamic PUBLIC :: CD_Cosserat_Mechanical_Energy PUBLIC :: CD_Spatial_Inertia, CD_Spatial_Inertia_Dir, CD_Gyro_Torque, CD_Gyro_Torque_DOmega PUBLIC :: CD_Reset_Cosserat_Dyn_Counts - PUBLIC :: CD_COSDYN_HIST_MAX, CD_COSDYN_N_STALE_ACCEPT, CD_COSDYN_N_STALE_REJECT - PUBLIC :: CD_COSDYN_N_DEFERRED_REFRESH - PUBLIC :: CD_COSDYN_STALE_ACCEPT_HIST, CD_COSDYN_STALE_REJECT_HIST - PUBLIC :: CD_COSDYN_DEFERRED_REFRESH_HIST - - ! Modified-Newton stale-tangent diagnostics. CONTRACT: like the assembly counters in - ! CableDyn_CosseratAssemble, these are PROCESS-GLOBAL, single-run, single-threaded - ! instrumentation -- not per-model and not synchronized. They are only meaningful for - ! one model stepped on one thread (reset via CD_Reset_Cosserat_Dyn_Counts, then read); - ! concurrent multi-model or multi-threaded stepping would interleave them. Diagnostics - ! only -- a corrupted count never affects a physics result. + PUBLIC :: CD_COSDYN_HIST_MAX + + ! Histogram bins of the modified-Newton diagnostics of CD_CosseratGenAlphaWorkspace: the + ! Newton iteration of a stale-tangent outcome, the last bin collecting the later ones. INTEGER, PARAMETER :: CD_COSDYN_HIST_MAX = 16 - INTEGER, SAVE :: CD_COSDYN_N_STALE_ACCEPT = 0 - INTEGER, SAVE :: CD_COSDYN_N_STALE_REJECT = 0 - INTEGER, SAVE :: CD_COSDYN_N_DEFERRED_REFRESH = 0 - INTEGER, SAVE :: CD_COSDYN_STALE_ACCEPT_HIST(0:CD_COSDYN_HIST_MAX) = 0 - INTEGER, SAVE :: CD_COSDYN_STALE_REJECT_HIST(0:CD_COSDYN_HIST_MAX) = 0 - INTEGER, SAVE :: CD_COSDYN_DEFERRED_REFRESH_HIST(0:CD_COSDYN_HIST_MAX) = 0 ABSTRACT INTERFACE SUBROUTINE CD_Cosserat_Dynamic_Force_Proc(q, v, force, ErrStat, ErrMsg) @@ -123,6 +110,15 @@ END SUBROUTINE CD_Cosserat_Dynamic_Load_Banded_Proc REAL(wp), ALLOCATABLE :: load_jv_band(:, :) REAL(wp), ALLOCATABLE :: eff_band(:, :) TYPE(CD_CosseratAssemblyWorkspace) :: assembly + ! Modified-Newton stale-tangent diagnostics of the steps run on this workspace (one per + ! model, so concurrent models never mix their counts) since CD_Reset_Cosserat_Dyn_Counts: + ! stale-tangent steps accepted and rejected, refreshes before the first solve (no path + ! takes one), and histograms over the Newton iteration of each outcome. No result + ! depends on them. + INTEGER :: n_stale_accept = 0, n_stale_reject = 0, n_deferred_refresh = 0 + INTEGER :: stale_accept_hist(0:CD_COSDYN_HIST_MAX) = 0 + INTEGER :: stale_reject_hist(0:CD_COSDYN_HIST_MAX) = 0 + INTEGER :: deferred_refresh_hist(0:CD_COSDYN_HIST_MAX) = 0 END TYPE CD_CosseratGenAlphaWorkspace CONTAINS @@ -167,15 +163,16 @@ SUBROUTINE CD_Clear_CosseratGenAlpha_Workspace(work) work%ldab_capacity = 0 END SUBROUTINE CD_Clear_CosseratGenAlpha_Workspace - SUBROUTINE CD_Reset_Cosserat_Dyn_Counts() - !! Zero modified-Newton diagnostic counters. These are benchmark-only + SUBROUTINE CD_Reset_Cosserat_Dyn_Counts(work) + !! Zero the modified-Newton diagnostic counters of a workspace. These are benchmark-only !! diagnostics and do not affect the numerical path. - CD_COSDYN_N_STALE_ACCEPT = 0 - CD_COSDYN_N_STALE_REJECT = 0 - CD_COSDYN_N_DEFERRED_REFRESH = 0 - CD_COSDYN_STALE_ACCEPT_HIST = 0 - CD_COSDYN_STALE_REJECT_HIST = 0 - CD_COSDYN_DEFERRED_REFRESH_HIST = 0 + TYPE(CD_CosseratGenAlphaWorkspace), INTENT(INOUT) :: work + work%n_stale_accept = 0 + work%n_stale_reject = 0 + work%n_deferred_refresh = 0 + work%stale_accept_hist = 0 + work%stale_reject_hist = 0 + work%deferred_refresh_hist = 0 END SUBROUTINE CD_Reset_Cosserat_Dyn_Counts SUBROUTINE CD_Cosserat_Mechanical_Energy(nodes_ref, elem_conn, ea, gas, ei, gj, rho_a, & @@ -1216,7 +1213,7 @@ SUBROUTINE CD_Cosserat_Gen_Alpha_Step(nodes_ref, elem_conn, ea, gas, ei, gj, rho CALL CD_Solve_Factored_Banded(eff_band, kl, ku, ipiv, dq, es, em) IF (es /= 0 .OR. .NOT. CD_All_Finite(dq)) THEN IF (cfg%modified_newton .AND. .NOT. tangent_fresh) THEN - CALL record_stale_reject(n_iter) + CALL record_stale_reject(work, n_iter) have_eff = .FALSE. CYCLE END IF @@ -1246,13 +1243,13 @@ SUBROUTINE CD_Cosserat_Gen_Alpha_Step(nodes_ref, elem_conn, ea, gas, ei, gj, rho n_iter = n_iter + 1 IF (.NOT. accepted) THEN IF (cfg%modified_newton .AND. .NOT. tangent_fresh) THEN - CALL record_stale_reject(n_iter - 1) + CALL record_stale_reject(work, n_iter - 1) have_eff = .FALSE. CYCLE END IF stalled = .TRUE.; EXIT END IF - IF (cfg%modified_newton .AND. .NOT. tangent_fresh) CALL record_stale_accept(n_iter - 1) + IF (cfg%modified_newton .AND. .NOT. tangent_fresh) CALL record_stale_accept(work, n_iter - 1) qk = q_trial IF (cfg%modified_newton) THEN R = R_trial @@ -1689,20 +1686,22 @@ SUBROUTINE ensure_real_matrix(x, nrow, ncol, ErrStat, ErrMsg) END IF END SUBROUTINE ensure_real_matrix - SUBROUTINE record_stale_accept(iter) + SUBROUTINE record_stale_accept(work, iter) + TYPE(CD_CosseratGenAlphaWorkspace), INTENT(INOUT) :: work INTEGER, INTENT(IN) :: iter INTEGER :: idx idx = MIN(MAX(iter, 0), CD_COSDYN_HIST_MAX) - CD_COSDYN_N_STALE_ACCEPT = CD_COSDYN_N_STALE_ACCEPT + 1 - CD_COSDYN_STALE_ACCEPT_HIST(idx) = CD_COSDYN_STALE_ACCEPT_HIST(idx) + 1 + work%n_stale_accept = work%n_stale_accept + 1 + work%stale_accept_hist(idx) = work%stale_accept_hist(idx) + 1 END SUBROUTINE record_stale_accept - SUBROUTINE record_stale_reject(iter) + SUBROUTINE record_stale_reject(work, iter) + TYPE(CD_CosseratGenAlphaWorkspace), INTENT(INOUT) :: work INTEGER, INTENT(IN) :: iter INTEGER :: idx idx = MIN(MAX(iter, 0), CD_COSDYN_HIST_MAX) - CD_COSDYN_N_STALE_REJECT = CD_COSDYN_N_STALE_REJECT + 1 - CD_COSDYN_STALE_REJECT_HIST(idx) = CD_COSDYN_STALE_REJECT_HIST(idx) + 1 + work%n_stale_reject = work%n_stale_reject + 1 + work%stale_reject_hist(idx) = work%stale_reject_hist(idx) + 1 END SUBROUTINE record_stale_reject PURE REAL(wp) FUNCTION infnorm(x) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index d914afda..b1731ce3 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -157,7 +157,7 @@ MODULE CableDyn_DeckDriver USE CableDyn_RigidKinematics, ONLY: CD_Rigid_Advance_Newmark, CD_RIGID_OK, CD_RIGID_NEWMARK_GAMMA, & CD_RIGID_NEWMARK_BETA USE CableDyn_SO3, ONLY: CD_Log_SO3, CD_Exp_SO3 - USE CableDyn_PathIO, ONLY: CD_Open_Input, CD_Native_Path, CD_Strip_BOM + USE CableDyn_PathIO, ONLY: CD_Open_Input, CD_Open_Write, CD_Native_Path, CD_Strip_BOM USE CableDyn_Profile, ONLY: CD_Profile_Enter, CD_Profile_Step, CD_PROF_INPUT, CD_PROF_INIT, CD_PROF_FLUID, & CD_PROF_SOLVE, CD_PROF_CHECK, CD_PROF_OUTPUT, CD_PROF_PROGRESS, CD_PROF_FINAL USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE @@ -18550,7 +18550,7 @@ SUBROUTINE write_out(out_root, channels, lines, points, ne, q_all, q_off, ten_al END DO END IF path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN END IF @@ -18609,7 +18609,7 @@ SUBROUTINE write_static_config_out(out_root, lines, ne, q_all, q_off, ten_all, t ErrMsg = '' tab = char_tab() path = TRIM(out_root)//'.static.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open static-configuration output file: '//TRIM(path)); RETURN END IF @@ -18697,7 +18697,7 @@ SUBROUTINE write_static_line_position_file(out_root, line_id, nelem, q_line, Err ErrStat = CD_DECKDRV_OK ErrMsg = '' path = TRIM(out_root)//'.Line'//TRIM(int_to_str(line_id))//'.p.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open line position output file: '//TRIM(path)); RETURN END IF @@ -18724,7 +18724,7 @@ SUBROUTINE write_static_line_tension_file(out_root, line_id, nelem, tension_line ErrStat = CD_DECKDRV_OK ErrMsg = '' path = TRIM(out_root)//'.Line'//TRIM(int_to_str(line_id))//'.t.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open line tension output file: '//TRIM(path)); RETURN END IF @@ -18774,7 +18774,7 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni ne = nnode - 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) + CALL CD_Open_Write(pos_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open dynamic line position output file: '//TRIM(path)); RETURN @@ -18790,7 +18790,7 @@ SUBROUTINE open_dynamic_line_outputs(out_root, lines, models, pos_units, ten_uni 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) + CALL CD_Open_Write(ten_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open dynamic line tension output file: '//TRIM(path)); RETURN @@ -18851,7 +18851,7 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, ne = nnode - 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) + CALL CD_Open_Write(pos_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open system dynamic line position output file: '//TRIM(path)); RETURN @@ -18867,7 +18867,7 @@ SUBROUTINE open_dynamic_system_line_outputs(out_root, lines, system, pos_units, 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) + CALL CD_Open_Write(ten_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open system dynamic line tension output file: '//TRIM(path)); RETURN @@ -19137,7 +19137,7 @@ SUBROUTINE open_line_lift_file(out_root, line_id, nnode, unit, ErrStat, ErrMsg, ErrStat = CD_DECKDRV_OK ErrMsg = '' path = TRIM(out_root)//'.Line'//TRIM(int_to_str(line_id))//'.V.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN unit = 0 CALL fail(ErrStat, ErrMsg, 'cannot open dynamic line VIV lift output file: '//TRIM(path)); RETURN @@ -19178,7 +19178,7 @@ SUBROUTINE open_dynamic_rod_outputs(out_root, rods, pos_units, ErrStat, ErrMsg) IF (.NOT. rod_outputs_requested(rods(i)%outputs)) CYCLE IF (rod_output_has_flag(rods(i)%outputs, 'p')) THEN path = TRIM(out_root)//'.Rod'//TRIM(int_to_str(rods(i)%id))//'.p.out' - OPEN (NEWUNIT=pos_units(i), FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(pos_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_rod_outputs(pos_units) CALL fail(ErrStat, ErrMsg, 'cannot open dynamic rod position output file: '//TRIM(path)); RETURN @@ -19307,7 +19307,7 @@ SUBROUTINE write_dynamic_out(out_root, channels, lines, points, opts, models, co lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) RETURN path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN @@ -19463,7 +19463,7 @@ SUBROUTINE write_system_dynamic_out(out_root, channels, lines, points, opts, sys lift_units=lift_units) IF (ErrStat /= CD_DECKDRV_OK) RETURN path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN @@ -19852,7 +19852,7 @@ SUBROUTINE write_rigid6_dynamic_out(out_root, channels, bodies, lines, points, o bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN END IF @@ -20028,7 +20028,7 @@ SUBROUTINE write_rod_dynamic_out(out_root, channels, rod_types, rods, lines, poi bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)) RETURN @@ -21173,7 +21173,7 @@ SUBROUTINE write_objects_dynamic_out(out_root, channels, bodies, rod_types, rods rst(k)%a, rst(k)%alpha, ErrStat, ErrMsg, rod=rst(k), bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO - OPEN (NEWUNIT=unit, FILE=TRIM(out_root)//'.out', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, TRIM(out_root)//'.out', ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(out_root)//'.out'); RETURN END IF @@ -21891,7 +21891,7 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod ! ---- output ---- nstep = NINT(opts%tmax/opts%dtM) path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); GOTO 900 END IF @@ -30977,7 +30977,7 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca CALL range_setup_planned(ranges, lines, channels, opts, ErrStat, ErrMsg, cables=cables, bathymetry=bathymetry) IF (ErrStat /= CD_DECKDRV_OK) RETURN path = TRIM(out_root)//'.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN END IF @@ -31312,7 +31312,7 @@ SUBROUTINE write_hermite_static_profile(out_root, lines, cables, ErrStat, ErrMsg CALL fail(ErrStat, ErrMsg, 'Hermite static-profile cable count does not match line count'); RETURN END IF path = TRIM(out_root)//'.static.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open Hermite static profile: '//TRIM(path)); RETURN END IF @@ -31406,7 +31406,7 @@ SUBROUTINE write_hermite_static_element_profile(out_root, lines, cables, ErrStat CALL fail(ErrStat, ErrMsg, 'Hermite static-element cable count does not match line count'); RETURN END IF path = TRIM(out_root)//'.elements.out' - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open Hermite static-element profile: '//TRIM(path)); RETURN END IF @@ -31715,7 +31715,7 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, IF (.NOT. line_outputs_requested(lines(i)%outputs)) CYCLE 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) + CALL CD_Open_Write(pos_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open Hermite line position output: '//TRIM(path)); RETURN @@ -31740,7 +31740,7 @@ SUBROUTINE open_dynamic_hermite_line_outputs(out_root, lines, cables, pos_units, 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) + CALL CD_Open_Write(ten_units(i), path, ios) IF (ios /= 0) THEN CALL close_dynamic_line_outputs(pos_units, ten_units, lift_units) CALL fail(ErrStat, ErrMsg, 'cannot open Hermite line tension output: '//TRIM(path)); RETURN @@ -32174,7 +32174,7 @@ SUBROUTINE write_modes_file(out_root, lines, res, ErrStat, ErrMsg) ErrStat = CD_DECKDRV_OK ErrMsg = '' tb = char_tab() - OPEN (NEWUNIT=unit, FILE=TRIM(out_root)//'.modes.out', STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, TRIM(out_root)//'.modes.out', ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open modal output file: '//TRIM(out_root)//'.modes.out'); RETURN END IF @@ -39840,7 +39840,9 @@ END FUNCTION real_defect_text INTEGER FUNCTION real_token_defect(tok) RESULT(k) !! real_value_defect of a token that reads whole as a real number; REAL_OK for a token - !! that is not a number at all (a name), which its own reader then judges. + !! that is not a number at all (a name), which its own reader then judges. A token spelled + !! as a number that the READ refuses is a magnitude beyond the range of the kind: gfortran + !! reads one beyond HUGE as Inf, the Intel run-time stops the READ with a conversion error. CHARACTER(*), INTENT(IN) :: tok REAL(wp) :: x INTEGER :: ios @@ -39848,7 +39850,10 @@ INTEGER FUNCTION real_token_defect(tok) RESULT(k) IF (LEN_TRIM(tok) == 0) RETURN IF (.NOT. numeric_token_shape(tok)) RETURN READ (tok, *, IOSTAT=ios) x - IF (ios /= 0) RETURN + IF (ios /= 0) THEN + k = REAL_NONFINITE + RETURN + END IF k = real_value_defect(x) END FUNCTION real_token_defect diff --git a/src/CableDyn_Driver.f90 b/src/CableDyn_Driver.f90 index a68c39a8..e7f6eb9d 100644 --- a/src/CableDyn_Driver.f90 +++ b/src/CableDyn_Driver.f90 @@ -34,6 +34,7 @@ MODULE CableDyn_Driver !! CableDyn_Static path; tensions are recovered with !! CD_Compute_Cable_Tension on the converged state. USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_All_Finite, CD_Is_Finite + USE CableDyn_PathIO, ONLY: CD_Open_Read, CD_Open_Write USE CableDyn_Loads, ONLY: CD_Submerged_Weight, CD_Assemble_Distributed_Load USE CableDyn_Assemble, ONLY: CD_Compute_Cable_Tension USE CableDyn_Static, ONLY: CableSolverConfig, CD_Static_Cable_Solve, & @@ -333,7 +334,7 @@ SUBROUTINE parse_input(path, gravity, rho_water, tension_only, has_seabed, z_flo ! error return and silences -Wmaybe-uninitialized. ALLOCATE (nodes(3, 0), conn(2, 0), l0(0), ea(0), mass_pl(0), diam(0), fixed_dofs(0)) - OPEN (NEWUNIT=unit, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL CD_Open_Read(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open input file: '//TRIM(path)) RETURN @@ -515,7 +516,7 @@ SUBROUTINE parse_line_deck(path, gravity, rho_water, tension_only, has_seabed, z ALLOCATE (line_types(0), sections(0)) ALLOCATE (factors(4)); factors = [0.25_wp, 0.5_wp, 0.75_wp, CD_ONE] - OPEN (NEWUNIT=unit, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL CD_Open_Read(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open input file: '//TRIM(path)); RETURN END IF @@ -688,7 +689,7 @@ SUBROUTINE CD_Deck_Is_Line_Object(input_path, is_line, ErrStat, ErrMsg) is_line = .FALSE. ErrStat = 0 ErrMsg = '' - OPEN (NEWUNIT=unit, FILE=input_path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL CD_Open_Read(unit, input_path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open input file: '//TRIM(input_path)); RETURN END IF @@ -747,7 +748,7 @@ SUBROUTINE write_csv(path, q, conn, tension, converged, stalled, at_floor, n_ite ErrMsg = '' n_nodes = SIZE(q)/3 n_elem = SIZE(conn, 2) - OPEN (NEWUNIT=unit, FILE=path, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, path, ios) IF (ios /= 0) THEN CALL fail(ErrStat, ErrMsg, 'cannot open output file: '//TRIM(path)); RETURN END IF diff --git a/src/CableDyn_Dynamic.f90 b/src/CableDyn_Dynamic.f90 index 20c2ca98..7fe89be4 100644 --- a/src/CableDyn_Dynamic.f90 +++ b/src/CableDyn_Dynamic.f90 @@ -53,6 +53,7 @@ MODULE CableDyn_Dynamic PUBLIC :: CD_Cable_Dynamic_Force_Proc PUBLIC :: CD_Cable_Added_Mass_Proc PUBLIC :: CD_Cable_Added_Mass_Banded_Proc + PUBLIC :: CD_Cable_Step_Loads TYPE :: GenAlphaConfig !! Generalized-alpha policy. The Chung-Hulbert parameters (alpha_m, alpha_f, beta, gamma) are derived from @@ -303,6 +304,60 @@ SUBROUTINE CD_Cable_Added_Mass_Banded_Proc(q, accel, free, kl, ku, M_add_a, M_ad END SUBROUTINE CD_Cable_Added_Mass_Banded_Proc END INTERFACE + !> The banded dynamic loads of a step as an object (the `loads` argument of + !> CD_Cable_Gen_Alpha_Step and CD_Cable_Initial_Acceleration), for a caller whose loads are + !> computed from its own data, such as a line model: an extension carries that data as + !> components. Such a caller does not pass internal procedures as the callbacks: an internal + !> procedure passed as an argument is a closure over its host's frame, which Intel ifx + !> (2025.3, Windows) calls through a trampoline kept in memory every thread shares, so two + !> threads stepping distinct models through closures corrupt each other's calls. + !> has_force: the object gives the force and the banded load (load_force_proc and + !> load_band_proc); has_added_mass: the banded added mass (added_mass_band_proc). + TYPE, ABSTRACT :: CD_Cable_Step_Loads + LOGICAL :: has_force = .FALSE. + LOGICAL :: has_added_mass = .FALSE. + CONTAINS + PROCEDURE(step_loads_force), DEFERRED :: force + PROCEDURE(step_loads_load_banded), DEFERRED :: load_banded + PROCEDURE(step_loads_added_mass_banded), DEFERRED :: added_mass_banded + END TYPE CD_Cable_Step_Loads + + ABSTRACT INTERFACE + SUBROUTINE step_loads_force(self, q, v, force, ErrStat, ErrMsg) + !! CD_Cable_Dynamic_Force_Proc of the object. + IMPORT :: wp, CD_Cable_Step_Loads + CLASS(CD_Cable_Step_Loads), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: q(:), v(:) + REAL(wp), INTENT(OUT) :: force(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + END SUBROUTINE step_loads_force + + SUBROUTINE step_loads_load_banded(self, q, v, free, kl, ku, force, jac_q_band, jac_v_band, ErrStat, ErrMsg) + !! CD_Cable_Dynamic_Load_Banded_Proc of the object. + IMPORT :: wp, CD_Cable_Step_Loads + CLASS(CD_Cable_Step_Loads), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: q(:), v(:) + INTEGER, INTENT(IN) :: free(:), kl, ku + REAL(wp), INTENT(OUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + END SUBROUTINE step_loads_load_banded + + SUBROUTINE step_loads_added_mass_banded(self, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & + ErrStat, ErrMsg, need_tangent) + !! CD_Cable_Added_Mass_Banded_Proc of the object. + IMPORT :: wp, CD_Cable_Step_Loads + CLASS(CD_Cable_Step_Loads), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: q(:), accel(:) + INTEGER, INTENT(IN) :: free(:), kl, ku + REAL(wp), INTENT(OUT) :: M_add_a(:), M_add_band(:, :), dMa_a_dq_band(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: need_tangent + END SUBROUTINE step_loads_added_mass_banded + END INTERFACE + CONTAINS SUBROUTINE CD_Clear_GenAlpha_Workspace(work) @@ -409,11 +464,13 @@ END SUBROUTINE CD_Clear_GenAlpha_Workspace SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension_only, & f_ext, fixed_dofs, a0, ErrStat, ErrMsg, & load_proc, added_mass_proc, load_force_proc, structural_mass, workspace, & - added_mass_band_proc) + added_mass_band_proc, loads) !! Consistent-mass initial acceleration: solve M a = f_ext - f_int(q) on the free !! DOFs (fixed DOFs get a = 0), without load callbacks. Gives the caller a !! consistent a_n to seed CD_Cable_Gen_Alpha_Step; ``v`` is accepted for !! signature parity with the loaded case but does not enter the structural solve. + !! loads (CD_Cable_Step_Loads) stands for load_force_proc (has_force) and + !! added_mass_band_proc (has_added_mass), which are then not passed. REAL(wp), INTENT(IN) :: q(:), v(:) INTEGER, INTENT(IN) :: elem_conn(:, :) REAL(wp), INTENT(IN) :: l0(:), ea(:), rho_a(:) @@ -429,6 +486,7 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension PROCEDURE(CD_Cable_Added_Mass_Banded_Proc), OPTIONAL :: added_mass_band_proc REAL(wp), INTENT(IN), OPTIONAL :: structural_mass(:, :) TYPE(CD_CableGenAlphaWorkspace), INTENT(INOUT), TARGET, OPTIONAL :: workspace + CLASS(CD_Cable_Step_Loads), INTENT(INOUT), OPTIONAL :: loads INTEGER :: n_dof, n_elem, n_free, kl, ku, ldab INTEGER, POINTER :: free(:) @@ -439,10 +497,25 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension INTEGER :: es CHARACTER(1024) :: em LOGICAL :: use_element_mass_band + ! the force and the banded added mass: from a callback, or from loads (loads_force, loads_mass) + LOGICAL :: has_force, has_mass_band, loads_force, loads_mass a0 = CD_ZERO ErrStat = CD_DYN_OK ErrMsg = '' + loads_force = .FALSE. + loads_mass = .FALSE. + IF (PRESENT(loads)) THEN + loads_force = loads%has_force + loads_mass = loads%has_added_mass + END IF + IF ((loads_force .AND. (PRESENT(load_proc) .OR. PRESENT(load_force_proc))) .OR. & + (loads_mass .AND. (PRESENT(added_mass_proc) .OR. PRESENT(added_mass_band_proc)))) THEN + CALL fail(ErrStat, ErrMsg, 'pass a load either as a callback or in loads, not both') + RETURN + END IF + has_force = PRESENT(load_force_proc) .OR. loads_force + has_mass_band = PRESENT(added_mass_band_proc) .OR. loads_mass n_dof = SIZE(q) CALL check_state_shapes(n_dof, [SIZE(v), SIZE(a0), SIZE(f_ext)], ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN @@ -463,14 +536,14 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension work%dof_marker, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN free => work%free(1:n_free) - IF (PRESENT(added_mass_proc) .AND. PRESENT(added_mass_band_proc)) THEN + IF (PRESENT(added_mass_proc) .AND. has_mass_band) THEN CALL fail(ErrStat, ErrMsg, 'pass either added_mass_proc or added_mass_band_proc, not both') RETURN END IF ! Banded added mass requires the banded path; a dense load_proc is incompatible ! (mirrors CD_Cable_Gen_Alpha_Step). Keep validation consistent across both entry ! points so a banded callback is never mixed with a dense one. - IF (PRESENT(added_mass_band_proc) .AND. PRESENT(load_proc)) THEN + IF (has_mass_band .AND. PRESENT(load_proc)) THEN CALL fail(ErrStat, ErrMsg, 'added_mass_band_proc cannot be mixed with a dense load_proc; use one path') RETURN END IF @@ -506,7 +579,7 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension M_add => work%M_add_eval(1:n_dof, 1:n_dof) dMa_a_dq => work%dMa_a_dq_eval(1:n_dof, 1:n_dof) END IF - IF (PRESENT(added_mass_band_proc)) THEN + IF (has_mass_band) THEN M_add_a => work%M_add_a_eval(1:n_dof) M_add_band => work%M_add_band(1:ldab, 1:n_free) dMa_band => work%dMa_a_dq_band(1:ldab, 1:n_free) @@ -538,8 +611,12 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension CALL fail(ErrStat, ErrMsg, 'internal-force assembly failed: '//TRIM(em)) RETURN END IF - IF (PRESENT(load_force_proc)) THEN - CALL load_force_proc(q, v, load, es, em) + IF (has_force) THEN + IF (loads_force) THEN + CALL loads%force(q, v, load, es, em) + ELSE + CALL load_force_proc(q, v, load, es, em) + END IF IF (es /= 0) THEN CALL fail_callback(ErrStat, ErrMsg, 'dynamic force load failed: '//TRIM(em), es) RETURN @@ -574,10 +651,15 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension RETURN END IF M = M + M_add - ELSE IF (PRESENT(added_mass_band_proc)) THEN + ELSE IF (has_mass_band) THEN zero_accel = CD_ZERO - CALL added_mass_band_proc(q, zero_accel, free, kl, ku, M_add_a, M_add_band, dMa_band, es, em, & - need_tangent=.TRUE.) + IF (loads_mass) THEN + CALL loads%added_mass_banded(q, zero_accel, free, kl, ku, M_add_a, M_add_band, dMa_band, es, em, & + need_tangent=.TRUE.) + ELSE + CALL added_mass_band_proc(q, zero_accel, free, kl, ku, M_add_a, M_add_band, dMa_band, es, em, & + need_tangent=.TRUE.) + END IF IF (es /= 0) THEN CALL fail_callback(ErrStat, ErrMsg, 'banded added mass failed: '//TRIM(em), es) RETURN @@ -612,7 +694,7 @@ SUBROUTINE CD_Cable_Initial_Acceleration(q, v, elem_conn, l0, ea, rho_a, tension CALL fail(ErrStat, ErrMsg, 'mass band packing failed: '//TRIM(em)) RETURN END IF - IF (PRESENT(added_mass_band_proc)) M_band = M_band + M_add_band + IF (has_mass_band) M_band = M_band + M_add_band CALL CD_Solve_Banded(M_band, kl, ku, rhs, es, em) END IF IF (es /= 0 .OR. .NOT. CD_All_Finite(rhs)) THEN @@ -630,9 +712,11 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on load_band_proc, prescribed_q, prescribed_v, prescribed_a, structural_mass, & workspace, added_mass_band_proc, start_load, start_tension, & probe_q, probe_R, probe_K, start_stiffness, axial_damping, & - axial_l0_rate, start_l0, mass_l0, start_l0_rate) + axial_l0_rate, start_l0, mass_l0, start_l0_rate, loads) !! One generalized-alpha step: the constant load f_ext plus the optional load, !! banded-load, force-only and added-mass callbacks (hydrodynamics, damping, contact). + !! loads (CD_Cable_Step_Loads) stands for load_force_proc and load_band_proc (has_force) + !! and for added_mass_band_proc (has_added_mass), which are then not passed. !! On a singular effective tangent returns CD_DYN_SINGULAR; on a line-search !! stall returns converged=.FALSE., stalled=.TRUE. !! @@ -723,6 +807,7 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on !! with, for T_d,n; axial_l0_rate stays the rate at t_{n+1}, for T_d,n+1. Absent: !! axial_l0_rate. REAL(wp), INTENT(IN), OPTIONAL :: start_l0(:), mass_l0(:), start_l0_rate(:) + CLASS(CD_Cable_Step_Loads), INTENT(INOUT), OPTIONAL :: loads INTEGER :: n_dof, n_elem, n_free, bt, kl, ku, ldab INTEGER, POINTER :: free(:), fixed(:), ipiv(:) @@ -757,6 +842,8 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on REAL(wp) :: diag_scale_cached, op_norm, op_norm_cached LOGICAL :: accepted, has_load_proc, has_load_band_proc, has_added_mass_proc, has_added_mass_band_proc LOGICAL :: has_load_force_proc + ! the force and banded load (loads_force) and the banded added mass (loads_mass) from loads + LOGICAL :: loads_force, loads_mass LOGICAL :: has_prescribed, direct_banded, have_eff, tangent_fresh, use_element_mass_band ! clock at the start of a profiled kernel (CABLEDYN_PROFILE; zero when not profiling) INTEGER(int64) :: prof_k0 @@ -778,17 +865,28 @@ SUBROUTINE CD_Cable_Gen_Alpha_Step(q, v, a, elem_conn, l0, ea, rho_a, tension_on ! call that fails early cannot leave an older step's data to a later armed re-solve. IF (PRESENT(workspace)) workspace%start_valid = workspace%start_valid .AND. workspace%guess_armed n_dof = SIZE(q) + loads_force = .FALSE. + loads_mass = .FALSE. + IF (PRESENT(loads)) THEN + loads_force = loads%has_force + loads_mass = loads%has_added_mass + END IF + IF ((loads_force .AND. (PRESENT(load_proc) .OR. PRESENT(load_band_proc) .OR. PRESENT(load_force_proc))) .OR. & + (loads_mass .AND. (PRESENT(added_mass_proc) .OR. PRESENT(added_mass_band_proc)))) THEN + CALL fail(ErrStat, ErrMsg, 'pass a load either as a callback or in loads, not both') + RETURN + END IF has_load_proc = PRESENT(load_proc) - has_load_band_proc = PRESENT(load_band_proc) + has_load_band_proc = PRESENT(load_band_proc) .OR. loads_force has_added_mass_proc = PRESENT(added_mass_proc) - has_added_mass_band_proc = PRESENT(added_mass_band_proc) - has_load_force_proc = PRESENT(load_force_proc) + has_added_mass_band_proc = PRESENT(added_mass_band_proc) .OR. loads_mass + has_load_force_proc = PRESENT(load_force_proc) .OR. loads_force NULLIFY (load_proc_cb, added_mass_proc_cb, load_force_proc_cb, load_band_proc_cb, added_mass_band_proc_cb) IF (has_load_proc) load_proc_cb => load_proc - IF (has_load_band_proc) load_band_proc_cb => load_band_proc + IF (PRESENT(load_band_proc)) load_band_proc_cb => load_band_proc IF (has_added_mass_proc) added_mass_proc_cb => added_mass_proc - IF (has_added_mass_band_proc) added_mass_band_proc_cb => added_mass_band_proc - IF (has_load_force_proc) load_force_proc_cb => load_force_proc + IF (PRESENT(added_mass_band_proc)) added_mass_band_proc_cb => added_mass_band_proc + IF (PRESENT(load_force_proc)) load_force_proc_cb => load_force_proc IF (has_load_proc .AND. has_load_band_proc) THEN CALL fail(ErrStat, ErrMsg, 'pass either load_proc or load_band_proc, not both') RETURN @@ -1721,7 +1819,11 @@ SUBROUTINE start_forces(es_s, em_s) load_n(i) = start_load(i) END DO ELSE IF (has_load_force_proc) THEN - CALL load_force_proc_cb(q_n, v_n, load_n, es_s, em_s) + IF (loads_force) THEN + CALL loads%force(q_n, v_n, load_n, es_s, em_s) + ELSE + CALL load_force_proc_cb(q_n, v_n, load_n, es_s, em_s) + END IF IF (es_s /= 0) THEN em_s = 'step-start dynamic force load failed: '//TRIM(em_s) RETURN @@ -2002,7 +2104,11 @@ SUBROUTINE eval_dynamic_core(q_eval, Rout, es_e, em_e, effout, effbandout) END IF IF (has_load_band_proc) THEN ! the callback defines every INTENT(OUT) band entry itself - CALL load_band_proc_cb(qf, vf, free, kl, ku, load_eval, jq_band, jv_band, es_e, em_e) + IF (loads_force) THEN + CALL loads%load_banded(qf, vf, free, kl, ku, load_eval, jq_band, jv_band, es_e, em_e) + ELSE + CALL load_band_proc_cb(qf, vf, free, kl, ku, load_eval, jq_band, jv_band, es_e, em_e) + END IF IF (es_e /= 0) THEN em_e = 'dynamic banded load failed: '//TRIM(em_e) Rout = CD_ZERO @@ -2059,7 +2165,11 @@ SUBROUTINE eval_dynamic_core(q_eval, Rout, es_e, em_e, effout, effbandout) RETURN END IF ELSE IF (has_load_force_proc .AND. .NOT. tangent_requested) THEN - CALL load_force_proc_cb(qf, vf, load_eval, es_e, em_e) + IF (loads_force) THEN + CALL loads%force(qf, vf, load_eval, es_e, em_e) + ELSE + CALL load_force_proc_cb(qf, vf, load_eval, es_e, em_e) + END IF IF (es_e /= 0) THEN em_e = 'dynamic force load failed: '//TRIM(em_e) Rout = CD_ZERO @@ -2109,8 +2219,13 @@ SUBROUTINE eval_dynamic_core(q_eval, Rout, es_e, em_e, effout, effbandout) END IF M_eff_eval = M_eff_eval + M_add_eval ELSE IF (has_added_mass_band_proc) THEN - CALL added_mass_band_proc_cb(q_alpha, a_alpha, free, kl, ku, M_add_a_eval, M_add_band, & - dMa_a_dq_band, es_e, em_e, PRESENT(effbandout)) + IF (loads_mass) THEN + CALL loads%added_mass_banded(q_alpha, a_alpha, free, kl, ku, M_add_a_eval, M_add_band, & + dMa_a_dq_band, es_e, em_e, PRESENT(effbandout)) + ELSE + CALL added_mass_band_proc_cb(q_alpha, a_alpha, free, kl, ku, M_add_a_eval, M_add_band, & + dMa_a_dq_band, es_e, em_e, PRESENT(effbandout)) + END IF IF (es_e /= 0) THEN em_e = 'banded added mass failed: '//TRIM(em_e) Rout = CD_ZERO diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index ba175eee..10e0bf21 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -223,10 +223,11 @@ MODULE CableDyn_HermiteCableDynamic 'end_conn', 'wave_fk', 'held_fk', 'torsion'] REAL(wp), SAVE :: prof_t_asm(HC_ASM_NSEC) = 0.0_wp - ! Number of coupling intervals completed by internal generalised-alpha substeps after the nominal - ! interval was too large for the prescribed boundary motion or environmental load. This counter is - ! independent of prof_enabled so temporal-refinement studies can report the actual line advances. - INTEGER, SAVE :: n_substep_recoveries = 0 + ! Coupling intervals completed by internal generalised-alpha substeps (the nominal interval was + ! too large for the prescribed boundary motion or environmental load), summed over every model + ! while the profile is armed, for the profile reports of the driver and the OpenFAST module. + ! Each model counts its own in recovery_event_count (CD_HermiteCable_Dyn_Get_Recovery_Diagnostics). + INTEGER, SAVE :: prof_n_recover = 0 TYPE :: CD_HermiteCableDynType !! Persistent finite-EI Hermite dynamic model: geometry, gen-alpha constants, and state. @@ -623,7 +624,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Reset_Profile() !! the SYSTEM_CLOCK overhead in the step/residual hot path. prof_enabled = .TRUE. prof_n_step = 0; prof_n_resid = 0; prof_n_solve = 0; prof_n_am = 0; prof_n_alloc = 0 - prof_n_tan = 0; prof_n_factor = 0; prof_n_correct = 0 + prof_n_tan = 0; prof_n_factor = 0; prof_n_correct = 0; prof_n_recover = 0 prof_t_step = 0.0_wp; prof_t_resid = 0.0_wp; prof_t_eff = 0.0_wp prof_t_tan = 0.0_wp; prof_t_factor = 0.0_wp prof_t_solve = 0.0_wp; prof_t_am = 0.0_wp @@ -5486,8 +5487,10 @@ SUBROUTINE CD_HermiteCable_Dyn_Step_Recovering(model, dt, max_iter, tol, ErrStat END IF END DO IF (es == CD_HCDYN_OK) THEN - !$OMP ATOMIC UPDATE - n_substep_recoveries = n_substep_recoveries + 1 + IF (prof_enabled) THEN + !$OMP ATOMIC UPDATE + prof_n_recover = prof_n_recover + 1 + END IF model%recovery_event_count = model%recovery_event_count + 1 model%recovery_max_substeps_used = MAX(model%recovery_max_substeps_used, nsub) ErrStat = CD_HCDYN_OK; ErrMsg = '' @@ -5734,15 +5737,18 @@ LOGICAL FUNCTION temporal_increment_ok(model) RESULT(ok) END FUNCTION temporal_increment_ok PURE FUNCTION CD_HermiteCable_Dyn_Recovery_Count() RESULT(n) - !! Coupling intervals that completed only via internal substepping since the last - !! CD_HermiteCable_Dyn_Recovery_Reset (the finite-EI analogue of CD_System_Fallback_Count). + !! Coupling intervals of every model that completed only via internal substepping while the + !! step profile was armed (CD_HermiteCable_Dyn_Reset_Profile), since the last + !! CD_HermiteCable_Dyn_Recovery_Reset: a process-wide figure of the opt-in profile, like + !! the other profile counts (a profiled run steps its cables serially). One model's own + !! count is CD_HermiteCable_Dyn_Get_Recovery_Diagnostics. INTEGER :: n - n = n_substep_recoveries + n = prof_n_recover END FUNCTION CD_HermiteCable_Dyn_Recovery_Count SUBROUTINE CD_HermiteCable_Dyn_Recovery_Reset() - !! Zero the substep-recovery tripwire (start of a measured window). - n_substep_recoveries = 0 + !! Zero the profile's substep-recovery count (start of a measured window). + prof_n_recover = 0 END SUBROUTINE CD_HermiteCable_Dyn_Recovery_Reset SUBROUTINE CD_HermiteCable_Dyn_Energy(model, kinetic, strain, ErrStat, ErrMsg, connection) diff --git a/src/CableDyn_Hydro.f90 b/src/CableDyn_Hydro.f90 index 7cc03891..a8965123 100644 --- a/src/CableDyn_Hydro.f90 +++ b/src/CableDyn_Hydro.f90 @@ -14,6 +14,7 @@ MODULE CableDyn_Hydro !! * Dean & Dalrymple (1991), linear Airy wave theory. !! * Wheeler (1970), vertical stretching through the splash zone. USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_All_Finite, CD_Is_Finite + USE CableDyn_WaveMath, ONLY: CD_Wave_SinCos, CD_Wave_Exp USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 IMPLICIT NONE PRIVATE @@ -2257,11 +2258,11 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc !! remains full validation for public/direct calls. `amplitude_scale` multiplies every !! amplitude (a start-up ramp) without the caller forming a scaled copy of the table; the !! result equals passing amplitude_scale*amplitude. - !! Each component's phase cosine and sine and its depth-profile ratios are evaluated in - !! element-wise loops (vectorisable, one trigonometric pair per component) into fixed-size - !! local buffers, and the sums then run in component order. Components beyond the buffer - !! length are evaluated one at a time with the same expressions, so the result does not - !! depend on the buffer. exp_m2kd is the caller's table of EXP(-2 k_comp(i) depth) for this + !! Each component's phase sine and cosine (one argument reduction for both) and its depth + !! exponential come from the block kernels of CableDyn_WaveMath into fixed-size local + !! buffers, and the sums then run in component order. Components beyond the buffer length + !! are evaluated block by block with the same expressions, so the result does not depend on + !! the buffer. exp_m2kd is the caller's table of EXP(-2 k_comp(i) depth) for this !! depth (constant for a fixed table): it replaces the per-call exponential with the same !! value, so the result is bit-identical. !! tail_sums(:, i) holds the sums over components j >= i of a_j omega_j, a_j omega_j^2 and @@ -2285,13 +2286,14 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc REAL(wp), INTENT(IN), OPTIONAL :: exp_m2kd(:), tail_sums(:, :) INTEGER :: i, n, nb, n_small, i0, j, nk REAL(wp) :: amp - REAL(wp) :: cb, sb, x_along, theta, z_eval + REAL(wp) :: cb, sb, x_along, z_eval ! the elevation keeps the cosines of the first NBUF components; the velocity sums run in ! blocks of NBLK (NBUF a multiple of NBLK, so a block lies wholly inside or past the buffer) INTEGER, PARAMETER :: NBUF = 1024, NBLK = 32 REAL(wp), PARAMETER :: HALF_ULP = 0.5_wp*EPSILON(CD_ONE) REAL(wp) :: scl, e_neg, denom - REAL(wp) :: cth(NBUF), bc(NBLK), bs(NBLK), ch(NBLK), sh(NBLK), mag(3), rest(3) + REAL(wp) :: cth(NBUF), sth(NBUF), thb(NBUF), th(NBLK), bc(NBLK), bs(NBLK), ch(NBLK), sh(NBLK) + REAL(wp) :: mag(3), rest(3) LOGICAL :: trust_inputs, at_bed, use_tail, small(NBLK) eta = CD_ZERO @@ -2358,16 +2360,24 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc sb = SIN(direction_deg*DEG2RAD) x_along = x*cb + y*sb nb = MIN(n, NBUF) - ! the elevation sums every component (Wheeler stretching needs the total eta) + ! the elevation sums every component (Wheeler stretching needs the total eta); the phase + ! sines of the first NBUF components are kept for the velocity sums DO i = 1, nb - cth(i) = COS(k_comp(i)*x_along - omega_comp(i)*t + phase(i)) + thb(i) = k_comp(i)*x_along - omega_comp(i)*t + phase(i) END DO + CALL CD_Wave_SinCos(nb, thb, sth, cth) DO i = 1, nb eta = eta + (scl*amplitude(i))*cth(i) END DO - DO i = nb + 1, n - theta = k_comp(i)*x_along - omega_comp(i)*t + phase(i) - eta = eta + (scl*amplitude(i))*COS(theta) + DO i0 = nb + 1, n, NBLK + nk = MIN(n - i0 + 1, NBLK) + DO j = 1, nk + th(j) = k_comp(i0 + j - 1)*x_along - omega_comp(i0 + j - 1)*t + phase(i0 + j - 1) + END DO + CALL CD_Wave_SinCos(nk, th, bs, bc) + DO j = 1, nk + eta = eta + (scl*amplitude(i0 + j - 1))*bc(j) + END DO END DO IF (stretch) THEN @@ -2393,24 +2403,22 @@ SUBROUTINE CD_Component_Wave_Kinematics(x, y, z, t, depth, direction_deg, stretc nk = MIN(n - i0 + 1, NBLK) IF (i0 <= nb) THEN bc(1:nk) = cth(i0:i0 + nk - 1) + bs(1:nk) = sth(i0:i0 + nk - 1) ELSE DO j = 1, nk - bc(j) = COS(k_comp(i0 + j - 1)*x_along - omega_comp(i0 + j - 1)*t + phase(i0 + j - 1)) + th(j) = k_comp(i0 + j - 1)*x_along - omega_comp(i0 + j - 1)*t + phase(i0 + j - 1) END DO + CALL CD_Wave_SinCos(nk, th, bs, bc) END IF - ! the sine in its own loop: a compiler fuses COS and SIN of one argument into a sincos - ! call, which in the MinGW runtime costs several times a cos plus a sin DO j = 1, nk - bs(j) = SIN(k_comp(i0 + j - 1)*x_along - omega_comp(i0 + j - 1)*t + phase(i0 + j - 1)) + th(j) = k_comp(i0 + j - 1)*z_eval END DO + CALL CD_Wave_Exp(nk, th, ch) IF (PRESENT(exp_m2kd)) THEN - DO j = 1, nk - ch(j) = EXP(k_comp(i0 + j - 1)*z_eval) - sh(j) = exp_m2kd(i0 + j - 1) - END DO + sh(1:nk) = exp_m2kd(i0:i0 + nk - 1) ELSE + ! the intrinsic, as the caller's table exp_m2kd is built, so both give the same bits DO j = 1, nk - ch(j) = EXP(k_comp(i0 + j - 1)*z_eval) sh(j) = EXP(-2.0_wp*(k_comp(i0 + j - 1)*depth)) END DO END IF diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index d81f086c..39d4f3f7 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -59,7 +59,8 @@ MODULE CableDyn_Model USE CableDyn_VIV, ONLY: CD_VIV_Node_Lift, CD_VIV_Crossflow_Motion, CD_VIV_Phase_Rate, CD_VIV_Mean_Square, & CD_VIV_Wrap_Phase, CD_VIV_NM, CD_VIV_TWO_PI USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_CableGenAlphaWorkspace, CD_Clear_GenAlpha_Workspace, & - CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_DYN_OK, CD_DYN_ALLOCFAIL, & + CD_Cable_Initial_Acceleration, CD_Cable_Gen_Alpha_Step, CD_Cable_Step_Loads, & + CD_DYN_OK, CD_DYN_ALLOCFAIL, & CD_EI0_SUBSTEPS_AUTO, CD_EI0_SUBSTEPS_OFF USE CableDyn_Mesh, ONLY: CD_Partition_Free_Dofs, CD_Validate_Connectivity USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 @@ -454,6 +455,20 @@ MODULE CableDyn_Model LOGICAL :: sub_test_repeat = .FALSE., sub_test_more = .FALSE. END TYPE CD_ModelType + !> The load contributors and added mass of a model as the dynamic loads of its steps + !> (CD_Cable_Step_Loads): the integrator calls them on the model this object points to, with + !> the added mass on the lengths l0_mass when associated (the blended lengths of the inertia + !> after a length change under the force blend). The model passes this object, never + !> internal procedures, so that distinct models step concurrently (see CD_Cable_Step_Loads). + TYPE, EXTENDS(CD_Cable_Step_Loads) :: model_step_loads + TYPE(CD_ModelType), POINTER :: model => NULL() + REAL(wp), POINTER :: l0_mass(:) => NULL() + CONTAINS + PROCEDURE :: force => model_step_force + PROCEDURE :: load_banded => model_step_load_banded + PROCEDURE :: added_mass_banded => model_step_added_mass_banded + END TYPE model_step_loads + CONTAINS SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, & @@ -475,7 +490,7 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, !! initial acceleration is computed consistently from the current structure, !! load, and fixed DOFs; callers do not provide a0. Existing model storage is !! released before the new model is populated. - TYPE(CD_ModelType), INTENT(INOUT) :: model + TYPE(CD_ModelType), INTENT(INOUT), TARGET :: model REAL(wp), INTENT(IN) :: q0(:), v0(:) INTEGER, INTENT(IN) :: elem_conn(:, :) REAL(wp), INTENT(IN) :: l0(:), ea(:), rho_a(:) @@ -531,6 +546,7 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, INTEGER :: n_dof, n_elem, n_nodes, es, istat, e INTEGER, ALLOCATABLE :: free(:) TYPE(CD_ModelType) :: old_model + TYPE(model_step_loads) :: step_loads CHARACTER(1024) :: em LOGICAL :: use_seabed, use_seabed_damping, use_seabed_friction LOGICAL :: use_damping, use_drag, use_fk, use_buoyancy, use_added_mass, has_load @@ -1395,22 +1411,24 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, has_load = model%has_seabed .OR. model%has_seabed_damping .OR. model%has_seabed_friction .OR. & model%has_damping .OR. model%has_viscoelastic .OR. model%has_syrope .OR. model%has_morison_drag .OR. & model%has_froude_krylov .OR. model%has_buoyancy_recovery + step_loads%model => model + step_loads%has_force = has_load + step_loads%has_added_mass = model%has_added_mass IF (has_load .AND. model%has_added_mass) THEN CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & model%fixed_dofs, model%a, es, em, & - load_force_proc=model_force, workspace=model%dynamic_workspace, & - added_mass_band_proc=model_added_mass_band) + workspace=model%dynamic_workspace, loads=step_loads) ELSE IF (has_load) THEN CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & model%fixed_dofs, model%a, es, em, & - load_force_proc=model_force, workspace=model%dynamic_workspace) + workspace=model%dynamic_workspace, loads=step_loads) ELSE IF (model%has_added_mass) THEN CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & model%fixed_dofs, model%a, es, em, & - workspace=model%dynamic_workspace, added_mass_band_proc=model_added_mass_band) + workspace=model%dynamic_workspace, loads=step_loads) ELSE CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & @@ -1426,30 +1444,6 @@ SUBROUTINE CD_Init_Model(model, q0, v0, elem_conn, l0, ea, rho_a, tension_only, model%initialized = .TRUE. ! the line's initial tension, the floor of the tension scale of the sub-stepping (sub_count) model%sub_t_init = initial_tension(model) - - CONTAINS - - SUBROUTINE model_force(q, v, force, ErrStat, ErrMsg) - REAL(wp), INTENT(IN) :: q(:), v(:) - REAL(wp), INTENT(OUT) :: force(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - CALL model_contributor_force(model, q, v, force, ErrStat, ErrMsg) - ErrStat = as_dyn_callback_status(ErrStat) - END SUBROUTINE model_force - - SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, ErrStat, ErrMsg, & - need_tangent) - REAL(wp), INTENT(IN) :: q(:), accel(:) - INTEGER, INTENT(IN) :: free(:), kl, ku - REAL(wp), INTENT(OUT) :: M_add_a(:), M_add_band(:, :), dMa_a_dq_band(:, :) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - LOGICAL, INTENT(IN), OPTIONAL :: need_tangent - CALL model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & - ErrStat, ErrMsg, need_tangent=need_tangent) - ErrStat = as_dyn_callback_status(ErrStat) - END SUBROUTINE model_added_mass_band END SUBROUTINE CD_Init_Model SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gravity, rho_water, & @@ -2643,7 +2637,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM prescribed_q, prescribed_v, prescribed_a) !! One generalized-alpha step of the model over dt, as given (CD_Step_Model without its !! resolved sub-stepping). - TYPE(CD_ModelType), INTENT(INOUT) :: model + TYPE(CD_ModelType), INTENT(INOUT), TARGET :: model REAL(wp), INTENT(IN) :: dt LOGICAL, INTENT(OUT) :: converged, stalled INTEGER, INTENT(OUT) :: n_iter, ErrStat @@ -2654,9 +2648,11 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM CHARACTER(1024) :: em LOGICAL :: has_load, blend, force_lengths REAL(wp) :: af - REAL(wp), ALLOCATABLE :: l0_new(:), l0_dot_new(:), l0_start(:), l0_mass(:), f_ext_new(:), f_ext_c(:) + REAL(wp), ALLOCATABLE :: l0_new(:), l0_dot_new(:), l0_start(:), f_ext_new(:), f_ext_c(:) + REAL(wp), ALLOCATABLE, TARGET :: l0_mass(:) REAL(wp), ALLOCATABLE :: l0_dot_start(:) TYPE(model_lengths_aside) :: aside + TYPE(model_step_loads) :: step_loads converged = .FALSE. stalled = .FALSE. @@ -2773,13 +2769,16 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%l0_dot(e) = (CD_ONE - af)*l0_dot_new(e) + af*model%l0_dot_c(e) END DO END IF + step_loads%model => model + step_loads%has_force = has_load + step_loads%has_added_mass = model%has_added_mass + IF (ALLOCATED(l0_mass)) step_loads%l0_mass => l0_mass IF (PRESENT(prescribed_q) .AND. has_load .AND. model%has_added_mass) THEN CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, & - es, em, load_force_proc=model_force, load_band_proc=model_load_band, & - added_mass_band_proc=model_added_mass_band, prescribed_q=prescribed_q, & + es, em, loads=step_loads, prescribed_q=prescribed_q, & prescribed_v=prescribed_v, prescribed_a=prescribed_a, & workspace=model%dynamic_workspace, start_load=model%load_start_work, & start_tension=model%tension_start_work, & @@ -2791,7 +2790,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, & - es, em, load_force_proc=model_force, load_band_proc=model_load_band, & + es, em, loads=step_loads, & prescribed_q=prescribed_q, prescribed_v=prescribed_v, & prescribed_a=prescribed_a, workspace=model%dynamic_workspace, & start_load=model%load_start_work, start_tension=model%tension_start_work, & @@ -2803,7 +2802,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, & - es, em, added_mass_band_proc=model_added_mass_band, prescribed_q=prescribed_q, & + es, em, loads=step_loads, prescribed_q=prescribed_q, & prescribed_v=prescribed_v, prescribed_a=prescribed_a, & workspace=model%dynamic_workspace, & start_l0=l0_start, mass_l0=l0_mass) @@ -2820,8 +2819,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, es, em, & - load_force_proc=model_force, load_band_proc=model_load_band, & - added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace, & + loads=step_loads, workspace=model%dynamic_workspace, & start_load=model%load_start_work, start_tension=model%tension_start_work, & start_stiffness=model%stiffness_start_work, & axial_damping=model%ba_dyn, axial_l0_rate=model%l0_dot, & @@ -2831,7 +2829,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, es, em, & - load_force_proc=model_force, load_band_proc=model_load_band, & + loads=step_loads, & workspace=model%dynamic_workspace, start_load=model%load_start_work, & start_tension=model%tension_start_work, & start_stiffness=model%stiffness_start_work, & @@ -2842,7 +2840,7 @@ SUBROUTINE step_model_plain(model, dt, converged, stalled, n_iter, ErrStat, ErrM model%rho_a, model%tension_only, model%f_ext, model%fixed_dofs, & dt, model%cfg, model%q_step, model%v_step, model%a_step, converged, stalled, & n_iter, es, em, & - added_mass_band_proc=model_added_mass_band, workspace=model%dynamic_workspace, & + loads=step_loads, workspace=model%dynamic_workspace, & start_l0=l0_start, mass_l0=l0_mass) ELSE CALL CD_Cable_Gen_Alpha_Step(model%q, model%v, model%a, model%elem_conn, model%l0, model%ea_dyn, & @@ -3079,40 +3077,6 @@ SUBROUTINE step_start_load(es_s, em_s) END IF model%load_start_valid = .TRUE. END SUBROUTINE step_start_load - - SUBROUTINE model_force(q, v, force, ErrStat, ErrMsg) - REAL(wp), INTENT(IN) :: q(:), v(:) - REAL(wp), INTENT(OUT) :: force(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - CALL model_contributor_force(model, q, v, force, ErrStat, ErrMsg) - ErrStat = as_dyn_callback_status(ErrStat) - END SUBROUTINE model_force - - SUBROUTINE model_load_band(q, v, free, kl, ku, force, jac_q_band, jac_v_band, ErrStat, ErrMsg) - REAL(wp), INTENT(IN) :: q(:), v(:) - INTEGER, INTENT(IN) :: free(:), kl, ku - REAL(wp), INTENT(OUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - CALL model_contributor_load_banded(model, q, v, free, kl, ku, force, jac_q_band, jac_v_band, & - ErrStat, ErrMsg) - END SUBROUTINE model_load_band - - SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, ErrStat, ErrMsg, & - need_tangent) - !! The added mass at q_alpha; after a length change under the force blend with the - !! blended lengths of the inertia (l0_mass, unallocated and so absent otherwise). - REAL(wp), INTENT(IN) :: q(:), accel(:) - INTEGER, INTENT(IN) :: free(:), kl, ku - REAL(wp), INTENT(OUT) :: M_add_a(:), M_add_band(:, :), dMa_a_dq_band(:, :) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - LOGICAL, INTENT(IN), OPTIONAL :: need_tangent - CALL model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & - ErrStat, ErrMsg, need_tangent=need_tangent, l0_elem=l0_mass) - ErrStat = as_dyn_callback_status(ErrStat) - END SUBROUTINE model_added_mass_band END SUBROUTINE step_model_plain SUBROUTINE CD_Step_Model_Recovering(model, dt, converged, stalled, n_iter, ErrStat, ErrMsg, & @@ -6099,7 +6063,7 @@ END SUBROUTINE CD_Recompute_Model_Acceleration SUBROUTINE recompute_model_acceleration_now(model, ErrStat, ErrMsg) !! CD_Recompute_Model_Acceleration with the lengths and rates in place. - TYPE(CD_ModelType), INTENT(INOUT) :: model + TYPE(CD_ModelType), INTENT(INOUT), TARGET :: model INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg @@ -6111,6 +6075,7 @@ SUBROUTINE recompute_model_acceleration_now(model, ErrStat, ErrMsg) ! Entry acceleration: every failure below restores it whole, so a failed ! recompute leaves the committed state untouched. REAL(wp) :: a_entry(model%n_dof) + TYPE(model_step_loads) :: step_loads ErrStat = CD_MODEL_OK ErrMsg = '' @@ -6131,22 +6096,24 @@ SUBROUTINE recompute_model_acceleration_now(model, ErrStat, ErrMsg) END IF a_entry = model%a model%a_prescribed_work(1:nc) = model%a(model%fixed_dofs) + step_loads%model => model + step_loads%has_force = has_load + step_loads%has_added_mass = model%has_added_mass IF (has_load .AND. model%has_added_mass) THEN CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & model%fixed_dofs, model%a, es, em, & - load_force_proc=model_force, workspace=model%dynamic_workspace, & - added_mass_band_proc=model_added_mass_band) + workspace=model%dynamic_workspace, loads=step_loads) ELSE IF (has_load) THEN CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & model%fixed_dofs, model%a, es, em, & - load_force_proc=model_force, workspace=model%dynamic_workspace) + workspace=model%dynamic_workspace, loads=step_loads) ELSE IF (model%has_added_mass) THEN CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & model%fixed_dofs, model%a, es, em, & - workspace=model%dynamic_workspace, added_mass_band_proc=model_added_mass_band) + workspace=model%dynamic_workspace, loads=step_loads) ELSE CALL CD_Cable_Initial_Acceleration(model%q, model%v, model%elem_conn, model%l0, model%ea_dyn, & model%rho_a, model%tension_only, model%f_ext, & @@ -6348,28 +6315,6 @@ SUBROUTINE ensure_support_acceleration_workspace(model, n_free, ErrStat, ErrMsg) END IF END IF END SUBROUTINE ensure_support_acceleration_workspace - - SUBROUTINE model_force(q, v, force, ErrStat, ErrMsg) - REAL(wp), INTENT(IN) :: q(:), v(:) - REAL(wp), INTENT(OUT) :: force(:) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - CALL model_contributor_force(model, q, v, force, ErrStat, ErrMsg) - ErrStat = as_dyn_callback_status(ErrStat) - END SUBROUTINE model_force - - SUBROUTINE model_added_mass_band(q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, ErrStat, ErrMsg, & - need_tangent) - REAL(wp), INTENT(IN) :: q(:), accel(:) - INTEGER, INTENT(IN) :: free(:), kl, ku - REAL(wp), INTENT(OUT) :: M_add_a(:), M_add_band(:, :), dMa_a_dq_band(:, :) - INTEGER, INTENT(OUT) :: ErrStat - CHARACTER(*), INTENT(OUT) :: ErrMsg - LOGICAL, INTENT(IN), OPTIONAL :: need_tangent - CALL model_added_mass_banded(model, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & - ErrStat, ErrMsg, need_tangent=need_tangent) - ErrStat = as_dyn_callback_status(ErrStat) - END SUBROUTINE model_added_mass_band END SUBROUTINE recompute_model_acceleration_now SUBROUTINE CD_Audit_Model_Step(model, time, dt, new_spike) @@ -9365,6 +9310,46 @@ SUBROUTINE alloc_fail(ErrStat, ErrMsg, msg) ErrMsg = 'CableDyn_Model: '//msg END SUBROUTINE alloc_fail + SUBROUTINE model_step_force(self, q, v, force, ErrStat, ErrMsg) + !! The force of the model's load contributors at (q, v) (model_step_loads). + CLASS(model_step_loads), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: q(:), v(:) + REAL(wp), INTENT(OUT) :: force(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + CALL model_contributor_force(self%model, q, v, force, ErrStat, ErrMsg) + ErrStat = as_dyn_callback_status(ErrStat) + END SUBROUTINE model_step_force + + SUBROUTINE model_step_load_banded(self, q, v, free, kl, ku, force, jac_q_band, jac_v_band, ErrStat, ErrMsg) + !! The force and banded Jacobians of the model's load contributors at (q, v) + !! (model_step_loads). + CLASS(model_step_loads), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: q(:), v(:) + INTEGER, INTENT(IN) :: free(:), kl, ku + REAL(wp), INTENT(OUT) :: force(:), jac_q_band(:, :), jac_v_band(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + CALL model_contributor_load_banded(self%model, q, v, free, kl, ku, force, jac_q_band, jac_v_band, & + ErrStat, ErrMsg) + END SUBROUTINE model_step_load_banded + + SUBROUTINE model_step_added_mass_banded(self, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & + ErrStat, ErrMsg, need_tangent) + !! The model's banded added mass at q (model_step_loads), on the lengths l0_mass when + !! associated (a disassociated pointer is an absent l0_elem). + CLASS(model_step_loads), INTENT(INOUT) :: self + REAL(wp), INTENT(IN) :: q(:), accel(:) + INTEGER, INTENT(IN) :: free(:), kl, ku + REAL(wp), INTENT(OUT) :: M_add_a(:), M_add_band(:, :), dMa_a_dq_band(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + LOGICAL, INTENT(IN), OPTIONAL :: need_tangent + CALL model_added_mass_banded(self%model, q, accel, free, kl, ku, M_add_a, M_add_band, dMa_a_dq_band, & + ErrStat, ErrMsg, need_tangent=need_tangent, l0_elem=self%l0_mass) + ErrStat = as_dyn_callback_status(ErrStat) + END SUBROUTINE model_step_added_mass_banded + PURE INTEGER FUNCTION as_dyn_callback_status(model_es) RESULT(dyn_es) !! Translate a model load-callback status into the integrator's namespace so an allocation !! failure inside model_contributor_load/_force is forwarded as CD_DYN_ALLOCFAIL (and preserved diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 62d59dcb..8d5007e7 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -42,6 +42,7 @@ MODULE CableDyn_OpenFAST_Aggregate !! dt that differs from it (a mismatched size would silently desync the cables, whose !! generalised-alpha step carries the Init dt, from the mooring columns). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_All_Finite + USE CableDyn_PathIO, ONLY: CD_Open_Write USE CableDyn_FatalReport, ONLY: CD_Fatal_Thread_Init USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 USE CableDyn_Linalg, ONLY: CD_Blas_Runtime_Check, CD_LINALG_OK @@ -92,6 +93,7 @@ MODULE CableDyn_OpenFAST_Aggregate CD_Deck_Current_End USE CableDyn_RangeOutput, ONLY: CD_RangeSet, CD_Range_End USE CableDyn_System, ONLY: CD_Get_System_Substep_Counts, CD_System_NLines, CD_System_Line_NDOF, & + CD_System_Fallback_Count, CD_System_Fallback_Reset, & CD_Get_System_Line_State, & CD_Update_System_Line_SegmentLength, CD_Save_System_Line_Control, & CD_Restore_System_Line_Control, & @@ -108,6 +110,7 @@ MODULE CableDyn_OpenFAST_Aggregate PUBLIC :: CD_AGG_HasRigid6 PUBLIC :: CD_AGG_HasRod PUBLIC :: CD_AGG_HasPoint3 + PUBLIC :: CD_AGG_Fallback_Count, CD_AGG_Fallback_Reset PUBLIC :: CD_AGG_Rigid6_MirrorSize, CD_AGG_Get_Rigid6_States, CD_AGG_Set_Rigid6_States PUBLIC :: CD_AGG_Rod_MirrorSize, CD_AGG_Get_Rod_States, CD_AGG_Set_Rod_States PUBLIC :: CD_AGG_Refresh_PointMesh @@ -624,6 +627,20 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi CALL CD_AGG_End(candidate, es, em) END SUBROUTINE CD_AGG_Init_From_Deck + PURE INTEGER FUNCTION CD_AGG_Fallback_Count(self) RESULT(n) + !! Subdivision-retry entries of the EI = 0 system step since its initialisation or the + !! last CD_AGG_Fallback_Reset (CD_System_Fallback_Count); 0 without an EI = 0 system. + TYPE(CD_AGG_ModuleType), INTENT(IN) :: self + n = 0 + IF (self%has_sys) n = CD_System_Fallback_Count(self%sys%fast%system) + END FUNCTION CD_AGG_Fallback_Count + + SUBROUTINE CD_AGG_Fallback_Reset(self) + !! Zero the subdivision-retry tripwire of the EI = 0 system (start of a measured window). + TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: self + IF (self%has_sys) CALL CD_System_Fallback_Reset(self%sys%fast%system) + END SUBROUTINE CD_AGG_Fallback_Reset + INTEGER FUNCTION CD_AGG_NMovingPoints(self, ErrStat, ErrMsg) RESULT(n) !! Total host-prescribed (moving) points: the EI=0 system's moving points followed by !! one fairlead per cable. @@ -2675,7 +2692,7 @@ SUBROUTINE CD_AGG_WriteStaticProfile(self, path, ErrStat, ErrMsg) ErrMsg = 'CableDyn_OpenFAST_Aggregate: line map unavailable for the static profile' RETURN END IF - OPEN (NEWUNIT=unit, FILE=TRIM(path), STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, TRIM(path), ios) IF (ios /= 0) THEN ErrStat = CD_AGG_BADINPUT ErrMsg = 'CableDyn_OpenFAST_Aggregate: cannot open static profile: '//TRIM(path) diff --git a/src/CableDyn_PathIO.f90 b/src/CableDyn_PathIO.f90 index 9b16ceb1..500cee6d 100644 --- a/src/CableDyn_PathIO.f90 +++ b/src/CableDyn_PathIO.f90 @@ -13,7 +13,8 @@ MODULE CableDyn_PathIO IMPLICIT NONE PRIVATE - PUBLIC :: CD_Get_Argument, CD_Native_Path, CD_Open_Input, CD_Path_Is_Device, CD_Lock_Path + PUBLIC :: CD_Get_Argument, CD_Native_Path, CD_Open_Input, CD_Open_Read, CD_Open_Write, CD_Path_Openable + PUBLIC :: CD_Path_Is_Device, CD_Lock_Path PUBLIC :: CD_Strip_BOM !> CD_Native_Path status: converted, a reserved device name, a name the ANSI code @@ -61,6 +62,12 @@ FUNCTION c_path_lock(in, in_len) RESULT(n) BIND(C, name='cabledyn_path_lock') INTEGER(C_INT), VALUE :: in_len INTEGER(C_INT) :: n END FUNCTION c_path_lock + FUNCTION c_path_probe(in, in_len, for_output) RESULT(n) BIND(C, name='cabledyn_path_probe') + IMPORT :: C_INT, C_CHAR + CHARACTER(KIND=C_CHAR), INTENT(IN) :: in(*) + INTEGER(C_INT), VALUE :: in_len, for_output + INTEGER(C_INT) :: n + END FUNCTION c_path_probe END INTERFACE CONTAINS @@ -168,9 +175,59 @@ SUBROUTINE CD_Open_Input(unit, path, ios, reason) ios = 1 RETURN END IF - OPEN (NEWUNIT=unit, FILE=native, STATUS='OLD', ACTION='READ', IOSTAT=ios) + CALL CD_Open_Read(unit, native, ios) END SUBROUTINE CD_Open_Input + SUBROUTINE CD_Open_Read(unit, name, ios) + !! OPEN the existing file name (a runtime spelling, such as one CD_Native_Path gave) for + !! sequential formatted reading. ios /= 0 on failure: the OPEN's IOSTAT, or 1 when + !! CD_Path_Openable refused the name and no OPEN was attempted. + INTEGER, INTENT(OUT) :: unit, ios + CHARACTER(*), INTENT(IN) :: name + + unit = -1 + ios = 1 + IF (.NOT. CD_Path_Openable(name, .FALSE.)) RETURN + OPEN (NEWUNIT=unit, FILE=name, STATUS='OLD', ACTION='READ', IOSTAT=ios) + END SUBROUTINE CD_Open_Read + + SUBROUTINE CD_Open_Write(unit, name, ios, status) + !! OPEN name (a runtime spelling: one CD_Native_Path gave, or an output root's spelling + !! with a suffix) for sequential formatted writing, STATUS 'REPLACE' or, given, status. + !! ios /= 0 on failure: the OPEN's IOSTAT, or 1 when CD_Path_Openable refused the name + !! and no OPEN was attempted. + INTEGER, INTENT(OUT) :: unit, ios + CHARACTER(*), INTENT(IN) :: name + CHARACTER(*), INTENT(IN), OPTIONAL :: status + + unit = -1 + ios = 1 + IF (.NOT. CD_Path_Openable(name, .TRUE.)) RETURN + IF (PRESENT(status)) THEN + OPEN (NEWUNIT=unit, FILE=name, STATUS=status, ACTION='WRITE', IOSTAT=ios) + ELSE + OPEN (NEWUNIT=unit, FILE=name, STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + END IF + END SUBROUTINE CD_Open_Write + + LOGICAL FUNCTION CD_Path_Openable(name, for_output) RESULT(openable) + !! Whether the system opens name (a runtime spelling, trailing blanks ignored) for + !! reading an existing file or, with for_output, for writing (a missing file is then + !! created empty, an existing one left as it is). Every OPEN of a user-supplied name asks + !! here first and is not attempted when the answer is no: the Intel Fortran run-time + !! (ifx 2025.3, Windows) ends the process with a stack buffer overrun (0xC0000409) while + !! it formats the error of a failing OPEN of a name of about 600 characters or more (the + !! extended-length \\?\ spelling CD_Native_Path gives a long path), where an INQUIRE or + !! this probe returns. + CHARACTER(*), INTENT(IN) :: name + LOGICAL, INTENT(IN) :: for_output + INTEGER(C_INT) :: mode + + mode = 0_C_INT + IF (for_output) mode = 1_C_INT + openable = c_path_probe(name, INT(LEN_TRIM(name), C_INT), mode) == 0_C_INT + END FUNCTION CD_Path_Openable + PURE LOGICAL FUNCTION CD_Path_Is_Device(path) RESULT(is_device) !! True on Windows when any component of path is a reserved device name. CHARACTER(*), INTENT(IN) :: path diff --git a/src/CableDyn_RangeOutput.f90 b/src/CableDyn_RangeOutput.f90 index de2b6b96..7680cfa5 100644 --- a/src/CableDyn_RangeOutput.f90 +++ b/src/CableDyn_RangeOutput.f90 @@ -27,6 +27,7 @@ MODULE CableDyn_RangeOutput !! length the deformed chord length from the grounded end to the TDP (0 while no node !! beyond the grounded end node is grounded). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE + USE CableDyn_PathIO, ONLY: CD_Open_Write USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Floor, CD_Bathymetry_Is_Initialized, & CD_BATHY_OK USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND @@ -522,7 +523,7 @@ SUBROUTINE CD_Range_Write_Files(set, out_root, ErrStat, ErrMsg) END IF WRITE (id_text, '(I0)') set%lines(il)%line_id path = TRIM(out_root)//'.Line'//TRIM(id_text)//'.range.out' - OPEN (NEWUNIT=unit, FILE=TRIM(path), STATUS='REPLACE', ACTION='WRITE', IOSTAT=ios) + CALL CD_Open_Write(unit, TRIM(path), ios) IF (ios /= 0) THEN ErrStat = CD_RANGE_BADINPUT ErrMsg = 'CableDyn_RangeOutput: cannot open range-graph output file: '//TRIM(path) diff --git a/src/CableDyn_System.f90 b/src/CableDyn_System.f90 index 87760f8a..6ca7fc81 100644 --- a/src/CableDyn_System.f90 +++ b/src/CableDyn_System.f90 @@ -123,14 +123,6 @@ MODULE CableDyn_System INTEGER, PARAMETER, PUBLIC :: CD_LINE_END_A = 1 INTEGER, PARAMETER, PUBLIC :: CD_LINE_END_B = 2 - ! Adaptive-substep fallback tripwire: how many times CD_Step_System entered the - ! subdivision retry since the last reset. A plain integer increment on the RARE - ! stall path only (the converged path never touches it), so it is always on -- - ! diagnostics can read it to assert a healthy run never needed the fallback, and a - ! coupled log can report it at shutdown. - ! Module-level (not per-system): a diagnostics tally, not model state. - INTEGER, SAVE :: n_fallback_entries = 0 - TYPE :: CD_SystemPointType !! Named system point. Fixed/coupled points are externally prescribed. !! Free/connect points are integrated by the system dynamic-point step. @@ -245,6 +237,13 @@ MODULE CableDyn_System ! mean squares per node, 3 per node: sized like snap_q, line by line). REAL(wp), ALLOCATABLE :: snap_viv(:) LOGICAL :: snap_valid = .FALSE. + ! Adaptive-substep fallback tripwire: how many times CD_Step_System entered the + ! subdivision retry of this system since its initialisation or the last + ! CD_System_Fallback_Reset. An increment on the RARE stall path only (the converged path + ! never touches it), so it is always on: diagnostics can assert that a healthy run never + ! needed the fallback. Per system, so concurrent systems never mix their counts; not part + ! of the snapshot (a restored step keeps its count) and of no result. + INTEGER :: n_fallback_entries = 0 END TYPE CD_SystemType CONTAINS @@ -1534,8 +1533,8 @@ RECURSIVE SUBROUTINE CD_Step_System(system, dt, q_coupled, v_coupled, a_coupled, ! and on ANY failure to complete the full interval converged it restores that snapshot ! -- so a mid-interval state can never leak. IF (.NOT. converged .AND. depth < MAX_SUBDIV) THEN - !$OMP ATOMIC UPDATE - n_fallback_entries = n_fallback_entries + 1 + ! the system's own count, outside the lines' parallel region: one thread steps a system + system%n_fallback_entries = system%n_fallback_entries + 1 ! Capture the coupled motion at the START of the interval only on the rare subdivision ! path. The common converged path must not heap-allocate just to prepare an unused retry. ALLOCATE (q0(SIZE(q_coupled)), v0(SIZE(q_coupled)), a0(SIZE(q_coupled))) @@ -3639,16 +3638,18 @@ SUBROUTINE CD_Get_System_Substep_Counts(system, calls, events, max_used, capped, END DO END SUBROUTINE CD_Get_System_Substep_Counts - PURE FUNCTION CD_System_Fallback_Count() RESULT(n) - !! Subdivision-retry entries since the last CD_System_Fallback_Reset (see the - !! module-level tripwire note). + PURE FUNCTION CD_System_Fallback_Count(system) RESULT(n) + !! Subdivision-retry entries of system since its initialisation or the last + !! CD_System_Fallback_Reset (see CD_SystemType%n_fallback_entries). + TYPE(CD_SystemType), INTENT(IN) :: system INTEGER :: n - n = n_fallback_entries + n = system%n_fallback_entries END FUNCTION CD_System_Fallback_Count - SUBROUTINE CD_System_Fallback_Reset() - !! Zero the subdivision-retry tripwire (start of a measured window). - n_fallback_entries = 0 + SUBROUTINE CD_System_Fallback_Reset(system) + !! Zero the subdivision-retry tripwire of system (start of a measured window). + TYPE(CD_SystemType), INTENT(INOUT) :: system + system%n_fallback_entries = 0 END SUBROUTINE CD_System_Fallback_Reset END MODULE CableDyn_System diff --git a/src/CableDyn_WaveMath.f90 b/src/CableDyn_WaveMath.f90 new file mode 100644 index 00000000..c77b7df1 --- /dev/null +++ b/src/CableDyn_WaveMath.f90 @@ -0,0 +1,144 @@ +! File: src/CableDyn_WaveMath.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +MODULE CableDyn_WaveMath + !! The sines, cosines and exponentials of the wave kinematics, evaluated in blocks. + !! + !! An irregular sea sums, at every point and time, one phase cosine and sine and one depth + !! exponential per component: thousands of transcendental evaluations per node and step. The + !! intrinsic functions become one scalar library call per element where the compiler may not + !! use its vector library (Intel ifx under /fp:precise, as every ifx build compiles), and the + !! MinGW-w64 library of gfortran reduces large arguments in x87 precision (errors of 10^4 to + !! 10^5 ulp at |x| ~ 10^4). Here each block is plain IEEE arithmetic that compilers vectorise + !! under any value-safe floating-point model (a value-unsafe one may fold the rounding to an + !! integer below; the build compiles this file value-safe with every compiler): + !! + !! * sine and cosine together, from ONE argument reduction (they are always needed in pairs): + !! theta = n pi/2 + r with n the integer nearest 2 theta/pi and + !! r = ((theta - n P1) - n P2) - n P3, the Cody-Waite reduction with pi/2 split in three + !! parts whose products with |n| < 2^20 are exact (P1 and P2 carry 33 bits); sin r and cos r + !! by their Taylor series through r^17 and r^18 (|r| <= pi/4, truncation below 2e-19); the + !! quadrant n mod 4 selects and signs them; + !! * exp(x) = 2^n exp(r) with n the integer nearest x/ln 2, r = (x - n L1) - n L2 (ln 2 in two + !! parts, |r| <= ln(2)/2), exp r by its Taylor series through r^13 (truncation below 1e-17) + !! and 2^n from its IEEE bits. + !! + !! Against quadruple precision (test_wave_math, and sweeps of 10^6 phases per decade) the + !! results are within 2.4 ulp over |theta| <= 2^20 pi/2 (sine, cosine) and 1.1 ulp over + !! -708 <= x <= 709 (exponential). Next to a zero of the sine or cosine, the double nearest + !! n pi/2, the value is as small as theta's distance from the multiple (down to 6.2e-19) and the + !! part of pi/2 below P1 + P2 + P3, 8.5e-32, adds |n| 8.5e-32 (at most 9e-26) to the error: + !! up to 2.8e6 ulp of that tiny value, 4e-10 ulp of 1. A phase formed as k x - omega t + phi + !! already carries a rounding error of |theta| ulp(1), far above both. + !! Elements beyond the reduction (|theta| > 2^20 pi/2) or the normal range (x < -708, + !! x > 709), and NaN, take the intrinsic, so a NaN argument gives NaN as the intrinsic does (the + !! clamp to the range may turn it into a finite bound: Fortran leaves MIN and MAX of a NaN + !! unspecified, and gfortran returns the other argument). The arrays are explicit-shape: + !! inlined into a caller's loops, the blocks then still vectorise. + USE CableDyn_Precision, ONLY: wp + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + IMPLICIT NONE + PRIVATE + + PUBLIC :: CD_Wave_SinCos, CD_Wave_Exp + + REAL(wp), PARAMETER :: TWO_OVER_PI = 0.63661977236758134308_wp + ! pi/2 = P1 + P2 + P3 (+ 8.5e-32): P1 and P2 carry 33 significant bits (fdlibm's pio2_1, pio2_2) + REAL(wp), PARAMETER :: P1 = 1.57079632673412561417e+00_wp + REAL(wp), PARAMETER :: P2 = 6.07710050630396597660e-11_wp + REAL(wp), PARAMETER :: P3 = 2.02226624871116645580e-21_wp + REAL(wp), PARAMETER :: THETA_MAX = 1.6470993291652855e+06_wp ! 2^20 pi/2 + REAL(wp), PARAMETER :: INV_LN2 = 1.44269504088896338700e+00_wp + ! ln 2 = L1 + L2: L1 carries 32 significant bits (fdlibm's ln2_hi), so n L1 is exact for |n| < 2^21 + REAL(wp), PARAMETER :: L1 = 6.93147180369123816490e-01_wp + REAL(wp), PARAMETER :: L2 = 1.90821492927058770002e-10_wp + REAL(wp), PARAMETER :: X_LOW = -708.0_wp, X_HIGH = 709.0_wp + ! (y + ROUNDER) - ROUNDER is y rounded to the nearest integer for |y| < 2^51, in plain IEEE + ! arithmetic (ANINT can become a library call that blocks the vector loop) + REAL(wp), PARAMETER :: ROUNDER = 6755399441055744.0_wp ! 1.5 * 2^52 + ! Taylor coefficients 1/m! + REAL(wp), PARAMETER :: F2 = 0.5_wp, F3 = 1.0_wp/6.0_wp, F4 = 1.0_wp/24.0_wp, F5 = 1.0_wp/120.0_wp, & + F6 = 1.0_wp/720.0_wp, F7 = 1.0_wp/5040.0_wp, F8 = 1.0_wp/40320.0_wp, & + F9 = 1.0_wp/362880.0_wp, F10 = 1.0_wp/3628800.0_wp, F11 = 1.0_wp/39916800.0_wp, & + F12 = 1.0_wp/479001600.0_wp, F13 = 1.0_wp/6227020800.0_wp, & + F14 = 1.0_wp/87178291200.0_wp, F15 = 1.0_wp/1307674368000.0_wp, & + F16 = 1.0_wp/20922789888000.0_wp, F17 = 1.0_wp/355687428096000.0_wp, & + F18 = 1.0_wp/6402373705728000.0_wp + +CONTAINS + + PURE SUBROUTINE CD_Wave_SinCos(n, theta, s, c) + !! s = sin(theta), c = cos(theta) for the n elements (explicit-shape arrays, so that the + !! loop vectorises wherever the call is inlined). + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(IN) :: theta(n) + REAL(wp), INTENT(OUT) :: s(n), c(n) + INTEGER :: i, q + REAL(wp) :: th, fn, r, r2, ps, pc, ss, cc + LOGICAL :: far + + DO i = 1, n + th = MAX(-THETA_MAX, MIN(THETA_MAX, theta(i))) + fn = (th*TWO_OVER_PI + ROUNDER) - ROUNDER + r = ((th - fn*P1) - fn*P2) - fn*P3 + r2 = r*r + ! Horner's scheme, its innermost terms first + ps = F13 + r2*(-F15 + r2*F17) + ps = r + (r*r2)*(-F3 + r2*(F5 + r2*(-F7 + r2*(F9 + r2*(-F11 + r2*ps))))) + pc = F12 + r2*(-F14 + r2*(F16 - r2*F18)) + pc = (1.0_wp - F2*r2) + (r2*r2)*(F4 + r2*(-F6 + r2*(F8 + r2*(-F10 + r2*pc)))) + ps = MERGE(ps, r, ABS(r) > 0.0_wp) ! sin(-0) = -0 (ifx's SIGN would drop the sign) + ! quadrant q = n mod 4: (sin, cos) = (ps, pc), (pc, -ps), (-ps, -pc), (-pc, ps) + q = IAND(INT(fn), 3) + ss = MERGE(pc, ps, BTEST(q, 0)) + cc = MERGE(ps, pc, BTEST(q, 0)) + s(i) = MERGE(-ss, ss, BTEST(q, 1)) + c(i) = MERGE(-cc, cc, BTEST(q + 1, 1)) + END DO + ! beyond the reduction, or NaN (every comparison with a NaN is false) + far = .FALSE. + DO i = 1, n + far = far .OR. .NOT. (ABS(theta(i)) <= THETA_MAX) + END DO + IF (.NOT. far) RETURN + DO i = 1, n + IF (.NOT. (ABS(theta(i)) <= THETA_MAX)) THEN + s(i) = SIN(theta(i)) + c(i) = COS(theta(i)) + END IF + END DO + END SUBROUTINE CD_Wave_SinCos + + PURE SUBROUTINE CD_Wave_Exp(n, x, e) + !! e = exp(x) for the n elements (explicit-shape arrays, as CD_Wave_SinCos). + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(IN) :: x(n) + REAL(wp), INTENT(OUT) :: e(n) + INTEGER :: i + INTEGER(INT64) :: m + REAL(wp) :: xc, fn, r, p + LOGICAL :: outside + + DO i = 1, n + xc = MAX(X_LOW, MIN(X_HIGH, x(i))) + fn = (xc*INV_LN2 + ROUNDER) - ROUNDER + r = (xc - fn*L1) - fn*L2 + p = F9 + r*(F10 + r*(F11 + r*(F12 + r*F13))) + p = 1.0_wp + r*(1.0_wp + r*(F2 + r*(F3 + r*(F4 + r*(F5 + r*(F6 + r*(F7 + r*(F8 + r*p)))))))) + ! times 2^m from its IEEE bits, m in [-1022, 1023] for the clamped argument (SCALE can + ! become a library call per element) + m = INT(fn, INT64) + 1023_INT64 + e(i) = p*TRANSFER(ISHFT(m, 52), p) + END DO + ! outside the normal range, or NaN + outside = .FALSE. + DO i = 1, n + outside = outside .OR. .NOT. (x(i) >= X_LOW .AND. x(i) <= X_HIGH) + END DO + IF (.NOT. outside) RETURN + DO i = 1, n + IF (.NOT. (x(i) >= X_LOW .AND. x(i) <= X_HIGH)) e(i) = EXP(x(i)) + END DO + END SUBROUTINE CD_Wave_Exp + +END MODULE CableDyn_WaveMath diff --git a/src/CableDyn_WaveSpectra.f90 b/src/CableDyn_WaveSpectra.f90 index 2b617f1e..09487849 100644 --- a/src/CableDyn_WaveSpectra.f90 +++ b/src/CableDyn_WaveSpectra.f90 @@ -30,6 +30,7 @@ MODULE CableDyn_WaveSpectra !! |theta - theta_p| <= pi/2, K(s) = Gamma(s+1)/(sqrt(pi) Gamma(s+1/2)). USE CableDyn_Precision, ONLY: wp, CD_ZERO, CD_ONE, CD_Is_Finite USE CableDyn_Hydro, ONLY: CD_Solve_Dispersion_Wavenumber, CD_HYDRO_OK + USE CableDyn_WaveMath, ONLY: CD_Wave_SinCos, CD_Wave_Exp USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 IMPLICIT NONE PRIVATE @@ -621,6 +622,8 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel !! Linear multi-directional sea kinematics at (x, y, z, t) with Wheeler stretching. !! scale multiplies every amplitude (the start-up ramp). pdyn: the linear dynamic !! pressure per unit density at the stretched depth [m^2/s^2]; zero above the surface. + !! The phase sines and cosines (one argument reduction for both) and the depth exponentials + !! come from the block kernels of CableDyn_WaveMath. TYPE(CD_SeaType), INTENT(IN) :: sea REAL(wp), INTENT(IN) :: x, y, z, t, depth, scale REAL(wp), INTENT(OUT) :: eta, velocity(3), acceleration(3) @@ -628,11 +631,11 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel CHARACTER(*), INTENT(OUT) :: ErrMsg REAL(wp), INTENT(OUT), OPTIONAL :: pdyn INTEGER, PARAMETER :: NB = 256 - ! The phase cosines of the elevation pass, kept for the kinematics pass (whose chunk loop - ! would compute the same values again), for the first NKEEP components; the rest are - ! recomputed there. A multiple of NB, so each chunk is either kept whole or recomputed. + ! The phase cosines and sines of the elevation pass, kept for the kinematics pass (whose + ! chunk loop would compute the same values again), for the first NKEEP components; the rest + ! are recomputed there. A multiple of NB, so each chunk is either kept whole or recomputed. INTEGER, PARAMETER :: NKEEP = 16*NB - REAL(wp) :: cth(NB), sth(NB), ch(NB), sh(NB), ckeep(NKEEP) + REAL(wp) :: th(NB), cth(NB), sth(NB), ch(NB), sh(NB), ckeep(NKEEP), skeep(NKEEP) INTEGER :: i0, i1, i, m, n_small REAL(wp) :: z_eval, a, e1, e2, den, uh @@ -648,13 +651,18 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel END IF DO i0 = 1, sea%n_comp, NB i1 = MIN(sea%n_comp, i0 + NB - 1) + m = i1 - i0 + 1 DO i = i0, i1 - cth(i - i0 + 1) = COS(sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i)) + th(i - i0 + 1) = sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i) END DO + CALL CD_Wave_SinCos(m, th, sth, cth) DO i = i0, i1 eta = eta + (scale*sea%amplitude(i))*cth(i - i0 + 1) END DO - IF (i1 <= NKEEP) ckeep(i0:i1) = cth(1:i1 - i0 + 1) + IF (i1 <= NKEEP) THEN + ckeep(i0:i1) = cth(1:m) + skeep(i0:i1) = sth(1:m) + END IF END DO IF (z > eta) RETURN IF (.NOT. (depth + eta > EPSILON(depth)*depth)) THEN @@ -668,21 +676,21 @@ SUBROUTINE CD_Sea_Kinematics(sea, x, y, z, t, depth, scale, eta, velocity, accel m = i1 - i0 + 1 IF (i1 <= NKEEP) THEN cth(1:m) = ckeep(i0:i1) + sth(1:m) = skeep(i0:i1) ELSE DO i = i0, i1 - cth(i - i0 + 1) = COS(sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i)) + th(i - i0 + 1) = sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i) END DO + CALL CD_Wave_SinCos(m, th, sth, cth) END IF - DO i = i0, i1 - sth(i - i0 + 1) = SIN(sea%k(i)*(x*sea%cosb(i) + y*sea%sinb(i)) - sea%omega(i)*t + sea%phase(i)) - END DO ! cosh(k(z+h))/sinh(kh) and sinh(k(z+h))/sinh(kh) without overflow, from e1 = EXP(k z) ! and e2 = EXP(-k (z + 2h)) = e2kd/e1 at the synthesis depth: one exponential per ! component. A component whose e1 or e2kd underflows, or a call at another depth than the ! synthesis, takes the second exponential instead. DO i = i0, i1 - ch(i - i0 + 1) = EXP(sea%k(i)*z_eval) + th(i - i0 + 1) = sea%k(i)*z_eval END DO + CALL CD_Wave_Exp(m, th, ch) n_small = 0 IF (ABS(depth - sea%depth) <= CD_ZERO) THEN n_small = COUNT(ch(1:m) <= TINY(CD_ONE) .OR. sea%e2kd(i0:i1) <= TINY(CD_ONE)) diff --git a/src/cabledyn_path.c b/src/cabledyn_path.c index c3c605bf..3ba1983a 100644 --- a/src/cabledyn_path.c +++ b/src/cabledyn_path.c @@ -24,7 +24,11 @@ * the console or discards output; * cabledyn_path_lock * an exclusive lock file for an output root, released by the operating - * system when the process ends, however it ends. + * system when the process ends, however it ends; + * cabledyn_path_probe + * whether the system opens a runtime spelling for reading or for writing, asked + * before the Fortran OPEN so that an OPEN that would fail is never attempted + * (see CD_Path_Openable in src/CableDyn_PathIO.f90). * * On other systems names are UTF-8 byte strings that the runtime opens unchanged, * so the conversion is the identity and the lock uses an advisory flock(). @@ -52,6 +56,18 @@ int cabledyn_path_arg(int index, char *buf, int buflen); int cabledyn_path_native(const char *in, int in_len, int for_output, int reserve, char *out, int outlen); int cabledyn_path_is_device(const char *in, int in_len); int cabledyn_path_lock(const char *in, int in_len); +int cabledyn_path_probe(const char *in, int in_len, int for_output); + +/* The name s[0..n) as a NUL-terminated copy (malloc), or NULL. */ +static char *terminated(const char *s, int n) { + char *t; + if (s == NULL || n <= 0) return NULL; + t = (char *)malloc((size_t)n + 1); + if (t == NULL) return NULL; + memcpy(t, s, (size_t)n); + t[n] = '\0'; + return t; +} /* Copies n bytes and a terminating NUL when they fit; returns n or CD_PATH_ERR_BUFFER. */ static int copy_out(const char *src, int n, char *out, int outlen) { @@ -402,6 +418,24 @@ int cabledyn_path_lock(const char *in, int in_len) { return CD_LOCK_FAILED; } +/* 0 when the system opens the runtime spelling in[0..in_len) (the narrow name the Fortran + * OPEN is given) for reading an existing file, or for writing (for_output; a missing file + * is created, an existing one left as it is), else 1. The ANSI entry point reads the name + * as the runtime's own calls do. A directory is refused: without backup semantics it does + * not open. The handle is closed at once. */ +int cabledyn_path_probe(const char *in, int in_len, int for_output) { + char *name = terminated(in, in_len); + HANDLE h; + if (name == NULL) return 1; + h = CreateFileA(name, for_output ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, + for_output ? OPEN_ALWAYS : OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + free(name); + if (h == INVALID_HANDLE_VALUE) return 1; + CloseHandle(h); + return 0; +} + #else /* !_WIN32 */ #include @@ -425,6 +459,22 @@ int cabledyn_path_native(const char *in, int in_len, int for_output, int reserve return copy_out(in, in_len, out, outlen); } +/* 0 when the system opens in[0..in_len) for reading an existing regular file (not a + * directory), or for writing (for_output; a missing file is created, an existing one left + * as it is), else 1. */ +int cabledyn_path_probe(const char *in, int in_len, int for_output) { + char *name = terminated(in, in_len); + struct stat st; + int fd, ok; + if (name == NULL) return 1; + fd = open(name, for_output ? (O_WRONLY | O_CREAT) : O_RDONLY, 0666); + free(name); + if (fd < 0) return 1; + ok = fstat(fd, &st) == 0 && !S_ISDIR(st.st_mode); + close(fd); + return ok ? 0 : 1; +} + static char *lock_name = NULL; static int lock_fd = -1; diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 64cc4138..c4a56e8f 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -77,6 +77,7 @@ MODULE CableDyn USE CableDyn_Types USE NWTC_Library USE CableDyn_Precision, ONLY: wp + USE CableDyn_PathIO, ONLY: CD_Path_Openable USE CableDyn_Conventions, ONLY: CD_NATIVE_CHANNEL_FMT USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_SeaState_Steady_Current, CD_HYDRO_OK USE CableDyn_DeckDriver, ONLY: CD_Deck_Query_dtM, CD_DECKDRV_OK, CD_Is_Line_Node_Channel, & @@ -359,8 +360,14 @@ SUBROUTINE open_native_outputs( id, root, t_start, ErrStat, ErrMsg, write_profil ! BACKSPACE and replace the abandoned row. OpenFOutFile opens write-only and ! therefore makes that standard record-positioning operation fail on gfortran. iomsg = '' - OPEN (un, FILE=TRIM(root)//'.out', STATUS='REPLACE', FORM='FORMATTED', & - ACTION='READWRITE', POSITION='REWIND', IOSTAT=ios, IOMSG=iomsg) + ! CD_Path_Openable: a failing OPEN of a long name ends the ifx run-time (CableDyn_PathIO) + IF (CD_Path_Openable(TRIM(root)//'.out', .TRUE.)) THEN + OPEN (un, FILE=TRIM(root)//'.out', STATUS='REPLACE', FORM='FORMATTED', & + ACTION='READWRITE', POSITION='REWIND', IOSTAT=ios, IOMSG=iomsg) + ELSE + ios = 1 + iomsg = 'The file cannot be created or written.' + END IF IF (ios /= 0) THEN CALL SetErrStat( ErrID_Fatal, 'Cannot open native output file "'//TRIM(root)// & '.out" for transactional read/write access. '//TRIM(iomsg), & @@ -5089,6 +5096,7 @@ END SUBROUTINE write_deck_copy SUBROUTINE delete_file( path ) CHARACTER(*), INTENT(IN) :: path INTEGER(IntKi) :: un, ios + IF (.NOT. CD_Path_Openable(TRIM(path), .FALSE.)) RETURN ! no OPEN that fails (CableDyn_PathIO) CALL GetNewUnit( un ) OPEN (un, FILE=TRIM(path), STATUS='OLD', IOSTAT=ios) IF (ios == 0) CLOSE (un, STATUS='DELETE', IOSTAT=ios) diff --git a/tests/check_driver_paths.cmake b/tests/check_driver_paths.cmake index 50aac37b..67b53205 100644 --- a/tests/check_driver_paths.cmake +++ b/tests/check_driver_paths.cmake @@ -5,6 +5,8 @@ # by a best-fit look-alike (café -> cafe); # * no output file may be the deck or a file the deck reads, however it is spelled; # * reserved Windows device names are refused instead of blocking on the console; +# * an output root beyond the path limit in a folder that does not exist is refused with +# the reason (exit 1), not a run-time crash; # * a second run on an output root that a live run holds is refused, and the lock # disappears with the run. if(DEFINED DELAYED_RUN) @@ -136,6 +138,20 @@ file(WRITE "${WORK}/auxclash_deck.dat" "${clash_text}") run_driver("auxclash_deck.dat" "auxclash") expect_refusal("output over the bathymetry file" "would overwrite the input file") +# --- an output root beyond the path limit in a folder that does not exist ---------------- +# Its runtime spelling (extended-length on Windows) is about 700 characters: a failing OPEN +# of such a name ended an ifx-built driver inside the Intel run-time (0xC0000409); it must +# be refused with the reason instead. +string(REPEAT "a" 200 seg_a) +string(REPEAT "b" 200 seg_b) +string(REPEAT "c" 200 seg_c) +file(WRITE "${WORK}/long_root_deck.dat" "${static_text}") +run_driver("long_root_deck.dat" "${WORK}/no_such_folder/${seg_a}/${seg_b}/${seg_c}/run") +if(NOT run_rc EQUAL 1 OR NOT run_err MATCHES "cannot write output files") + message(FATAL_ERROR "long output root in a missing folder: expected exit 1 and 'cannot write output files', " + "got rc=${run_rc}\n${run_err}") +endif() + # --- reserved Windows device names ----------------------------------------------------- if(WIN32) run_driver("CON" "dev_run") diff --git a/tests/check_driver_profile.cmake b/tests/check_driver_profile.cmake index 56aee54d..7352002f 100644 --- a/tests/check_driver_profile.cmake +++ b/tests/check_driver_profile.cmake @@ -49,7 +49,9 @@ foreach(row "\n outputs +[0-9]+\\.[0-9]+ s" "\n progress and bookkeeping +[0-9]+\\.[0-9]+ s" "\n finalisation +[0-9]+\\.[0-9]+ s" - "\n total +[0-9]+\\.[0-9]+ s +100\\.0 %" + # the total is 100 % of itself, or 0.000 s and 0.0 % when the whole run took less than half a + # millisecond (a fast build on the short deck): the driver gives no share of a zero total + "\n total +([0-9]+\\.[0-9]+ s +100\\.0|0\\.000 s +0\\.0) %" "\n March: [1-9][0-9]* committed step\\(s\\), [0-9]+\\.[0-9]+ ms per step\\.") if(NOT profiled MATCHES "${row}") message(FATAL_ERROR "the profiled stdout lacks \"${row}\":\n${profiled}") diff --git a/tests/check_driver_profile_failure.cmake b/tests/check_driver_profile_failure.cmake index ff924c4c..b0d5bde4 100644 --- a/tests/check_driver_profile_failure.cmake +++ b/tests/check_driver_profile_failure.cmake @@ -20,7 +20,9 @@ foreach(row "Run-time profile \\(CABLEDYN_PROFILE\\), wall-clock time:" "\n dynamic march +[0-9]+\\.[0-9]+ s" "\n finalisation +0\\.000 s +0\\.0 %" - "\n total +[0-9]+\\.[0-9]+ s +100\\.0 %") + # the total is 100 % of itself, or 0.000 s and 0.0 % when the whole run took less than half a + # millisecond (a fast build on the short deck): the driver gives no share of a zero total + "\n total +([0-9]+\\.[0-9]+ s +100\\.0|0\\.000 s +0\\.0) %") if(NOT out MATCHES "${row}") message(FATAL_ERROR "the stdout of the failed run lacks \"${row}\":\n${out}") endif() diff --git a/tests/data/c_api_free_rod.dat b/tests/data/c_api_free_rod.dat new file mode 100644 index 00000000..f5d8e5e3 --- /dev/null +++ b/tests/data/c_api_free_rod.dat @@ -0,0 +1,41 @@ +--------------------- CableDyn Input File ------------------------------------ +C API concurrency test deck: a Free rod hung between a Fixed anchor line and a line to a +Coupled point, so a handle steps the rod through the coupled aggregate (fixed step dtM) +(test_c_api_threads --mixed). +--------------------------- LINE TYPES ---------------------------------------- +Name Diam Mass EA BA EI Cdn Cdt Can Cat +(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-) +line 0.10 80.0 1.0e5 0.0 0.0 1.0 0.0 1.0 0.0 +--------------------------- ROD TYPES ----------------------------------------- +Name Diam Mass Cd Ca CdEnd CaEnd +(-) (m) (kg/m) (-) (-) (-) (-) +rodmat 0.20 50.0 1.0 1.0 0.0 0.0 +--------------------------- RODS ---------------------------------------------- +ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs +(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-) +1 rodmat Free 0.0 0.0 -4.0 0.0 0.0 -2.0 2 - +--------------------------- POINTS -------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m3) (m2) (-) +1 Fixed 2.0 0.0 -5.0 0.0 0.0 0.0 0.0 +2 Rod1A 0.0 0.0 -4.0 0.0 0.0 0.0 0.0 +3 Rod1B 0.0 0.0 -2.0 0.0 0.0 0.0 0.0 +4 Coupled 0.0 0.0 -1.0 0.0 0.0 0.0 0.0 +--------------------------- LINES --------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +1 2 1 - +2 3 4 - +--------------------------- SECTIONS ------------------------------------------ +LineID LineType Length NumSegs +(-) (-) (m) (-) +1 line 3.5 3 +2 line 1.2 2 +--------------------------- OPTIONS ------------------------------------------- +9.80665 g +1025.0 rhoW +10.0 WtrDpth +1.0e5 kBot +0.05 dtM +1.0 TMax +--------------------------- END ----------------------------------------------- diff --git a/tests/test_c_api_threads.c b/tests/test_c_api_threads.c index 414e8a98..ecd3f935 100644 --- a/tests/test_c_api_threads.c +++ b/tests/test_c_api_threads.c @@ -21,6 +21,13 @@ * 5. 24 threads step distinct handles concurrently while other threads keep * failing to open a missing deck; every trajectory matches a serial reference. * + * test_c_api_threads --mixed [ ...] instead steps every deck on + * several threads at once, all decks concurrently (each handle its own model: EI = 0 + * lines, finite-EI cables, Syrope and viscoelastic segments, points, bodies and rods take + * their own code paths), n_steps steps each, and checks every trajectory against the + * deck's serial reference. A procedure whose locals or callbacks live in storage that + * every thread shares (static locals, closure trampolines) fails it. + * * CABLEDYN_THREAD_TEST_LOOPS= repeats checks 2-5 n times in one process (stress * mode). A watchdog thread ends the process with a failure naming the phase in * progress when the run exceeds CABLEDYN_THREAD_TEST_TIMEOUT seconds (default 300), @@ -252,8 +259,8 @@ static double private_mb(void) #endif } -/* Initialises `path`, takes N_STEP held steps, and records the final coupled loads. */ -static int step_deck(const char *path, double *loads, int *ndof_out, char *msg, size_t msg_len) +/* Initialises `path`, takes n_step steps, and records the final coupled loads. */ +static int step_deck(const char *path, int n_step, double *loads, int *ndof_out, char *msg, size_t msg_len) { void *h = NULL; int err = -1, ndof, k, n_iter = 0; @@ -273,7 +280,7 @@ static int step_deck(const char *path, double *loads, int *ndof_out, char *msg, return 1; } CableDyn_GetCoupledMotion(h, q, v, a, ndof, &err); - for (k = 0; k < N_STEP && err == CD_C_OK; ++k) { + for (k = 0; k < n_step && err == CD_C_OK; ++k) { /* A slow surge of every coupled x DOF keeps the lines working. */ int i; for (i = 0; i < ndof; i += 3) q[i] += 0.002; @@ -326,6 +333,7 @@ static void init_worker(void *raw) struct step_job { const char *path; const char *missing_path; + int n_step; int ndof; int failed; double loads[MAX_DOF]; @@ -335,7 +343,7 @@ struct step_job { static void step_worker(void *raw) { struct step_job *job = (struct step_job *)raw; - job->failed = step_deck(job->path, job->loads, &job->ndof, job->msg, sizeof job->msg); + job->failed = step_deck(job->path, job->n_step, job->loads, &job->ndof, job->msg, sizeof job->msg); } static void missing_worker(void *raw) @@ -478,7 +486,7 @@ static int check_concurrent_steps(const char *deck) char msg[512] = {0}; int i, j, ndof = 0, failed = 0; - if (step_deck(deck, reference, &ndof, msg, sizeof msg) != 0) { + if (step_deck(deck, N_STEP, reference, &ndof, msg, sizeof msg) != 0) { fprintf(stderr, "FAIL serial reference run: %s\n", msg); return 1; } @@ -486,6 +494,7 @@ static int check_concurrent_steps(const char *deck) for (i = 0; i < N_STEPPERS + N_MISSING; ++i) { jobs[i].path = deck; jobs[i].missing_path = "missing_deck_for_thread_test.dat"; + jobs[i].n_step = N_STEP; tasks[i].fn = i < N_STEPPERS ? step_worker : missing_worker; tasks[i].arg = &jobs[i]; } @@ -523,6 +532,67 @@ static int check_concurrent_steps(const char *deck) return 0; } +/* Steps every deck on MAX_THREADS / n_decks threads at once, all decks concurrently, and + * checks every final coupled load against the deck's serial reference. */ +static int check_mixed_steps(int n_decks, char **decks, int n_step) +{ + enum { MAX_DECKS = 8 }; + static struct step_job jobs[MAX_THREADS]; + static double reference[MAX_DECKS][MAX_DOF]; + struct task tasks[MAX_THREADS]; + int ndof[MAX_DECKS]; + char msg[512] = {0}; + int d, i, j, per_deck, n, failed = 0; + + if (n_decks < 1 || n_decks > MAX_DECKS) { + fprintf(stderr, "FAIL --mixed takes 1 to %d decks\n", MAX_DECKS); + return 1; + } + for (d = 0; d < n_decks; ++d) { + if (step_deck(decks[d], n_step, reference[d], &ndof[d], msg, sizeof msg) != 0) { + fprintf(stderr, "FAIL serial reference run of %s: %s\n", decks[d], msg); + return 1; + } + } + per_deck = MAX_THREADS / n_decks; + if (per_deck > 6) per_deck = 6; + n = per_deck * n_decks; + memset(jobs, 0, sizeof jobs); + for (i = 0; i < n; ++i) { + jobs[i].path = decks[i % n_decks]; + jobs[i].n_step = n_step; + tasks[i].fn = step_worker; + tasks[i].arg = &jobs[i]; + } + if (run_tasks(n, tasks) != 0) { + fprintf(stderr, "FAIL could not start the mixed stepping threads\n"); + return 1; + } + for (i = 0; i < n; ++i) { + d = i % n_decks; + if (jobs[i].failed || jobs[i].ndof != ndof[d]) { + fprintf(stderr, " thread %d (%s) failed: %s\n", i, decks[d], jobs[i].msg); + ++failed; + continue; + } + for (j = 0; j < ndof[d]; ++j) { + if (fabs(jobs[i].loads[j] - reference[d][j]) > 1.0e-9 * (1.0 + fabs(reference[d][j]))) { + fprintf(stderr, " thread %d (%s): load %d = %.17g, reference %.17g\n", i, decks[d], j, + jobs[i].loads[j], reference[d][j]); + ++failed; + break; + } + } + } + printf("mixed concurrent steps: %d decks x %d threads x %d steps: failed=%d\n", n_decks, per_deck, n_step, + failed); + if (failed != 0) { + fprintf(stderr, "FAIL concurrent Step of mixed decks on distinct handles\n"); + return 1; + } + return 0; +} + #if defined(_WIN32) /* ------------------------------------------------------- exit stress (Win32) -- */ @@ -666,6 +736,20 @@ int main(int argc, char **argv) return exit_stress(argv[2], atoi(argv[3])); } #endif + /* test_c_api_threads --mixed [ ...]: concurrent steps of mixed decks. */ + if (argc >= 4 && strcmp(argv[1], "--mixed") == 0) { + setvbuf(stdout, NULL, _IONBF, 0); + if (watchdog_start() != 0) return 1; + loops = env_seconds("CABLEDYN_THREAD_TEST_LOOPS", 1); + if (loops < 1) loops = 1; + for (loop = 0; loop < loops; ++loop) { + if (loops > 1) printf("loop %ld of %ld\n", loop + 1, loops); + current_phase = "concurrent Step (mixed decks)"; + if (check_mixed_steps(argc - 3, argv + 3, atoi(argv[2])) != 0) return 1; + } + printf("PASS c_api_threads --mixed\n"); + return 0; + } if (argc != 4) { fprintf(stderr, "usage: test_c_api_threads \n"); return 2; diff --git a/tests/test_core_release_regressions.f90 b/tests/test_core_release_regressions.f90 index 9193d831..c8c62411 100644 --- a/tests/test_core_release_regressions.f90 +++ b/tests/test_core_release_regressions.f90 @@ -178,12 +178,12 @@ SUBROUTINE case_fallback_restores_constitutive_state() END DO ac = 0.0_wp - CALL CD_System_Fallback_Reset() + CALL CD_System_Fallback_Reset(system) CALL CD_Step_System(system, DT, qc, vc, ac, conv, stalled, n_iter, es, em) CALL require(es == CD_SYSTEM_OK, 'fallback:system-step '//TRIM(em)) CALL require(.NOT. conv, 'fallback:step-stalls-at-every-depth') - CALL require(CD_System_Fallback_Count() > 0, 'fallback:subdivision-entered') - CALL CD_System_Fallback_Reset() + CALL require(CD_System_Fallback_Count(system) > 0, 'fallback:subdivision-entered') + CALL CD_System_Fallback_Reset(system) DO i = 1, 2 CALL CD_Get_Model_State(ref(i), pq, pv, pa, es, em) @@ -264,12 +264,12 @@ SUBROUTINE case_fallback_restores_committed_lengths() vc(4) = 0.2_wp ac = 0.0_wp - CALL CD_System_Fallback_Reset() + CALL CD_System_Fallback_Reset(system) CALL CD_Step_System(system, DT, qc, vc, ac, conv, stalled, n_iter, es, em) CALL require(es == CD_SYSTEM_OK, 'fallback-lengths:system-step '//TRIM(em)) CALL require(.NOT. conv, 'fallback-lengths:step-stalls-at-every-depth') - CALL require(CD_System_Fallback_Count() > 0, 'fallback-lengths:subdivision-entered') - CALL CD_System_Fallback_Reset() + CALL require(CD_System_Fallback_Count(system) > 0, 'fallback-lengths:subdivision-entered') + CALL CD_System_Fallback_Reset(system) CALL CD_Get_Model_State(ref, pq, pv, pa, es, em) DO j = 1, 6 diff --git a/tests/test_cosserat_assemble.f90 b/tests/test_cosserat_assemble.f90 index 397b8976..8f05584d 100644 --- a/tests/test_cosserat_assemble.f90 +++ b/tests/test_cosserat_assemble.f90 @@ -15,8 +15,8 @@ PROGRAM test_cosserat_assemble CD_Assemble_Cosserat_Tangent_Force_Banded_Free, & CD_Assemble_Cosserat_Internal_Force, & CD_Cosserat_Free_Bandwidth, & - CD_COSASM_N_FORCE, CD_COSASM_N_TANGENT, & - CD_Reset_Cosserat_Asm_Counts + CD_Assemble_Cosserat_Internal_Force_Workspace, & + CD_CosseratAssemblyWorkspace, CD_Reset_Cosserat_Asm_Counts IMPLICIT NONE REAL(wp), PARAMETER :: EA = 1.0e3_wp, GAS = 5.0e2_wp, EI = 2.0e2_wp, GJ = 1.5e2_wp @@ -30,6 +30,7 @@ PROGRAM test_cosserat_assemble REAL(wp) :: fplus(NDOF), fminus(NDOF), ffd(NDOF), fref(NDOF), kd(NDOF), frob, ksum, h REAL(wp), ALLOCATABLE :: Kb(:, :), Kfree(:, :), Kfrom_band(:, :) CHARACTER(120) :: em + TYPE(CD_CosseratAssemblyWorkspace) :: asm_work nfail = 0 nodes_ref(:, 1) = [0.0_wp, 0.0_wp, 0.0_wp] @@ -131,10 +132,10 @@ PROGRAM test_cosserat_assemble ! Force-only assembly must remain a true residual-only path: it should not ! increment the tangent assembly counter or route through the Hessian path. - CALL CD_Reset_Cosserat_Asm_Counts() - CALL CD_Assemble_Cosserat_Internal_Force(nodes_ref, conn, ea_a, gas_a, ei_a, gj_a, q, .TRUE., & - fint2, es, em) - CALL require(es == 0 .AND. CD_COSASM_N_FORCE == 1 .AND. CD_COSASM_N_TANGENT == 0, & + CALL CD_Reset_Cosserat_Asm_Counts(asm_work) + CALL CD_Assemble_Cosserat_Internal_Force_Workspace(nodes_ref, conn, ea_a, gas_a, ei_a, gj_a, q, .TRUE., & + asm_work, fint2, es, em) + CALL require(es == 0 .AND. asm_work%n_force == 1 .AND. asm_work%n_tangent == 0, & 'force-only-does-not-touch-tangent-counter') ! === fail-closed connectivity / property validation (mirrors the reference mesh diff --git a/tests/test_cosserat_dynamic.f90 b/tests/test_cosserat_dynamic.f90 index a61ded70..062c30db 100644 --- a/tests/test_cosserat_dynamic.f90 +++ b/tests/test_cosserat_dynamic.f90 @@ -16,8 +16,7 @@ PROGRAM test_cosserat_dynamic CD_Cosserat_Mechanical_Energy, CD_Assemble_Cosserat_Mass, & CD_Assemble_Cosserat_Mass_Banded_Free, CD_Cosserat_Mass_MatVec, & CD_CosseratGenAlphaWorkspace, CD_Clear_CosseratGenAlpha_Workspace, & - CD_Reset_Cosserat_Dyn_Counts, CD_COSDYN_N_STALE_ACCEPT, & - CD_COSDYN_N_STALE_REJECT, CD_COSDYN_N_DEFERRED_REFRESH + CD_Reset_Cosserat_Dyn_Counts USE CableDyn_CosseratAssemble, ONLY: CD_Assemble_Cosserat_Internal_Force, CD_Cosserat_Free_Bandwidth USE CableDyn_Cosserat, ONLY: CD_Reference_Frame, CD_Cosserat_Element_Energy USE CableDyn_Dynamic, ONLY: GenAlphaConfig, CD_DYN_OK @@ -363,6 +362,7 @@ SUBROUTINE check_modified_newton_reuses_tangent() INTEGER :: es_l, nit_full, nit_mod LOGICAL :: cvg_full, stl_full, cvg_mod, stl_mod CHARACTER(120) :: em_l + TYPE(CD_CosseratGenAlphaWorkspace) :: mod_work amp = 2.0e-3_wp q0 = q @@ -391,14 +391,16 @@ SUBROUTINE check_modified_newton_reuses_tangent() q_full, v_full, a_full, cvg_full, stl_full, nit_full, es_l, em_l) CALL require(es_l == CD_DYN_OK .AND. cvg_full .AND. .NOT. stl_full, 'cosserat-mod-newton:full-converged') - CALL CD_Reset_Cosserat_Dyn_Counts() + CALL CD_Reset_Cosserat_Dyn_Counts(mod_work) CALL CD_Cosserat_Gen_Alpha_Step(nodes_ref, conn, ea_a, gas_a, ei_a, gj_a, ra, it, in_, .TRUE., & q0, v0, a_init, f_load, [INTEGER ::], 0.02_wp, cfg_mod, & - q_mod, v_mod, a_mod, cvg_mod, stl_mod, nit_mod, es_l, em_l) + q_mod, v_mod, a_mod, cvg_mod, stl_mod, nit_mod, es_l, em_l, & + workspace=mod_work) CALL require(es_l == CD_DYN_OK .AND. cvg_mod .AND. .NOT. stl_mod, 'cosserat-mod-newton:modified-converged') - CALL require(CD_COSDYN_N_STALE_ACCEPT + CD_COSDYN_N_STALE_REJECT > 0, & + CALL require(mod_work%n_stale_accept + mod_work%n_stale_reject > 0, & 'cosserat-mod-newton:stale-tangent-attempted') - CALL require(CD_COSDYN_N_DEFERRED_REFRESH == 0, 'cosserat-mod-newton:no-pre-solve-refresh') + CALL require(mod_work%n_deferred_refresh == 0, 'cosserat-mod-newton:no-pre-solve-refresh') + CALL CD_Clear_CosseratGenAlpha_Workspace(mod_work) dqmax = nan_max_abs(q_mod - q_full) dvmax = nan_max_abs(v_mod - v_full) damax = nan_max_abs(a_mod - a_full) diff --git a/tests/test_deck_reader_io.f90 b/tests/test_deck_reader_io.f90 index c676fc3f..a58f50a5 100644 --- a/tests/test_deck_reader_io.f90 +++ b/tests/test_deck_reader_io.f90 @@ -7,10 +7,15 @@ PROGRAM test_deck_reader_io !! whitespace-only rows, ASCII whitespace separators), rejected characters (NUL and !! non-ASCII whitespace outside comments), whole-record section headers, row-level !! diagnostics that name the deck line, per-row OPTIONS validation (a shadowed invalid - !! row still fails), bathymetry grids in any row order, and reserved device names. + !! row still fails), bathymetry grids in any row order, reserved device names, and files + !! that do not open: a failing OPEN of a name of 600 characters or more ends an ifx-built + !! program inside the Intel run-time (0xC0000409), so the opens of names beyond the Windows + !! path limit in a folder that does not exist, and of a folder, must return a status (and + !! the deck run with such an output root a message) instead; this program then ends. USE CableDyn_Precision, ONLY: wp USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_Deck_Query_dtM, CD_DECKDRV_OK, CD_DECKDRV_BADINPUT - USE CableDyn_PathIO, ONLY: CD_Path_Is_Device, CD_Native_Path, CD_PATH_OK, CD_PATH_ERR_DEVICE + USE CableDyn_PathIO, ONLY: CD_Path_Is_Device, CD_Native_Path, CD_PATH_OK, CD_PATH_ERR_DEVICE, & + CD_Open_Read, CD_Open_Write, CD_Open_Input, CD_Path_Openable IMPLICIT NONE CHARACTER(*), PARAMETER :: ANCHOR = '1 Fixed 400.0 0.0 -50.0', SECTION = '1 chain 410.0 41' @@ -26,6 +31,7 @@ PROGRAM test_deck_reader_io CALL check_bathymetry_row_order() CALL check_waterkin_diagnostics() CALL check_device_names() + CALL check_files_that_do_not_open() CALL check_nonfinite_and_subnormal_values() CALL check_admissible_magnitudes() CALL check_strict_line_attachments() @@ -284,6 +290,54 @@ SUBROUTINE check_device_names() 'reserved Windows device') END SUBROUTINE check_device_names + SUBROUTINE check_files_that_do_not_open() + !! Opens that fail return a status without attempting the OPEN (CD_Path_Openable): a + !! folder, and names of about 680 characters (three 200-character folders that do not + !! exist, spelt for the runtime as CD_Native_Path spells them, extended-length on Windows) + !! for writing, for reading and as a deck run's output root. A short name still writes + !! and reads back, and a probe for writing leaves an existing file as it is. + CHARACTER(:), ALLOCATABLE :: native, long_name + CHARACTER(512) :: why + CHARACTER(64) :: line + INTEGER :: stat, unit, ios, es + CHARACTER(1024) :: em + LOGICAL :: conv + + long_name = 'reader_missing_folder/'//REPEAT('a', 200)//'/'//REPEAT('b', 200)//'/'//REPEAT('c', 200)//'/run' + CALL CD_Native_Path(long_name, native, stat, why, for_output=.TRUE.) + CALL require(stat == CD_PATH_OK .AND. LEN(native) >= LEN(long_name), & + 'a long output name has a runtime spelling: '//TRIM(why)) + IF (stat /= CD_PATH_OK) RETURN + WRITE (*, '(A,I0,A)') ' files that do not open: a runtime spelling of ', LEN(native), ' characters' + CALL require(.NOT. CD_Path_Openable(native//'.out', .TRUE.), 'a name in a missing folder does not open') + CALL CD_Open_Write(unit, native//'.out', ios) + CALL require(ios /= 0, 'writing a long name in a missing folder fails with a status') + CALL CD_Open_Read(unit, native//'.out', ios) + CALL require(ios /= 0, 'reading a long missing name fails with a status') + CALL CD_Open_Input(unit, long_name//'.dat', ios, why) + CALL require(ios /= 0, 'a long missing input fails with a status') + CALL CD_Open_Read(unit, '.', ios) + CALL require(ios /= 0, 'a folder does not open for reading') + CALL write_bytes('reader_long_root.dat', chain_deck(ANCHOR, '', 'FairTen1')) + CALL CD_Run_Deck_Driver('reader_long_root.dat', native, conv, es, em) + CALL require(es /= CD_DECKDRV_OK .AND. INDEX(em, 'cannot open output file') > 0, & + 'a deck run with a long output root in a missing folder reports it: '//TRIM(em(1:200))) + ! a short name still opens, and a write probe leaves the file as it is + CALL CD_Open_Write(unit, 'reader_open_probe.txt', ios) + CALL require(ios == 0, 'a short name opens for writing') + IF (ios /= 0) RETURN + WRITE (unit, '(A)') 'kept' + CLOSE (unit) + CALL require(CD_Path_Openable('reader_open_probe.txt', .TRUE.), 'an existing file opens for writing') + CALL CD_Open_Read(unit, 'reader_open_probe.txt', ios) + CALL require(ios == 0, 'a short name opens for reading') + IF (ios /= 0) RETURN + line = '' + READ (unit, '(A)', IOSTAT=ios) line + CLOSE (unit, STATUS='DELETE') + CALL require(ios == 0 .AND. line == 'kept', 'a write probe leaves the file as it is') + END SUBROUTINE check_files_that_do_not_open + SUBROUTINE check_nonfinite_and_subnormal_values() !! Every number of an OPTIONS row and of a numeric table column must be finite and !! normal: "x < lo .OR. x > hi" is false for NaN, so a NaN must never reach a range diff --git a/tests/test_documentation.py b/tests/test_documentation.py index e87011c2..ca217be3 100644 --- a/tests/test_documentation.py +++ b/tests/test_documentation.py @@ -144,6 +144,20 @@ def test_windows_release_is_publicly_reproducible(self) -> None: build_script.index("integrate_openfast_vs_solution.ps1"), "the host glue patch must be applied before adding the Visual Studio project", ) + # openfast.exe names its OpenFAST base and the CableDyn version, never '-dirty': + # both build routes stamp it, the release build checks it, and the release + # checkout carries the tags `git describe` needs. + integrate_script = ( + ROOT / "integration" / "openfast" / "integrate_openfast_vs_solution.ps1" + ).read_text(encoding="utf-8") + self.assertIn("CreateGitVersion.bat", integrate_script) + self.assertIn("describe --tags --abbrev=8", integrate_script) + version_patch = ( + ROOT / "integration" / "openfast" / "patches" / "0021-version-cmake.patch" + ).read_text(encoding="utf-8") + self.assertIn('-CableDyn-${_cabledyn_version}', version_patch) + self.assertIn("@('-v')", build_script) + self.assertIn("fetch-depth: 0", workflow) self.assertIn("devenv.com", build_script) self.assertIn("Release|x64", build_script) self.assertNotIn('cmake --build `"$ofBuild`"', build_script) diff --git a/tests/test_hermite_cable_dynamic.f90 b/tests/test_hermite_cable_dynamic.f90 index 6d59e505..f23800d9 100644 --- a/tests/test_hermite_cable_dynamic.f90 +++ b/tests/test_hermite_cable_dynamic.f90 @@ -562,7 +562,7 @@ SUBROUTINE check_tensile_safety() TYPE(CD_HermiteCableDynType) :: m REAL(wp), ALLOCATABLE :: l0(:), EAv(:), EIv(:), rhoAv(:), wv(:), seed(:), q_before(:) INTEGER, ALLOCATABLE :: fx(:) - INTEGER :: es, event_count, worst_element + INTEGER :: es, event_count, worst_element, n_before REAL(wp) :: worst_force, worst_threshold, worst_xi, worst_time CHARACTER(300) :: em @@ -580,12 +580,12 @@ SUBROUTINE check_tensile_safety() CALL require(INDEX(em, 'axial compression') > 0, 'tensile-safety diagnostic identifies axial compression') CALL require(nan_max_abs(m%q - q_before) <= TINY(1.0_wp), & 'rejected tensile-safety step does not commit its candidate state') - CALL CD_HermiteCable_Dyn_Recovery_Reset() + n_before = recovered_intervals(m) CALL CD_HermiteCable_Dyn_Step_Recovering(m, 0.01_wp, 20, 1.0e-9_wp, es, em) CALL require(es == CD_HCDYN_NOCONVERGE, 'recovering step preserves tensile-safety rejection') CALL require(INDEX(em, 'tensile qualification failed') > 0 .AND. INDEX(em, 'diverged') == 0, & 'recovering step reports spatial qualification rather than temporal divergence') - CALL require(CD_HermiteCable_Dyn_Recovery_Count() == 0, & + CALL require(recovered_intervals(m) == n_before, & 'tensile-safety rejection does not attempt temporal subdivision') CALL require(nan_max_abs(m%q - q_before) <= TINY(1.0_wp), & 'recovering tensile-safety rejection preserves the committed state') @@ -838,7 +838,6 @@ SUBROUTINE check_recovering_step() CALL require(es == CD_HCDYN_OK, 'recovering identity init m1: '//TRIM(em)) CALL CD_HermiteCable_Dyn_Init(m2, l0, EAv, EIv, rhoAv, wv, seed, fx, 0.0_wp, 0.0_wp, 0.9_wp, es, em) CALL require(es == CD_HCDYN_OK, 'recovering identity init m2: '//TRIM(em)) - CALL CD_HermiteCable_Dyn_Recovery_Reset() pd(1) = 3 DO s = 1, 5 pq(1) = 0.002_wp*REAL(s, wp); pv(1) = 0.002_wp/DTC; pa(1) = 0.0_wp @@ -852,7 +851,7 @@ SUBROUTINE check_recovering_step() CALL require(nan_max_abs(m1%q - m2%q) <= 0.0_wp, 'recovering wrapper q bit-identical on a converging step') CALL require(nan_max_abs(m1%v - m2%v) <= 0.0_wp, 'recovering wrapper v bit-identical on a converging step') CALL require(nan_max_abs(m1%a - m2%a) <= 0.0_wp, 'recovering wrapper a bit-identical on a converging step') - CALL require(CD_HermiteCable_Dyn_Recovery_Count() == 0, 'no recovery on converging steps (count stays 0)') + CALL require(recovered_intervals(m2) == 0, 'no recovery on converging steps (count stays 0)') CALL CD_HermiteCable_Dyn_End(m1) CALL CD_HermiteCable_Dyn_End(m2) @@ -871,16 +870,20 @@ SUBROUTINE check_recovering_step() pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa) CALL require(es == CD_HCDYN_NOCONVERGE, 'recovery probe: plain full step diverges on the hard interval') ! Wrapper on the same interval + same budget: substeps and completes, landing at t+dt on target. + ! the armed step profile counts the recovered interval too (process-wide, with its reset) + CALL CD_HermiteCable_Dyn_Reset_Profile() CALL CD_HermiteCable_Dyn_Recovery_Reset() - n0 = CD_HermiteCable_Dyn_Recovery_Count() + n0 = recovered_intervals(mr) CALL CD_HermiteCable_Dyn_Step_Recovering(mr, DTV, MAXIT_HARD, 1.0e-6_wp, es, em, & pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa) CALL require(es == CD_HCDYN_OK, 'recovery: wrapper completes the violent interval via substepping: '//TRIM(em)) - CALL require(CD_HermiteCable_Dyn_Recovery_Count() == n0 + 1, 'recovery: the substep tripwire incremented') + CALL require(recovered_intervals(mr) == n0 + 1, 'recovery: the substep tripwire incremented') + CALL require(CD_HermiteCable_Dyn_Recovery_Count() == 1, 'recovery: the armed profile counts the interval') CALL require(ABS(mr%q(3) - ZJUMP) < 1.0e-10_wp, 'recovery: prescribed boundary landed exactly on target') CALL require(ABS(mr%t - DTV) < 1.0e-9_wp, 'recovery: cable landed at t+dt (fixed-dt aggregate contract)') CALL CD_HermiteCable_Dyn_Recovery_Reset() CALL require(CD_HermiteCable_Dyn_Recovery_Count() == 0, 'recovery tripwire zero after reset') + CALL CD_HermiteCable_Dyn_Disable_Profile() ! --- (3) a converged full step can still be temporally under-resolved --- CALL CD_HermiteCable_Dyn_Init(mq, l0, EAv, EIv, rhoAv, wv, seed, fx, 0.0_wp, 0.0_wp, 0.9_wp, es, em) @@ -890,11 +893,10 @@ SUBROUTINE check_recovering_step() CALL CD_HermiteCable_Dyn_Step(mq, DTV, 40, 1.0e-6_wp, es, em, & pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa) CALL require(es == CD_HCDYN_OK, 'quality-gate probe: full step is Newton-converged') - CALL CD_HermiteCable_Dyn_Recovery_Reset() CALL CD_HermiteCable_Dyn_Step_Recovering(mrq, DTV, 40, 1.0e-6_wp, es, em, & pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa) CALL require(es == CD_HCDYN_OK, 'quality-gate recovery: under-resolved step subdivides: '//TRIM(em)) - CALL require(CD_HermiteCable_Dyn_Recovery_Count() == 1, & + CALL require(recovered_intervals(mrq) == 1, & 'quality-gate recovery: converged but under-resolved interval counted') CALL require(ABS(mrq%q(3) - ZJUMP) < 1.0e-10_wp, 'quality-gate recovery lands on prescribed target') CALL CD_HermiteCable_Dyn_End(mq) @@ -912,12 +914,11 @@ SUBROUTINE check_recovering_step() ! temporal gate's limit, while each quarter step is resolved (the gate measures ! deformation, so a smaller, nearly rigid rotation of the beam is accepted whole). pq = [-2.0_wp]; pv = [0.3_wp]; pa = [0.1_wp] - CALL CD_HermiteCable_Dyn_Recovery_Reset() CALL CD_HermiteCable_Dyn_Step_Recovering(mk, DTV, 40, 1.0e-6_wp, es, em, & pres_dofs=pd, pres_q=pq, pres_v=pv, pres_a=pa, & max_substeps=4) CALL require(es == CD_HCDYN_OK, 'quintic recovery completes on four substeps: '//TRIM(em)) - CALL require(CD_HermiteCable_Dyn_Recovery_Count() == 1, 'quintic comparison exercised recovery') + CALL require(recovered_intervals(mk) == 1, 'quintic comparison exercised recovery') CALL CD_HermiteCable_Dyn_Get_Recovery_Diagnostics(mk, recovery_events, recovery_max_used, es, em) CALL require(es == CD_HCDYN_OK .AND. recovery_events == 1 .AND. recovery_max_used == 4, & 'recovery diagnostics report the committed interval and winning rung') @@ -1026,6 +1027,14 @@ SUBROUTINE test_quintic_state(q0, v0, a0, q1, v1, a1, duration, u, q, v, a) (3.0_wp*u - 12.0_wp*u2 + 10.0_wp*u3)*a1 END SUBROUTINE test_quintic_state + INTEGER FUNCTION recovered_intervals(model) RESULT(n) + !! The intervals the model completed by internal substeps (its recovery diagnostics). + TYPE(CD_HermiteCableDynType), INTENT(IN) :: model + INTEGER :: max_used, es + CHARACTER(256) :: em + CALL CD_HermiteCable_Dyn_Get_Recovery_Diagnostics(model, n, max_used, es, em) + END FUNCTION recovered_intervals + SUBROUTINE require(cond, label) LOGICAL, INTENT(IN) :: cond CHARACTER(*), INTENT(IN) :: label diff --git a/tests/test_l3_lazywave_dynamic.f90 b/tests/test_l3_lazywave_dynamic.f90 index 703c4fd6..b74083b2 100644 --- a/tests/test_l3_lazywave_dynamic.f90 +++ b/tests/test_l3_lazywave_dynamic.f90 @@ -55,7 +55,7 @@ PROGRAM test_l3_lazywave_dynamic CD_HermiteCable_Dyn_Set_ForceBlend, & CD_HermiteCable_Dyn_Set_Drag, CD_HermiteCable_Dyn_Set_AddedMass, & CD_HermiteCable_Dyn_Step, CD_HermiteCable_Dyn_Step_Recovering, & - CD_HermiteCable_Dyn_Recovery_Count, CD_HermiteCable_Dyn_Recovery_Reset, & + CD_HermiteCable_Dyn_Get_Recovery_Diagnostics, & CD_HermiteCable_Dyn_Curvature_Exact, & CD_HermiteCable_Dyn_End, CD_HCDYN_OK IMPLICIT NONE @@ -752,7 +752,7 @@ SUBROUTINE refined_dynamic_response(l0, q0, eav, eiv, w, rhoa, diam, cdn, cdt, c TYPE(CD_HermiteCableDynType) :: dyn REAL(wp) :: t, z0, zt, vt, at, pq(1), pv(1), pa(1), k, arc, mnorm, tension, axial_now REAL(wp) :: cycle_tsum(3), nodal_curvature(SIZE(l0) + 1) - INTEGER :: pdof(1), step, nscore, cycle_count(3), cycle_index + INTEGER :: pdof(1), step, nscore, cycle_count(3), cycle_index, recovery_max_used CALL CD_HermiteCable_Dyn_Init(dyn, l0, eav, eiv, rhoa, w, q0, fixed, -2000.0_wp, 0.0_wp, 0.5_wp, es, em) IF (es /= CD_HCDYN_OK) RETURN @@ -763,7 +763,6 @@ SUBROUTINE refined_dynamic_response(l0, q0, eav, eiv, w, rhoa, diam, cdn, cdt, c CALL CD_HermiteCable_Dyn_Set_ForceBlend(dyn, force_blend, es, em) IF (es /= CD_HCDYN_OK) THEN; CALL CD_HermiteCable_Dyn_End(dyn); RETURN; END IF z0 = q0(3); pdof = [3] - CALL CD_HermiteCable_Dyn_Recovery_Reset() peak = 0.0_wp; peak_arc = 0.0_wp; tmean = 0.0_wp; minimum_axial = HUGE(1.0_wp) tmin = HUGE(1.0_wp); tmax = -HUGE(1.0_wp); nscore = 0 curvature_profile = 0.0_wp; cycle_peak = 0.0_wp; cycle_tsum = 0.0_wp @@ -802,7 +801,8 @@ SUBROUTINE refined_dynamic_response(l0, q0, eav, eiv, w, rhoa, diam, cdn, cdt, c DO cycle_index = 1, 3 cycle_tmean(cycle_index) = cycle_tsum(cycle_index)/REAL(MAX(1, cycle_count(cycle_index)), wp) END DO - recoveries = CD_HermiteCable_Dyn_Recovery_Count() + ! the model's own count of intervals recovered by substeps + CALL CD_HermiteCable_Dyn_Get_Recovery_Diagnostics(dyn, recoveries, recovery_max_used, es, em) CALL CD_HermiteCable_Dyn_End(dyn) END SUBROUTINE refined_dynamic_response diff --git a/tests/test_of_mooring_counters.f90 b/tests/test_of_mooring_counters.f90 index cb8a1846..47135ac0 100644 --- a/tests/test_of_mooring_counters.f90 +++ b/tests/test_of_mooring_counters.f90 @@ -22,10 +22,10 @@ PROGRAM test_of_mooring_counters !! subdivides) and its reset semantics hold; !! * loads out are finite every step. USE CableDyn_Precision, ONLY: wp - USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_Fallback_Count, CD_AGG_Fallback_Reset, & + CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & CD_AGG_GetMovingPointMesh, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & CD_AGG_End, CD_AGG_OK - USE CableDyn_System, ONLY: CD_System_Fallback_Count, CD_System_Fallback_Reset USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE IMPLICIT NONE @@ -62,8 +62,8 @@ PROGRAM test_of_mooring_counters CALL require(es == CD_AGG_OK, 'initial mesh read') ! reset semantics: the tripwire starts a measured window at zero - CALL CD_System_Fallback_Reset() - CALL require(CD_System_Fallback_Count() == 0, 'fallback tripwire zero after reset') + CALL CD_AGG_Fallback_Reset(agg) + CALL require(CD_AGG_Fallback_Count(agg) == 0, 'fallback tripwire zero after reset') nstep = NINT(DURATION/DTM) w = 2.0_wp*pi/PERIOD @@ -109,11 +109,11 @@ PROGRAM test_of_mooring_counters WRITE (*, '(A,F6.2,A,I0)') 'counters: newton/step mean = ', iter_sum/REAL(nstep, wp), & ' max = ', iter_max - WRITE (*, '(A,I0)') 'counters: substep fallbacks = ', CD_System_Fallback_Count() + WRITE (*, '(A,I0)') 'counters: substep fallbacks = ', CD_AGG_Fallback_Count(agg) CALL require(iter_sum/REAL(nstep, wp) <= MEAN_ITER_GATE, 'mean Newton/step within the band') CALL require(iter_max <= MAX_ITER_GATE, 'max Newton/step within the band') - CALL require(CD_System_Fallback_Count() == 0, 'no substep fallback over the healthy window') + CALL require(CD_AGG_Fallback_Count(agg) == 0, 'no substep fallback over the healthy window') CALL CD_AGG_End(agg, es, em) CALL require(es == CD_AGG_OK, 'aggregate End') diff --git a/tests/test_openfast_touchdown.f90 b/tests/test_openfast_touchdown.f90 index d432050b..b4d53f53 100644 --- a/tests/test_openfast_touchdown.f90 +++ b/tests/test_openfast_touchdown.f90 @@ -7,11 +7,11 @@ PROGRAM test_openfast_touchdown !! a multi-node grounded run (not merely a seabed endpoint), and drives all platform attachments !! through a finite surge/heave trajectory in a uniform current. USE CableDyn_Precision, ONLY: wp - USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, & + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_Fallback_Count, CD_AGG_Fallback_Reset, & + CD_AGG_ModuleType, CD_AGG_Init_From_Deck, & CD_AGG_NMovingPoints, CD_AGG_NFluidNodes, & CD_AGG_GetMovingPointMesh, CD_AGG_SetFluidFields, & CD_AGG_Step_Moving, CD_AGG_CalcOutput, CD_AGG_End, CD_AGG_OK - USE CableDyn_System, ONLY: CD_System_Fallback_Count, CD_System_Fallback_Reset USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE IMPLICIT NONE @@ -67,7 +67,7 @@ PROGRAM test_openfast_touchdown nstep = NINT(DURATION/DT) iter_max = 0 stalled_count = 0 - CALL CD_System_Fallback_Reset() + CALL CD_AGG_Fallback_Reset(agg) DO s = 1, nstep t = REAL(s, wp)*DT phase = omega*t @@ -109,7 +109,7 @@ PROGRAM test_openfast_touchdown EXIT END IF END DO - CALL require(CD_System_Fallback_Count() == 0, 'no EI=0 adaptive-substep fallback at 40 Hz') + CALL require(CD_AGG_Fallback_Count(agg) == 0, 'no EI=0 adaptive-substep fallback at 40 Hz') CALL require(stalled_count == 0, 'no aggregate nonlinear-stall recovery at 40 Hz') CALL require(iter_max <= 40, 'bounded nonlinear iterations over the touchdown trajectory') WRITE (*, '(A,I0,A,I0)') 'touchdown gate: grounded nodes=', grounded_nodes, ', max Newton iterations=', iter_max diff --git a/tests/test_thread_safe_sources.py b/tests/test_thread_safe_sources.py new file mode 100644 index 00000000..442bcd28 --- /dev/null +++ b/tests/test_thread_safe_sources.py @@ -0,0 +1,298 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Source audit of the storage that concurrent models could share. + +Separate models (C API handles, Python objects) may step on several threads at once, so +the Fortran sources of the library and the driver (src/, app/) must keep every model's data +in the model. Compiler-independent checks, so that a gfortran build catches what only an +ifx build would show at run time (test_c_api_threads): + +* no internal procedure is a procedure value (an actual argument, a keyword argument or a + pointer target): ifx calls such a closure through a trampoline kept in memory that every + thread shares; +* no local variable is initialised in its declaration (an implicit SAVE: one copy for every + thread), and no DATA or COMMON; +* every variable in static storage (SAVE, module variables) is one of the reviewed + process-wide entries below, with the reason it is not per-model state; +* the build makes every other local automatic (CMakeLists.txt: /Qauto, -auto, -frecursive; + the OpenFAST Visual Studio project: LocalVariableStorage in every configuration). +""" + +from __future__ import annotations + +import re +import unittest +from collections.abc import Iterator +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +SOURCES = sorted( + list((ROOT / "src").rglob("*.f90")) + list((ROOT / "app").rglob("*.f90")), +) + +# (file, variable): why the process-wide storage is not model state. +REVIEWED_STATIC = { + ("CableDyn_CAPI.f90", "g_handle_registry"): "live-handle registry, under the registry lock", + ("CableDyn_CAPI.f90", "g_handle_count"): "live-handle registry, under the registry lock", + ("CableDyn_OF.f90", "Inst"): "OpenFAST instance registry, resized at initialisation only", + ("CableDyn_OF.f90", "g_serial"): "OpenFAST instance generation counter, at initialisation only", + ("CableDyn_DeckDriver.f90", "body_static_pass_limit"): "test hook of the standalone body statics", + ("CableDyn_DeckDriver.f90", "probe_armed"): "test hook of the standalone multibody march", + ("CableDyn_DeckDriver.f90", "probe_v0"): "test hook of the standalone multibody march", + ("CableDyn_DeckDriver.f90", "probe_w0"): "test hook of the standalone multibody march", + ("CableDyn_DeckDriver.f90", "probe_rec"): "test hook of the standalone multibody march", + ("CableDyn_DeckDriver.f90", "warned"): "warn-once flag of a message, under an OpenMP critical", + ("CableDyn_Profile.f90", "*"): "opt-in run profile (CABLEDYN_PROFILE), written only when armed", + ("CableDyn_HermiteCableDynamic.f90", "prof_*"): "opt-in step profile, written only when armed", + ("cabledyn.f90", "printed"): "the driver program prints its profile once", +} + +DECL = re.compile( + r"^(integer|real|logical|character|complex|double\s+precision|type\s*\(|class\s*\(|procedure\s*\()", + re.I, +) +UNIT = re.compile( + r"^(?:(?:pure|elemental|impure|recursive|non_recursive|module)\s+)*" + r"(?:(?:integer|real|logical|character|complex|double\s+precision|type\s*\([^)]*\))" + r"(?:\s*\([^)]*\))?\s+)?(?:(?:pure|elemental|impure|recursive)\s+)*" + r"(subroutine|function)\s+(\w+)", + re.I, +) + + +def statements(path: Path) -> Iterator[tuple[int, str]]: + """(line number, statement) with comments, continuations and semicolons resolved.""" + buf, start = "", 0 + for no, raw in enumerate(path.read_text(encoding="utf-8").splitlines(), 1): + if raw.lstrip().startswith("#"): + continue + out: list[str] = [] + quote: str | None = None + for ch in raw: + if quote: + out.append(ch) + if ch == quote: + quote = None + elif ch in "'\"": + quote = ch + out.append(ch) + elif ch == "!": + break + else: + out.append(ch) + text = "".join(out).strip() + if not text: + continue + if buf and text.startswith("&"): + text = text[1:] + if not buf: + start = no + if text.endswith("&"): + buf += text[:-1] + " " + continue + line, buf, line_no = buf + text, "", start + for stmt in split_top(line, ";"): + if stmt.strip(): + yield line_no, stmt.strip() + + +def split_top(text: str, sep: str) -> list[str]: + parts: list[str] = [] + cur: list[str] = [] + depth = 0 + quote: str | None = None + for ch in text: + if quote: + cur.append(ch) + if ch == quote: + quote = None + continue + if ch in "'\"": + quote = ch + elif ch in "([": + depth += 1 + elif ch in ")]": + depth -= 1 + elif ch == sep and depth == 0: + parts.append("".join(cur)) + cur = [] + continue + cur.append(ch) + parts.append("".join(cur)) + return parts + + +def without_strings(text: str) -> str: + return re.sub(r"'[^']*'|\"[^\"]*\"", "''", text) + + +class Scope: + def __init__(self, kind: str, name: str) -> None: + self.kind, self.name = kind, name + self.contains = False + self.internal: list[str] = [] + self.declared: set[str] = set() + self.body: list[tuple[int, str, Scope]] = [] + + +def scan(path: Path) -> Iterator[tuple[str, int, str, str]]: + """Yield (kind, line, scope name, detail) findings of one file.""" + stack: list[Scope] = [] + in_type = in_interface = 0 + hosts: list[Scope] = [] + for no, stmt in statements(path): + low = stmt.lower() + if in_interface: + if re.match(r"^end\s*interface\b", low): + in_interface -= 1 + continue + if re.match(r"^(abstract\s+)?interface\b", low): + in_interface += 1 + continue + if in_type: + if re.match(r"^end\s*type\b", low): + in_type -= 1 + continue + if re.match(r"^type\b(?!\s*\()(?!\s+is\b)", low): + in_type += 1 + continue + if re.match(r"^(module|submodule\s*\([^)]*\))\s+\w+\s*$", low) and not re.match( + r"^module\s+(procedure|subroutine|function)\b", low + ): + stack.append(Scope("module", low.split()[-1])) + continue + if re.match(r"^program\s+\w+", low): + stack.append(Scope("program", low.split()[1])) + continue + m = UNIT.match(stmt) + if m and not low.startswith("end"): + if stack and stack[-1].kind in ("unit", "program") and stack[-1].contains: + stack[-1].internal.append(m.group(2).lower()) + stack.append(Scope("unit", m.group(2))) + continue + if re.match(r"^end\s*(subroutine|function|module|program|submodule)\b|^end$", low): + if stack: + done = stack.pop() + if done.kind in ("unit", "program") and done.internal: + hosts.append(done) + continue + if low == "contains": + if stack: + stack[-1].contains = True + continue + unit = next((s for s in reversed(stack) if s.kind in ("unit", "program")), None) + if unit is not None: + for scope in stack: + if scope.kind in ("unit", "program"): + scope.body.append((no, stmt, unit)) + where = unit.name if unit else (stack[-1].name if stack else "?") + if re.match(r"^(data\s+\w|common\b)", low): + yield "DATA/COMMON", no, where, stmt + continue + if re.match(r"^save\b(?!\s*=)", low): + yield "SAVE statement", no, where, stmt + continue + if not DECL.match(stmt) or "::" not in stmt: + continue + attrs, names = stmt.split("::", 1) + attrs_low = attrs.lower() + variables = [m.group(1) for n in split_top(names, ",") if (m := re.match(r"\s*(\w+)", n))] + if unit is not None: + unit.declared.update(v.lower() for v in variables) + if "parameter" in attrs_low: + continue + if unit is not None and unit.kind == "program": + continue # a main program's variables: one program, one thread + if unit is None or re.search(r"\bsave\b", attrs_low): + for name in variables: + yield "STATIC", no, where, name + continue + if "intent" in attrs_low or re.search(r"\bvalue\b", attrs_low): + continue + for item in split_top(names, ","): + body = item.replace("==", "") + if "=" in body: # an initialiser, "=> NULL()" included, implies SAVE + yield "INITIALISED LOCAL", no, where, stmt + break + for host in hosts: + internal_names = set(host.internal) + for no, stmt, inside in host.body: + code = without_strings(stmt).lower() + # in its own body the name is the result; a local declaration hides it + for name in internal_names - {inside.name.lower()} - inside.declared: + for m in re.finditer(r"(?|\w\s*=)$", before) and not re.match(r"^\s*$", before): + yield "CLOSURE", no, host.name, f"{name}: {stmt[:120]}" + + +def reviewed(file: str, name: str) -> bool: + for (f, pattern), _ in REVIEWED_STATIC.items(): + if f != file: + continue + if pattern == "*" or name == pattern: + return True + if pattern.endswith("*") and name.lower().startswith(pattern[:-1].lower()): + return True + return False + + +class ThreadSafeSources(unittest.TestCase): + def setUp(self) -> None: + self.findings = [(p.name, *f) for p in SOURCES for f in scan(p)] + self.assertGreater(len(SOURCES), 40) + + def test_no_closures(self) -> None: + bad = [f for f in self.findings if f[1] == "CLOSURE"] + self.assertEqual(bad, [], "internal procedures passed as procedure values") + + def test_no_implicit_static_storage(self) -> None: + bad = [ + f + for f in self.findings + if f[1] in ("INITIALISED LOCAL", "DATA/COMMON", "SAVE statement") + ] + self.assertEqual(bad, [], "locals in static storage") + + def test_static_storage_is_reviewed(self) -> None: + bad = [f for f in self.findings if f[1] == "STATIC" and not reviewed(f[0], f[4])] + self.assertEqual(bad, [], "static storage not in REVIEWED_STATIC") + n = sum(1 for f in self.findings if f[1] == "STATIC") + print(f"{n} reviewed variables in static storage in {len(SOURCES)} files") + + def test_build_makes_locals_automatic(self) -> None: + cmake = (ROOT / "CMakeLists.txt").read_text(encoding="utf-8") + for flag in ("-frecursive>", "/Qauto>", "-auto>"): + self.assertTrue(flag in cmake, f"CMakeLists.txt does not pass {flag[:-1]}") + # the OpenFAST Visual Studio project compiles the adapter: every configuration too + vfproj = (ROOT / "integration/openfast/vs-build/CableDyn.vfproj.in").read_text( + encoding="utf-8" + ) + tools = re.findall(r"]*>", vfproj) + self.assertGreater(len(tools), 0) + for tool in tools: + self.assertIn('LocalVariableStorage="localStorageAutomatic"', tool) + + def test_audit_sees_a_closure_and_an_initialised_local(self) -> None: + # the checks themselves: a closure and an implicit SAVE in a scratch source + probe = Path(__file__).with_name("thread_safe_probe.f90.tmp") + probe.write_text( + "MODULE m\nCONTAINS\n SUBROUTINE host(x)\n REAL :: x\n INTEGER :: calls = 0\n" + " CALL apply(f, x)\n CALL apply(g=f)\n CONTAINS\n REAL FUNCTION f(y)\n" + " REAL :: y\n f = y + x\n END FUNCTION f\n END SUBROUTINE host\nEND MODULE m\n", + encoding="utf-8", + ) + try: + kinds = [f[0] for f in scan(probe)] + finally: + probe.unlink() + self.assertEqual(kinds.count("CLOSURE"), 2, kinds) + self.assertEqual(kinds.count("INITIALISED LOCAL"), 1, kinds) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_wave_math.f90 b/tests/test_wave_math.f90 new file mode 100644 index 00000000..0e27307d --- /dev/null +++ b/tests/test_wave_math.f90 @@ -0,0 +1,207 @@ +! File: tests/test_wave_math.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_wave_math + !! Gate for the block kernels of CableDyn_WaveMath against an independent oracle, the + !! quadruple-precision intrinsics (a double argument is exact in quadruple precision): + !! 1. sine and cosine of 400,000 phases over |theta| <= 4e4 (the phases of a 3-hour sea) + !! and of 400,000 over 4e4 < |theta| < 2^20 pi/2 (long records, short waves) within 3 ulp + !! of the correctly rounded values, and the identities sin^2 + cos^2 = 1 to 4 ulp and + !! sin(-theta) = -sin(theta), cos(-theta) = cos(theta) bit for bit; + !! 2. the quadrant boundaries (theta = n pi/2 rounded, n up to 2^19) and tiny phases + !! (sin theta = theta, cos theta = 1 below 2^-27, signed zero kept); at the double + !! nearest n pi/2 for every 1 <= n < 2^20, where sine or cosine falls to the distance from + !! the multiple (down to 6.2e-19), the error within the reduction's bound: 3 ulp of the + !! value plus |n| 8.5e-32, the part of pi/2 below P1 + P2 + P3 (with P3 dropped the + !! error would be |n| 2e-21, with P3 rounded to 53 bits n P3 inexact); + !! 3. exp over -745 <= x <= 709 within 2 ulp (in the normal range; the ulp from the + !! exponent, since SPACING returns TINY below 2^-969), the subnormal tail and underflow + !! to zero as the intrinsic gives them, exp(0) = 1; + !! 4. phases beyond the reduction's range (|theta| > 2^20 pi/2) take the intrinsic (to 1e-6: + !! a clamped reduction would be off by O(1)); + !! 5. a NaN argument gives NaN (sine, cosine and exponential) and an infinite phase NaN, as + !! the intrinsics: the clamp to the reduction's range must not turn a NaN into a finite + !! value (gfortran's MIN and MAX return the non-NaN argument). + USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: INT64 + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN, IEEE_POSITIVE_INF, IEEE_IS_NAN + USE CableDyn_Precision, ONLY: wp + USE CableDyn_WaveMath, ONLY: CD_Wave_SinCos, CD_Wave_Exp + IMPLICIT NONE + INTEGER, PARAMETER :: qp = SELECTED_REAL_KIND(30) + INTEGER, PARAMETER :: N = 400000 + INTEGER :: nfail, i + REAL(wp), ALLOCATABLE :: th(:), s(:), c(:), x(:), e(:), s2(:), c2(:), tb(:), sb(:), cb(:) + REAL(wp) :: ulp_s, ulp_c, ulp_e, ulp_id, pi_wp + REAL(qp) :: pi_q, sq, cq + REAL(wp), PARAMETER :: THETA_MAX = 1.6470993291652855e6_wp ! 2^20 pi/2 + + nfail = 0 + ALLOCATE (th(N), s(N), c(N), x(N), e(N), s2(N), c2(N)) + ! 1. phases over |theta| <= 4e4, with irrational spacing + DO i = 1, N + th(i) = -4.0e4_wp + 8.0e4_wp*REAL(i, wp)/REAL(N, wp) + 1.0e-7_wp*REAL(i, wp)*SQRT(2.0_wp) + END DO + CALL CD_Wave_SinCos(N, th, s, c) + ulp_s = 0.0_wp + ulp_c = 0.0_wp + ulp_id = 0.0_wp + DO i = 1, N + ulp_s = MAX(ulp_s, ulp_error(s(i), SIN(REAL(th(i), qp)))) + ulp_c = MAX(ulp_c, ulp_error(c(i), COS(REAL(th(i), qp)))) + ulp_id = MAX(ulp_id, REAL(ABS(REAL(s(i), qp)**2 + REAL(c(i), qp)**2 - 1.0_qp), wp)/EPSILON(1.0_wp)) + END DO + WRITE (*, '(A,F6.3,A,F6.3,A,F6.3,A)') ' sin, cos over |theta| <= 4e4: max error ', ulp_s, ' and ', ulp_c, & + ' ulp; sin^2 + cos^2 - 1 within ', ulp_id, ' ulp' + CALL require(ulp_s <= 3.0_wp .AND. ulp_c <= 3.0_wp, 'sine and cosine within 3 ulp') + CALL require(ulp_id <= 4.0_wp, 'sin^2 + cos^2 = 1 within 4 ulp') + x = -th ! (not -th as the actual argument: a 3 MB temporary on the stack) + CALL CD_Wave_SinCos(N, x, s2, c2) + CALL require(ALL(s2 == -s) .AND. ALL(c2 == c), 'sine odd and cosine even bit for bit') + ! 1b. 4e4 < |theta| < 2^20 pi/2, geometric spacing, alternating sign + DO i = 1, N + th(i) = 4.0e4_wp*(0.99999_wp*THETA_MAX/4.0e4_wp)**(REAL(i, wp)/REAL(N, wp)) + IF (MOD(i, 2) == 0) th(i) = -th(i) + END DO + CALL CD_Wave_SinCos(N, th, s, c) + ulp_s = 0.0_wp + ulp_c = 0.0_wp + DO i = 1, N + ulp_s = MAX(ulp_s, ulp_error(s(i), SIN(REAL(th(i), qp)))) + ulp_c = MAX(ulp_c, ulp_error(c(i), COS(REAL(th(i), qp)))) + END DO + WRITE (*, '(A,F6.3,A,F6.3,A)') ' sin, cos over 4e4 < |theta| < 2^20 pi/2: max error ', ulp_s, ' and ', ulp_c, & + ' ulp' + CALL require(ulp_s <= 3.0_wp .AND. ulp_c <= 3.0_wp, 'sine and cosine within 3 ulp up to 2^20 pi/2') + + ! 2. quadrant boundaries and tiny phases + pi_wp = 4.0_wp*ATAN(1.0_wp) + pi_q = 4.0_qp*ATAN(1.0_qp) + DO i = 1, 2000 + th(i) = REAL(REAL(MOD(i*262, 524288) - 262144, qp)*pi_q/2.0_qp, wp) + END DO + CALL CD_Wave_SinCos(2000, th, s, c) + ulp_s = 0.0_wp + DO i = 1, 2000 + ulp_s = MAX(ulp_s, abs_error(s(i), SIN(REAL(th(i), qp)), REAL(th(i), qp)), & + abs_error(c(i), COS(REAL(th(i), qp)), REAL(th(i), qp))) + END DO + WRITE (*, '(A,ES9.2)') ' at the quadrant boundaries (|n| <= 2^18): max |error| / ulp(theta) ', ulp_s + CALL require(ulp_s <= 1.0_wp, 'quadrant boundaries: error below ulp(theta)') + ! the double nearest n pi/2: the smallest sines and cosines the reduction meets + ALLOCATE (tb(2**20 - 1), sb(2**20 - 1), cb(2**20 - 1)) + DO i = 1, 2**20 - 1 + tb(i) = REAL(REAL(i, qp)*pi_q/2.0_qp, wp) + END DO + CALL CD_Wave_SinCos(2**20 - 1, tb, sb, cb) + ulp_s = 0.0_wp + ulp_c = 0.0_wp + DO i = 1, 2**20 - 1 + sq = SIN(REAL(tb(i), qp)) + cq = COS(REAL(tb(i), qp)) + ulp_s = MAX(ulp_s, ulp_error(sb(i), sq), ulp_error(cb(i), cq)) + ulp_c = MAX(ulp_c, REAL(ABS(REAL(sb(i), qp) - sq)/(3.0_qp*ulp_q(REAL(sq, wp)) + REAL(i, qp)*8.5e-32_qp), wp), & + REAL(ABS(REAL(cb(i), qp) - cq)/(3.0_qp*ulp_q(REAL(cq, wp)) + REAL(i, qp)*8.5e-32_qp), wp)) + END DO + WRITE (*, '(A,ES9.2,A,F6.3,A,ES9.2,A)') ' at the doubles nearest n pi/2 (1 <= n < 2^20): max error ', ulp_s, & + ' ulp, ', ulp_c, ' of 3 ulp + |n| 8.5e-32 (|sin| or |cos| down to ', MINVAL(MIN(ABS(sb), ABS(cb))), ')' + CALL require(ulp_c <= 1.0_wp, 'nearest n pi/2: within 3 ulp + |n| 8.5e-32') + DEALLOCATE (tb, sb, cb) + th(1:4) = [0.0_wp, -0.0_wp, 1.0e-10_wp, -2.0_wp**(-30)] + CALL CD_Wave_SinCos(4, th, s, c) + ! the sign bits themselves: ifx's SIGN treats -0 as +0 by default (/assume:nominus0) + CALL require(s(1) == 0.0_wp .AND. s(2) == 0.0_wp .AND. .NOT. BTEST(TRANSFER(s(1), 0_INT64), 63) .AND. & + BTEST(TRANSFER(s(2), 0_INT64), 63), 'sin(+-0) = +-0') + CALL require(ALL(c(1:4) == 1.0_wp) .AND. s(3) == th(3) .AND. s(4) == th(4), 'tiny phases: sin = theta, cos = 1') + + ! 3. exponential + DO i = 1, N + x(i) = -745.0_wp + 1454.0_wp*REAL(i, wp)/REAL(N, wp) + 1.0e-9_wp*REAL(i, wp) + END DO + x(N) = 0.0_wp + CALL CD_Wave_Exp(N, x, e) + ulp_e = 0.0_wp + DO i = 1, N + IF (x(i) >= -708.0_wp .AND. x(i) <= 709.0_wp) THEN + ulp_e = MAX(ulp_e, ulp_error(e(i), EXP(REAL(x(i), qp)))) + ELSE + CALL require(e(i) == EXP(x(i)), 'exp outside the normal range is the intrinsic') + END IF + END DO + WRITE (*, '(A,F6.3,A)') ' exp over -708 <= x <= 709: max error ', ulp_e, ' ulp' + CALL require(ulp_e <= 2.0_wp, 'exp within 2 ulp') + CALL require(e(N) == 1.0_wp, 'exp(0) = 1') + x(1:3) = [-745.2_wp, -800.0_wp, -720.0_wp] + CALL CD_Wave_Exp(3, x, e) + CALL require(e(1) == EXP(x(1)) .AND. e(2) == 0.0_wp .AND. e(3) == EXP(x(3)) .AND. e(3) > 0.0_wp, & + 'subnormal tail and underflow as the intrinsic') + + ! 4. beyond the reduction's range + th(1:3) = [2.0e6_wp, -3.5e7_wp, 1.0e9_wp] + CALL CD_Wave_SinCos(3, th, s, c) + ulp_s = 0.0_wp + DO i = 1, 3 + ulp_s = MAX(ulp_s, REAL(ABS(REAL(s(i), qp) - SIN(REAL(th(i), qp))), wp), & + REAL(ABS(REAL(c(i), qp) - COS(REAL(th(i), qp))), wp)) + END DO + WRITE (*, '(A,ES9.2)') ' beyond 2^20 pi/2 (the intrinsic): max |error| ', ulp_s + CALL require(ulp_s <= 1.0e-6_wp, 'phases beyond 2^20 pi/2 are not reduced as near ones') + + ! 5. NaN and infinite arguments, alone and within a block of finite ones + th(1:5) = [0.5_wp, IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN), 1.0e3_wp, -IEEE_VALUE(1.0_wp, IEEE_POSITIVE_INF), 2.0_wp] + CALL CD_Wave_SinCos(5, th, s, c) + WRITE (*, '(A,4ES11.3)') ' sin, cos of NaN and of -Inf: ', s(2), c(2), s(4), c(4) + CALL require(IEEE_IS_NAN(s(2)) .AND. IEEE_IS_NAN(c(2)) .AND. IEEE_IS_NAN(s(4)) .AND. IEEE_IS_NAN(c(4)), & + 'sine and cosine of NaN and of an infinite phase are NaN') + CALL require(ABS(REAL(s(3), qp) - SIN(REAL(th(3), qp))) <= REAL(4.0_wp*SPACING(1.0_wp), qp), & + 'finite phases of the same block unaffected') + x(1:3) = [-1.0_wp, IEEE_VALUE(1.0_wp, IEEE_QUIET_NAN), 2.0_wp] + CALL CD_Wave_Exp(3, x, e) + WRITE (*, '(A,ES11.3)') ' exp of NaN: ', e(2) + CALL require(IEEE_IS_NAN(e(2)) .AND. .NOT. IEEE_IS_NAN(e(1)) .AND. .NOT. IEEE_IS_NAN(e(3)), 'exp of NaN is NaN') + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'test_wave_math: ', nfail, ' check(s) FAILED' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'test_wave_math: all checks passed' + +CONTAINS + + REAL(wp) FUNCTION ulp_error(value, exact) RESULT(ulps) + !! |value - exact| in units of the last place of the correctly rounded exact value. + REAL(wp), INTENT(IN) :: value + REAL(qp), INTENT(IN) :: exact + REAL(wp) :: rounded + rounded = REAL(exact, wp) + IF (rounded == 0.0_wp) THEN + ulps = REAL(ABS(REAL(value, qp) - exact), wp)/TINY(1.0_wp) + ELSE + ulps = REAL(ABS(REAL(value, qp) - exact)/ulp_q(rounded), wp) + END IF + END FUNCTION ulp_error + + REAL(qp) FUNCTION ulp_q(r) RESULT(u) + !! The spacing of the doubles at r, 2^(e - 53), down to the subnormal spacing 2^-1074 (SPACING + !! returns TINY wherever that spacing is subnormal, below 2^-969). + REAL(wp), INTENT(IN) :: r + u = SCALE(1.0_qp, MAX(EXPONENT(r), MINEXPONENT(r)) - DIGITS(r)) + END FUNCTION ulp_q + + REAL(wp) FUNCTION abs_error(value, exact, arg) RESULT(rel) + !! |value - exact| over ulp(arg): near a zero of sine or cosine the phase's own rounding + !! (half an ulp of theta) bounds what any evaluation can resolve. + REAL(wp), INTENT(IN) :: value + REAL(qp), INTENT(IN) :: exact, arg + rel = REAL(ABS(REAL(value, qp) - exact)/REAL(SPACING(MAX(1.0_wp, REAL(ABS(arg), wp))), qp), wp) + END FUNCTION abs_error + + SUBROUTINE require(cond, label) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: label + IF (.NOT. cond) THEN + nfail = nfail + 1 + WRITE (*, '(A)') 'FAIL: '//label + END IF + END SUBROUTINE require + +END PROGRAM test_wave_math From 4fd6a720eec571afdcfae1338d63993d8956934b Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 13:54:33 +0900 Subject: [PATCH 32/51] fix(cable): one Newton tolerance for a finite-EI cable on every route (#81) ## Summary A finite-EI cable on the coupled aggregate (a mixed `EI = 0` + finite-EI standalone deck, OpenFAST `CompMooring = 5`, FAST.Farm, the C API) stepped to a fixed relative Newton tolerance of 5e-3 (200 iterations), whatever the deck's `dynamic_solver` row said; the same cable alone in a deck stepped to the deck's tolerance (default 1e-8, 30 iterations). Every route now takes the deck's `rel` and `max_iter`, and the static start `min(1e-6, rel)`. ## What the loose step did - **Silent wrong tensions.** A lazy cable beside a chain, both fairleads moved 3.5 m: at `rhoInf` 1, `dtM` 0.05 s the mixed route's fairlead tension peaked at 4.3e5 N (anchor 5.5e5 N) against 1.9e4 N (2.1e3 N) for the cable alone; at `dtM` 0.1 s it fell to 8307 N against 10 799 N and the fairlead bend moment rose to 1612 against 3.9 N m (robustness campaign D03). - **A non-dissipative coupled cable.** Held at both ends in still water, the residual each step left grew at `rhoInf` 0.4 into a sustained oscillation (+-14 N at 8 Hz on 1.2e4 N on the IEA-15 MW mixed cable, also inside OpenFAST), and at `rhoInf` 1 the march diverged (6.1e5 N within 5 s) (end-to-end validation E2E-D2). On that reproducer the held cable now stays constant (0 N range over the second half of 80 s at `rhoInf` 0.4, and at `rhoInf` 1). Now the routes, and the C API, OpenFAST and FAST.Farm builds driven through the same motion, agree to 5e-8 of the peak tension; a seeded disturbance decays as on the single-line route. ## Also - The standalone vessel march passed `TRANSPOSE(motion%rot(...))` as an orientation argument every step, which the compiler packed into a heap temporary; the DCM is formed in a local array (gate `step_allocations_driver_vessel`). - `mixed_route_currents` (#79) needed a 2e-3 cable tolerance only because of the loose coupled step; its driver-level comparison now agrees exactly and the gate is at 1e-6. ## Cost About 2.0 tangent factorisations per coupled cable step instead of 1.1: the aggregate step of the IEA-15 MW mixed example takes 38 % more CPU time. ## Checks - New test `coupled_cable_tolerance` (gates 1-3: mixed vs single-line route at `rhoInf` 1 / `dtM` 0.05 and `rhoInf` 0.4 / `dtM` 0.1; C API, OpenFAST and FAST.Farm builds; held and seeded cables at `rhoInf` 0, 0.4, 1), each failing on the old code. - ctest 350 of 350; checked Debug build (`-fcheck=all`) on the 13 touched tests; example A/B 53 of 53 identical; pre-commit, Sphinx `-W`, no duplicate `PUBLIC`. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 19 + CMakeLists.txt | 20 +- doc/driver_format.md | 2 +- doc/options.rst | 13 +- src/CableDyn_DeckDriver.f90 | 55 +-- tests/allocation_phase_counter.c | 46 +++ tests/test_coupled_cable_tolerance.f90 | 529 +++++++++++++++++++++++++ tests/test_mixed_route_currents.f90 | 20 +- tests/test_mixed_route_torsion.f90 | 10 +- tests/test_openfast_aggregate.f90 | 18 +- tests/test_step_allocations.f90 | 98 ++++- 11 files changed, 770 insertions(+), 60 deletions(-) create mode 100644 tests/allocation_phase_counter.c create mode 100644 tests/test_coupled_cable_tolerance.f90 diff --git a/CHANGELOG.md b/CHANGELOG.md index a102a6f1..ba47391b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -432,6 +432,25 @@ All notable changes to CableDyn are recorded in this file. The format follows the statics matrix overflowed the 1 MiB stack of an MSVC-linked program. Every ifx build now compiles with `/heap-arrays:1024` (`-heap-arrays 1024` off Windows), as the static release and the OpenFAST Visual Studio project did; the static release is unchanged. +- A finite-EI cable on the coupled aggregate (a mixed `EI = 0` + finite-EI standalone deck, + OpenFAST `CompMooring = 5`, FAST.Farm and the C API) stepped to a fixed relative Newton + tolerance of 5e-3 (200 iterations) whatever the deck's `dynamic_solver` row said, and its static + start to 1e-6; the same cable alone in a deck stepped to the deck's tolerance (default 1e-8, 30 + iterations). Every route now takes the deck's `rel` and `max_iter` and the static tolerance + `min(1e-6, rel)`. A lazy cable beside a chain, both fairleads moved 3.5 m from rest: at + `rhoInf` 1, `dtM` 0.05 s the mixed route's fairlead tension peaked at 4.3e5 N (anchor 5.5e5 N) + against 1.9e4 N (2.1e3 N) for the cable alone; at `dtM` 0.1 s it fell to 8307 N against + 10799 N and the fairlead bend moment rose to 1612 against 3.9 N m. The routes, and the C API, + OpenFAST and FAST.Farm builds driven through the same motion, now agree to 5e-8 of the peak + tension. The loose steps also made the coupled cable non-dissipative: held at both ends in still + water, the residual each step left grew at `rhoInf` 0.4 into a sustained oscillation (+-2.1 N on + 1.5e4 N in 10 s on that cable; +-14 N at 8 Hz on 1.2e4 N on the IEA-15 MW mixed cable, also in + OpenFAST `CompMooring = 5`), and at `rhoInf` 1 a seeded march diverged; the held cable + now stays at its static tensions to 6e-5 N and a seeded one decays as on the single-line route. + On the default `rhoInf` 0.4 under motion the difference was 4.7e-4 of the anchor tension, and + the IEA-15 MW mixed example in a 60 s platform motion changes by 1.6e-6 of its cable tension. + Cost: a coupled cable step takes about 2.0 tangent factorisations instead of 1.1, and the + aggregate step of that example (chains included) 38 % more CPU time (the D03 deck: 19 %). - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index de683382..7e462550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1302,6 +1302,15 @@ target_link_libraries(test_c_api PRIVATE cabledyn_core) add_test(NAME c_api COMMAND test_c_api) set_tests_properties(c_api PROPERTIES LABELS "fortran;unit;dynamic;capi") +# One Newton tolerance for a finite-EI cable on every route: the mixed deck's cable (coupled +# aggregate) against the same cable alone (standalone cubic-Hermite route) at rhoInf 1 / dtM 0.05 +# and rhoInf 0.4 / dtM 0.1, and the C API, OpenFAST and FAST.Farm builds of the aggregate driven +# by a host through the same motion, against the driver. +add_executable(test_coupled_cable_tolerance tests/test_coupled_cable_tolerance.f90) +target_link_libraries(test_coupled_cable_tolerance PRIVATE cabledyn_core) +add_test(NAME coupled_cable_tolerance COMMAND test_coupled_cable_tolerance $) +set_tests_properties(coupled_cable_tolerance PROPERTIES LABELS "fortran;driver;integration;dynamic;capi;openfast") + # Compile and run through the installed-style C header against the SHARED ABI # product. This catches missing Windows exports, C/Fortran prototype drift, ABI # version drift, and loader failures that the Fortran-native lifecycle gate cannot. @@ -1513,9 +1522,12 @@ set_tests_properties(memory_growth_aggregate PROPERTIES LABELS "fortran;openfast # Zero heap allocations in the per-step aggregate advance after warm-up, counted through # GNU ld --wrap malloc/calloc/realloc wrappers (GNU toolchains only). if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GNU") - add_executable(test_step_allocations tests/test_step_allocations.f90 tests/allocation_counter.c) + add_executable(test_step_allocations tests/test_step_allocations.f90 tests/allocation_counter.c + tests/allocation_phase_counter.c) target_link_libraries(test_step_allocations PRIVATE cabledyn_core) - target_link_options(test_step_allocations PRIVATE "-Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc") + # the phase window of a whole driver run (tests/allocation_phase_counter.c) wraps CD_Profile_Enter + target_link_options(test_step_allocations PRIVATE + "-Wl,--wrap=malloc,--wrap=calloc,--wrap=realloc,--wrap=__cabledyn_profile_MOD_cd_profile_enter") add_test(NAME step_allocations COMMAND test_step_allocations ${CMAKE_CURRENT_SOURCE_DIR}/examples/iea15mw_umaine_mixed_cabledyn.dat 200.0 200) @@ -1546,6 +1558,10 @@ if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_ID STREQUAL "GN # And with the nodal twist of a line free in torsion at one end. add_test(NAME step_allocations_torsion_one_end COMMAND test_step_allocations free) set_tests_properties(step_allocations_torsion_one_end PROPERTIES LABELS "fortran;dynamic;memory") + # The standalone driver's march of a finite-EI line on the cubic-Hermite route moved by a vessel, + # run in process: the step phase of every step after warm-up. + add_test(NAME step_allocations_driver_vessel COMMAND test_step_allocations driver_vessel) + set_tests_properties(step_allocations_driver_vessel PROPERTIES LABELS "fortran;driver;dynamic;memory") endif() add_executable(test_snap_load tests/test_snap_load.f90) diff --git a/doc/driver_format.md b/doc/driver_format.md index 1512b826..41d49e02 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -1276,7 +1276,7 @@ syntax form. The most frequently edited keywords are: | `ei0_substep_max` | integer from 2 to 1024; most sub-steps `auto` takes for one step | `16` | | `axial_quadrature_order` | Gauss order 1–6 for the finite-EI axial energy; a value different from the bending order gives selective integration | `4` | | `bending_quadrature_order` | Gauss order 1–6 for the finite-EI curvature energy | `4` | -| `dynamic_solver rel abs max_iter backtracks [rhoInf]` | dynamic Newton controls; keyword-first syntax, unlike scalar rows. `EI = 0` solves use all four; standalone finite-EI decks use `rel` and `max_iter` (coupled cables: see the OPTIONS reference). Choose them for the mesh and load case; the 952-element Gulf of Maine example uses `1e-4 1e-14 100 12` | `1e-8 1e-14 30 12` | +| `dynamic_solver rel abs max_iter backtracks [rhoInf]` | dynamic Newton controls; keyword-first syntax, unlike scalar rows. `EI = 0` solves use all four; finite-EI cables use `rel` and `max_iter` on every route (standalone, mixed, OpenFAST, FAST.Farm, C API). Choose them for the mesh and load case; the 952-element Gulf of Maine example uses `1e-4 1e-14 100 12` | `1e-8 1e-14 30 12` | | `current` | `none current` / `uniform vx vy vz current` / `profile z1 vx1 vy1 vz1 z2 vx2 vy2 vz2 current`; included in the static initial condition. Standalone only | none | | `waves` | `none waves` / `airy H T dir waves` / `stream H T dir waves` (`dean`; regular nonlinear stream-function wave) / `jonswap Hs Tp gamma dir waves` / `pm Hs Tp dir waves` (`issc`, `bretschneider`) / `torsethaugen Hs Tp dir waves` / `ochihubble Hs1 Tp1 lambda1 Hs2 Tp2 lambda2 dir waves`. Standalone only | none | | `wavetrain` | one train of a multi-train sea, rows add up (at most 16): `airy H T dir wavetrain`, `jonswap Hs Tp gamma dir s wavetrain`, `pm Hs Tp dir s wavetrain`, `torsethaugen Hs Tp dir s wavetrain`, `ochihubble Hs1 Tp1 lambda1 Hs2 Tp2 lambda2 dir s wavetrain`; `s` is the cos-2s spreading exponent (`0` long-crested). Excludes a `waves` row | none | diff --git a/doc/options.rst b/doc/options.rst index 2564dbd5..cc59b65b 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -338,13 +338,12 @@ rejected as unknown. The dynamic Newton controls are set with ``dynamic_solver`` - ``1e-8 1e-14 30 12`` - ``rel`` and ``abs`` finite and > 0; ``max_iter`` an integer ≥ 1; ``backtracks`` an integer ≥ 0; the optional sixth token sets ``rhoInf`` (same range). ``EI = 0`` dynamic solves - use all four controls. A standalone finite-EI (Hermite) deck uses only ``rel`` and - ``max_iter`` for each step (``abs`` and ``backtracks`` are ignored on this route) and - converges its static equilibrium to at least ``min(1e-6, rel)``. Finite-EI cables in - OpenFAST and in mixed ``EI = 0`` + finite-EI standalone decks do not read ``rel``, - ``abs``, ``max_iter`` or ``backtracks``: they use a fixed step tolerance (relative - ``5e-3``, 200 Newton iterations) and a ``1e-6`` static tolerance; only the optional - ``rhoInf`` token applies to them. Use controls qualified for + use all four controls. A finite-EI (Hermite) cable uses only ``rel`` and ``max_iter`` + for each step (``abs`` and ``backtracks`` are ignored on this route) and converges its + static equilibrium to at least ``min(1e-6, rel)``, on every route: alone in a standalone + deck, in a mixed ``EI = 0`` + finite-EI standalone deck, in OpenFAST + (``CompMooring = 5``), in FAST.Farm and behind the C API, so a cable driven by the same + motion steps to the same state on each. Use controls qualified for the mesh and load case; the maintained 952-element Gulf of Maine cable uses ``1e-4 1e-14 100 12`` - both (see rules) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index b1731ce3..79e3d75a 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -1601,6 +1601,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, INTEGER, INTENT(OUT) :: coupled_node INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + ! TRUE: a standalone build (its notes printed, a Fixed End A admitted). FALSE: a static helper + ! build inside this one (still-water, light-line, coarse pass), whose cable is never stepped: + ! its static tolerance stays at COUPLED_STATIC_TOL. Absent: a coupled build (aggregate, OpenFAST, + ! FAST.Farm, C API, mixed deck). Every build that is stepped takes the deck's dynamic_solver + ! rel and max_iter, so a cable steps to the same Newton tolerance on every route. LOGICAL, INTENT(IN), OPTIONAL :: standalone_controls TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry REAL(wp), INTENT(IN), OPTIONAL :: fairlead_orientation(3, 3) @@ -1651,8 +1656,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, REAL(wp) :: step_tol, static_tol, static_tol_target REAL(wp), ALLOCATABLE :: q_coupled_tol(:) INTEGER :: polish_iters - ! Static tolerance of the coupled route (step_tol 5e-3 there), on which the mesh- - ! sequenced hierarchy's intermediate readiness and recovery budgets are exercised. + ! Loosest static tolerance (that of a static helper build), on which the mesh-sequenced + ! hierarchy's intermediate readiness and recovery budgets are exercised. REAL(wp), PARAMETER :: COUPLED_STATIC_TOL = 1.0e-6_wp ! Newton-iteration budget of one mesh-sequenced fallback solve: a bounded failure path. INTEGER, PARAMETER :: FALLBACK_SEQUENCE_BUDGET = 2000 @@ -1724,8 +1729,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ErrStat = CD_DECKDRV_OK ErrMsg = '' - step_max_iter = 200 - step_tol = 5.0e-3_wp + step_max_iter = opts%dynamic_max_iter + step_tol = opts%dynamic_rel_tol standalone_mode = .FALSE. weightless_bow = .FALSE. contact_enabled = .FALSE. @@ -1774,20 +1779,19 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, end_b_dcm = end_b_orientation END IF contact_z = -2000.0_wp - IF (PRESENT(standalone_controls)) THEN - IF (standalone_controls) THEN - standalone_mode = .TRUE. - step_max_iter = opts%dynamic_max_iter - step_tol = opts%dynamic_rel_tol - END IF - END IF - fixed_fairlead_ok = standalone_mode - IF (PRESENT(fixed_fairlead)) fixed_fairlead_ok = fixed_fairlead_ok .OR. fixed_fairlead ! Hand the dynamic integrator an equilibrium converged at least as tightly as ! its own Newton stopping criterion. A looser static tolerance can otherwise ! appear as an artificial load impulse on the first nominally stationary step, ! particularly after local refinement of a light, bending-stiff cable. static_tol = MIN(COUPLED_STATIC_TOL, step_tol) + IF (PRESENT(standalone_controls)) THEN + standalone_mode = standalone_controls + ! a static helper build is never stepped: the static state it hands back is the one of + ! the loosest static tolerance, as before (the parent build polishes its own) + IF (.NOT. standalone_controls) static_tol = COUPLED_STATIC_TOL + END IF + fixed_fairlead_ok = standalone_mode + IF (PRESENT(fixed_fairlead)) fixed_fairlead_ok = fixed_fairlead_ok .OR. fixed_fairlead contact_enabled = opts%has_wtrdpth .OR. PRESENT(bathymetry) IF (opts%has_wtrdpth) contact_z = -opts%wtrdpth IF (PRESENT(bathymetry)) THEN @@ -3093,11 +3097,12 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ' attachment(s) lumped at the nearest nodes (largest arc offset ', att_offset, ' m)' CALL report_note(note_text) END IF - ! Dynamic step controls: a relative Newton tolerance of 5e-3 (0.5% of the physical weight - ! force scale, on the coupling boundary) with a generous iteration budget. This is the - ! usual order for a coupling-boundary force residual; a stiffer 1e-4/1e-3 would demand a - ! static seed tighter than the static solve delivers and add - ! no coupling-force accuracy. The 1e-6 static seed sits far inside it at rest. + ! Dynamic step controls: the deck's dynamic_solver relative tolerance and iteration budget + ! (default 1e-8 and 30) on every route, standalone or coupled, so that a cable driven by the + ! same motion steps to the same state on each. The tolerance is not a coupling-force accuracy + ! alone: at rhoInf near 1 the march does not damp the residual a step leaves in the modes dtM + ! does not resolve, and a lazy wave stepped to 5e-3 under the same motion peaked at 4.3e5 N + ! against 1.9e4 N (the subdivision ladder takes the steps that do not converge in max_iter). CALL CD_HFMF_Init(cable, l0, ea, ei, rho_a, w, q_static, dynamic_fixed_dofs, contact_z, CD_ZERO, & opts%rho_inf, dt, coupled_node, es, em, max_iter=step_max_iter, tol=step_tol, & frame_cs=frame_cs, axial_quadrature_order=opts%axial_quadrature_order, & @@ -31030,12 +31035,14 @@ SUBROUTINE write_hermite_dynamic_out(out_root, channels, lines, points, opts, ca 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); a moving End B rides on the - ! same vessel + ! same vessel. The DCM is formed in a local array: TRANSPOSE as an actual argument is + ! a strided view the compiler packs into a heap temporary at every step. + dcm_a = TRANSPOSE(motion%rot(:, :, step + 1)) CALL hermite_step_ends(cables(i), up, uv, ua, ubp, ubv, uba, es, em, & - u_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), & + u_orientation=dcm_a, & u_angular_velocity=motion%omega(:, step + 1), & u_angular_acceleration=motion%alpha(:, step + 1), & - ub_orientation=TRANSPOSE(motion%rot(:, :, step + 1)), & + ub_orientation=dcm_a, & ub_angular_velocity=motion%omega(:, step + 1), & ub_angular_acceleration=motion%alpha(:, step + 1)) ELSE IF (motion%has_turb_rot) THEN @@ -31493,11 +31500,13 @@ SUBROUTINE apply_motion_to_hermite_cables(cables, lines, points, motion, time_in END IF IF (motion%has_rot) THEN ! vessel motion: an end connection at the fairlead (and at a moving End B) turns with the vessel + ! (the DCM in a local array, as in the march: no packed temporary) + dcm_a = TRANSPOSE(motion%rot(:, :, time_index)) CALL hermite_set_ends(cables(i), q, v, a, qb, vb, ab, es, em, & - u_orientation=TRANSPOSE(motion%rot(:, :, time_index)), & + u_orientation=dcm_a, & u_angular_velocity=motion%omega(:, time_index), & u_angular_acceleration=motion%alpha(:, time_index), & - ub_orientation=TRANSPOSE(motion%rot(:, :, time_index)), & + ub_orientation=dcm_a, & ub_angular_velocity=motion%omega(:, time_index), & ub_angular_acceleration=motion%alpha(:, time_index)) ELSE IF (motion%has_turb_rot) THEN diff --git a/tests/allocation_phase_counter.c b/tests/allocation_phase_counter.c new file mode 100644 index 00000000..bbe82e0a --- /dev/null +++ b/tests/allocation_phase_counter.c @@ -0,0 +1,46 @@ +/* File: tests/allocation_phase_counter.c + * SPDX-License-Identifier: Apache-2.0 + * Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University + * + * Phase window of the allocation counter (tests/allocation_counter.c) for a whole standalone + * driver run made in process. The test executable is linked with GNU ld + * --wrap=__cabledyn_profile_MOD_cd_profile_enter (the gfortran symbol of CD_Profile_Enter), which + * every time march calls at each phase change of every step, armed or not. Armed, the wrapper + * counts the allocations of the step phase (CD_PROF_SOLVE) after a number of warm-up steps and + * switches the counter off at the next phase change, so the march's fluid sampling, checks and + * outputs stay outside the counted window. */ + +void __real___cabledyn_profile_MOD_cd_profile_enter(const int *phase); +void cd_test_allocation_counting(int on); + +/* CD_PROF_SOLVE of CableDyn_Profile */ +enum { PHASE_SOLVE = 4 }; + +static int armed = 0; +static long long warm_steps = 0; +static long long solve_entries = 0; + +void __wrap___cabledyn_profile_MOD_cd_profile_enter(const int *phase) +{ + if (armed) { + if (*phase == PHASE_SOLVE) { + solve_entries++; + cd_test_allocation_counting(solve_entries > warm_steps); + } else { + cd_test_allocation_counting(0); + } + } + __real___cabledyn_profile_MOD_cd_profile_enter(phase); +} + +/* Arm (on != 0) with the number of step phases left uncounted, or disarm. */ +void cd_test_phase_counting(int on, long long warm) +{ + armed = on; + warm_steps = warm; + solve_entries = 0; + if (!on) cd_test_allocation_counting(0); +} + +/* Step phases entered since the arming. */ +long long cd_test_phase_solve_entries(void) { return solve_entries; } diff --git a/tests/test_coupled_cable_tolerance.f90 b/tests/test_coupled_cable_tolerance.f90 new file mode 100644 index 00000000..e8230ef1 --- /dev/null +++ b/tests/test_coupled_cable_tolerance.f90 @@ -0,0 +1,529 @@ +! File: tests/test_coupled_cable_tolerance.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +!> One Newton tolerance for a finite-EI cable on every route. A cable in a mixed EI = 0 + finite-EI +!> deck, in OpenFAST (CompMooring = 5), in FAST.Farm and behind the C API runs on the coupled +!> aggregate; alone in a deck it runs on the standalone cubic-Hermite route. Both step it with the +!> deck's dynamic_solver relative tolerance and iteration budget (default 1e-8, 30). A lazy cable +!> (EI 1.99e4 N m^2, 80 elements, its run on a 100 m seabed) hangs from a Coupled fairlead that +!> moves along (3, 1, 1.5) m sin(2 pi t / 10 s), ramped in over 5 s (C2), beside a 450 m chain on +!> a second Coupled point moved the same way. The standalone driver (the executable given as the +!> first argument) runs the mixed deck and the cable alone, from the same motionFile. +!> 1. rhoInf 1.0, dtM 0.05 s and rhoInf 0.4, dtM 0.1 s: FairTen2 and AnchTen2 of the two routes +!> agree at every row to 1e-6 of their peak (measured: to the printed precision, 5e-8), and the +!> fairlead bend moment BendMom2N1 (a near-zero moment at the pinned end, 0.07 and 3.9 N m) to +!> 1e-3 of its peak (measured 1.2e-5 and 5e-8). The coupled cable stepped to the former fixed +!> coupled tolerance 5e-3 failed both: at rhoInf 1 the mixed route's FairTen2 peaked at 4.3e5 N +!> against 1.9e4 N (AnchTen2 5.5e5 against 2.1e3 N), at dtM 0.1 its FairTen2 fell to 8307 N +!> against 10799 N and its BendMom2N1 rose to 1612 against 3.9 N m. +!> 2. rhoInf 1.0, dtM 0.05 s, the cable alone driven by a host through the analytic motion: the +!> C API (CableDyn_InitDeck, CableDyn_Step, CableDyn_EvalChannel), the aggregate as OpenFAST +!> builds it (host environment, no deck ambient, host fluid fields) and as FAST.Farm builds it +!> (a TURBINES row, a Turbine1 fairlead) give the standalone driver's channels to the gate 1 +!> bounds from the static row on (measured 4.5e-8 and 2.1e-5); the OpenFAST and FAST.Farm cables +!> carry the deck's default tolerance and budget, and a deck's dynamic_solver row (2e-8, 25) +!> reaches them. +!> 3. The same mixed deck and the cable alone, both fairleads held in still water for 10 s at dtM +!> 0.025 s: at rhoInf 0, 0.4 and 1.0 the held equilibrium stays put on both routes (FairTen2 and +!> AnchTen2 within HELD_TOL = 1e-3 N of the static row; measured 6e-5 N, the printed digits) and +!> the routes agree to TEN_TOL. Stepped to 5e-3 the coupled cable was not dissipative: the +!> residual each step left grew at rhoInf 0.4 into an oscillation of +-2.1 N (FairTen2) and +!> +-1.1 N (AnchTen2) by 10 s, and the anchor tension moved by 0.029 N at rhoInf 0 and 0.015 N +!> at rhoInf 1. With the fairlead row 1 placed 0.1 mm off the static fairlead and then held +!> (a seed), the disturbance decays at rhoInf 0.4 (the last 2.5 s at most half the first) and +!> stays bounded at rhoInf 1 (at most the first 2.5 s), as on the single-line route, which the +!> mixed route matches to TEN_TOL; stepped to 5e-3 the coupled cable seeded by 1 cm grew at +!> rhoInf 1 from +-8.2e5 N to +-3.0e6 N while the single-line route decayed from 5.0e4 N to +!> 3.3e3 N. +PROGRAM test_coupled_cable_tolerance + USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_BOOL, C_CHAR, C_DOUBLE, C_INT, C_LOC, C_NULL_CHAR, C_PTR + USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE + USE CableDyn_Precision, ONLY: wp + USE CableDyn_CAPI, ONLY: CableDyn_Create, CableDyn_Close, CableDyn_InitDeck, CableDyn_Step, & + CableDyn_EvalChannel, CableDyn_GetLastError, CableDyn_NCoupledDOF + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & + CD_AGG_NFluidNodes, CD_AGG_SetFluidFields, CD_AGG_Step_Moving, & + CD_AGG_EvalChannel, CD_AGG_End, CD_AGG_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp, PERIOD = 10.0_wp, RAMP = 5.0_wp, TMAX = 20.0_wp + REAL(wp), PARAMETER :: DIR(3) = [3.0_wp, 1.0_wp, 1.5_wp] + REAL(wp), PARAMETER :: CHAIN_FAIR(3) = [20.0_wp, 0.0_wp, -10.0_wp], CAB_FAIR(3) = [-20.0_wp, 0.0_wp, -10.0_wp] + ! gate bounds: tensions to TEN_TOL of their peak, the fairlead bend moment to BEND_TOL of its peak or + ! of BEND_FLOOR [N m] (a held fairlead's moment is round-off about zero); SEED_TOL replaces TEN_TOL + ! for the seeded undamped march of gate 3 (rhoInf 1), which keeps the step-to-step solver residual + REAL(wp), PARAMETER :: TEN_TOL = 1.0e-6_wp, BEND_TOL = 1.0e-3_wp, BEND_FLOOR = 1.0_wp, SEED_TOL = 1.0e-4_wp + ! gate 3: the held equilibrium's tensions to HELD_TOL [N] of the static row; the seed of the + ! fairlead row 1 [m]; the time step, duration and decay windows [s] + REAL(wp), PARAMETER :: HELD_TOL = 1.0e-3_wp, SEED = 1.0e-4_wp, HELD_DT = 0.025_wp, HELD_TMAX = 10.0_wp, & + DECAY_WINDOW = 2.5_wp + INTEGER, PARAMETER :: MAXROW = 500, MAXCOL = 8, NCH = 3 + CHARACTER(16), PARAMETER :: CHANNELS(NCH) = [CHARACTER(16) :: 'FairTen2', 'AnchTen2', 'BendMom2N1'] + ! host routes of gate 2 + INTEGER, PARAMETER :: HOST_CAPI = 1, HOST_OPENFAST = 2, HOST_FARM = 3 + CHARACTER(10), PARAMETER :: HOST_NAME(3) = [CHARACTER(10) :: 'C API', 'OpenFAST', 'FAST.Farm'] + CHARACTER(1024) :: driver + INTEGER :: n_fail = 0, host + + IF (COMMAND_ARGUMENT_COUNT() < 1) ERROR STOP 'usage: test_coupled_cable_tolerance ' + CALL GET_COMMAND_ARGUMENT(1, driver) + + CALL check_routes(1.0_wp, 0.05_wp, 'cct_r1') + CALL check_routes(0.4_wp, 0.1_wp, 'cct_r04') + DO host = HOST_CAPI, HOST_FARM + CALL check_host(host) + END DO + CALL check_held(0.0_wp, .FALSE., 'cct_h0') + CALL check_held(0.4_wp, .FALSE., 'cct_h04') + CALL check_held(1.0_wp, .FALSE., 'cct_h1') + CALL check_held(0.4_wp, .TRUE., 'cct_s04') + CALL check_held(1.0_wp, .TRUE., 'cct_s1') + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' coupled-cable tolerance gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: the coupled and the standalone finite-EI cable step to the same tolerance' + +CONTAINS + + SUBROUTINE require(cond, msg) + LOGICAL, INTENT(IN) :: cond + CHARACTER(*), INTENT(IN) :: msg + IF (.NOT. cond) THEN + n_fail = n_fail + 1 + WRITE (*, '(A,A)') 'FAILED: ', msg + END IF + END SUBROUTINE require + + SUBROUTINE motion_state(t, g, dg, d2g) + !! g(t) = r(t) sin(2 pi t / PERIOD) with the C2 ramp r = 10 s^3 - 15 s^4 + 6 s^5, s = min(t / RAMP, 1), + !! and its exact first and second derivatives: from rest with zero acceleration at t = 0. + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: g, dg, d2g + REAL(wp) :: s, r, dr, d2r, w, f, df, d2f + s = MIN(t/RAMP, 1.0_wp) + r = 10.0_wp*s**3 - 15.0_wp*s**4 + 6.0_wp*s**5 + dr = 0.0_wp + d2r = 0.0_wp + IF (t < RAMP) THEN + dr = (30.0_wp*s**2 - 60.0_wp*s**3 + 30.0_wp*s**4)/RAMP + d2r = (60.0_wp*s - 180.0_wp*s**2 + 120.0_wp*s**3)/RAMP**2 + END IF + w = 2.0_wp*PI/PERIOD + f = SIN(w*t) + df = w*COS(w*t) + d2f = -w*w*SIN(w*t) + g = r*f + dg = dr*f + r*df + d2g = d2r*f + 2.0_wp*dr*df + r*d2f + END SUBROUTINE motion_state + + SUBROUTINE write_motion(path, dt, with_chain) + !! The motionFile of the cable's fairlead (point 3) and, with_chain, the chain's (point 1). + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: dt + LOGICAL, INTENT(IN) :: with_chain + INTEGER :: u, k + REAL(wp) :: t, g, dg, d2g + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az' + DO k = 0, NINT(TMAX/dt) + 1 + t = REAL(k, wp)*dt + CALL motion_state(t, g, dg, d2g) + IF (with_chain) WRITE (u, '(F10.6,A,9ES24.15E3)') t, ' 1 ', CHAIN_FAIR + DIR*g, DIR*dg, DIR*d2g + WRITE (u, '(F10.6,A,9ES24.15E3)') t, ' 3 ', CAB_FAIR + DIR*g, DIR*dg, DIR*d2g + END DO + CLOSE (u) + END SUBROUTINE write_motion + + SUBROUTINE write_held_motion(path, with_chain) + !! The gate 3 seed: the cable's fairlead (point 3) and, with_chain, the chain's (point 1) at + !! SEED m along DIR off their deck positions from row 1 on, at rest. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: with_chain + REAL(wp), PARAMETER :: ZERO(6) = 0.0_wp + INTEGER :: u, k + REAL(wp) :: t, off(3) + off = SEED*DIR/NORM2(DIR) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') '# time id x y z vx vy vz ax ay az' + DO k = 0, NINT(HELD_TMAX/HELD_DT) + 1 + t = REAL(k, wp)*HELD_DT + IF (with_chain) WRITE (u, '(F10.6,A,9ES24.15E3)') t, ' 1 ', CHAIN_FAIR + off, ZERO + WRITE (u, '(F10.6,A,9ES24.15E3)') t, ' 3 ', CAB_FAIR + off, ZERO + END DO + CLOSE (u) + END SUBROUTINE write_held_motion + + SUBROUTINE write_deck(path, rho_inf, dt, mixed, motion, farm, solver, run_tmax) + !! The cable (line 2, points 3 -> 4) alone or, mixed, beside the chain (line 1, points 1 -> 2); + !! motion: the motionFile (blank: a host drives point 3, or the deck holds it); farm: point 3 is + !! Turbine1 of a TURBINES row at the origin; solver: a dynamic_solver row (blank: the defaults); + !! run_tmax: TMax (default TMAX). + CHARACTER(*), INTENT(IN) :: path, motion, solver + REAL(wp), INTENT(IN) :: rho_inf, dt + LOGICAL, INTENT(IN) :: mixed, farm + REAL(wp), INTENT(IN), OPTIONAL :: run_tmax + INTEGER :: u + REAL(wp) :: tm + tm = TMAX + IF (PRESENT(run_tmax)) tm = run_tmax + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'coupled-cable tolerance 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)') 'chain 0.1 48.8389796939 500000000 -0.5 0 1.2 0.4 1 0.5' + WRITE (u, '(A)') 'cab 0.16 36.7 469000000 -0.5 19900 1.2 0.1 1 0' + IF (farm) THEN + WRITE (u, '(A)') '--- TURBINES ---' + WRITE (u, '(A)') 'J X0 Y0 Z0' + WRITE (u, '(A)') '(-) (m) (m) (m)' + WRITE (u, '(A)') '1 0 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) (-)' + IF (mixed) THEN + WRITE (u, '(A)') '1 Coupled 20 0 -10 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 400 0 -100 0 0 0 0' + END IF + WRITE (u, '(A)') '3 '//MERGE('Turbine1', 'Coupled ', farm)//' -20 0 -10 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -200 0 -100 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + IF (mixed) WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 4 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + IF (mixed) WRITE (u, '(A)') '1 chain 450 50' + WRITE (u, '(A)') '2 cab 260 80' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '100 WtrDpth' + WRITE (u, '(A)') '1e5 kBot' + WRITE (u, '(A)') '1e4 cBot' + WRITE (u, '(F6.3,A)') dt, ' dtM' + WRITE (u, '(F6.2,A)') tm, ' TMax' + WRITE (u, '(F5.2,A)') rho_inf, ' rhoInf' + IF (LEN_TRIM(motion) > 0) WRITE (u, '(A)') TRIM(motion)//' motionFile' + IF (LEN_TRIM(solver) > 0) WRITE (u, '(A)') TRIM(solver) + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen2' + WRITE (u, '(A)') 'AnchTen2' + WRITE (u, '(A)') 'BendMom2N1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE run_driver(deck, root, ok) + CHARACTER(*), INTENT(IN) :: deck, root + LOGICAL, INTENT(OUT) :: ok + INTEGER :: ex, cs + CALL EXECUTE_COMMAND_LINE('"'//TRIM(driver)//'" '//deck//' '//root//' > '//root//'.log 2>&1', & + WAIT=.TRUE., EXITSTAT=ex, CMDSTAT=cs) + ok = cs == 0 .AND. ex == 0 + END SUBROUTINE run_driver + + SUBROUTINE read_channels(path, vals, nrow) + !! The CHANNELS columns of a driver .out file, one row per output time. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(OUT) :: vals(MAXROW, NCH) + INTEGER, INTENT(OUT) :: nrow + CHARACTER(32) :: names(MAXCOL) + CHARACTER(4096) :: buf + REAL(wp) :: row(MAXCOL) + INTEGER :: u, ios, ncol, k, c, col(NCH) + vals = 0.0_wp + nrow = 0 + OPEN (NEWUNIT=u, FILE=path, STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + READ (u, '(A)', IOSTAT=ios) buf + READ (u, '(A)', IOSTAT=ios) buf + names = '' + READ (buf, *, IOSTAT=ios) names + ncol = 0 + DO k = 1, MAXCOL + IF (LEN_TRIM(names(k)) > 0) ncol = k + END DO + col = 0 + DO c = 1, NCH + DO k = 1, ncol + IF (TRIM(names(k)) == TRIM(CHANNELS(c))) col(c) = k + END DO + END DO + IF (ANY(col == 0)) THEN + CLOSE (u); RETURN + END IF + DO + IF (nrow == MAXROW) EXIT + READ (u, *, IOSTAT=ios) row(1:ncol) + IF (ios /= 0) EXIT + nrow = nrow + 1 + vals(nrow, :) = row(col) + END DO + CLOSE (u) + END SUBROUTINE read_channels + + SUBROUTINE compare(label, ref, got, n, ten_bound) + !! Each channel of got against ref over n rows: |got - ref| <= tol max|ref| (the bend moment: + !! tol max(max|ref|, BEND_FLOOR)); ten_bound replaces TEN_TOL. + CHARACTER(*), INTENT(IN) :: label + REAL(wp), INTENT(IN) :: ref(:, :), got(:, :) + INTEGER, INTENT(IN) :: n + REAL(wp), INTENT(IN), OPTIONAL :: ten_bound + REAL(wp) :: e, peak, tol + INTEGER :: c + DO c = 1, NCH + peak = MAXVAL(ABS(ref(1:n, c))) + IF (c == 3) peak = MAX(peak, BEND_FLOOR) + e = MAXVAL(ABS(got(1:n, c) - ref(1:n, c)))/MAX(peak, TINY(1.0_wp)) + IF (.NOT. IEEE_IS_FINITE(e)) e = HUGE(1.0_wp) + tol = TEN_TOL + IF (PRESENT(ten_bound)) tol = ten_bound + IF (c == 3) tol = BEND_TOL + WRITE (*, '(2X,A,1X,A,A,ES10.3,A,ES10.3,A,ES10.3,A,ES10.3,A,ES9.2,A,ES8.1,A)') label, TRIM(CHANNELS(c)), & + ': peak ', peak, ' (', MAXVAL(ABS(got(1:n, c))), '), range ', MINVAL(ref(1:n, c)), ' (', & + MINVAL(got(1:n, c)), '), max|diff|/peak ', e, ' (bound ', tol, ')' + CALL require(e <= tol, label//': '//TRIM(CHANNELS(c))//' agrees with the standalone route') + END DO + END SUBROUTINE compare + + SUBROUTINE check_routes(rho_inf, dt, root) + !! Gate 1: the mixed route against the standalone cubic-Hermite route, same cable and motion. + REAL(wp), INTENT(IN) :: rho_inf, dt + CHARACTER(*), INTENT(IN) :: root + REAL(wp) :: va(MAXROW, NCH), vb(MAXROW, NCH) + INTEGER :: ra, rb + LOGICAL :: ok_a, ok_b + CHARACTER(64) :: label + WRITE (label, '(A,F4.2,A,F5.3,A)') 'rhoInf ', rho_inf, ', dtM ', dt, ' s' + CALL write_motion(root//'_single.txt', dt, .FALSE.) + CALL write_motion(root//'_mixed.txt', dt, .TRUE.) + CALL write_deck(root//'_single.dat', rho_inf, dt, .FALSE., root//'_single.txt', .FALSE., '') + CALL write_deck(root//'_mixed.dat', rho_inf, dt, .TRUE., root//'_mixed.txt', .FALSE., '') + CALL run_driver(root//'_single.dat', root//'_single', ok_a) + CALL run_driver(root//'_mixed.dat', root//'_mixed', ok_b) + CALL require(ok_a .AND. ok_b, TRIM(label)//': both routes run') + IF (.NOT. (ok_a .AND. ok_b)) RETURN + CALL read_channels(root//'_single.out', va, ra) + CALL read_channels(root//'_mixed.out', vb, rb) + CALL require(ra == NINT(TMAX/dt) + 1 .AND. rb == ra, TRIM(label)//': every output row is written') + IF (ra /= rb .OR. ra < 2) RETURN + WRITE (*, '(A)') 'gate 1, '//TRIM(label)//': standalone (mixed route):' + CALL compare('mixed', va, vb, ra) + END SUBROUTINE check_routes + + REAL(wp) FUNCTION half_swing(v, n, t0, t1) RESULT(h) + !! Half the peak-to-peak of v over the output rows with t0 < t <= t1 (row k at (k - 1) HELD_DT). + REAL(wp), INTENT(IN) :: v(:), t0, t1 + INTEGER, INTENT(IN) :: n + REAL(wp) :: lo, hi, t + INTEGER :: k + lo = HUGE(1.0_wp) + hi = -HUGE(1.0_wp) + DO k = 1, n + t = REAL(k - 1, wp)*HELD_DT + IF (t <= t0 + 1.0e-9_wp .OR. t > t1 + 1.0e-9_wp) CYCLE + lo = MIN(lo, v(k)) + hi = MAX(hi, v(k)) + END DO + h = 0.5_wp*(hi - lo) + IF (.NOT. IEEE_IS_FINITE(h)) h = HUGE(1.0_wp) + END FUNCTION half_swing + + SUBROUTINE check_held(rho_inf, seeded, root) + !! Gate 3: both fairleads held in still water (seeded: row 1 SEED m off the static fairlead). + REAL(wp), INTENT(IN) :: rho_inf + LOGICAL, INTENT(IN) :: seeded + CHARACTER(*), INTENT(IN) :: root + REAL(wp) :: va(MAXROW, NCH), vb(MAXROW, NCH), dev, h0, h1, ratio, bound + INTEGER :: ra, rb, c, r + LOGICAL :: ok_a, ok_b + CHARACTER(80) :: label + WRITE (label, '(A,F4.2,A)') 'rhoInf ', rho_inf, MERGE(', seeded', ', held ', seeded) + IF (seeded) THEN + CALL write_held_motion(root//'_single.txt', .FALSE.) + CALL write_held_motion(root//'_mixed.txt', .TRUE.) + CALL write_deck(root//'_single.dat', rho_inf, HELD_DT, .FALSE., root//'_single.txt', .FALSE., '', HELD_TMAX) + CALL write_deck(root//'_mixed.dat', rho_inf, HELD_DT, .TRUE., root//'_mixed.txt', .FALSE., '', HELD_TMAX) + ELSE + CALL write_deck(root//'_single.dat', rho_inf, HELD_DT, .FALSE., '', .FALSE., '', HELD_TMAX) + CALL write_deck(root//'_mixed.dat', rho_inf, HELD_DT, .TRUE., '', .FALSE., '', HELD_TMAX) + END IF + CALL run_driver(root//'_single.dat', root//'_single', ok_a) + CALL run_driver(root//'_mixed.dat', root//'_mixed', ok_b) + CALL require(ok_a .AND. ok_b, TRIM(label)//': both routes run') + IF (.NOT. (ok_a .AND. ok_b)) RETURN + CALL read_channels(root//'_single.out', va, ra) + CALL read_channels(root//'_mixed.out', vb, rb) + CALL require(ra == NINT(HELD_TMAX/HELD_DT) + 1 .AND. rb == ra, TRIM(label)//': every output row is written') + IF (ra /= rb .OR. ra < 2) RETURN + WRITE (*, '(A)') 'gate 3, '//TRIM(label)//': standalone (mixed route):' + IF (seeded .AND. rho_inf > 0.95_wp) THEN + CALL compare('mixed', va, vb, ra, SEED_TOL) + ELSE + CALL compare('mixed', va, vb, ra) + END IF + DO c = 1, 2 + IF (.NOT. seeded) THEN + DO r = 1, 2 + IF (r == 1) dev = MAXVAL(ABS(va(1:ra, c) - va(1, c))) + IF (r == 2) dev = MAXVAL(ABS(vb(1:rb, c) - vb(1, c))) + IF (.NOT. IEEE_IS_FINITE(dev)) dev = HUGE(1.0_wp) + WRITE (*, '(2X,A,1X,A,A,ES10.3,A,ES8.1,A)') TRIM(MERGE('single', 'mixed ', r == 1)), TRIM(CHANNELS(c)), & + ': held equilibrium, max|T - T(0)| ', dev, ' N (bound ', HELD_TOL, ' N)' + CALL require(dev <= HELD_TOL, TRIM(label)//': '//TRIM(CHANNELS(c))//' holds the equilibrium on the '// & + TRIM(MERGE('single', 'mixed ', r == 1))//' route') + END DO + ELSE + h0 = half_swing(vb(:, c), rb, 0.0_wp, DECAY_WINDOW) + h1 = half_swing(vb(:, c), rb, HELD_TMAX - DECAY_WINDOW, HELD_TMAX) + ratio = h1/MAX(h0, TINY(1.0_wp)) + bound = MERGE(1.0_wp, 0.5_wp, rho_inf > 0.95_wp) + WRITE (*, '(2X,A,1X,A,A,ES10.3,A,ES10.3,A,F7.4,A,F4.2,A)') 'mixed', TRIM(CHANNELS(c)), ': half swing ', h0, & + ' N in the first 2.5 s, ', h1, ' N in the last, ratio ', ratio, ' (bound ', bound, ')' + CALL require(ratio <= bound, TRIM(label)//': the '//TRIM(CHANNELS(c))//' disturbance '// & + TRIM(MERGE('stays bounded', 'decays ', rho_inf > 0.95_wp))//' on the mixed route') + END IF + END DO + END SUBROUTINE check_held + + SUBROUTINE check_host(route) + !! Gate 2: a host drives the cable alone through the analytic motion at rhoInf 1, dtM 0.05. + INTEGER, INTENT(IN) :: route + REAL(wp), PARAMETER :: RI = 1.0_wp, DT = 0.05_wp + CHARACTER(*), PARAMETER :: ROOT = 'cct_r1' + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + CHARACTER(KIND=C_CHAR), TARGET :: c_path(64), c_tok(16), msg(512) + TYPE(C_PTR) :: handle + INTEGER(C_INT) :: ces, n_iter + LOGICAL(C_BOOL) :: cconv, cstall + REAL(C_DOUBLE), TARGET :: q(3), v(3), a(3) + REAL(C_DOUBLE) :: cval + REAL(wp) :: va(MAXROW, NCH), got(MAXROW, NCH), pos(3, 1), vel(3, 1), acc(3, 1), t, g, dg, d2g + REAL(wp), ALLOCATABLE :: fv(:, :), fa(:, :), wz(:) + INTEGER :: ra, k, c, i, es, nit, nfl + LOGICAL :: conv, stall + CHARACTER(2048) :: em + CHARACTER(64) :: deck + CHARACTER(16) :: tok + + CALL read_channels(ROOT//'_single.out', va, ra) + CALL require(ra == NINT(TMAX/DT) + 1, HOST_NAME(route)//': the standalone reference of gate 1 exists') + IF (ra /= NINT(TMAX/DT) + 1) RETURN + deck = 'cct_host_'//TRIM(MERGE('farm', 'host', route == HOST_FARM))//'.dat' + CALL write_deck(TRIM(deck), RI, DT, .FALSE., '', route == HOST_FARM, '') + got = 0.0_wp + IF (route == HOST_CAPI) THEN + c_path = C_NULL_CHAR + DO i = 1, LEN_TRIM(deck) + c_path(i) = deck(i:i) + END DO + CALL CableDyn_Create(handle, ces) + CALL CableDyn_InitDeck(handle, C_LOC(c_path), INT(LEN_TRIM(deck), C_INT), ces) + IF (ces /= 0_C_INT) THEN + CALL CableDyn_GetLastError(handle, C_LOC(msg), INT(SIZE(msg), C_INT)) + em = '' + DO i = 1, SIZE(msg) + IF (msg(i) == C_NULL_CHAR) EXIT + em(i:i) = msg(i) + END DO + END IF + CALL require(ces == 0_C_INT .AND. CableDyn_NCoupledDOF(handle, ces) == 3_C_INT, & + 'C API: the cable deck initialises with one coupled point: '//TRIM(em)) + IF (ces /= 0_C_INT) THEN + CALL CableDyn_Close(handle, ces); RETURN + END IF + ! row k + 1 at t = k dt; row 1 is the static state + DO k = 0, ra - 1 + t = REAL(k, wp)*DT + CALL motion_state(t, g, dg, d2g) + q = CAB_FAIR + DIR*g + v = DIR*dg + a = DIR*d2g + IF (k > 0) THEN + CALL CableDyn_Step(handle, REAL(DT, C_DOUBLE), C_LOC(q), C_LOC(v), C_LOC(a), 3_C_INT, cconv, cstall, & + n_iter, ces) + IF (ces /= 0_C_INT .OR. .NOT. LOGICAL(cconv)) EXIT + END IF + DO c = 1, NCH + c_tok = C_NULL_CHAR + tok = CHANNELS(c) + DO i = 1, LEN_TRIM(tok) + c_tok(i) = tok(i:i) + END DO + CALL CableDyn_EvalChannel(handle, C_LOC(c_tok), INT(SIZE(c_tok), C_INT), cval, ces) + got(k + 1, c) = REAL(cval, wp) + END DO + IF (ces /= 0_C_INT) EXIT + END DO + CALL require(ces == 0_C_INT .AND. k == ra, 'C API: every step converges and every channel evaluates') + CALL CableDyn_Close(handle, ces) + ELSE + ALLOCATE (agg) + IF (route == HOST_OPENFAST) THEN + CALL CD_AGG_Init_From_Deck(agg, TRIM(deck), DT, es, em, env_gravity=9.80665_wp, env_rho_water=1025.0_wp, & + env_wtrdpth=100.0_wp, external_fluid=.TRUE., forbid_deck_ambient=.TRUE.) + ELSE + CALL CD_AGG_Init_From_Deck(agg, TRIM(deck), DT, es, em, n_turbines=1, & + turbine_ref_pos=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp], [3, 1]), & + forbid_deck_ambient=.TRUE.) + END IF + CALL require(es == CD_AGG_OK, HOST_NAME(route)//': the cable deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(CD_AGG_NMovingPoints(agg, es, em) == 1 .AND. agg%ncable == 1, & + HOST_NAME(route)//': one cable, one moving point') + IF (agg%ncable /= 1) RETURN + CALL require(agg%cables(1)%tol == 1.0e-8_wp .AND. agg%cables(1)%max_iter == 30, & + HOST_NAME(route)//': the cable steps to the deck default dynamic_solver 1e-8, 30') + nfl = CD_AGG_NFluidNodes(agg, es, em) + ALLOCATE (fv(3, nfl), fa(3, nfl), wz(nfl)) + fv = 0.0_wp + fa = 0.0_wp + wz = 0.0_wp + DO k = 0, ra - 1 + t = REAL(k, wp)*DT + CALL motion_state(t, g, dg, d2g) + pos(:, 1) = CAB_FAIR + DIR*g + vel(:, 1) = DIR*dg + acc(:, 1) = DIR*d2g + IF (k > 0) THEN + IF (route == HOST_OPENFAST) THEN + CALL CD_AGG_SetFluidFields(agg, fv, fa, wz, es, em) + IF (es /= CD_AGG_OK) EXIT + END IF + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stall, nit, es, em, t_committed=t) + IF (es /= CD_AGG_OK .OR. .NOT. conv) EXIT + END IF + DO c = 1, NCH + CALL CD_AGG_EvalChannel(agg, c, got(k + 1, c), es, em) + END DO + IF (es /= CD_AGG_OK) EXIT + END DO + CALL require(es == CD_AGG_OK .AND. k == ra, HOST_NAME(route)//': every step converges: '//TRIM(em)) + CALL CD_AGG_End(agg, es, em) + ! a deck's dynamic_solver row reaches the host route's cable + CALL write_deck(TRIM(deck), RI, DT, .FALSE., '', route == HOST_FARM, 'dynamic_solver 2.0e-8 1.0e-14 25 12') + IF (route == HOST_OPENFAST) THEN + CALL CD_AGG_Init_From_Deck(agg, TRIM(deck), DT, es, em, env_gravity=9.80665_wp, env_rho_water=1025.0_wp, & + env_wtrdpth=100.0_wp, external_fluid=.TRUE., forbid_deck_ambient=.TRUE.) + ELSE + CALL CD_AGG_Init_From_Deck(agg, TRIM(deck), DT, es, em, n_turbines=1, & + turbine_ref_pos=RESHAPE([0.0_wp, 0.0_wp, 0.0_wp], [3, 1]), & + forbid_deck_ambient=.TRUE.) + END IF + CALL require(es == CD_AGG_OK, HOST_NAME(route)//': the dynamic_solver deck initialises: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + CALL require(agg%cables(1)%tol == 2.0e-8_wp .AND. agg%cables(1)%max_iter == 25, & + HOST_NAME(route)//': the deck dynamic_solver row sets the cable tolerance and budget') + CALL CD_AGG_End(agg, es, em) + END IF + WRITE (*, '(A)') 'gate 2, '//TRIM(HOST_NAME(route))//', rhoInf 1.00, dtM 0.050 s: standalone (host route):' + CALL compare(TRIM(HOST_NAME(route)), va, got, ra) + END SUBROUTINE check_host + +END PROGRAM test_coupled_cable_tolerance diff --git a/tests/test_mixed_route_currents.f90 b/tests/test_mixed_route_currents.f90 index 8e60d849..2abe5024 100644 --- a/tests/test_mixed_route_currents.f90 +++ b/tests/test_mixed_route_currents.f90 @@ -11,14 +11,12 @@ !> cable along x, the chain along y), in the static start and the march: the mixed route !> against the single-line routes, each channel to a fraction of its range, beside the same !> comparison in still water (the route difference without a current). The static start agrees -!> within STATIC_TOL: the chain exactly, the cable to the stopping point of the coupled cable -!> build's static polish (its out-of-plane offset, the softest coordinate, by 4 um of 0.55 m; -!> in still water exactly). In the march the cable steps with the coupled Newton controls on -!> the mixed route (relative tolerance 5e-3, a fresh factor) and with the deck's on its own -!> (1e-8, a carried factor), which differ by about 1.2e-3 of the range in still water too -!> (DRIVER_CABLE_TOL); with the deck's controls given to the aggregate cable (the library -!> march of the driver's loop) the march keeps the static start's difference -!> (LIBRARY_CABLE_TOL). The chain agrees within CHAIN_TOL (exactly in a sheared current; its +!> within STATIC_TOL: the chain and the cable exactly (measured 0). In the march the cable steps +!> with the deck's Newton controls on both routes (1e-8 by default), in the driver and in the +!> library march of the driver's loop alike: it agrees within DRIVER_CABLE_TOL (measured 0) and +!> LIBRARY_CABLE_TOL (1.9e-8). Before the coupled cable took the deck's controls, it stepped to +!> 5e-3 on the mixed route and differed by 1.2e-3 of the range, in still water too. The chain +!> agrees within CHAIN_TOL (exactly in a sheared current; its !> row-1 transfer re-derives its interior accelerations on the mixed route, by 5e-5 in still !> water). The current is felt: both mid nodes leave the vertical plane of their chord, and !> the chain's fairlead tension history differs from the still-water run's. @@ -66,8 +64,8 @@ PROGRAM test_mixed_route_currents CHARACTER(16), PARAMETER :: CHAIN_OUTS(5) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'L1N11px', 'L1N11py', & 'L1N11pz'] ! differences of the mixed route from the single-line routes, of each channel's range (gate 1): the - ! static start; the cable stepped with the coupled Newton controls, and with the deck's; the chain - REAL(wp), PARAMETER :: STATIC_TOL = 1.0e-5_wp, DRIVER_CABLE_TOL = 2.0e-3_wp, LIBRARY_CABLE_TOL = 1.0e-5_wp + ! static start; the cable stepped by the driver, and by the library loop; the chain + REAL(wp), PARAMETER :: STATIC_TOL = 1.0e-6_wp, DRIVER_CABLE_TOL = 1.0e-6_wp, LIBRARY_CABLE_TOL = 1.0e-6_wp REAL(wp), PARAMETER :: CHAIN_TOL = 1.0e-4_wp ! round-off between two writings of one field (gates 3 and 4), of each channel's range, and of a ! uniform field interpolated on a grid (gate 4) @@ -363,7 +361,7 @@ SUBROUTINE compare_case(dir, label, still) e_cable_static, e_cable, ', chain ', e_chain_static, e_chain, ' (static start, march; of each channel''s range)' CALL require(e_cable_static <= STATIC_TOL .AND. e_chain_static <= STATIC_TOL, & label//': the static start agrees within the static tolerance') - CALL require(e_cable <= DRIVER_CABLE_TOL, label//': the cable agrees within the coupled Newton tolerance') + CALL require(e_cable <= DRIVER_CABLE_TOL, label//': the cable agrees within the deck''s Newton tolerance') CALL require(e_chain <= CHAIN_TOL, label//': the chain agrees within the row-1 transfer') ! the current is felt: both mid nodes leave the vertical plane of their chord IF (PRESENT(still)) THEN diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 index ec685c8d..f33803a1 100644 --- a/tests/test_mixed_route_torsion.f90 +++ b/tests/test_mixed_route_torsion.f90 @@ -10,11 +10,11 @@ !> alone on the standalone cubic-Hermite route and beside a moving EI = 0 chain on the mixed !> route. Torq, Twist and the mid-line node agree to the printed precision of the .out !> (8 digits), the fairlead and anchor tension, fairlead inclination and End A bend moment -!> (the Rigid clamp turns with the vessel on both routes) to 5e-5 of their range: the -!> coupled cables step with the coupled Newton controls (relative tolerance 5e-3, a fresh -!> factor every step), the standalone line with the deck's (1e-8, a carried factor). With -!> the aggregate cables given the standalone controls the mixed route reproduces every -!> channel of the standalone route to the printed precision. The same chain moved by a +!> (the Rigid clamp turns with the vessel on both routes) to 5e-5 of their range: both step +!> to the deck's Newton tolerance (1e-8), the coupled cables with a fresh factor every step, +!> the standalone line with a carried factor. With the aggregate cables given the carried +!> factor too the mixed route reproduces every channel of the standalone route to the +!> printed precision. The same chain moved by a !> motionFile of the same point translations holds the frames: the End A bend moment and !> the twist then differ from the turning-vessel run (the rotation is not dropped). !> 2. A motionFile surge with a roll column (End A rolls 20 deg about its director, from diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index 4187e938..7ffb2192 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -1123,20 +1123,18 @@ SUBROUTINE case_cable_modified_newton() ! The DETERMINISTIC plumbing gate: the option must land on the cable model itself ! (a plumbed-but-dead flag fails here; the flag's solver behavior is gated at the ! element level by hermite_cable_dynamic::check_modified_newton). The counters are - ! reported, not gated: at this path's frozen production tolerance (5e-3 relative) - ! per-iteration contraction is weak, so reuse yields no assembly saving on this rig - ! -- the benefit lives at tighter tolerances (the committed 800 m bench at 1e-4). + ! reported, not gated: on this small rig reuse yields no reliable assembly saving + ! -- the benefit lives on longer, finer cables (the committed 800 m bench at 1e-4). CALL require(.NOT. aggf%cables(1)%line%modified_newton, 'mn-cable: plain deck leaves the flag off') CALL require(aggm%cables(1)%line%modified_newton, 'mn-cable: the OPTIONS row reaches the cable model') - ! Both variants commit each step at the SAME relative tolerance; the coupled-node - ! reaction lives on FIXED DOFs outside the converged free residual, so the honest - ! agreement bound is tolerance-consistent (a few x 5e-3 of the force scale), not - ! trajectory-tight. Gate at 10% of magnitude as the same-physics sanity check. + ! Both variants commit each step at the SAME relative tolerance (the deck's); the + ! coupled-node reaction lives on FIXED DOFs outside the converged free residual, so the + ! agreement bound is tolerance-consistent, not trajectory-tight. Gate at 10% of + ! magnitude as the same-physics sanity check. CALL require(NORM2(lf(:, 1) - lm(:, 1)) <= 0.10_wp*NORM2(lf(:, 1)), & 'mn-cable: coupled loads agree to the shared step tolerance') - ! The counters stay collected (they document that reuse saves nothing at this - ! path's frozen 5e-3 tolerance -- see the CHANGELOG scope note) but a passing - ! test prints nothing; gate them only for finiteness of the collection itself. + ! The counters stay collected but a passing test prints nothing; gate them only for + ! finiteness of the collection itself. CALL require(ntan_full > 0 .AND. ntan_mn > 0, 'mn-cable: profile counters collected') CALL CD_AGG_End(aggf, es, em) diff --git a/tests/test_step_allocations.f90 b/tests/test_step_allocations.f90 index f101c1eb..80369904 100644 --- a/tests/test_step_allocations.f90 +++ b/tests/test_step_allocations.f90 @@ -39,10 +39,15 @@ PROGRAM test_step_allocations !! With "mixed_current" the same march of a mixed deck takes the deck's own current !! (deck_current): a MoorDyn-C Currents 5 grid that varies in space and time, sampled at every !! node of the chain and of the finite-EI cable before each step, past its last sample too. + !! With "driver_vessel" the gate runs a whole standalone driver run in process + !! (CD_Run_Deck_Driver) of a finite-EI line on the cubic-Hermite route moved by a vesselMotion + !! record, and counts the step phase of every step after warm-up (tests/allocation_phase_counter.c: + !! the end kinematics, the vessel orientation and rates handed to the cable, its implicit step). !! !! Usage: test_step_allocations [ranges] !! test_step_allocations torsion | nodal | free | current_grid | motion_roll | motion_vessel | !! mixed_current + !! test_step_allocations driver_vessel USE, INTRINSIC :: ISO_C_BINDING, ONLY: C_INT, C_LONG_LONG USE CableDyn_Precision, ONLY: wp USE CableDyn_EndConnection, ONLY: CD_ENDCONN_RIGID @@ -53,6 +58,7 @@ PROGRAM test_step_allocations USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Dyn_End_Force, CD_HermiteCable_Dyn_Energy, & CD_HermiteCable_Dyn_Torsion_State, CD_HermiteCable_Dyn_Node_Torque, & CD_HermiteCable_Dyn_Element_Twist + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver USE CableDyn_Hydro, ONLY: CD_CurrentGridType, CD_Current_Grid_Resample, CD_Current_Grid_Velocity, & CD_Current_Grid_Gradient USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_NMovingPoints, & @@ -71,6 +77,15 @@ SUBROUTINE cd_test_allocation_counting(on) BIND(C, NAME='cd_test_allocation_coun IMPORT :: C_INT INTEGER(C_INT), VALUE :: on END SUBROUTINE cd_test_allocation_counting + SUBROUTINE cd_test_phase_counting(on, warm) BIND(C, NAME='cd_test_phase_counting') + IMPORT :: C_INT, C_LONG_LONG + INTEGER(C_INT), VALUE :: on + INTEGER(C_LONG_LONG), VALUE :: warm + END SUBROUTINE cd_test_phase_counting + FUNCTION cd_test_phase_solve_entries() BIND(C, NAME='cd_test_phase_solve_entries') RESULT(n) + IMPORT :: C_LONG_LONG + INTEGER(C_LONG_LONG) :: n + END FUNCTION cd_test_phase_solve_entries END INTERFACE INTEGER, PARAMETER :: WARMUP_STEPS = 40 REAL(wp), PARAMETER :: DT = 0.025_wp, SURGE_AMPLITUDE = 0.5_wp, SURGE_PERIOD = 20.0_wp @@ -95,9 +110,11 @@ END SUBROUTINE cd_test_allocation_counting CALL motion_gate(TRIM(arg) == 'motion_vessel') CASE ('mixed_current') CALL mixed_current_gate() + CASE ('driver_vessel') + CALL driver_vessel_gate() CASE DEFAULT ERROR STOP 'a single argument must be "torsion", "nodal", "free", "current_grid", "motion_roll", '// & - '"motion_vessel" or "mixed_current"' + '"motion_vessel", "mixed_current" or "driver_vessel"' END SELECT STOP END IF @@ -475,6 +492,85 @@ SUBROUTINE motion_gate(vessel) PRINT '(A)', 'PASS: no heap allocation in the prescribed-motion march of a mixed deck after warm-up' END SUBROUTINE motion_gate + SUBROUTINE driver_vessel_gate() + !! Zero heap allocation in the step phase of the standalone driver's march of a finite-EI line on + !! the cubic-Hermite route (a lazy cable from a Vessel fairlead to a Fixed anchor on the seabed), + !! moved by a vesselMotion record (surge 1 m and roll 3 deg from rest): every step hands the + !! cable the vessel's orientation, angular velocity and acceleration with its fairlead state. + INTEGER, PARAMETER :: N_WARM = 40, NT = 200 + REAL(wp), PARAMETER :: DTM = 0.05_wp, PI = 3.14159265358979323846_wp + CHARACTER(*), PARAMETER :: ROOT = 'step_alloc_driver_vessel' + REAL(wp) :: t, x, vx, ax, ro, dro, d2ro, om + INTEGER :: u, k + INTEGER(C_LONG_LONG) :: c0, n_alloc, n_steps + LOGICAL :: converged + om = 2.0_wp*PI/10.0_wp + OPEN (NEWUNIT=u, FILE=ROOT//'.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NT + 1 + t = DTM*k + x = 0.5_wp*(1.0_wp - COS(om*t)) + vx = 0.5_wp*om*SIN(om*t) + ax = 0.5_wp*om*om*COS(om*t) + ro = 1.5_wp*(1.0_wp - COS(om*t)) + dro = 1.5_wp*om*SIN(om*t)*PI/180.0_wp + d2ro = 1.5_wp*om*om*COS(om*t)*PI/180.0_wp + ! time x y z roll pitch yaw vx vy vz wx wy wz ax ay az alx aly alz + WRITE (u, '(F8.3,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A,ES25.16E3,A)') t, x, & + ' 0 -10 ', ro, ' 0 0 ', vx, ' 0 0 ', dro, ' 0 0 ', ax, ' 0 0 ', d2ro, ' 0 0' + END DO + CLOSE (u) + OPEN (NEWUNIT=u, FILE=ROOT//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'step allocation gate: finite-EI line on a vessel, standalone driver' + 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.16 36.7 469000000 -0.5 19900 1.2 0.1 1 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 Vessel -20 0 -10 0 0 0 0' + WRITE (u, '(A)') '2 Fixed -200 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)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 260 80' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '100 WtrDpth' + WRITE (u, '(F5.3,A)') DTM, ' dtM' + WRITE (u, '(F6.2,A)') DTM*NT, ' TMax' + WRITE (u, '(A)') ROOT//'.txt vesselMotion' + WRITE (u, '(A)') '0|0|-10 vesselRef' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + c0 = cd_test_allocation_count() + CALL cd_test_phase_counting(1_C_INT, INT(N_WARM, C_LONG_LONG)) + CALL CD_Run_Deck_Driver(ROOT//'.dat', ROOT, converged, es, em) + n_steps = cd_test_phase_solve_entries() + CALL cd_test_phase_counting(0_C_INT, 0_C_LONG_LONG) + n_alloc = cd_test_allocation_count() - c0 + CALL check('driver run') + IF (.NOT. converged) ERROR STOP 'the driver run did not converge' + PRINT '(A,I0,A,I0,A,I0,A)', 'standalone driver, finite-EI line on a vessel: ', n_steps, ' steps (', & + n_steps - N_WARM, ' counted), ', n_alloc, ' heap allocations in their step phase' + IF (n_steps /= NT) THEN + PRINT '(A)', 'FAIL: the step phase window did not see every step (CD_Profile_Enter not wrapped?)' + ERROR STOP 1 + END IF + IF (n_alloc /= 0) THEN + PRINT '(A)', 'FAIL: the step phase of the standalone Hermite march allocated after warm-up' + ERROR STOP 1 + END IF + PRINT '(A)', 'PASS: no heap allocation in the step phase of the standalone Hermite march after warm-up' + END SUBROUTINE driver_vessel_gate + SUBROUTINE mixed_current_gate() !! Zero heap allocation in the standalone driver's per-step march of a mixed deck in its own !! current: a sagging finite-EI line beside a chain, both fairleads surging (motionFile), in From 3a15aef169162e733843eb9299bcf990db78eee8 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 17:31:26 +0900 Subject: [PATCH 33/51] fix(torsion): coupled held lines step, body passes converge, a lazy wave in current starts at any pretwist (#82) ## Summary Three torsion defects from the 0.4.0 robustness campaign (all present on dev), each with a gate that fails on the old code. - **Strong torque-tension coupling** (`torsion_coupling_still`). With `K >= 0.85 sqrt(EA GJ)` (and `-0.8` with one end free in torsion) a held line in exact static equilibrium failed its dynamic step within 0.05-0.9 s ("Newton did not converge, ||G|| = 2.4e-8 > tol = 1e-8"). The round-off floor of the step's convergence norm took only the kernel's `EA - K^2/GJ`; it now also takes the coupling's share of the axial force and of the element torque, whose twist `-(K/GJ)(l - l0)` is formed from coordinates. Held lines with `K` up to `0.99 sqrt(EA GJ)`, in either sense and with one end free, hold at the default `dtM` and tolerance. - **Static body passes of a cable restrained in torsion between two Rigid6 bodies** (`torsion_body_passes`). The passes compared the change of the cable's end loads with 1e-10 of their scale, below the resolution of the core's body balance (1e-9 of the bodies' net weight): at 360 deg (Rigid ends) and 300 deg (Pinned) they stalled near 2e-9 and the deck stopped, with advice (`bodyIC deck`) that was not the remedy. They now stop at the resolution the core leaves; the Rigid 360 deg case converges in 6 passes (torque 4886.24 N m) and the pretwist sweep 120-720 deg converges for both end kinds. - **A lazy wave restrained in torsion in an in-plane current** (`torsion_current_start`). With 25 buoyancy modules in a 0.5 m/s current its untwisted static state, solved in its vertical plane, is unstable out of that plane on its mesh, which the deck without torsion accepts with a note; the torsion stage refused the twisted state although the twist added no negative stiffness mode ("torsion continuation stalled at Phi = 0 (target 0)" at pretwist 0, an unstable equilibrium after a failed Newton solve at 360 deg). A twisted state with no more negative modes than its untwisted one is now kept, and the note names the instability as the untwisted state's. Two more causes made this start depend on the pretwist and on the BLAS kernel's round-off. First, the coarse branch-selection build (and the other static helper builds) ran the torsion stage, and its twisted state seeded the untwisted solve on the deck mesh: 180 deg stopped in the attachment polish, and 360 deg needed the polish's fallbacks and stopped with `OPENBLAS_CORETYPE=Prescott`. Second, each pass of the attachment fixed point after the first applied the drag of the last twisted shape in full at the untwisted start, so 270 deg and more stopped before any twist. Helper builds now solve the untwisted line, and the change of the attachment loads is ramped with the imposed twist (new `f_nodal_twist` of `CD_HermiteCable_Static_Solve`). Pretwists from 0 to 720 deg now start without fallbacks, with the same torques on Haswell and Prescott kernels, proportional to the pretwist. Also: the "unresolved/kinked equilibrium" refusal names the factor to refine the section's `NumSegs` by. ## Checks ctest 356 of 356 (OpenBLAS `Prescott` kernel); checked Debug build (`-fcheck=all`) on the 26 torsion tests; `torsion_current_start` deck at pretwist 0-720 deg on the Haswell and Prescott kernels; example A/B 53 of 53 identical; pre-commit (fprettify-stable), Sphinx `-W`. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 32 +++++ CMakeLists.txt | 25 ++++ doc/troubleshooting.rst | 30 ++++- src/CableDyn_DeckDriver.f90 | 187 +++++++++++++++++++++----- src/CableDyn_HermiteCableDynamic.f90 | 41 +++++- src/CableDyn_HermiteCableStatic.f90 | 165 ++++++++++++++++++++++- src/CableDyn_HermiteTorsion.f90 | 11 ++ tests/test_torsion_body_passes.f90 | 169 +++++++++++++++++++++++ tests/test_torsion_coupling_still.f90 | 186 +++++++++++++++++++++++++ tests/test_torsion_current_start.py | 130 ++++++++++++++++++ 10 files changed, 926 insertions(+), 50 deletions(-) create mode 100644 tests/test_torsion_body_passes.f90 create mode 100644 tests/test_torsion_coupling_still.f90 create mode 100644 tests/test_torsion_current_start.py diff --git a/CHANGELOG.md b/CHANGELOG.md index ba47391b..339d5a95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -451,6 +451,38 @@ All notable changes to CableDyn are recorded in this file. The format follows the IEA-15 MW mixed example in a 60 s platform motion changes by 1.6e-6 of its cable tension. Cost: a coupled cable step takes about 2.0 tangent factorisations instead of 1.1, and the aggregate step of that example (chains included) 38 % more CPU time (the D03 deck: 19 %). +- A held line under strong torque-tension coupling stays still in its dynamics. With + `K >= 0.85 sqrt(EA GJ)` (and at `-0.8` with one end free in torsion) a line in exact static + equilibrium failed its step within 0.05-0.9 s ("Newton did not converge, ||G|| = 2.4e-8 > + tol = 1e-8"): the round-off floor of the step's convergence norm took only the kernel's + `EA - K^2/GJ`, not the coupling's share of the axial force and of the torque. It now takes + both; at `K` up to `0.99 sqrt(EA GJ)` in either sense the held line holds at the default `dtM` + and tolerance (`torsion_coupling_still`), and lines with `|K| <= 0.8 sqrt(EA GJ)` step as before. +- The static passes of a finite-EI cable restrained in torsion between two Rigid6 bodies + converge at every pretwist. They compared the change of the cable's end loads with 1e-10 of + their scale, below the resolution of the core's body balance (1e-9 of the bodies' net weight), + so at 360 deg (Rigid ends) and 300 deg (Pinned) they stalled near 2e-9 and the deck stopped, + with advice (`bodyIC deck`) that was not the remedy. They now stop at the resolution the core + leaves: the Rigid 360 deg case converges in 6 passes (torque 4886.24 N m), and the + pretwist sweep 120-720 deg of both end kinds converges (`torsion_body_passes`). +- A lazy wave restrained in torsion starts in an in-plane current. In a 0.5 m/s current its + untwisted static state, solved in its vertical plane, is unstable out of that plane on its mesh + (one negative stiffness mode), which the deck without torsion accepts with a note; the torsion + stage refused the twisted state as unstable although the twist added no negative mode ("torsion + continuation stalled at Phi = 0 (target 0)" at pretwist 0, an unstable equilibrium after a + failed Newton solve at 360 deg). A twisted state with no more negative modes than its untwisted + one is now kept, and the note names the instability as the untwisted state's + (`torsion_current_start`). Its start also depended on the pretwist and on the round-off of the + BLAS kernel: the coarse branch-selection build of a line restrained in torsion twisted it, and + that twisted state seeded the untwisted solve on the deck mesh (pretwist 180 deg stopped in the + attachment polish, 360 deg needed the polish's fallbacks and stopped with + `OPENBLAS_CORETYPE=Prescott`); and each pass of the attachment fixed point after the first + applied the drag of the last twisted shape in full at the untwisted start (270 deg and more + stopped before any twist). The static helper builds now solve the untwisted line, and the + change of the attachment loads is ramped with the imposed twist: pretwists from 0 to 720 deg + start with the same torques on every kernel, proportional to the pretwist. +- The "unresolved/kinked equilibrium" refusal names the element and the factor to refine its + section's `NumSegs` by. - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e462550..9521cb50 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1803,6 +1803,18 @@ if(Python3_Interpreter_FOUND) # 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. + # A lazy wave restrained in torsion starts in an in-plane current (its untwisted state's + # out-of-plane instability is kept, not refused by the torsion stage). + add_test(NAME torsion_current_start + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_torsion_current_start.py + --exe $ + --data ${CMAKE_CURRENT_SOURCE_DIR}/tests/data + --output ${CMAKE_BINARY_DIR}/torsion_current_start) + set_tests_properties(torsion_current_start PROPERTIES + LABELS "python;driver;integration;static" + TIMEOUT 900 + ENVIRONMENT "${_cabledyn_python_test_environment}") + add_test(NAME body_rod_numbering COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_body_rod_numbering.py --exe $ @@ -2321,6 +2333,12 @@ 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") +# The static passes of a cable restrained in torsion between two moored bodies converge at every +# pretwist (they stop at the resolution of the core's balance): the mirror-symmetric start, held. +add_executable(test_torsion_body_passes tests/test_torsion_body_passes.f90) +target_link_libraries(test_torsion_body_passes PRIVATE cabledyn_core) +add_test(NAME torsion_body_passes COMMAND test_torsion_body_passes) +set_tests_properties(torsion_body_passes PROPERTIES LABELS "fortran;driver;integration;dynamic;static") add_executable(test_pinned_cable_light_object tests/test_pinned_cable_light_object.f90) target_link_libraries(test_pinned_cable_light_object PRIVATE cabledyn_core) @@ -2355,6 +2373,13 @@ 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") +# A held line under strong torque-tension coupling (K up to 0.99 sqrt(EA GJ), either sense, one +# end free in torsion) stays still at the default dtM and dynamic tolerance: the round-off floor of +# the step's convergence norm carries the coupling's share of the axial force and of the torque. +add_executable(test_torsion_coupling_still tests/test_torsion_coupling_still.f90) +target_link_libraries(test_torsion_coupling_still PRIVATE cabledyn_core) +add_test(NAME torsion_coupling_still COMMAND test_torsion_coupling_still) +set_tests_properties(torsion_coupling_still PROPERTIES LABELS "fortran;driver;integration;dynamic") # Torsion and prescribed motion on the standalone mixed EI = 0 + finite-EI route (the driver # executable marches the aggregate): route equivalence with the cubic-Hermite route under vessel diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 8322bfe9..fdefde91 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -281,11 +281,17 @@ Model data 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`` + on a body or rod) did not converge after 60 passes (relative end-load change ..., + tolerance ...)`` - 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``). + more strongly than their own restoring holds them. The passes stop at a change of 1e-7 of + the end-load scale (1e-10 with torsion), or at the resolution each pass's balance of the + objects leaves (four times its residual load) where that is larger, so a change above the + reported tolerance is not round-off. Restrain the object more stiffly (its moorings or + ``C44``/``C55``) or soften the connection (a finite ``Stiffness``, a ``Pinned`` end or a + finite ``TorsStiffness``); ``OPTION bodyIC deck`` skips the balance and starts the objects + out of equilibrium at their deck poses. * - ``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``/ @@ -546,9 +552,14 @@ but a few geometries are genuinely hard: - **A residual-converged folded branch.** CableDyn checks the element rotation measure after every finite-EI sequence attempt, every final deck-built equilibrium, and the public automatic-mesh route. ``max(h*kappa) > 0.7`` is rejected by name even if Newton's residual is small. This is a - mesh/branch safety failure, not permission to relax the tolerance. Increase resolution in the - reported high-curvature section and inspect the static profile. The check samples element - interiors adaptively, so a cubic-element fold cannot hide between output nodes. + mesh/branch safety failure, not permission to relax the tolerance. The refusal names the + element and the factor to refine ``NumSegs`` by there (``refine NumSegs at least x about + element ...``): on a resolved bend the curvature does not change with the mesh, so ``h*kappa`` + falls with the element length and ``n`` is ``max(h*kappa)/0.7`` rounded up, times the + refinement the solve already applied to the deck element. Refine the reported section by it + and inspect the static profile; a fold that stays kinked on the finer mesh is a non-physical + branch, not a resolution limit. The check samples element interiors adaptively, so a + cubic-element fold cannot hide between output nodes. - **Odd, prime, or section-wise nonuniform meshes.** These are supported; do not change ``NumSegs`` merely to make the total divisible by two. The nested hierarchy retains physical section interfaces and interpolates at the true cumulative rest-length coordinate. Its @@ -595,7 +606,12 @@ but a few geometries are genuinely hard: equilibrium on the path, typically because a loop is forming (hockling), which needs a dynamic analysis and is not resolved as self-contact. ``finite-EI torsion static solve ended on an unstable equilibrium`` means the descent from a buckled (unstable) twisted state did not - find a stable one. ``the twist moved more than pi/2 from its committed value in one step`` + find a stable one. The twist stages refuse, or descend from, only an instability the twist + adds: a twisted state with no more negative stiffness modes than its untwisted state (a + planar state that is unstable out of its plane, which a line without torsion starts from with + a note) starts with the note ``the twisted static state keeps the instability of its untwisted + state``. Where such a state cannot be kept, ``torsion stage failed: the untwisted equilibrium + it starts from is itself unstable`` names the untwisted state, not the twist, as the cause. ``the twist moved more than pi/2 from its committed value in one step`` stops a dynamic step that would change the twist by more than a quarter turn (the unwrapping of the twist cannot be trusted beyond it): reduce ``dtM`` or slow the imposed roll. ``tangent turns by more than 120 degrees`` names an element or node pair where the twist of diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 79e3d75a..467f8277 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -78,8 +78,8 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Axial_Resultant_Range, CD_HermiteCable_Element, CD_HCABLE_OK, & CD_HermiteCable_Gauss_Rule USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve_AutoMesh, CD_HermiteCable_Static_Solve, & - CD_HermiteCable_Prolong_Arc, & - CD_HC_OSCILLATION_REL_TOL, & + CD_HermiteCable_Prolong_Arc, CD_HermiteCable_Kink_Advice, & + CD_HermiteCable_Element_Ratio, CD_HC_OSCILLATION_REL_TOL, & CD_HermiteCable_Static_Solve_Sequenced, CD_HCSTAT_OK, & CD_HCSTAT_BADINPUT, & CD_HermiteCable_Sequence_Coarse_Max_Length, & @@ -1667,6 +1667,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! Set when the attachment polish needed its fallbacks (attachment_fallback_checks). LOGICAL :: att_fell_back LOGICAL :: bathymetry_flat, require_3d_static, sym_broken, planar_unstable, saddle_kept + ! whether the line would be solved in 3D without its torsion (a twisted line always is) + LOGICAL :: require_3d_untwisted ! A planar equilibrium in a current that is a saddle out of its plane (see route_pass). REAL(wp), ALLOCATABLE :: l0_saddle(:), ea_saddle(:), ei_saddle(:), w_saddle(:), q_saddle(:), curv_saddle(:) INTEGER, ALLOCATABLE :: fixed_saddle(:) @@ -1718,6 +1720,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! static load stage on the final mesh, then installed in the cable; a line restrained at one ! end only (ln%tors_free_end) has no static torque and installs its free end. LOGICAL :: tors_line + ! whether this build twists the line: not in a static helper build (standalone_controls + ! .FALSE.: the coarse branch selection, the auxiliary-weight seed, the friction reference and + ! the no-current diagnosis), whose callers take the untwisted equilibrium. A coarse state + ! twisted by the line's pretwist seeded the untwisted solve on the deck mesh, which then + ! depended on the pretwist (a lazy wave restrained in torsion in an in-plane current stopped + ! at 180 deg). + LOGICAL :: twist_here TYPE(CD_HermiteTorsionType) :: tors ! the residual tolerance the accepted torsion stage met (torsion_note) REAL(wp) :: tors_tol_used @@ -1897,7 +1906,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! torsional line is solved in 3D from the start; a line free in torsion at one end carries no ! static torque, so its statics are those of the line without torsion. tors_line = line_torsion_active(ln) - IF (tors_line .AND. ln%tors_free_end == 0) require_3d_static = .TRUE. + twist_here = tors_line + IF (PRESENT(standalone_controls)) twist_here = tors_line .AND. standalone_controls ! A current with a component across the vertical plane of the chord pushes the line out ! of that plane, which the dynamics (endpoints held, every other DOF free) follow: the ! static equilibrium is then solved in 3D as well. @@ -1934,6 +1944,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, ! reference, and the friction it holds, out of that plane: solved in 3D as well. This is ! decided here, before the held (planar) DOFs below are chosen. IF (as_laid_off_plane()) require_3d_static = .TRUE. + require_3d_untwisted = require_3d_static + IF (tors_line .AND. ln%tors_free_end == 0) 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, ktt=ktt_in, bt=bt_in) @@ -2925,7 +2937,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF ! A line with ATTACHMENTS takes its torsion stage on the discrete equilibrium, after the ! attachment polish (torsion_after_attachments). - IF (tors_line .AND. .NOT. has_att) THEN + IF (twist_here .AND. .NOT. has_att) THEN CALL torsion_stage(es, em) IF (es /= CD_DECKDRV_OK) THEN ErrStat = es @@ -2959,6 +2971,8 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, WRITE (em, '(A,ES12.5,A,ES12.5,A,I0)') & 'unresolved/kinked finite-EI equilibrium: max(h*kappa)=', diag%h_kappa_peak, & ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', diag%h_kappa_elem + em = TRIM(em)//TRIM(CD_HermiteCable_Kink_Advice(diag%h_kappa_peak, diag%h_kappa_elem, SIZE(l0_am), & + CD_HermiteCable_Element_Ratio(l0, l0_am, diag%h_kappa_elem))) CALL fail_solve(ErrStat, ErrMsg, TRIM(em)); RETURN END IF IF (opts%tensile_mode == CD_HCDYN_TENSILE_ERROR .AND. diag%axial_compression) THEN @@ -3081,7 +3095,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, IF (.NOT. tors_line) & CALL handoff_lateral_note(l0, l0, ea, ei, w_bare, w, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & fixed_dofs, .TRUE.) - IF (tors_line) THEN + IF (twist_here) THEN CALL torsion_after_attachments(es, em) IF (es == CD_DECKDRV_OK) CALL twisted_attachment_checks(es, em) IF (es /= CD_DECKDRV_OK) THEN @@ -3149,13 +3163,13 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, CALL fail(ErrStat, ErrMsg, 'finite-EI cable end-connection wiring failed: '//TRIM(em)); RETURN END IF END IF - IF (tors_line .AND. ln%tors_free_end == 1) THEN + IF (twist_here .AND. ln%tors_free_end == 1) THEN ! a free End A: its torsion frame is a gauge, which no parent turns CALL CD_HFMF_Set_Torsion(cable, tors, es, em) IF (es /= CD_HFMF_OK) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI cable torsion wiring failed: '//TRIM(em)); RETURN END IF - ELSE IF (tors_line) THEN + ELSE IF (twist_here) 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; a ! moving End B's frame (director -Ez, normal Nx of End B) is held by End B's parent likewise. @@ -3311,7 +3325,7 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, END IF CONTAINS - SUBROUTINE torsion_stage(est, emt, f_nodal) + SUBROUTINE torsion_stage(est, emt, f_nodal, f_twist) !! The condensed-torsion load stage of a line restrained in torsion at both ends: from the !! converged untwisted state on the final mesh (l0_am), CD_HermiteCable_Static_Solve ramps !! the imposed twist Phi = Pretwist(End B) - Pretwist(End A) with the same loads, contact, @@ -3320,7 +3334,8 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) !! is deck End B (global axes), end 2 deck End A (its parent's axes, turned with it). !! f_nodal: the stage of a line with ATTACHMENTS, after the attachment polish (the final !! mesh then is l0, with the bare weights w_bare and the deck mesh l0_deck_att), with the - !! attachments' lumped loads. + !! attachments' lumped loads; f_twist, with f_nodal, a change of those loads ramped with + !! the imposed twist (torsion_after_attachments). !! A line restrained at one end only (ln%tors_free_end) carries no static torque: the !! untwisted state is its static state, Theta is evaluated there, and the free end's frame !! is a gauge (end_free): the end's connection direction, or its static tangent at a @@ -3328,6 +3343,7 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) + REAL(wp), INTENT(IN), OPTIONAL :: f_twist(:) REAL(wp) :: nvec(3), dvec(3), tol_t INTEGER :: k, attempt, kf LOGICAL :: nodal_loads @@ -3348,6 +3364,14 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) tors = CD_HermiteTorsionType() tors%active = .TRUE. tors%quadrature_order = opts%bending_quadrature_order + ! The untwisted state was accepted by the checks of a line without torsion, which start a + ! state that is unstable out of its vertical plane with a note (handoff_lateral_note, a + ! kept planar saddle): the stage refuses, or descends from, only an instability the twist + ! adds, and keeps the untwisted state's own (torsion_note names it). A lazy wave with 25 + ! modules in an in-plane 0.5 m/s current, whose discrete planar equilibrium has one + ! out-of-plane negative mode with or without torsion, was refused at Phi = 0 ("the twisted + ! equilibrium is unstable", with no twist to impose). + tors%keep_untwisted_instability = .TRUE. tors%gj = gj_in IF (SIZE(lf) /= SIZE(ld)) CALL remap_elem_by_reference_arc(tors%gj, ld, lf) ! torque-tension coupling: K/GJ per element (left unallocated without coupling) @@ -3428,12 +3452,14 @@ SUBROUTINE torsion_stage(est, emt, f_nodal) CALL hermite_static_torsion(l0, l0, ea, ei, w_bare, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & q_static, curv, fixed_dofs, contact_enabled, contact_z, frame_cs, & endconn_k, endconn_d0_local, endconn_mode, opts, tol_t, tors, est, emt, & - bathymetry=bathymetry, cur_obj=cur_obj, f_nodal=f_nodal) + bathymetry=bathymetry, cur_obj=cur_obj, f_nodal=f_nodal, & + f_nodal_twist=f_twist) ELSE CALL hermite_static_torsion(l0, l0, ea, ei, w_bare, diam, opts%rhoW*opts%g*QUARTER_PI*diam**2, & q_static, curv, fixed_dofs, contact_enabled, contact_z, frame_cs, & endconn_k, endconn_d0_local, endconn_mode, opts, tol_t, tors, est, emt, & - cur_obj=cur_obj, f_nodal=f_nodal) + cur_obj=cur_obj, f_nodal=f_nodal, & + f_nodal_twist=f_twist) END IF ELSE IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN CALL hermite_static_torsion(l0, l0_am, ea_am, ei_am, w_am, diam, dry_b, q_static, curv, fixed_am, & @@ -3468,6 +3494,12 @@ SUBROUTINE torsion_note() tors%phi*45.0_wp/QUARTER_PI, ' deg, torque ', tors%torque, ' N m (', tors%ramp_steps, & ' twist stage(s), ', tors%descents, ' buckling descent(s))' CALL report_note(tnote) + IF (tors%untwisted_instability) THEN + WRITE (tnote, '(A,I0,A,I0,A)') 'line ', ln%id, ': the twisted static state keeps the instability of '// & + 'its untwisted state (', tors%n_negative, ' negative stiffness mode(s), none added by the twist), '// & + 'which a line without torsion starts from as well; a disturbance can move the line away from it' + CALL report_note(tnote) + END IF END SUBROUTINE torsion_note SUBROUTINE torsion_after_attachments(est, emt) @@ -3478,12 +3510,16 @@ SUBROUTINE torsion_after_attachments(est, emt) !! line tangent, and the weight on the side of the surface, so the stage is repeated, each !! time a fresh torsion solve from the last state, with the loads of the last solution until !! the solution stops moving and no attachment changes side (fixed point, as in - !! attachment_static_polish). + !! attachment_static_polish). Every pass starts from the polished state, in equilibrium + !! under the loads at that state: the change to the loads of the last solution is ramped + !! with the imposed twist, in full at the target. Taken in full from the untwisted start, the + !! drag of a twisted shape pushed a lazy wave whose untwisted state is unstable out of its + !! plane off that state before any twist (pretwist 270 deg and more in a 0.5 m/s current). INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt INTEGER, PARAMETER :: MAX_FIXED_POINT = 60 REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m - REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), q_prev(:), q_polished(:) + REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), q_prev(:), q_polished(:), f_untwisted(:) LOGICAL, ALLOCATABLE :: att_dry(:), att_dry_now(:) LOGICAL :: has_drag INTEGER :: fp, k_cross @@ -3513,7 +3549,12 @@ SUBROUTINE torsion_after_attachments(est, emt) END IF q_prev = q_static q_static = q_polished - CALL torsion_stage(est, emt, f_att + f_drag) + IF (fp == 1) THEN + f_untwisted = f_att + f_drag + CALL torsion_stage(est, emt, f_untwisted) + ELSE + CALL torsion_stage(est, emt, f_untwisted, f_att + f_drag - f_untwisted) + END IF IF (est /= CD_DECKDRV_OK) THEN IF (k_cross > 0) emt = TRIM(cause)//'; '//TRIM(emt) RETURN @@ -3559,11 +3600,12 @@ SUBROUTINE twisted_attachment_checks(est, emt) IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN CALL attachment_mesh_checks(l0, q_static, ea, ei, att_node, contact_z, & opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, TWISTED_WHAT, accepted_t, msg_t, & - bathymetry=bathymetry, frame_cs=frame_cs, axial_offset=tors_axial_offset) + bathymetry=bathymetry, frame_cs=frame_cs, axial_offset=tors_axial_offset, & + l0_deck=l0_deck_att) ELSE CALL attachment_mesh_checks(l0, q_static, ea, ei, att_node, contact_z, & opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, TWISTED_WHAT, accepted_t, msg_t, & - axial_offset=tors_axial_offset) + axial_offset=tors_axial_offset, l0_deck=l0_deck_att) END IF IF (.NOT. accepted_t) THEN est = CD_DECKDRV_SOLVEFAIL @@ -4483,8 +4525,30 @@ SUBROUTINE attachment_fallback_checks() !! dead loads), the rest there. Fails closed with the verdict's message. LOGICAL :: stable_f, accepted_f CHARACTER(1024) :: msg_f + INTEGER, ALLOCATABLE :: fixed_f(:) + INTEGER :: nn_f, i_f + ! A line restrained in torsion is solved in 3D, but where the same line free in torsion is + ! solved in its vertical plane, its untwisted discrete state is tested as that line's is, with + ! the out-of-plane DOFs held: the torsion stage that follows tests the twisted state in 3D and + ! keeps only an instability its untwisted state has (a planar state unstable out of its plane, + ! which the line free in torsion starts from with a note). Without it the lazy wave with 25 + ! modules restrained in torsion, Pretwist 360 deg, in an in-plane 0.5 m/s current, was refused + ! for its out-of-plane mode before any twist whenever its polish needed its fallbacks. + fixed_f = fixed_dofs + IF (tors_line .AND. ln%tors_free_end == 0 .AND. .NOT. require_3d_untwisted) THEN + IF (.NOT. as_laid_cross_slope()) THEN + nn_f = SIZE(l0) + 1 + fixed_f = [1, 2, 3, 6*nn_f - 5, 6*nn_f - 4, 6*nn_f - 3] + DO i_f = 1, nn_f + fixed_f = [fixed_f, 6*(i_f - 1) + 2] + IF ((i_f == 1 .AND. endconn_mode(1) == CD_ENDCONN_RIGID) .OR. & + (i_f == nn_f .AND. endconn_mode(2) == CD_ENDCONN_RIGID)) CYCLE + fixed_f = [fixed_f, 6*(i_f - 1) + 5] + END DO + END IF + END IF IF (PRESENT(bathymetry) .AND. .NOT. bathymetry_flat) THEN - CALL hermite_static_stable(l0, l0, ea, ei, w_bare, diam, dry_b_final(), q_static, fixed_dofs, & + CALL hermite_static_stable(l0, l0, ea, ei, w_bare, diam, dry_b_final(), q_static, fixed_f, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, endconn_mode, & opts, stable_f, ErrStat, ErrMsg, bathymetry=bathymetry, cur_obj=cur_obj) IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -4492,7 +4556,7 @@ SUBROUTINE attachment_fallback_checks() opts%tensile_mode == CD_HCDYN_TENSILE_ERROR, stable_f, accepted_f, msg_f, & bathymetry=bathymetry, frame_cs=frame_cs) ELSE - CALL hermite_static_stable(l0, l0, ea, ei, w_bare, diam, dry_b_final(), q_static, fixed_dofs, & + CALL hermite_static_stable(l0, l0, ea, ei, w_bare, diam, dry_b_final(), q_static, fixed_f, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0_local, endconn_mode, & opts, stable_f, ErrStat, ErrMsg, cur_obj=cur_obj) IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -6830,7 +6894,7 @@ END SUBROUTINE hermite_static_stable SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q, curv, fixed_dofs, & contact_enabled, contact_z, frame_cs, endconn_k, endconn_d0, endconn_mode, opts, & - tol, tors, ErrStat, ErrMsg, bathymetry, cur_obj, f_nodal) + tol, tors, ErrStat, ErrMsg, bathymetry, cur_obj, f_nodal, f_nodal_twist) !! Torsion stage of a deck cable on its final mesh l0: CD_HermiteCable_Static_Solve from the !! converged untwisted state q (one EI and buoyancy stage, a polish) with the torsion !! description tors, under the same contact, dry-buoyancy, end-connection and current terms @@ -6850,6 +6914,8 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry TYPE(CD_HermiteStaticCurrentType), INTENT(IN), OPTIONAL :: cur_obj REAL(wp), INTENT(IN), OPTIONAL :: f_nodal(:) + ! with f_nodal: its change ramped with the imposed twist (CD_HermiteCable_Static_Solve) + REAL(wp), INTENT(IN), OPTIONAL :: f_nodal_twist(:) REAL(wp), ALLOCATABLE :: diam(:), dry(:), knnode(:), q_out(:) REAL(wp) :: res INTEGER :: i, ne, it, es @@ -6880,7 +6946,7 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors, & - f_nodal=f_nodal) + f_nodal=f_nodal, f_nodal_twist=f_nodal_twist) ELSE CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w, q, fixed_dofs, contact_z, CD_ZERO, 1, 200, & tol, 0.7_wp, q_out, curv, res, it, es, em, n_buoy_steps=1, & @@ -6889,14 +6955,14 @@ SUBROUTINE hermite_static_torsion(l0_deck, l0, ea, ei, w, diam_deck, dry_deck, q endconn_stiffness=endconn_k, endconn_direction=endconn_d0, & endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & water_weight=opts%rhoW*opts%g, current=cur_obj, torsion=tors, & - f_nodal=f_nodal) + f_nodal=f_nodal, f_nodal_twist=f_nodal_twist) END IF IF (es == CD_HCSTAT_BADINPUT) THEN CALL fail(ErrStat, ErrMsg, 'finite-EI torsion static solve rejected the input: '//TRIM(em)); RETURN ELSE IF (es /= CD_HCSTAT_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI torsion static solve failed: '//TRIM(em)); RETURN END IF - IF (.NOT. tors%stable) THEN + IF (.NOT. tors%stable .AND. .NOT. tors%untwisted_instability) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI torsion static solve ended on an unstable equilibrium'); RETURN END IF q = q_out @@ -6951,7 +7017,7 @@ SUBROUTINE CD_Attachment_Discrete_Verdict(l0, q, ea, ei, w, diam, endconn_mode, END SUBROUTINE CD_Attachment_Discrete_Verdict SUBROUTINE attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_error, what, accepted, message, & - bathymetry, frame_cs, axial_offset) + bathymetry, frame_cs, axial_offset, l0_deck) !! The mesh safety checks of a discrete attachment equilibrium on its mesh l0 with state q: !! 1. the kink limit (h*kappa <= CD_HC_KINK_LIMIT), except on the elements beside an !! attachment node att_node, where the lumped load turns the line by a slope jump that the @@ -6970,6 +7036,8 @@ SUBROUTINE attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_er TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry REAL(wp), INTENT(IN), OPTIONAL :: frame_cs(2) REAL(wp), INTENT(IN), OPTIONAL :: axial_offset(:) + ! the deck mesh l0 refines (the kink advice names the factor for its NumSegs) + REAL(wp), INTENT(IN), OPTIONAL :: l0_deck(:) TYPE(CD_HermiteResolutionType) :: diag REAL(wp), ALLOCATABLE :: hk(:) LOGICAL, ALLOCATABLE :: beside(:) @@ -7011,6 +7079,12 @@ SUBROUTINE attachment_mesh_checks(l0, q, ea, ei, att_node, contact_z, tensile_er IF (hk_peak > CD_HC_KINK_LIMIT) THEN WRITE (em, '(A,ES12.5,A,ES12.5,A,I0,A)') 'is unresolved/kinked: max(h*kappa)=', hk_peak, & ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', e_peak, ' (away from the attachment nodes)' + IF (PRESENT(l0_deck)) THEN + em = TRIM(em)//TRIM(CD_HermiteCable_Kink_Advice(hk_peak, e_peak, ne, & + CD_HermiteCable_Element_Ratio(l0_deck, l0, e_peak))) + ELSE + em = TRIM(em)//TRIM(CD_HermiteCable_Kink_Advice(hk_peak, e_peak, ne)) + END IF message = what//TRIM(em); RETURN END IF IF (tensile_error .AND. diag%axial_compression) THEN @@ -7130,6 +7204,7 @@ SUBROUTINE audit_hermite_static(l0, q, ea, ei, w, diam, endconn_mode, physical, CASE (CD_HC_AUDIT_KINK) WRITE (message, '(A,ES10.3,A,ES10.3,A,I0)') 'unresolved/kinked equilibrium: max(h*kappa)=', & audit%h_kappa_peak, ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', audit%h_kappa_elem + message = TRIM(message)//TRIM(CD_HermiteCable_Kink_Advice(audit%h_kappa_peak, audit%h_kappa_elem, SIZE(l0))) END SELECT IF (physical) message = '' END SUBROUTINE audit_hermite_static @@ -26238,7 +26313,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_b) + end_force_a, quiet, skipped, ext_km, ext_rot, end_force_b, res_left) !! 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 @@ -26321,6 +26396,10 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l ! skipped: the objects were held at their deck poses (a moving line has no moving-end ! static solve), so nothing was balanced LOGICAL, INTENT(OUT), OPTIONAL :: skipped + ! res_left: the net load the solve leaves on the objects, the largest force [N] or moment + ! [N m] of an object at the returned poses (zero when nothing was balanced): the resolution of + ! the balance, which the passes of solve_body_equilibrium cannot refine + REAL(wp), INTENT(OUT), OPTIONAL :: res_left TYPE :: LineStaticCache !! A moving line's mesh and loads (fixed) and its last converged shape (the warm seed). @@ -26365,6 +26444,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l silent = .FALSE. IF (PRESENT(quiet)) silent = quiet IF (PRESENT(skipped)) skipped = .FALSE. + IF (PRESENT(res_left)) res_left = CD_ZERO IF (.NOT. (only_points .OR. opts%body_ic_static)) RETURN ! the objects that move: free Rigid6 bodies and free rods with a line, then Free/Connect points ALLOCATE (okind(SIZE(bodies) + SIZE(rods) + SIZE(points)), idx(SIZE(bodies) + SIZE(rods) + SIZE(points))) @@ -26693,6 +26773,18 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l END IF EXIT END DO + IF (PRESENT(res_left)) THEN + ! the force rows of r are in N, the moment rows scaled by the object length lsc + res_left = CD_ZERO + DO k = 1, nobj + IF (okind(k) == OBJ_PIN) THEN + res_left = MAX(res_left, MAXVAL(ABS(r(off(k) + 1:off(k) + ndof(k))))*lsc(k)) + ELSE + res_left = MAX(res_left, MAXVAL(ABS(r(off(k) + 1:off(k) + MIN(3, ndof(k)))))) + IF (ndof(k) > 3) res_left = MAX(res_left, MAXVAL(ABS(r(off(k) + 4:off(k) + ndof(k))))*lsc(k)) + END IF + END DO + END IF IF (unstable) THEN IF (only_points) THEN CALL fail_solve(ErrStat, ErrMsg, 'static point equilibrium found is unstable: '// & @@ -27911,13 +28003,22 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, !! Hermite connection moment, both evaluated at the previous pass's equilibrium. The passes !! repeat from the deck state until these loads change by at most 1e-7 of the force scale !! (moments of the force scale times 1 m), so the converged pose balances the Hermite cable - !! exactly: at the fixed point the core's surrogate end force cancels. A deck without such a + !! exactly: at the fixed point the core's surrogate end force cancels. A change is resolved + !! only down to the net load each pass's core solve leaves on the objects (res_left, its + !! tolerance 1e-9 of the core's own force scale, the largest net weight or line end force, or + !! its round-off): the end loads are those of poses balanced to that load, so two passes + !! differ by up to twice it (the end stiffness at most the stiffness that balances the + !! objects), and the passes stop on a change of at most PASS_RES_FACTOR times the larger of + !! the last two passes' res_left when that is above the tolerance. A deck without such a !! line is the core solve unchanged. A line with condensed torsion also returns its torque, !! which depends on the object's rotation as strongly as GJ/L: each pass then also gives the !! 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. A finite-EI line between + !! alone would need it far above GJ/L), to 1e-10 of the force scale (two moored 20 t bodies, + !! whose net weights set the core's scale to 13 times the line's end force, leave a res_left + !! of up to 5e-9 of that end force: their passes stalled at a change of 1-4e-9 for 60 passes, + !! the torque settled to six digits from the fourth). 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 @@ -27942,6 +28043,8 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, REAL(wp), INTENT(OUT), OPTIONAL :: jac_check_err INTEGER, PARAMETER :: MAX_PASS = 60, ANDERSON_DEPTH = 6 REAL(wp), PARAMETER :: PASS_TOL = 1.0e-7_wp, PASS_TOL_TORSION = 1.0e-10_wp, ANDERSON_DROP = 1.0e-6_wp + ! twice the res_left of a pass (two passes, each off by its own) and a margin of 2 + REAL(wp), PARAMETER :: PASS_RES_FACTOR = 4.0_wp TYPE(DeckBody), ALLOCATABLE :: bodies0(:) TYPE(DeckRod), ALLOCATABLE :: rods0(:) TYPE(DeckPoint), ALLOCATABLE :: points0(:) @@ -27961,8 +28064,17 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, TYPE(DeckLine), ALLOCATABLE :: lines_core(:) INTEGER :: attempt, n_attempt, first_stat CHARACTER(1024) :: first_msg - REAL(wp) :: scale, change, pass_tol_eff - CHARACTER(24) :: b1 + REAL(wp) :: scale, change, pass_tol_eff, res_core, res_core_prev, pass_floor + CHARACTER(24) :: b1, b2 + ! the failure's advice: the passes balance each object against the line's end loads at the + ! last pose, so they settle only where the object's own restoring stiffness and its other + ! lines hold it against the change of those loads with its pose + CHARACTER(*), PARAMETER :: PASS_REMEDY = 'the end loads of the line change with the pose of its object(s) '// & + 'faster than the object''s restoring stiffness and its other lines settle them; '// & + 'restrain the object more stiffly (its moorings or C44/C55) or soften the '// & + 'connection (a finite Stiffness, a Pinned end or a finite TorsStiffness); OPTION '// & + 'bodyIC deck skips this balance and starts the objects out of equilibrium at their '// & + 'deck poses' ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -28077,6 +28189,8 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, ext_fm = CD_ZERO ext_km = CD_ZERO ext_rot = CD_ZERO + res_core = CD_ZERO + pass_floor = CD_ZERO DO e = 1, ne ext_rot(1, 1, e) = CD_ONE ext_rot(2, 2, e) = CD_ONE @@ -28086,17 +28200,19 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, bodies = bodies0 rods = rods0 points = points0 + res_core_prev = res_core ! the torque stiffness only with torsion: without it the core's arithmetic is exactly that ! of a deck before torsion existed (no zero-stiffness correction, signed zeros kept) IF (pass_tol_eff < PASS_TOL) THEN CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines_core, 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, end_force_b=fsb) + ext_rot=ext_rot, end_force_b=fsb, res_left=res_core) ELSE CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines_core, sections, opts, & ErrStat, ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, & - end_force_a=fs, quiet=pass > 1, skipped=held, end_force_b=fsb) + end_force_a=fs, quiet=pass > 1, skipped=held, end_force_b=fsb, & + res_left=res_core) END IF IF (ErrStat /= CD_DECKDRV_OK) EXIT ! the objects stay at their deck poses (the core has already said why): nothing to balance @@ -28122,7 +28238,9 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, eworst = MAXLOC(MAXVAL(ABS(new_fm - ext_fm), DIM=1), DIM=1) ext_km = new_km ext_rot = new_rot - IF (change <= pass_tol_eff*scale) THEN + ! the resolution of the passes: the net load the last two core solves left + pass_floor = PASS_RES_FACTOR*MAX(res_core, MERGE(res_core_prev, res_core, pass > 1)) + IF (change <= MAX(pass_tol_eff*scale, pass_floor)) THEN ext_fm = new_fm EXIT END IF @@ -28133,20 +28251,21 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, END IF END DO IF (ErrStat == CD_DECKDRV_OK) THEN - IF (change <= pass_tol_eff*scale) EXIT + IF (change <= MAX(pass_tol_eff*scale, pass_floor)) EXIT WRITE (b1, '(ES10.3)') change/scale + WRITE (b2, '(ES10.3)') MAX(pass_tol_eff*scale, pass_floor)/scale IF (nb == 0) THEN CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the END CONNECTION or ATTACHMENTS '// & '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') + 'change '//TRIM(ADJUSTL(b1))//', tolerance '//TRIM(ADJUSTL(b2))//'): '//PASS_REMEDY) 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') + ', tolerance '//TRIM(ADJUSTL(b2))//'): '//PASS_REMEDY) END IF END IF IF (attempt == n_attempt) THEN diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 10e0bf21..6c030390 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -4761,7 +4761,7 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) REAL(wp), POINTER :: Gout(:) INTEGER :: ii, nd INTEGER(INT64) :: ec0, ec1 - REAL(wp) :: xref, xd + REAL(wp) :: xref, xd, xc, ea_r, kt, tw_round REAL(wp), PARAMETER :: RESID_ROUNDOFF = 16.0_wp REAL(wp), PARAMETER :: STATE_DIVERGED = 1.0e12_wp ec0 = 0_INT64 ! defined even with profiling off (see the step-entry note) @@ -4875,18 +4875,37 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) ! so its rounding error is about eps*|r|/l0*EA per element. On a finely meshed, stiff, ! long cable at rest (e.g. 1024 elements, EA ~ 5e8 N, coordinates ~ 1e3 m) that exceeds ! tol*|w|*l0 and a held step stagnates at the floor forever. Raise fscale so tol*fscale - ! is never below RESID_ROUNDOFF times that error; the floor binds only there. + ! is never below RESID_ROUNDOFF times that error; the floor binds only there. With the + ! torque-tension coupling K the kernel carries EA - K^2/GJ and the torque the rest: the + ! coupling force (K/GJ) M_t takes the stretch through M_t = (GJ/l0)(... - (K/GJ)(l - l0)), + ! whose rounding is (K^2/GJ) eps |r|/l0, so the floor takes the whole axial stiffness + ! EA - K^2/GJ + K^2/GJ of the line (without it the floor fell by 1 - K^2/(EA GJ): at + ! K = 0.99 sqrt(EA GJ) to 2 % of the rounding it bounds, and a held line failed its step). xref = MAXVAL(model%l0) DO ii = 1, ndof IF (MOD(ii - 1, 6) < 3) xref = MAX(xref, ABS(qcur(ii))) END DO - fscale = MAX(fscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*MAXVAL(model%EA/model%l0)*xref/tol) + IF (model%torsion%active .AND. ALLOCATED(model%torsion%couple)) THEN + ea_r = CD_ZERO + DO ii = 1, SIZE(model%l0) + ea_r = MAX(ea_r, (ABS(model%EA(ii)) + model%torsion%couple(ii)**2*model%torsion%gj(ii))/model%l0(ii)) + END DO + ELSE + ea_r = MAXVAL(model%EA/model%l0) + END IF + fscale = MAX(fscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*ea_r*xref/tol) ! Nodal twist: the torque scale of the angle rows, frozen with fscale and formed like it ! from the nodal loads (a node's torque imbalance, not the torque the line carries, ! which accumulates the imbalances along the line as the tension does the force's): the ! inertial torques and the predictor's imbalance, at least 1 N m, and the round-off ! floor of an element twist, (GJ/l0 + Bt/l0 gamma/(beta dt)) eps (max|phi| + max|x|/l0) - ! (the damping takes the twist rate, whose Newmark rate amplifies the rounding). + ! (the damping takes the twist rate, whose Newmark rate amplifies the rounding). With the + ! torque-tension coupling the twist tau also takes -(K/GJ)(l - l0), the element length l + ! formed from coordinates with the rounding eps max|x|, so the floor adds + ! (GJ/l0 + Bt/l0 gamma/(beta dt)) |K/GJ| eps max|x| = |K| eps max|x|/l0 (static share): + ! K/l0 exceeds GJ/l0^2 by K l0/GJ (165 on a 2 m mesh at K = 0.85 sqrt(EA GJ), EA/GJ = + ! 9.4e3 m^-2), and without it a held line's rounding of 2.4e-8 N m stood above the + ! tolerance of its 1 N m scale and the step failed. IF (model%tw_active) THEN model%tw_tscale = CD_ONE DO ii = 1, model%nn @@ -4897,8 +4916,18 @@ SUBROUTINE eval_res(qcur, use_trial, rn, esx, emx) END DO xd = MAXVAL(model%torsion%gj/model%l0) IF (ALLOCATED(model%torsion%bt)) xd = xd + MAXVAL(model%torsion%bt/model%l0)*gm/(bt*dt) - model%tw_tscale = MAX(model%tw_tscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*xd* & - (MAX(CD_ONE, MAXVAL(ABS(model%tw_pe))) + xref/MINVAL(model%l0))/tol) + xc = CD_ZERO + IF (ALLOCATED(model%torsion%couple)) THEN + DO ii = 1, SIZE(model%l0) + kt = model%torsion%gj(ii)/model%l0(ii) + IF (ALLOCATED(model%torsion%bt)) kt = kt + model%torsion%bt(ii)/model%l0(ii)*gm/(bt*dt) + xc = MAX(xc, ABS(model%torsion%couple(ii))*kt) + END DO + END IF + tw_round = MAX(CD_ONE, MAXVAL(ABS(model%tw_pe))) + xref/MINVAL(model%l0) + model%tw_tscale = MAX(model%tw_tscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*xd*tw_round/tol) + IF (xc > CD_ZERO) & + model%tw_tscale = MAX(model%tw_tscale, RESID_ROUNDOFF*EPSILON(CD_ONE)*(xd*tw_round + xc*xref)/tol) END IF scale_set = .TRUE. END IF diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 40b1dd63..4aa6374b 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -75,6 +75,7 @@ MODULE CableDyn_HermiteCableStatic PUBLIC :: CD_HermiteCable_Current_Load PUBLIC :: CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Friction_Reference, CD_HermiteCable_As_Laid_Offsets PUBLIC :: CD_HermiteCable_Mean_Axial_Extremes + PUBLIC :: CD_HermiteCable_Kink_Advice, CD_HermiteCable_Element_Ratio PUBLIC :: CD_Arclength_Dot, CD_Arclength_Unit_Tangent, CD_Arclength_Bordered_Update INTEGER, PARAMETER, PUBLIC :: CD_HCSTAT_OK = 0, CD_HCSTAT_BADINPUT = 1, CD_HCSTAT_NOCONVERGE = 2 @@ -301,7 +302,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ waterline_z, dry_buoyancy, merit_line_search, pseudo_transient, & energy_minimization, stable, water_weight, current, residual_out, & tangent_out, friction, residual_unmet, torsion, energy_out, & - end_share_hold) + end_share_hold, f_nodal_twist) !! Solve the finite-EI static equilibrium of a Hermite bending-cable line. !! !! l0(ne), EA(ne), EI(ne), w(ne) : per-element rest length, axial/bending stiffness, @@ -435,6 +436,14 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ !! resting on the seabed; the residual keeps the shares of !! each iterate (CD_Seabed_End_Element_Share). Omitted, an !! energy line search holds the shares of its start. + !! f_nodal_twist (optional, 6*nn) : with torsion, generalized nodal loads (as f_nodal) + !! ramped with the imposed twist: none at the untwisted + !! state, the fraction of the twist continuation at each + !! stage, in full at the target Phi. The change of a load + !! that follows the line's shape (the drag of discrete + !! attachments in a current, evaluated at a twisted state) + !! then leaves the untwisted state in equilibrium under + !! f_nodal alone. REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), seed(:) INTEGER, INTENT(IN) :: fixed_dofs(:) REAL(wp), INTENT(IN) :: seabed_z, kn, tol, damping @@ -472,6 +481,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ REAL(wp), INTENT(OUT), OPTIONAL :: energy_out REAL(wp), INTENT(IN), OPTIONAL :: end_share_hold(2) TYPE(CD_HermiteTorsionType), INTENT(INOUT), OPTIONAL :: torsion + REAL(wp), INTENT(IN), OPTIONAL :: f_nodal_twist(:) INTEGER :: ne, nn, ndof, c, it, es, i, b, nci, n_buoy, omp_threads, axial_order, bending_order REAL(wp) :: eifac, rnorm, fscale, bfac, rmerit, ptc_tau, ptc_rprev, pi_total, pi_abs, lm_mu, chord @@ -513,9 +523,15 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ ! tors_v the lowest mode of an unstable tangent (descent direction). LOGICAL :: use_tors, tors_on, tors_have_mode, tors_descending REAL(wp) :: tors_c, tors_phi_cur, tors_theta_acc, tors_theta_eval, tors_mt, tors_lambda + ! the share of f_nodal_twist the residual takes: the twist continuation's fraction + REAL(wp) :: tors_load_frac REAL(wp), ALLOCATABLE :: tors_g(:), tors_gr(:), tors_h(:, :), tors_v(:), tors_rhs(:), tors_q(:), tors_gs(:) REAL(wp), ALLOCATABLE :: tors_grs(:), tors_gt(:) REAL(wp), ALLOCATABLE :: tors_rhs2(:, :) + ! the untwisted equilibrium the twist starts from (its state, accepted Theta and Phi = Theta_0), + ! whose inertia an unstable twist stage is compared with (untwisted_inertia) + REAL(wp), ALLOCATABLE :: tors_q_untw(:) + REAL(wp) :: tors_th_untw, tors_phi_untw REAL(wp) :: contact_cs(2), end_support(3, 2), end_floor(3), end_g(2), end_sfac ! Floor-carried end moments in the potential: the end element shares of the last ! evaluation, and the shares held (end_share_held) by an energy line search or the caller. @@ -622,6 +638,17 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ CALL fail('f_nodal must be finite'); RETURN END IF END IF + IF (PRESENT(f_nodal_twist)) THEN + IF (.NOT. PRESENT(torsion)) THEN + CALL fail('f_nodal_twist needs torsion'); RETURN + END IF + IF (SIZE(f_nodal_twist) /= ndof) THEN + CALL fail('f_nodal_twist must be 6*(ne+1)'); RETURN + END IF + IF (.NOT. CD_All_Finite(f_nodal_twist)) THEN + CALL fail('f_nodal_twist must be finite'); RETURN + END IF + END IF IF (use_nodal_contact) THEN IF (SIZE(contact_kn) /= nn .OR. .NOT. CD_All_Finite(contact_kn) .OR. ANY(contact_kn <= CD_ZERO)) THEN CALL fail('contact_kn must be finite, positive, and have length n_nodes'); RETURN @@ -734,6 +761,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ tors_descending = .FALSE. tors_c = CD_ZERO tors_phi_cur = CD_ZERO + tors_load_frac = CD_ZERO tors_theta_acc = CD_ZERO tors_theta_eval = CD_ZERO tors_mt = CD_ZERO @@ -904,6 +932,12 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ fscale = MAX(fscale, MAXVAL(ABS(f_nodal(6*(i - 1) + 4:6*(i - 1) + 6)))/trib(i)) END DO END IF + IF (PRESENT(f_nodal_twist)) THEN + DO i = 1, nn + fscale = MAX(fscale, MAXVAL(ABS(f_nodal_twist(6*(i - 1) + 1:6*(i - 1) + 3)))) + fscale = MAX(fscale, MAXVAL(ABS(f_nodal_twist(6*(i - 1) + 4:6*(i - 1) + 6)))/trib(i)) + END DO + END IF ! The tension a taut line must carry: with its ends farther apart than its length L, a line ! is stretched by at least chord/L - 1 over its series axial stiffness, so it carries at ! least that force whatever its weight. A line that carries little weight for its tension @@ -1091,6 +1125,10 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ ELSE torsion%stable = stable END IF + ! an unstable state kept as the untwisted equilibrium's own instability (torsion_stage) + torsion%untwisted_instability = torsion%keep_untwisted_instability .AND. .NOT. torsion%stable .AND. & + torsion%n_negative_untwisted > 0 .AND. & + torsion%n_negative <= torsion%n_negative_untwisted END IF IF (res_out >= tol) THEN @@ -1265,6 +1303,14 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) pi_total = pi_total - e_term pi_abs = pi_abs + ABS(e_term) END IF + IF (PRESENT(f_nodal_twist)) THEN + IF (tors_load_frac > CD_ZERO) THEN + R = R - eifac*tors_load_frac*f_nodal_twist + e_term = eifac*tors_load_frac*DOT_PRODUCT(f_nodal_twist, q) + pi_total = pi_total - e_term + pi_abs = pi_abs + ABS(e_term) + END IF + END IF ! ---- optional rotational line-end connections ---- ! Ramped with the same factor as EI: a stiff connection introduced at full strength @@ -1879,6 +1925,8 @@ SUBROUTINE torsion_continuation(ecs, ecm) torsion%stable = .FALSE. torsion%n_negative = 0 torsion%lambda_min = CD_ZERO + torsion%n_negative_untwisted = -1 + torsion%untwisted_instability = .FALSE. 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 @@ -1908,6 +1956,9 @@ SUBROUTINE torsion_continuation(ecs, ecm) phi0 = tors_theta_acc total = torsion%phi - phi0 tors_on = .TRUE. + tors_q_untw = q + tors_th_untw = tors_theta_acc + tors_phi_untw = phi0 ! |total| <= 4000 pi (Phi and Theta_0 within 1000 turns of zero, Theta_0 within pi of its ! start): at most 16000 stages, so the integer stage count cannot overflow dlam_max = CD_ONE/REAL(MAX(1, CEILING(MIN(ABS(total), 2.0_wp*CD_HTORS_MAX_TWIST + CD_HTORS_PI)/ & @@ -1920,8 +1971,10 @@ SUBROUTINE torsion_continuation(ecs, ecm) lam_try = MIN(CD_ONE, lam + dlam) IF (lam_try >= CD_ONE) THEN tors_phi_cur = torsion%phi + tors_load_frac = CD_ONE ELSE tors_phi_cur = phi0 + lam_try*total + tors_load_frac = lam_try END IF q_keep = q th_keep = tors_theta_acc @@ -1947,6 +2000,16 @@ SUBROUTINE torsion_continuation(ecs, ecm) ecm = wbuf RETURN END IF + IF (lam <= CD_ZERO .AND. torsion%n_negative_untwisted > 0) THEN + ! the first stage failed on an instability the untwisted state already has: not a + ! loop of the twist (with no twist to impose, not a twist at all) + WRITE (wbuf, '(A,I0,A,ES12.5,A,ES12.5,A)', IOSTAT=wios) & + 'CD_HermiteCable_Static_Solve: torsion stage failed: the untwisted equilibrium it starts '// & + 'from is itself unstable (', torsion%n_negative_untwisted, ' negative stiffness mode(s) at '// & + 'Phi = Theta_0 = ', phi0, ' rad, target Phi ', torsion%phi, ' rad): '//TRIM(why) + ecm = wbuf + RETURN + END IF WRITE (wbuf, '(A,ES12.5,A,ES12.5,A)', IOSTAT=wios) & 'CD_HermiteCable_Static_Solve: torsion continuation stalled at Phi = ', tors_phi_cur, & ' rad (target ', torsion%phi, ' rad): '//TRIM(why)// & @@ -2009,10 +2072,54 @@ SUBROUTINE torsion_stage(ok, why) RETURN END IF torsion%stable = st - IF (st .OR. .NOT. torsion%descend) RETURN + IF (st) RETURN + ! An unstable stage: is the instability the twist's? The untwisted state's negative count + ! (once, at the start of the twist) tells; a stage with no more negative eigenvalues than + ! it is kept under keep_untwisted_instability (a descent would leave an instability the + ! twist did not bring, and with current drag cannot run at all). + IF (torsion%keep_untwisted_instability .OR. torsion%descend) THEN + CALL untwisted_inertia(ks, km) + IF (ks /= CD_HCSTAT_OK) THEN + ok = .FALSE. + why = km + RETURN + END IF + END IF + IF (torsion%keep_untwisted_instability .AND. torsion%n_negative_untwisted >= 0 .AND. & + torsion%n_negative <= torsion%n_negative_untwisted) RETURN + IF (.NOT. torsion%descend) RETURN CALL torsion_descent(ok, why) END SUBROUTINE torsion_stage + SUBROUTINE untwisted_inertia(ecs, ecm) + !! torsion%n_negative_untwisted, once: the stability test of the untwisted equilibrium the + !! twist started from (tors_q_untw at Phi = Theta_0, no torque); the current state, its + !! accepted Theta and Phi are then restored and tested again, which restores its report + !! and the lowest mode the descent takes. + INTEGER, INTENT(OUT) :: ecs + CHARACTER(*), INTENT(OUT) :: ecm + REAL(wp), ALLOCATABLE :: q_now(:) + REAL(wp) :: th_now, phi_now + LOGICAL :: st0 + ecs = CD_HCSTAT_OK + ecm = '' + IF (torsion%n_negative_untwisted >= 0 .OR. .NOT. ALLOCATED(tors_q_untw)) RETURN + q_now = q + th_now = tors_theta_acc + phi_now = tors_phi_cur + q = tors_q_untw + tors_theta_acc = tors_th_untw + tors_phi_cur = tors_phi_untw + CALL torsion_stability(st0, ecs, ecm) + q = q_now + tors_theta_acc = th_now + tors_phi_cur = phi_now + IF (ecs /= CD_HCSTAT_OK) RETURN + torsion%n_negative_untwisted = MERGE(0, MAX(1, torsion%n_negative), st0) + CALL torsion_stability(st0, ecs, ecm) + torsion%stable = st0 + END SUBROUTINE untwisted_inertia + SUBROUTINE torsion_stability(st, ecs, ecm) !! Stability of the state q with torsion: the inertia of the symmetric tangent !! B + g g^T / C on the free DOFs (CD_HermiteTorsion_Inertia). A negative (or unreliable) @@ -5199,11 +5306,57 @@ SUBROUTINE reject_unresolved_sequence(l0, q, ErrStat, ErrMsg) WRITE (wbuf, '(A,ES12.5,A,ES12.5,A,I0)', IOSTAT=wios) & 'mesh-sequenced equilibrium is unresolved/kinked: max(h*kappa)=', diag%h_kappa_peak, & ' > safety limit=', CD_HC_KINK_LIMIT, ' at element ', diag%h_kappa_elem - ErrMsg = wbuf + ErrMsg = TRIM(wbuf)//TRIM(CD_HermiteCable_Kink_Advice(diag%h_kappa_peak, diag%h_kappa_elem, SIZE(l0))) END BLOCK END IF END SUBROUTINE reject_unresolved_sequence + PURE FUNCTION CD_HermiteCable_Kink_Advice(h_kappa, elem, n_elem, deck_ratio) RESULT(advice) + !! The remedy of an unresolved/kinked refusal (max(h*kappa) = h_kappa above CD_HC_KINK_LIMIT + !! at element elem of n_elem): on a resolved bend the curvature kappa does not change with the + !! mesh, so h*kappa falls in proportion to the element length and a mesh n times finer there + !! clears the limit for n >= h_kappa/CD_HC_KINK_LIMIT; deck_ratio (default 1) is the deck + !! element's length over the solve element's (an automatically refined mesh), which the + !! factor for NumSegs takes. A fold that stays kinked on the finer mesh is a non-physical + !! branch, not a resolution limit. Starts with '; '. + REAL(wp), INTENT(IN) :: h_kappa + INTEGER, INTENT(IN) :: elem, n_elem + REAL(wp), INTENT(IN), OPTIONAL :: deck_ratio + CHARACTER(320) :: advice + REAL(wp) :: f + INTEGER :: n, ios + f = h_kappa/CD_HC_KINK_LIMIT + IF (PRESENT(deck_ratio)) f = f*MAX(CD_ONE, deck_ratio) + IF (.NOT. (f < 1.0e6_wp)) f = 1.0e6_wp + n = MAX(2, CEILING(f)) + advice = '' + WRITE (advice, '(A,I0,A,I0,A,I0,A)', IOSTAT=ios) '; refine NumSegs at least ', n, 'x about element ', elem, & + ' (of ', n_elem, ' in the solve): h*kappa falls in proportion to the element length on a resolved bend '// & + '(a fold that stays kinked on the finer mesh is a non-physical branch)' + END FUNCTION CD_HermiteCable_Kink_Advice + + PURE REAL(wp) FUNCTION CD_HermiteCable_Element_Ratio(l0_ref, l0_fin, elem) RESULT(ratio) + !! The length of the element of the mesh l0_ref (the deck's) that holds the rest-arc midpoint + !! of element elem of the mesh l0_fin (a refinement of it) over that element's length: the + !! refinement already applied there (1 outside the meshes or for one mesh). + REAL(wp), INTENT(IN) :: l0_ref(:), l0_fin(:) + INTEGER, INTENT(IN) :: elem + REAL(wp) :: s_mid, s_acc + INTEGER :: k + ratio = CD_ONE + IF (elem < 1 .OR. elem > SIZE(l0_fin) .OR. SIZE(l0_ref) < 1) RETURN + IF (.NOT. (l0_fin(elem) > CD_ZERO)) RETURN + s_mid = SUM(l0_fin(1:elem - 1)) + 0.5_wp*l0_fin(elem) + s_acc = CD_ZERO + DO k = 1, SIZE(l0_ref) + s_acc = s_acc + l0_ref(k) + IF (s_mid <= s_acc .OR. k == SIZE(l0_ref)) THEN + ratio = MAX(CD_ONE, l0_ref(k)/l0_fin(elem)) + RETURN + END IF + END DO + END FUNCTION CD_HermiteCable_Element_Ratio + 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, & @@ -6733,6 +6886,12 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs diag_out%h_kappa_peak, ' > safety limit=', CD_HC_KINK_LIMIT, & ' at element ', diag_out%h_kappa_elem IF (LEN_TRIM(local_stop) > 0) wbuf = TRIM(wbuf)//' (local refinement stopped: '//TRIM(local_stop)//')' + BLOCK + REAL(wp) :: deck_ratio + deck_ratio = CD_HermiteCable_Element_Ratio(l0, l0_out, diag_out%h_kappa_elem) + wbuf = TRIM(wbuf)//TRIM(CD_HermiteCable_Kink_Advice(diag_out%h_kappa_peak, diag_out%h_kappa_elem, & + SIZE(l0_out), deck_ratio)) + END BLOCK ErrMsg = wbuf RETURN END IF diff --git a/src/CableDyn_HermiteTorsion.f90 b/src/CableDyn_HermiteTorsion.f90 index 6f97c2f3..752b5586 100644 --- a/src/CableDyn_HermiteTorsion.f90 +++ b/src/CableDyn_HermiteTorsion.f90 @@ -146,11 +146,22 @@ MODULE CableDyn_HermiteTorsion LOGICAL :: check_stability = .TRUE. LOGICAL :: descend = .TRUE. LOGICAL :: zero_mode_allowed = .FALSE. + !! keep_untwisted_instability: a twist stage that is unstable with no more negative + !! eigenvalues than the untwisted equilibrium it starts from (the twist adds no instability: + !! the untwisted state's own, which its caller accepted, a planar state unstable out of its + !! plane for example) is kept as it is, not descended from or refused; the report then sets + !! untwisted_instability. + LOGICAL :: keep_untwisted_instability = .FALSE. !! Static report at the returned state: stability, negative-eigenvalue count of the tangent !! on the free DOFs, the lowest Jacobi-scaled eigenvalue when it was computed (0 otherwise), !! the total potential energy, the twist-continuation stage count and the descents taken. LOGICAL :: stable = .FALSE. INTEGER :: n_negative = 0 + !! The negative-eigenvalue count of the untwisted equilibrium the twist starts from (-1: not + !! evaluated, which it is only once a twist stage is unstable), and whether the returned + !! unstable state was kept under keep_untwisted_instability (its count at most that one). + INTEGER :: n_negative_untwisted = -1 + LOGICAL :: untwisted_instability = .FALSE. REAL(wp) :: lambda_min = CD_ZERO REAL(wp) :: energy = CD_ZERO INTEGER :: ramp_steps = 0 diff --git a/tests/test_torsion_body_passes.f90 b/tests/test_torsion_body_passes.f90 new file mode 100644 index 00000000..10208cb6 --- /dev/null +++ b/tests/test_torsion_body_passes.f90 @@ -0,0 +1,169 @@ +! File: tests/test_torsion_body_passes.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_torsion_body_passes + !! The static passes of a finite-EI cable restrained in torsion between two moored Rigid6 bodies + !! (bodyIC static) converge at every pretwist. The bodies (20 t, three mooring legs each) are each + !! other turned 180 deg about the vertical axis between them; the cable (64 m, 40 + !! elements, EA 5e8 N, EI 2e4 N m2, GJ 5e4 N m2) is clamped (Rigid) or bending-pinned at both + !! ends and Rigid in torsion, with the pretwist at End B. The passes compare the change of the + !! cable's end loads with 1e-10 of their scale, but each pass balances the bodies only to the + !! core solve's tolerance, 1e-9 of its own scale (the bodies' net weight, 13 times the cable end + !! force here): the change could not fall below 1-4e-9 and the passes stopped after 60 at 360 + !! deg (Rigid) and 300 deg (Pinned), the torque settled to six digits from the fourth pass. The + !! passes now stop at the resolution the core leaves (four times its residual load). + !! 1. Rigid ends, 360 deg, and Pinned ends, 300 deg (both failed): the static start is + !! found; + !! 2. it is the symmetric equilibrium (the deck's symmetry, which the passes do not impose): + !! body 2's pose is body 1's turned 180 deg about the vertical axis, to 1e-6 m and deg, and + !! the end tensions are equal to 1e-6; + !! 3. a still run of 0.5 s holds it: the poses within 2e-6 m and deg, the torque within 1e-6 of + !! its start. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + + INTEGER :: nfail = 0 + + CALL pair_case('tbp_rigid_360', 'Rigid', 360) + CALL pair_case('tbp_pinned_300', 'Pinned', 300) + IF (nfail > 0) THEN + PRINT '(I0,A)', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + PRINT '(A)', 'all torsion body-pass checks passed' + +CONTAINS + + SUBROUTINE pair_case(root, conn, pretwist) + !! Run the pair, then the symmetry and stillness gates on its .out (Body1/Body2 P/R, FairTen7, + !! AnchTen7, Torq7N1). + CHARACTER(*), INTENT(IN) :: root, conn + INTEGER, INTENT(IN) :: pretwist + REAL(wp) :: row(16), first(16), drift(16), sym + INTEGER :: u, ios, es, nrow + LOGICAL :: conv + CHARACTER(512) :: em + CHARACTER(4096) :: buf + CALL write_pair(root//'.dat', conn, pretwist) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL require(es == CD_DECKDRV_OK .AND. conv, root//': the static passes converge and the run ends: '//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 + nrow = 0 + drift = 0.0_wp + DO + READ (u, *, IOSTAT=ios) row + IF (ios /= 0) EXIT + nrow = nrow + 1 + IF (nrow == 1) first = row + drift = MAX(drift, ABS(row - first)) + END DO + CLOSE (u) + ! body 2 = body 1 turned 180 deg about z: (x, y, z) -> (-x, -y, z), rotations (rx, ry, rz) -> + ! (-rx, -ry, rz) + sym = MAXVAL(ABS([first(2) + first(8), first(3) + first(9), first(4) - first(10), first(5) + first(11), & + first(6) + first(12), first(7) - first(13)])) + PRINT '(A,ES10.3,A,ES10.3,A,ES10.3,A,ES14.7,A)', ' '//root//': symmetry ', sym, ', pose drift ', & + MAXVAL(drift(2:13)), ', torque drift ', drift(16), ' (torque ', first(16), ' N m)' + CALL require(sym <= 1.0e-6_wp, root//': the start is the mirror-symmetric equilibrium') + CALL require(ABS(first(14) - first(15)) <= 1.0e-6_wp*first(14), root//': equal end tensions') + CALL require(ABS(row(1) - 0.5_wp) < 1.0e-9_wp .AND. MAXVAL(drift(2:13)) <= 2.0e-6_wp, & + root//': the still run holds the poses') + CALL require(drift(16) <= 1.0e-6_wp*ABS(first(16)), root//': the still run holds the torque') + END SUBROUTINE pair_case + + SUBROUTINE write_pair(path, conn, pretwist) + !! The two moored bodies at x = -30 and 30 m, the cable between their points 13 and 14. + CHARACTER(*), INTENT(IN) :: path, conn + INTEGER, INTENT(IN) :: pretwist + INTEGER :: u, k + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'torsion body passes' + 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)') 'poly 0.12 15.0 5.0e7 -1.0 0.0 0 0 0 0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.2 60 500000000 -1 20000 100000000 50000 1 0.3 1.2 0 1 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 20000 40 0 2000000 2000000 8 0.5 35000 35000 35000' + WRITE (u, '(A)') '2 Rigid6 30 0 -20 0 0 0 20000 40 0 2000000 2000000 8 0.5 35000 35000 35000' + 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 0.0 0.0 -3.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + DO k = 1, 3 + WRITE (u, '(I0,A,I0,A,I0,A)') k, ' ', k, ' ', k + 3, ' -' + END DO + DO k = 4, 6 + WRITE (u, '(I0,A,I0,A,I0,A)') k, ' ', k + 3, ' ', k + 6, ' -' + END DO + WRITE (u, '(A)') '7 13 14 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + DO k = 1, 6 + WRITE (u, '(I0,A)') k, ' poly 86.85 20' + END DO + WRITE (u, '(A)') '7 cab 64 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)') '7 A '//conn//' 0.7071067811865476 0.0 -0.7071067811865476 Rigid 0 1 0 0' + WRITE (u, '(A,I0)') '7 B '//conn//' 0.7071067811865476 0.0 0.7071067811865476 Rigid 0 1 0 ', pretwist + 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, '(A)') '0.5 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') '--- OUTPUTS ---' + DO k = 1, 2 + WRITE (u, '(A,I0,A)') 'Body', k, 'Px' + WRITE (u, '(A,I0,A)') 'Body', k, 'Py' + WRITE (u, '(A,I0,A)') 'Body', k, 'Pz' + WRITE (u, '(A,I0,A)') 'Body', k, 'Rx' + WRITE (u, '(A,I0,A)') 'Body', k, 'Ry' + WRITE (u, '(A,I0,A)') 'Body', k, 'Rz' + END DO + WRITE (u, '(A)') 'FairTen7' + WRITE (u, '(A)') 'AnchTen7' + WRITE (u, '(A)') 'Torq7N1' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE write_pair + + 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_body_passes diff --git a/tests/test_torsion_coupling_still.f90 b/tests/test_torsion_coupling_still.f90 new file mode 100644 index 00000000..1b2dc95e --- /dev/null +++ b/tests/test_torsion_coupling_still.f90 @@ -0,0 +1,186 @@ +! File: tests/test_torsion_coupling_still.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_torsion_coupling_still + !! A held line under strong torque-tension coupling stays still in its dynamics at the default + !! dtM (0.05 s) and dynamic tolerance (1e-8). The line: 50 m neutral cable, EA 4.69e8 N, GJ 5e4 + !! N m2, Irn 0.1174 kg m (the nodal twist), 25 elements, stretched by eps = 1.07e-4 between a + !! held Coupled End A and a Fixed End B, the coupling K = r sqrt(EA GJ). Its static start is exact, + !! so a step of the held line is a residual at the round-off of its forces: the convergence norm + !! must place its floor at the rounding of the axial force of the whole axial stiffness (the + !! kernel's EA - K^2/GJ plus the coupling's K^2/GJ) and of the element torque, whose coupling + !! share (K/GJ)(l - l0) is formed from coordinates (|K| eps max|x|/l0). Before, at |r| >= 0.85 + !! (and at -0.8 with one end free) a step failed, "Newton did not converge, ||G|| = 2.4e-8 > + !! tol = 1e-8", within 0.05-0.9 s. + !! 1. Both ends Rigid in torsion, Pretwist 90 deg, r = 0.85, 0.9, 0.95, 0.99: the run of 2 s + !! holds, and its start is the section law T = EA eps + K Phi/L0, M = GJ Phi/L0 + K eps + !! (relative 1e-6). + !! 2. Both ends Rigid, r = -0.8, -0.9: the opposite-sense coupling compresses the line, which + !! buckles into a twisted bow; the run of 2 s holds its start. + !! 3. End B Free in torsion, r = -0.8, -0.9: the stretch twists the line, so T = (EA - + !! K^2/GJ) eps and M = 0; the run of 10 s holds. + !! Holding: every tension and torque channel stays within 1e-6 of the scale of its parts (EA eps + + !! |K| Phi/L0 for a tension, GJ Phi/L0 + |K| eps for a torque) of its start. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: EA = 4.69e8_wp, GJ = 5.0e4_wp, SPAN = 50.0_wp, L0 = 49.9946700778_wp + REAL(wp), PARAMETER :: PHI = 0.5_wp*PI + INTEGER :: nfail = 0 + + CALL still_case('tcst_p085', 0.85_wp, .FALSE., .TRUE.) + CALL still_case('tcst_p090', 0.90_wp, .FALSE., .TRUE.) + CALL still_case('tcst_p095', 0.95_wp, .FALSE., .TRUE.) + CALL still_case('tcst_p099', 0.99_wp, .FALSE., .TRUE.) + CALL still_case('tcst_m080', -0.80_wp, .FALSE., .FALSE.) + CALL still_case('tcst_m090', -0.90_wp, .FALSE., .FALSE.) + CALL still_case('tcst_fm080', -0.80_wp, .TRUE., .TRUE.) + CALL still_case('tcst_fm090', -0.90_wp, .TRUE., .TRUE.) + IF (nfail > 0) THEN + PRINT '(I0,A)', nfail, ' assertion(s) failed' + ERROR STOP 1 + END IF + PRINT '(A)', 'all held coupled-line checks passed' + +CONTAINS + + SUBROUTINE still_case(root, r, free_b, straight) + !! Run the case, check the start against the section law (straight) and the run's stillness. + CHARACTER(*), INTENT(IN) :: root + REAL(wp), INTENT(IN) :: r + LOGICAL, INTENT(IN) :: free_b, straight + REAL(wp) :: k, eps, t_ref, m_ref, t_sc, m_sc, row(5), first(5), dev(4) + INTEGER :: u, ios, es, nrow + LOGICAL :: conv + CHARACTER(512) :: em + CHARACTER(4096) :: buf + CHARACTER(160) :: what + k = r*SQRT(EA*GJ) + eps = SPAN/L0 - 1.0_wp + CALL write_case(root//'.dat', k, free_b) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + IF (free_b) THEN + WRITE (what, '(A,F6.2,A)') root//' (K/sqrt(EA GJ) = ', r, ', End B free)' + ELSE + WRITE (what, '(A,F6.2,A)') root//' (K/sqrt(EA GJ) = ', r, ', both Rigid)' + END IF + CALL require(es == CD_DECKDRV_OK .AND. conv, TRIM(what)//' runs: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + IF (free_b) THEN + t_ref = (EA - k*k/GJ)*eps + m_ref = 0.0_wp + t_sc = EA*eps + m_sc = ABS(k)*eps + ELSE + t_ref = EA*eps + k*PHI/L0 + m_ref = GJ*PHI/L0 + k*eps + t_sc = EA*eps + ABS(k)*PHI/L0 + m_sc = GJ*PHI/L0 + ABS(k)*eps + END IF + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='OLD', ACTION='READ', IOSTAT=ios) + READ (u, '(A)') buf + READ (u, '(A)') buf + nrow = 0 + dev = 0.0_wp + first = 0.0_wp + DO + READ (u, *, IOSTAT=ios) row + IF (ios /= 0) EXIT + nrow = nrow + 1 + IF (nrow == 1) first = row + dev = MAX(dev, ABS(row(2:5) - first(2:5))) + END DO + CLOSE (u) + PRINT '(A,ES11.3,A,4ES12.4)', ' '//root//': t_end ', row(1), ' s, max |change| T_A T_B M_A M_B ', dev + CALL require(ABS(row(1) - MERGE(10.0_wp, 2.0_wp, free_b)) < 1.0e-9_wp, TRIM(what)//' reaches TMax') + CALL require(MAXVAL(dev(1:2)) <= 1.0e-6_wp*t_sc .AND. MAXVAL(dev(3:4)) <= 1.0e-6_wp*m_sc, & + TRIM(what)//' holds its start') + IF (straight) THEN + PRINT '(A,4ES16.8)', ' start T, M and the section law ', first(2), first(4), t_ref, m_ref + CALL require(ABS(first(2) - t_ref) <= 1.0e-6_wp*t_sc .AND. ABS(first(3) - t_ref) <= 1.0e-6_wp*t_sc, & + TRIM(what)//' starts at the section tension') + CALL require(ABS(first(4) - m_ref) <= 1.0e-6_wp*m_sc .AND. ABS(first(5) - m_ref) <= 1.0e-6_wp*m_sc, & + TRIM(what)//' starts at the section torque') + END IF + END SUBROUTINE still_case + + SUBROUTINE write_case(path, k, free_b) + !! The held line: End A Coupled at the origin (no motion), End B Fixed 50 m along +x, both + !! ends clamped along x; torsion Rigid at End A and Rigid (Pretwist 90 deg) or Free at End B. + CHARACTER(*), INTENT(IN) :: path + REAL(wp), INTENT(IN) :: k + LOGICAL, INTENT(IN) :: free_b + INTEGER :: u + CHARACTER(64) :: gjcol + WRITE (gjcol, '(ES12.5,A,ES17.10)') GJ, '|', k + gjcol = remove_blanks(gjcol) + OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'held line under torque-tension coupling' + 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)') 'cab 0.16 20.6088478075 469000000 -0.8 20000 90000000 '//TRIM(gjcol)// & + ' 0.0587 0.1174 1.2 0.1 1 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 -50 0 0 0 0' + WRITE (u, '(A)') '2 Fixed 50 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 49.9946700778 25' + 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 1 0 0' + IF (free_b) THEN + WRITE (u, '(A)') '1 B Rigid 1 0 0 Free 0 1 0 0' + ELSE + WRITE (u, '(A)') '1 B Rigid 1 0 0 Rigid 0 1 0 90' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') MERGE('10 TMax', ' 2 TMax', free_b) + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') 'AnchTen1' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') 'Torq1N26' + 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 + + 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_still diff --git a/tests/test_torsion_current_start.py b/tests/test_torsion_current_start.py new file mode 100644 index 00000000..edcc1ce1 --- /dev/null +++ b/tests/test_torsion_current_start.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""A lazy wave restrained in torsion starts in an in-plane current. + +The lazy wave of ``tests/data/lazy_wave_torsion_attachments.dat`` (25 buoyancy modules, Rigid in +torsion at both ends) in a 0.5 m/s current along its plane: its untwisted static state, solved in +the vertical plane, is unstable out of that plane on its mesh (one negative stiffness mode), which +the same deck without torsion accepts with a note. The twist stage added no instability, yet the +torsion stage refused it: at pretwist 0 "torsion continuation stalled at Phi = 0 (target 0): the +twisted equilibrium is unstable", at 360 deg an unstable equilibrium after a failed Newton solve. +Two causes made the start depend on the pretwist and on the round-off of the BLAS kernel: the +coarse branch-selection build twisted its line, and that twisted state seeded the untwisted solve +on the deck mesh (180 deg stopped in the attachment polish; 360 deg needed its fallbacks, and +stopped under OPENBLAS_CORETYPE=Prescott); and every pass of the attachment fixed point after the +first applied the drag of the last twisted shape in full at the untwisted start (270 deg and more +stopped before any twist). + +Gate, on the driver's own output: at pretwist 0, 180, 360 and 720 deg the deck starts and runs, +the torsion note reports the twist solved, the instability is named as the untwisted state's own, +the attachment polish converges without its fallbacks, and the end torque is proportional to the +pretwist (to 1 % of the torque at 720 deg). + +usage: test_torsion_current_start.py --exe --data --output +""" + +from __future__ import annotations + +import argparse +import re +import subprocess +import sys +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path + + +def deck_text(base: str, pretwist: str) -> str: + lines = base.split("\n") + out = [] + for line in lines: + f = line.split() + if f and f[0] == "bare" and len(f) == 14: + f[9] = "0.12" + line = " ".join(f) + elif f[:3] == ["4", "B", "Rigid"]: + line = " ".join(f[:-1] + [pretwist]) + elif f[1:] == ["dtM"]: + line = "0.05 dtM" + elif f[1:] == ["TMax"]: + line = "0.5 TMax\nuniform 0.5 0 0 current" + out.append(line) + return "\n".join(out) + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--data", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + out = Path(args.output) + out.mkdir(parents=True, exist_ok=True) + base = (Path(args.data) / "lazy_wave_torsion_attachments.dat").read_text( + encoding="utf-8" + ) + failures = [] + torques = {} + pretwists = ("0", "180", "360", "720") + for pretwist in pretwists: + deck = out / f"lw_current_twist{pretwist}.dat" + deck.write_text(deck_text(base, pretwist), encoding="utf-8", newline="\n") + if "uniform 0.5 0 0 current" not in deck.read_text(encoding="utf-8"): + print("FAIL: the deck edit did not place the current") + return 1 + + def run(pretwist: str) -> subprocess.CompletedProcess[str]: + return subprocess.run( + [args.exe, str(out / f"lw_current_twist{pretwist}.dat"), str(out / f"lw_current_twist{pretwist}")], + capture_output=True, + text=True, + check=False, + ) + + # the four runs are independent: concurrently, so a Debug build stays within the test's timeout + with ThreadPoolExecutor(max_workers=len(pretwists)) as pool: + runs = dict(zip(pretwists, pool.map(run, pretwists))) + for pretwist in pretwists: + p = runs[pretwist] + log = p.stdout + p.stderr + solved = "torsion solved" in log + named = "keeps the instability of its untwisted state" in log + fell_back = "reached after a failed Newton solve" in log + m = re.search(r"torsion solved, imposed twist\s+\S+ deg, torque\s+(\S+) N m", log) + if m: + torques[pretwist] = float(m.group(1)) + print( + f"pretwist {pretwist}: exit {p.returncode}, solved {solved}, untwisted instability named {named}, " + f"polish fallbacks {fell_back}, torque {torques.get(pretwist)}" + ) + if fell_back: + failures.append(f"pretwist {pretwist}: the attachment polish needed its fallbacks") + if p.returncode != 0: + failures.append(f"pretwist {pretwist}: the deck stopped: {log[-400:]}") + if not solved: + failures.append(f"pretwist {pretwist}: no 'torsion solved' note") + if not named: + failures.append( + f"pretwist {pretwist}: the untwisted state's instability is not named" + ) + if "stalled" in log: + failures.append( + f"pretwist {pretwist}: a stalled torsion continuation is reported" + ) + if len(torques) == 4: + rate = torques["720"] / 720.0 + for pt, tq in torques.items(): + if abs(tq - rate * float(pt)) > 0.01 * abs(torques["720"]): + failures.append( + f"pretwist {pt}: torque {tq} N m not proportional to the pretwist " + f"({rate * float(pt)} N m from 720 deg)" + ) + for f in failures: + print("FAIL: " + f) + if not failures: + print("PASS: a lazy wave restrained in torsion starts in an in-plane current") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) From 7a7ef2701a9398ad9eeb2bca63882b6f09552e74 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 18:53:05 +0900 Subject: [PATCH 34/51] fix: findings of the 0.4.0 end-to-end validation in OpenFAST and FAST.Farm (#83) ## Summary Findings of the 0.4.0 end-to-end validation in OpenFAST and FAST.Farm (besides E2E-D2, fixed by #81). - **A standalone `TURBINES` deck of `EI = 0` and finite-EI lines runs.** A power cable shared by two turbines beside their chain legs stopped with the internal message "no farm init was given (pass n_turbines + turbine_ref_pos)": the driver called the aggregate without the deck's `TURBINES` context. It now passes it; the `Turbine` points are placed from the `TURBINES` rows, a finite-EI end on a `Turbine` point starts turned by its turbine's `PtfmInit`, and each turbine's `motionFile` moves its points and turns its columns' frames. A `Turbine` point in a run without a farm is refused by point. - **A coupled deck takes bodies or rods, not both** (documented; the lift is left for a later release). Such a deck stops at init on the coupled route while MoorDyn-F runs it, and the docs listed coupled bodies and rods without the limit. The message says what the coupled route takes and where such a deck runs; `doc/openfast.rst`, `doc/coupling.rst`, `doc/capabilities.rst` and `doc/troubleshooting.rst` state it, and the Python validator refuses the deck caller-driven. - **`FAST.Farm.exe` of the CMake route gets a stack reserve on Windows GNU.** With MinGW's 2 MiB default it stopped with `0xC00000FD` while initialising a farm's turbines. New patch `0022` links `openfast.exe` and `FAST.Farm.exe` with a 256 MiB reserve on WIN32 with the GNU compilers; the release's Visual Studio projects keep their own. - **Console messages that say what happens:** the SeaState-kinematics line is printed only when a SeaState component is taken; the body/rod static start reports the largest turn and the move of every carried point (a pinned rod that only turned read "largest move 0.000E+00 m"); a deck refused for a current names the declaring input (`CurrentMod 1` table or `current` OPTION); the torsion note reports the total twist `Twist` beside `Pretwist(B) - Pretwist(A)`; FAST.Farm names `DT_Mooring`, not a glue `DT`. ## Checks - ctest 358 of 358 on two OpenBLAS kernels (`Prescott` and the default). - Checked Debug build (`-fcheck=all`) on the 38 touched tests. - Example A/B 53 of 53 identical. - Every example deck on the `Prescott` and `Haswell` kernels: same exit codes, no fallback, stall or relaxed-tolerance note. - Test needles updated and added (`driver_cli_torsion_nmodes`, `mixed_route_torsion`, `openfast_aggregate`, `msg_pinned_rod_turn`). - pre-commit, Sphinx `-W`. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 38 +++ CMakeLists.txt | 11 +- NOTICE | 7 +- app/cabledyn.f90 | 7 +- doc/capabilities.rst | 4 +- doc/coupling.rst | 1 + doc/driver_format.md | 7 +- doc/openfast.rst | 12 +- doc/standalone_driver.rst | 4 + doc/troubleshooting.rst | 20 +- integration/openfast/README.md | 8 +- .../patches/0022-glue-stack-cmake.patch | 40 +++ python/cabledyn/deck_file.py | 14 +- python/tests/test_deck_native_parity.py | 21 ++ python/tests/test_objects.py | 29 ++ src/CableDyn_DeckDriver.f90 | 175 ++++++++-- src/CableDyn_OpenFAST_Aggregate.f90 | 12 +- src/openfast/CableDyn_OF.f90 | 68 +++- tests/data/msg_pinned_rod_turn.dat | 36 +++ tests/test_documentation.py | 10 + tests/test_mixed_route_torsion.f90 | 300 +++++++++++++++++- tests/test_openfast_aggregate.f90 | 35 ++ 22 files changed, 792 insertions(+), 67 deletions(-) create mode 100644 integration/openfast/patches/0022-glue-stack-cmake.patch create mode 100644 tests/data/msg_pinned_rod_turn.dat diff --git a/CHANGELOG.md b/CHANGELOG.md index 339d5a95..fb90fd13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -483,6 +483,44 @@ All notable changes to CableDyn are recorded in this file. The format follows start with the same torques on every kernel, proportional to the pretwist. - The "unresolved/kinked equilibrium" refusal names the element and the factor to refine its section's `NumSegs` by. +- Console messages that said something untrue now say what happens: + - OpenFAST: "SeaState wave/current kinematics drive the mooring hydro" is printed only when the + deck's `WaterKin` policy takes a SeaState component (a `WaterKin` file with `WaveKinMod 0` and + `CurrentMod 0` gives still water and says so); + - the body/rod static start reports the largest turn of a body or rod and the move of every + point the objects carry, so a pinned rod that only rotated no longer reads "largest move + 0.000E+00 m"; + - a mixed or FAST.Farm deck refused for a deck current names the input that declares it (the + `CurrentMod 1` table of its `WaterKin` file, or the `current` OPTION), not always "the current + OPTION"; + - the torsion note reports the line's total twist `Twist` at the static state, beside the + imposed `Pretwist(B) - Pretwist(A)` and with the end frames' turn (a `PtfmInit` or `TURBINES` + rotation) and the shape's geometric twist, not the pretwist alone; + - in FAST.Farm the time-step messages name the farm's `DT_Mooring`, not a "glue DT". +- A standalone `TURBINES` deck that mixes `EI = 0` lines and finite-EI cables (a power cable + shared by two turbines beside their chain legs, the usual farm deck) runs. It stopped with the + internal message `no farm init was given (pass n_turbines + turbine_ref_pos)`: the mixed route + did not take the `TURBINES` rows. It now places the `Turbine` points from them and moves the + points and turns the cable end frames with the per-turbine `motionFile` records, as the decks of + the cables alone and of the `EI = 0` lines alone do. The IEA 15 MW two-turbine deck (a 1530 m + cable restrained in torsion and four chains, 60 s of FAST.Farm platform motion) reproduces those + two decks to 3.2e-6 of the channel maxima and the FAST.Farm `Mod_SharedMooring = 5` run to + 2.3e-5. On a two-turbine test deck whose turbines heave and roll, the chains match their deck + bit for bit and the cable, marched with the single-cable route's Newton controls, matches its + deck to 0.44 of the last printed digit. A `Turbine` point in a run without a farm + (single-turbine OpenFAST, the C API) is now refused by point, naming FAST.Farm and the + `TURBINES` section. +- A coupled deck with both bodies and rods stopped at init with `a coupled deck mixing RODs and + Rigid6/point3 bodies is not supported (the aggregate marches one body/rod family per step)`, + a limit the OpenFAST and capability pages did not state. The message now says what the coupled + route takes (bodies or rods, a rod fixed to a body counting as a rod) and where such a deck runs + (MoorDyn `CompMooring = 3`, the standalone driver); the OpenFAST, capability and troubleshooting + pages state the limit, and the Python validator (`caller_driven=True`) refuses the deck. +- `FAST.Farm.exe` built through the CMake route of `integration/openfast` with the GNU compilers + on Windows stopped at start with `0xC00000FD` (stack overflow) while initialising the first + turbine: MinGW links it with a 2 MiB stack. The new patch `0022` gives `openfast.exe` and + `FAST.Farm.exe` a 256 MiB stack reserve on that toolchain, and the shared-mooring farm (two IEA + 15 MW turbines) runs to normal termination. - 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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 9521cb50..27306b1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2388,6 +2388,10 @@ add_executable(test_mixed_route_torsion tests/test_mixed_route_torsion.f90) target_link_libraries(test_mixed_route_torsion PRIVATE cabledyn_core) add_test(NAME mixed_route_torsion COMMAND test_mixed_route_torsion $) set_tests_properties(mixed_route_torsion PROPERTIES LABELS "fortran;driver;integration;dynamic") +# A standalone TURBINES deck of a finite-EI cable between two turbines and chain legs on the mixed +# route, against its cable-only and legs-only decks (gate 9). +add_test(NAME mixed_route_turbines COMMAND test_mixed_route_torsion $ turbines) +set_tests_properties(mixed_route_turbines PROPERTIES LABELS "fortran;driver;integration;dynamic") # Deck currents on the standalone mixed route (the aggregate samples the deck current at every # node before each step): OPTION uniform and profile and MoorDyn-C Currents 1/2/5 against the @@ -2623,7 +2627,7 @@ set_tests_properties(driver_cli_mixed_nmodes PROPERTIES LABELS "fortran;driver;c add_test(NAME driver_cli_torsion_nmodes COMMAND ${CMAKE_COMMAND} -DDRIVER=$ -DEXPECT_RC=0 "-DARGS=${CMAKE_CURRENT_SOURCE_DIR}/tests/data/torsion_lazy_wave_modes.dat|${CMAKE_CURRENT_BINARY_DIR}/driver_cli_torsion_nmodes" - "-DMUST_MATCH=torsion solved, imposed twist 7.20000E\\+02 deg;converged run written" + "-DMUST_MATCH=torsion solved, total twist Twist1 =;imposed Pretwist.B. - Pretwist.A. = +7.20000E\\+02 deg;converged run written" -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/check_driver_output.cmake) set_tests_properties(driver_cli_torsion_nmodes PROPERTIES LABELS "fortran;driver;cli") # Non-ASCII, reserved-device, input-clobbering, and concurrently used output paths. @@ -2898,6 +2902,11 @@ cabledyn_msg_test(mixed_waves msg_mixed_waves.dat 1 cabledyn_msg_test(mixed_connect_coupled_cable msg_mixed_connect_coupled_cable.dat 1 "finite-EI LINE 3: a Coupled/Vessel End A .POINT 1. would need motionFile coupling to drive it;remove the Connect/Free points;held still .that route takes no motionFile either." "is driven by a motionFile") +# A Pinned rod that its line turns at the static start: the completion line reports the move of its +# End B and its turn, not the zero translation of its pin. +cabledyn_msg_test(pinned_rod_turn msg_pinned_rod_turn.dat 0 + "body/rod static equilibrium .1 object.s., largest move [1-9].[0-9]+E[-+][0-9]+ m, largest turn [1-9]" + "largest move 0.000E\\+00") # The standalone mixed route warns about a coarse section and notes a static strain above maxStrain. cabledyn_msg_test(mixed_coarse_strain msg_mixed_coarse_strain.dat 0 "WARNING: LINE 1 section of type \"chain\" .150.00 m in 1 segment.s.. has segments of 150.00 m, 17.6 %;Note: LINE 1 is stretched to a static strain of;above 1.00E-02 % .OPTION maxStrain." diff --git a/NOTICE b/NOTICE index b56bb457..d4121b94 100644 --- a/NOTICE +++ b/NOTICE @@ -22,9 +22,10 @@ OpenFAST (Apache License, Version 2.0) https://github.com/OpenFAST/openfast * integration/openfast/patches/ contains patches that MODIFY OpenFAST source - files (the root, openfast-library, and version CMakeLists.txt; - FAST_AeroMap.f90, FAST_Funcs.f90, FAST_Mapping.f90, FAST_ModGlue.f90, - FAST_Registry.txt, FAST_Solver.f90, FAST_Subs.f90, and FAST_Types.f90 in + files (the root, openfast-library, version, glue-codes/openfast and + glue-codes/fast-farm CMakeLists.txt; FAST_AeroMap.f90, FAST_Funcs.f90, + FAST_Mapping.f90, FAST_ModGlue.f90, FAST_Registry.txt, FAST_Solver.f90, + FAST_Subs.f90, and FAST_Types.f90 in modules/openfast-library/src; FAST_Farm_IO.f90, FAST_Farm_Registry.txt, FAST_Farm_Subs.f90, and FAST_Farm_Types.f90 in glue-codes/fast-farm/src). The modified files remain under the Apache License, Version 2.0, and diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 3f83766b..4c51b0fa 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -533,10 +533,13 @@ SUBROUTINE run_mixed_held_deck(deck, root, dt, has_dt, run_time, has_run_time, h ! name instead of silently holding zero fluid. The deck's own current is the aggregate's ! (deck_current), sampled at the nodes before every step at the step's t_committed. The ! driver holds the line end frames or turns them with the deck's vesselMotion table - ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). + ! (host_orientation), and marches the deck's prescribed motion (prescribed_motion). A + ! TURBINES section places the Turbine points and its records move and turn them + ! (deck_turbines), as on the single-route decks. CALL CD_AGG_Init_From_Deck(aggregate, deck, step_dt, es, em, forbid_deck_ambient=.TRUE., & run_tmax=MAX(CD_ZERO, run_time), range_files=.TRUE., host_orientation=.TRUE., & - prescribed_motion=has_motion, static_run=nstep == 0, deck_current=.TRUE.) + prescribed_motion=has_motion, static_run=nstep == 0, deck_current=.TRUE., & + deck_turbines=.TRUE.) IF (es /= CD_AGG_OK) THEN CALL set_aggregate_error(es, em, run_stat, run_msg) EXIT mixed_run diff --git a/doc/capabilities.rst b/doc/capabilities.rst index 793046d3..cfba7e1d 100644 --- a/doc/capabilities.rst +++ b/doc/capabilities.rst @@ -218,7 +218,9 @@ rigid rods. In OpenFAST, ``Coupled``/``Vessel`` bodies and rods are platform-bor return a force and a moment, ``CoupledPinned``/``VesselPinned`` rods turn about a platform-borne node that takes the platform position only and returns a force with zero moment, as do ``CoupledPinned``/``VesselPinned`` bodies about a node at their reference point, and ``Pinned`` -rods turn about a fixed End A. The C API and Python +rods turn about a fixed End A. A coupled deck (OpenFAST, the C API and Python) carries bodies or +rods, not both, a rod fixed to a body counting as a rod; the standalone driver's multibody march +takes both, as does MoorDyn (``CompMooring = 3``). The C API and Python run free, fixed and pinned rods and free bodies in still water. The coupled body/rod routes carry checkpoint state and SeaState drag, Froude–Krylov, and added mass. ``Rigid6`` also carries the documented hydrostatic restoring terms. Consult :doc:`driver_format` diff --git a/doc/coupling.rst b/doc/coupling.rst index a5097995..31eed549 100644 --- a/doc/coupling.rst +++ b/doc/coupling.rst @@ -57,6 +57,7 @@ is their zero-frequency reduction ``D − C A⁻¹ B``, not a derivative CableDy command outside MoorDyn-F's bounds or one that would make a controlled segment non-positive, and ``CONTROL`` of a finite-EI cable under ``False alpha_force_blend``, - coupled ``Rigid6`` bodies and rods in a FAST.Farm deck, + - a deck with both bodies (Rigid6 or Point3) and rods, a rod fixed to a body included, - deck ``waves``/``wavetrain`` OPTIONS (the host SeaState supplies the waves), and a deck ``current`` except as a steady current on a single-turbine, pure ``EI = 0`` deck without Rigid6 bodies or rods in a SeaState without waves or current (a WaterKin ``CurrentMod 1`` diff --git a/doc/driver_format.md b/doc/driver_format.md index 41d49e02..8da2e336 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -596,8 +596,11 @@ follows `x + R(q) p`, with the rigid-body velocity and acceleration. A finite-EI `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. +host's orientations turn them. A `TURBINES` deck that mixes `EI = 0` lines and finite-EI cables (a +power cable shared by two turbines beside their chain legs) runs on the standalone mixed route, +the aggregate of FAST.Farm, with the same placement, records and end frames as the decks of its +cables alone and of its `EI = 0` lines alone. In FAST.Farm the host supplies the turbine positions +and the section is not used. ### ROD TYPES + RODS (rigid cylindrical rods) diff --git a/doc/openfast.rst b/doc/openfast.rst index c8259a5d..9b170d51 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -81,7 +81,9 @@ solves once per that many glue steps, which is faster. Between commits the coupl extrapolated from the last two commits (deck ``OPTIONS predictLoads``, the default) or, with ``predictLoads False``, held at the last commit, which delays them (see the note below). The console reports the result, for -example ``CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM)``. A deck ``dtM`` +example ``CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM)``; in FAST.Farm the +coupling step is the farm's mooring step ``DT_Mooring``, and the line reads ``1 x FAST.Farm +DT_Mooring``. A deck ``dtM`` larger than ``DT`` but not a whole multiple of it is never coarsened: CableDyn uses the largest multiple of ``DT`` that does not exceed it and reports a warning with both values (``dtM = 0.025`` with ``DT = 0.01`` runs at 0.02 s), matching MoorDyn, which only ever shortens its step to fit the @@ -427,7 +429,13 @@ without an auxiliary process: held fluid stay those of the committed step). ``PtfmInit`` moves and turns such a rod with the platform before the static solve balances it about its pin. ``Pinned`` rods turn about a fixed End A. ``Coupled``/``Vessel`` bodies are platform-borne the same way as ``Coupled`` rods, - with the node at the body reference point, and may share a deck with ``Free`` bodies. + with the node at the body reference point, and may share a deck with ``Free`` bodies. A deck + carries bodies (Rigid6 or Point3) or rods, not both: the coupled march advances one of the two + families, and a rod fixed to a body (``RODS`` type ``Body`` or ``BodyPinned``) counts as a + rod, so such a deck stops at init (``a coupled deck with both BODIES and RODS is not + supported``). MoorDyn (``CompMooring = 3``) in the same binary runs it, and so does the + standalone driver's multibody march when the deck has no ``CoupledPinned`` objects (those run in + OpenFAST only). ``CoupledPinned``/``VesselPinned`` bodies are pinned to the platform like ``CoupledPinned`` rods: the node at the body reference point follows the platform position only, the body turns about it with its own three rotations (its inertia about the node, its weight and buoyancy at the diff --git a/doc/standalone_driver.rst b/doc/standalone_driver.rst index 3ca77654..4be5b596 100644 --- a/doc/standalone_driver.rst +++ b/doc/standalone_driver.rst @@ -102,6 +102,10 @@ formerly NREL) and advances the objects atomically. Every ``Coupled``/``Vessel`` at its initialised position, or follows the deck's ``motionFile`` or ``vesselMotion`` (a vessel turns the end connection and torsion frames of the power cables on its points, and the ``motionFile`` roll column twists a cable restrained in torsion, as on the single-cable route). +A ``TURBINES`` deck (:doc:`driver_format`) places its ``Turbine`` points from the section, and +its per-turbine ``motionFile`` records move them and turn the frames of the cable ends on them +with their turbine, so a FAST.Farm shared-mooring deck of power cables and chain legs runs here +as a whole. A mixed deck that also has bodies, rods or ``Connect``/``Free`` points runs on the multibody march instead (:doc:`driver_format`), which accepts deck waves and current. ``examples/iea15mw_umaine_mixed_cabledyn.dat`` is the maintained four-line example; its ``TMax = 0`` setting writes the common static configuration. Give a positive ``TMax`` diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index fdefde91..542ad635 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -681,11 +681,15 @@ Warnings and notes that do not stop a run torque–tension coupling (``GJ|K``) its stretch twists it by :math:`-\sum (K/GJ)(l - L)`, so a free End B turns by :math:`+x` and a free End A by :math:`-x` about the End A → End B tangent. - * - ``Note: line : torsion solved, imposed twist ... deg, torque ... N m ( twist - stage(s), buckling descent(s))`` - - the static twist stage of a torsional line. A non-zero descent count means the straight or - untwisted branch was unstable at the imposed twist and the solve moved to a buckled shape; - check the shape and the ``Twist`` channel. + * - ``Note: line : torsion solved, total twist Twist = ... deg (imposed Pretwist(B) - + Pretwist(A) = ... deg, with the end frames' turn and the shape's geometric twist), torque + ... N m ( twist stage(s), buckling descent(s))`` + - the static twist stage of a torsional line. The total twist is the ``Twist`` channel at + the static state: the imposed pretwist difference plus the turn of the end frames (a + ``PtfmInit`` or ``TURBINES`` rotation of a parent turns its end) less the geometric twist the + line takes up by its shape; the torque follows from it. A non-zero descent count means the + straight or untwisted branch was unstable at the imposed twist and the solve moved to a + buckled shape; check the shape and the ``Twist`` channel. * - ``WARNING: CableDyn mooring module: of the CableDyn sampling nodes in the water lie outside the SeaState wave-kinematics grid at t = ... s (warned once)`` (OpenFAST) - the SeaState grid (``X_HalfWidth``, ``Y_HalfWidth``, ``Z_Depth``) does not cover the @@ -901,6 +905,12 @@ aborts with a CableDyn fatal error, check whether the deck uses one of these com * - a finite-EI cable in the same deck as Rigid6 bodies, rods, or ``Connect``/``Free`` points - model the cable and the body/point system in separate decks or use the supported combinations in :doc:`capabilities` + * - ``a coupled deck with both BODIES and RODS is not supported``: bodies (Rigid6 or Point3) + and rods in one deck, a rod fixed to a body (``Body``, ``BodyPinned``) included + - the coupled march advances the bodies or the rods of a deck, not both (also in the C API and + Python). Run the deck with stock MoorDyn (``CompMooring = 3``) in the same binary, or, without + ``CoupledPinned`` objects, with the standalone driver, whose multibody march takes both; a + deck with only bodies or only rods runs coupled * - OpenFAST linearisation of a cable with a ``Rigid`` ``END CONNECTIONS`` row (``formal OpenFAST linearization of a cable with a rigid end connection is not supported``), of a deck with ``Free`` or ``Connect`` points or a line with VIV (``Cl > 0``), or with a ``CONTROL`` diff --git a/integration/openfast/README.md b/integration/openfast/README.md index 74cb9fb4..9cc201ac 100644 --- a/integration/openfast/README.md +++ b/integration/openfast/README.md @@ -39,7 +39,13 @@ check the build: ``` The script fails unless `openfast.exe` builds, the smoke case initialises the CableDyn module, and -the output is finite to the last row. An `openfast.exe` built through CMake does not embed the +the output is finite to the last row. Configure with `-DBUILD_FASTFARM=ON` to build `FAST.Farm` +as well (target `FAST.Farm`); the release does not ship it, so FAST.Farm users take this route. +On Windows with the GNU compilers, patch `0022` links `openfast.exe` and `FAST.Farm.exe` with a +256 MiB stack reserve (`-Wl,--stack,268435456`, as the CableDyn driver): with the MinGW default +of 2 MiB, `FAST.Farm.exe` stops with `0xC00000FD` (stack overflow) while it initialises the +turbines of a farm, before any output. The reserve is address space, not committed memory; the +Visual Studio projects of the release set their own. An `openfast.exe` built through CMake does not embed the UTF-8 active-code-page manifest, so on Windows it may not open input files in folders whose names the system code page cannot spell; the static release build embeds it. diff --git a/integration/openfast/patches/0022-glue-stack-cmake.patch b/integration/openfast/patches/0022-glue-stack-cmake.patch new file mode 100644 index 00000000..f3003f41 --- /dev/null +++ b/integration/openfast/patches/0022-glue-stack-cmake.patch @@ -0,0 +1,40 @@ +diff --git a/glue-codes/fast-farm/CMakeLists.txt b/glue-codes/fast-farm/CMakeLists.txt +index 96672632b..2c58cef73 100644 +--- a/glue-codes/fast-farm/CMakeLists.txt ++++ b/glue-codes/fast-farm/CMakeLists.txt +@@ -49,6 +49,15 @@ if (${_build_type} STREQUAL "RELEASE" AND NOT WIN32) + set_source_files_properties(src/FAST_Farm_Types.f90 PROPERTIES COMPILE_FLAGS "-O2") + endif() + ++# CableDyn integration: MinGW-w64 gives an executable a 2 MiB stack reserve, which the GNU ++# build of FAST.Farm overflows while it initialises its turbines (STATUS_STACK_OVERFLOW, ++# 0xC00000FD). Reserve 256 MiB for openfast and FAST.Farm, as for the CableDyn driver (the ++# Visual Studio projects set a reserve of their own). A reserve is address space, not ++# committed memory. ++if (WIN32 AND ${_compiler_id} STREQUAL "GNU") ++ target_link_options(FAST.Farm PRIVATE "LINKER:--stack,268435456") ++endif() ++ + install(TARGETS FAST.Farm + RUNTIME DESTINATION bin + ) +diff --git a/glue-codes/openfast/CMakeLists.txt b/glue-codes/openfast/CMakeLists.txt +index 08fde158b..3a87962be 100644 +--- a/glue-codes/openfast/CMakeLists.txt ++++ b/glue-codes/openfast/CMakeLists.txt +@@ -30,6 +30,15 @@ if (${_compiler_id} STREQUAL "GNU" AND NOT ${VARIABLE_TRACKING}) + set_source_files_properties(src/FAST_Prog.f90 PROPERTIES COMPILE_FLAGS "-fno-var-tracking -fno-var-tracking-assignments") + endif() + ++# CableDyn integration: MinGW-w64 gives an executable a 2 MiB stack reserve, which the GNU ++# build of FAST.Farm overflows while it initialises its turbines (STATUS_STACK_OVERFLOW, ++# 0xC00000FD). Reserve 256 MiB for openfast and FAST.Farm, as for the CableDyn driver (the ++# Visual Studio projects set a reserve of their own). A reserve is address space, not ++# committed memory. ++if (WIN32 AND ${_compiler_id} STREQUAL "GNU") ++ target_link_options(openfast PRIVATE "LINKER:--stack,268435456") ++endif() ++ + install(TARGETS openfast + RUNTIME DESTINATION bin) + diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 9fb70d1a..bfe968c5 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -1624,7 +1624,9 @@ class DeckFile: rejected otherwise. The native C API (:class:`cabledyn.CableDyn`) reads decks with the standalone rules, so it rejects the ``CoupledPinned``/``VesselPinned`` bodies and rods that ``caller_driven=True`` accepts; FAST.Farm, in turn, refuses bodies and rods when it - initialises the module. + initialises the module. A coupled deck carries bodies or rods, not both (a rod fixed to a + body counts as a rod): ``caller_driven=True`` rejects a deck with both, as the coupled + route and the C API do, while the standalone driver's multibody march takes them. """ def __init__( @@ -3730,6 +3732,16 @@ def end_key(token: str) -> str: "single-turbine pure EI=0 deck without Rigid6 bodies or rods; remove the " "deck current OPTION (the host SeaState supplies the current)" ) + # native CD_Init_Deck_Aggregate: the coupled march advances the bodies or the rods + # of a deck, not both (a rod fixed to a body counts; a zero-length rod is a point) + if has_rods and body_types: + raise DeckFormatError( + f"{self._label}: a coupled deck with both BODIES and RODS is not " + "supported: the coupled march advances the bodies (Rigid6, Point3) or the " + "rods of a deck, not both, and a rod fixed to a body counts as a rod; run " + "the deck with MoorDyn (CompMooring = 3) or, without CoupledPinned objects, " + "with the standalone driver, whose multibody march takes both" + ) if has_viv_ei0 and not self.caller_driven: # native init_one_model: the lift acts with the line's Morison drag, which the # deck switches on with water (a depth or bathymetry, a current, or waves); on the diff --git a/python/tests/test_deck_native_parity.py b/python/tests/test_deck_native_parity.py index 55f4d6a0..c51115fa 100644 --- a/python/tests/test_deck_native_parity.py +++ b/python/tests/test_deck_native_parity.py @@ -443,6 +443,27 @@ def test_body_fixed_rod_ends_resolve_to_body_points(): assert keys["rod1b"] == "rod1b" and types["rod1b"] == "body1" and merged == {} +def test_coupled_decks_take_bodies_or_rods_not_both(): + # native CD_Init_Deck_Aggregate (OpenFAST CompMooring = 5, FAST.Farm, the C API): the coupled + # march advances the bodies or the rods of a deck; a rod fixed to the body counts as a rod + rods = ( + 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" + "1 spar Body1 0 0 -2 0 0 -8 2 -\n" + ) + # (in still water: a coupled deck current on a deck with bodies is refused first) + still = ("uniform 0.6 0.0 0.0 current", "none current") + text = _buoy(still, (f"{_BAR} POINTS", rods + f"{_BAR} POINTS")) + DeckFile.from_text(text) # the standalone multibody march + _rejects(text, "a coupled deck with both BODIES and RODS", caller_driven=True) + DeckFile.from_text(_buoy(still), caller_driven=True) + # a zero-length rod is a point, not a rod + zero = rods.replace("0 0 -8 2 -", "0 0 -2 0 -") + zero_text = _buoy(still, (f"{_BAR} POINTS", zero + f"{_BAR} POINTS")) + DeckFile.from_text(zero_text, caller_driven=True) + + # --------------------------------------------------------------------------- dispatch gates diff --git a/python/tests/test_objects.py b/python/tests/test_objects.py index e4f99a45..bfd122d6 100644 --- a/python/tests/test_objects.py +++ b/python/tests/test_objects.py @@ -476,3 +476,32 @@ def test_zero_length_rod_axis_is_a_value_error(tmp_path, monkeypatch): monkeypatch.setattr(type(rod), "node_positions", lambda self, out=None: np.zeros((3, 3))) with pytest.raises(ValueError, match="zero length"): rod.axis() + + +def test_c_api_takes_bodies_or_rods_not_both(tmp_path): + # the C API runs a deck with bodies or rods on the coupled aggregate, which marches one of the + # two families: a rod fixed to the buoy is refused by name, saying where such a deck runs + bar = "-" * 21 + base = (EXAMPLES / "rigid6_buoy.dat").read_text(encoding="utf-8") + # still water and a fluid-inert buoy (the aggregate refuses CdA/Ca without a host field) + base = base.replace("uniform 0.6 0.0 0.0 current", "none current", 1) + base = base.replace("0.0 0.0 0.0 8.0 0.5 3.5e4", "0.0 0.0 0.0 0.0 0.0 3.5e4", 1) + marker = f"{bar} POINTS" + rods = ( + 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" + "1 spar Body1 0 0 -2 0 0 -8 2 -\n" + ) + assert base.count(marker) == 1 + deck = tmp_path / "buoy_rod.dat" + deck.write_text(base.replace(marker, rods + marker), encoding="utf-8") + with CableDyn() as model, pytest.raises(CableDynError) as err: + model.init_deck(deck) + message = str(err.value) + assert "a coupled deck with both BODIES and RODS is not supported" in message + assert "CompMooring = 3" in message and "standalone driver" in message + still = tmp_path / "buoy.dat" + still.write_text(base, encoding="utf-8") + with CableDyn() as model: + model.init_deck(still) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 467f8277..af3746b7 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -111,7 +111,8 @@ MODULE CableDyn_DeckDriver CD_HermiteCable_Dyn_Node_Torque, CD_HermiteCable_Dyn_End_Twist USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Compliance, CD_HTORS_MAX_STEP, & CD_HTORS_MAX_TWIST, CD_HermiteTorsion_Zeta_Damping, CD_HermiteTorsion_Line, & - CD_HermiteTorsion_Unwrap, CD_HermiteTorsion_Element_Stretch, CD_HTORS_OK + CD_HermiteTorsion_Unwrap, CD_HermiteTorsion_Element_Stretch, CD_HTORS_OK, & + CD_HermiteTorsion_Coupling_Twist USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED, CD_ENDCONN_FINITE, CD_ENDCONN_RIGID USE CableDyn_Vessel, ONLY: CD_VesselRAOType, CD_Vessel_Euler_DCM, CD_Vessel_Euler_Angular, & CD_Vessel_Point_Kinematics, CD_Vessel_RAO_Set, CD_Vessel_RAO_Eval, & @@ -1097,6 +1098,9 @@ MODULE CableDyn_DeckDriver ! End A of a finite-EI line restrained in torsion at both ends, as on the standalone ! cubic-Hermite route) LOGICAL, ALLOCATABLE :: col_roll(:) + ! per aggregate moving column of a TURBINES deck: the turbine whose motionFile records turn the + ! column's frames (its point's Turbine; 0 for a column whose frames are held) + INTEGER, ALLOCATABLE :: col_turb(:) END TYPE !> Opaque deck current of a standalone mixed deck, which the standalone driver marches on the @@ -3481,18 +3485,35 @@ END SUBROUTINE torsion_stage SUBROUTINE torsion_note() !! The notes of the accepted torsion stage: a residual floor above the tolerance, and the - !! imposed twist and torque. A line restrained at one end only solves no twist stage; its - !! note is one_end_state's. + !! twist and torque. The twist is the line's total twist Twist = Phi - Theta (the Twist + !! channel at the static state): the imposed Phi = Pretwist(B) - Pretwist(A), which the note + !! also gives, with the turn of the end frames (a PtfmInit or TURBINES rotation of a parent) + !! and the shape's geometric twist, both in the holonomy Theta. The accepted theta is + !! Theta_eff = Theta + tw_K under torque-tension coupling, tw_K = -sum (K/GJ)(l - L) + !! (CD_HermiteTorsion_Coupling_Twist), so Phi - Theta = Phi - Theta_eff + tw_K. A line + !! restrained at one end only solves no twist stage; its note is one_end_state's. CHARACTER(320) :: tnote + REAL(wp) :: twist IF (ln%tors_free_end > 0) RETURN + twist = tors%phi - tors%theta + IF (ALLOCATED(tors%couple)) THEN + ! the final mesh of the stage: l0 after the attachment polish, l0_am otherwise + IF (has_att) THEN + twist = twist + CD_HermiteTorsion_Coupling_Twist(q_static, l0, tors%couple, tors%quadrature_order) + ELSE + twist = twist + CD_HermiteTorsion_Coupling_Twist(q_static, l0_am, tors%couple, tors%quadrature_order) + END IF + END IF IF (tors_tol_used > static_tol_target) THEN WRITE (tnote, '(A,I0,A,ES9.2,A,ES9.2)') 'line ', ln%id, ': torsion static residual floor above the '// & 'tolerance ', static_tol_target, '; twisted equilibrium accepted at ', tors_tol_used CALL report_note(tnote) END IF - 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))' + WRITE (tnote, '(A,I0,A,I0,A,ES12.5,A,ES12.5,A,ES12.5,A,I0,A,I0,A)') 'line ', ln%id, & + ': torsion solved, total twist Twist', ln%id, ' =', twist*45.0_wp/QUARTER_PI, & + ' deg (imposed Pretwist(B) - Pretwist(A) =', tors%phi*45.0_wp/QUARTER_PI, & + ' deg, with the end frames'' turn and the shape''s geometric twist), torque ', tors%torque, ' N m (', & + tors%ramp_steps, ' twist stage(s), ', tors%descents, ' buckling descent(s))' CALL report_note(tnote) IF (tors%untwisted_instability) THEN WRITE (tnote, '(A,I0,A,I0,A)') 'line ', ln%id, ': the twisted static state keeps the instability of '// & @@ -7354,7 +7375,7 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & range_files, host_orientation, static_current, prescribed_motion, & - static_run, deck_current) + static_run, deck_current, deck_turbines) !! Parse a MIXED deck ONCE and partition its lines into {EI=0 mooring} and !! {finite-EI cable}, returning the raw parts the OpenFAST aggregate facade wraps: !! the EI=0 mooring SYSTEM built from the mooring subset (over ALL deck points, the @@ -7455,8 +7476,16 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! supplying its own field and passes no deck_current. LOGICAL, INTENT(IN), OPTIONAL :: deck_current + ! deck_turbines: the caller is the standalone driver, which runs a TURBINES deck by itself: the + ! deck's TURBINES rows place every Turbine point at ref_J + PtfmInit_J(p) as the parse of + ! the single-route decks does (place_standalone_turbine_points), the end frames of a finite-EI + ! line on a Turbine point start turned by turbine J's PtfmInit rotation (turbine_end_dcm), + ! and the per-turbine motionFile records move the points and turn those frames + ! (build_aggregate_motion). Ignored in FAST.Farm mode (n_turbines >= 1). + LOGICAL, INTENT(IN), OPTIONAL :: deck_turbines + INTEGER :: nturb - LOGICAL :: host_turns, own_motion, dynamic_points, static_only, own_current + LOGICAL :: host_turns, own_motion, dynamic_points, static_only, own_current, own_turbines TYPE(DeckLineType), ALLOCATABLE :: types(:) TYPE(DeckBody), ALLOCATABLE :: bodies(:) TYPE(DeckRodType), ALLOCATABLE :: rod_types(:) @@ -7486,9 +7515,15 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi IF (.NOT. (dt > CD_ZERO)) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate requires a positive coupling dt'); RETURN END IF + nturb = 0 + IF (PRESENT(n_turbines)) nturb = MAX(0, n_turbines) + ! a standalone TURBINES deck: the parse places the Turbine points from the TURBINES rows (and + ! refuses Turbine points without them), as for the single-route decks + own_turbines = .FALSE. + IF (PRESENT(deck_turbines)) own_turbines = deck_turbines .AND. nturb == 0 CALL parse_deck(deck_path, types, bodies, rod_types, rods, points, lines, sections, opts, channels, & ErrStat, ErrMsg, caller_driven=.TRUE., env_gravity=env_gravity, & - env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.TRUE., & + env_rho_water=env_rho_water, env_wtrdpth=env_wtrdpth, allow_turbine=.NOT. own_turbines, & failures=fails, controls=ctrls, run_tmax=run_tmax, host_coupled_objects=.TRUE., & static_run=static_run) IF (ErrStat == CD_DECKDRV_OK) THEN @@ -7529,8 +7564,6 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF END IF ! ---- FAST.Farm mode ------------------------------------------------------- - nturb = 0 - IF (PRESENT(n_turbines)) nturb = MAX(0, n_turbines) IF (nturb > 0) THEN IF (PRESENT(ptfm_init)) THEN IF (MAXVAL(ABS(ptfm_init)) > CD_ZERO) THEN @@ -7571,11 +7604,15 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END DO CALL revalidate_ptfm_points(points, lines, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN - ELSE + ELSE IF (.NOT. own_turbines) THEN + ! Turbine coordinates are turbine-local: only a farm context (FAST.Farm) or the standalone + ! driver's TURBINES rows place them DO i = 1, SIZE(points) IF (points(i)%turbine_id > 0) THEN - CALL fail(ErrStat, ErrMsg, 'the deck carries Turbine points but no farm init was '// & - 'given (pass n_turbines + turbine_ref_pos)'); RETURN + CALL fail(ErrStat, ErrMsg, 'POINT '//TRIM(int_to_str(points(i)%id))//' is a Turbine point, whose '// & + 'coordinates are local to turbine J of a farm, but this run has no farm: run the deck in '// & + 'FAST.Farm (Mod_SharedMooring = 5) or with the standalone driver and a TURBINES section; '// & + 'a single-turbine OpenFAST model and the C API take Coupled/Vessel points'); RETURN END IF END DO END IF @@ -7698,9 +7735,9 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END IF IF ((opts%has_current .OR. opts%has_current_profile) .AND. .NOT. own_current) THEN IF (nturb > 0) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not supported in '// & - 'FAST.Farm: the shared mooring of a farm runs in STILL WATER (no fluid field spans the '// & - 'farm). Remove the current OPTION'); RETURN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck '//deck_current_source(opts)// & + ' is not supported in FAST.Farm: the shared mooring of a farm runs in STILL WATER (no '// & + 'fluid field spans the farm). Remove the '//deck_current_source(opts)); RETURN END IF ! (the standalone mixed route passes deck_current; this is a library caller without it) CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: the deck current OPTION is not marched by a '// & @@ -7784,8 +7821,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi END SELECT END DO ! RODS are marched on the coupled aggregate (the rod twin of the Rigid6 march), scope-validated - ! below (n_rod block) and built into agg%rod. A rod deck mixed with Rigid6 bodies fails closed - ! there (the aggregate marches one body/rod family per step). + ! below (n_rod block) and built into agg%rod. A rod deck with Rigid6 or Point3 bodies fails + ! closed there (the aggregate marches one body/rod family per step). n_rod = SIZE(rods) n_host_rod = COUNT(rods%rod_type == 'coupled' .OR. rods%rod_type == 'vessel' .OR. & rods%rod_type == 'coupledpinned') @@ -7890,9 +7927,16 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi ! field, another dynamic point, a Rigid6/point3 body, or line FAILURE is not composed with a rod march ! yet -- fail closed by name. IF (n_rod > 0) THEN + ! The step replaces the mooring step with either the body march or the rod march: a deck + ! with both (a rod fixed to a body included; a zero-length rod is a point by now) has no + ! coupled march. The standalone multibody march and MoorDyn-F take it. IF (n_rigid6 > 0 .OR. n_point3 > 0) THEN - CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled deck mixing RODs and Rigid6/point3 '// & - 'bodies is not supported (the aggregate marches one body/rod family per step)'); RETURN + CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled deck with both BODIES and RODS is not '// & + 'supported: the coupled march advances the bodies (Rigid6, Point3) or the rods of a deck, '// & + 'not both, and a rod fixed to a body counts as a rod. Coupled runs (OpenFAST CompMooring = 5, '// & + 'the C API and Python) take a deck with bodies or a deck with rods; run this one with MoorDyn '// & + '(CompMooring = 3) in the same OpenFAST binary, or, without CoupledPinned objects, with the '// & + 'standalone driver, whose multibody march takes both'); RETURN END IF IF (n_fin > 0) THEN CALL fail(ErrStat, ErrMsg, 'CD_Init_Deck_Aggregate: a coupled ROD with a finite-EI cable in the '// & @@ -8124,6 +8168,10 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi j = find_point(points, lines(i)%nodeA) IF (j > 0 .AND. points(j)%turbine_id > 0) & fairlead_dcm = ptfm_zyx_dcm(farm_ptfm_init(4:6, points(j)%turbine_id)) + ELSE IF (own_turbines) THEN + ! a standalone TURBINES deck: the PtfmInit rotation of the end's turbine, as on the + ! standalone cubic-Hermite route + fairlead_dcm = turbine_end_dcm(points, opts, lines(i)%nodeA) ELSE IF (PRESENT(ptfm_init)) THEN fairlead_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) END IF @@ -8137,6 +8185,8 @@ SUBROUTINE CD_Init_Deck_Aggregate(deck_path, dt, agg, ErrStat, ErrMsg, env_gravi 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 (own_turbines) THEN + end_b_dcm = turbine_end_dcm(points, opts, lines(i)%nodeB) ELSE IF (PRESENT(ptfm_init)) THEN end_b_dcm = ptfm_zyx_dcm(ptfm_init(4:6)) END IF @@ -8848,7 +8898,9 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM !! 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). + !! standalone cubic-Hermite route (check_motion_roll_lines). On a TURBINES deck the + !! per-turbine records also turn the frames of each column with the column's turbine when a + !! line carries end-connection or torsion frames (with_turbine_frames, as on that route). TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(IN) :: lines(:) LOGICAL, INTENT(IN) :: is_fin(:) @@ -8863,7 +8915,10 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM ErrMsg = '' CALL CD_Motion_End(rt) CALL read_motion_file(opts%motion_file, points, opts, rt%motion, ErrStat, ErrMsg, & - with_roll=ANY([(line_torsion_active(lines(i)), i=1, SIZE(lines))])) + 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_lines(rt%motion, lines, points, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN @@ -8905,7 +8960,7 @@ SUBROUTINE build_aggregate_motion(points, lines, is_fin, opts, rt, ErrStat, ErrM 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)) + IF (pass == 1) ALLOCATE (rt%col_point(n), rt%col_pos(3, n), rt%col_roll(n), rt%col_turb(n)) END DO IF (ErrStat /= CD_DECKDRV_OK) RETURN rt%active = .TRUE. @@ -8923,6 +8978,8 @@ SUBROUTINE set_column(col, ipt, takes_roll) rt%col_point(col) = ip rt%col_pos(:, col) = points(ipt)%pos rt%col_roll(col) = takes_roll + rt%col_turb(col) = 0 + IF (rt%motion%has_turb_rot) rt%col_turb(col) = points(ipt)%turbine_id END SUBROUTINE set_column END SUBROUTINE build_aggregate_motion @@ -8940,10 +8997,11 @@ INTEGER FUNCTION CD_Motion_NColumns(rt) RESULT(n) END FUNCTION CD_Motion_NColumns LOGICAL FUNCTION CD_Motion_Has_Rotation(rt) RESULT(has) - !! A vesselMotion table: the moving points turn with the vessel. + !! A vesselMotion table (the moving points turn with the vessel), or the per-turbine records of + !! a TURBINES deck whose lines carry end frames (each point turns with its turbine). TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt has = .FALSE. - IF (rt%active) has = rt%motion%has_rot + IF (rt%active) has = rt%motion%has_rot .OR. rt%motion%has_turb_rot END FUNCTION CD_Motion_Has_Rotation LOGICAL FUNCTION CD_Motion_Has_Roll(rt) RESULT(has) @@ -8978,16 +9036,17 @@ SUBROUTINE CD_Motion_Kinematics(rt, time_index, position, velocity, acceleration !! Grid row time_index (1 = t 0) of the moving surface, columns in the aggregate moving-set !! order: position, velocity and acceleration of each driving point (3, n); the !! global-to-parent DCM (3, 3, n) and the global-axis angular velocity and acceleration - !! (3, n) -- the vessel's under a vesselMotion table, the identity and zero otherwise, so a - !! motionFile turns no frame -- and the motionFile roll [rad] of each column that takes one - !! (zero elsewhere). Allocation free. + !! (3, n) -- the vessel's under a vesselMotion table, the column's turbine's under the + !! records of a TURBINES deck, the identity and zero otherwise, so motionFile point rows turn + !! no frame -- and the motionFile roll [rad] of each column that takes one (zero elsewhere). + !! Allocation free. TYPE(CD_MotionRuntimeType), INTENT(IN) :: rt INTEGER, INTENT(IN) :: time_index REAL(wp), INTENT(OUT) :: position(:, :), velocity(:, :), acceleration(:, :) REAL(wp), INTENT(OUT) :: orientation(:, :, :), angular_velocity(:, :), angular_acceleration(:, :), roll(:) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - INTEGER :: col, ip, n + INTEGER :: col, ip, n, j ErrStat = CD_DECKDRV_BADINPUT ErrMsg = '' @@ -9025,6 +9084,16 @@ SUBROUTINE CD_Motion_Kinematics(rt, time_index, position, velocity, acceleration orientation(3, 3, col) = CD_ONE angular_velocity(:, col) = CD_ZERO angular_acceleration(:, col) = CD_ZERO + IF (rt%motion%has_turb_rot) THEN + ! TURBINES records: the column turns with its own turbine J (turbine_end_rotation), the + ! parent DCM being the transpose of the record's turbine-to-global rotation + j = rt%col_turb(col) + IF (j >= 1 .AND. j <= SIZE(rt%motion%turb_rot, 3)) THEN + orientation(:, :, col) = TRANSPOSE(rt%motion%turb_rot(:, :, j, time_index)) + angular_velocity(:, col) = rt%motion%turb_omega(:, j, time_index) + angular_acceleration(:, col) = rt%motion%turb_alpha(:, j, time_index) + END IF + END IF END IF roll(col) = CD_ZERO IF (rt%col_roll(col)) roll(col) = rt%motion%roll(ip, time_index) @@ -9040,6 +9109,7 @@ SUBROUTINE CD_Motion_End(rt) IF (ALLOCATED(rt%col_point)) DEALLOCATE (rt%col_point) IF (ALLOCATED(rt%col_pos)) DEALLOCATE (rt%col_pos) IF (ALLOCATED(rt%col_roll)) DEALLOCATE (rt%col_roll) + IF (ALLOCATED(rt%col_turb)) DEALLOCATE (rt%col_turb) rt%active = .FALSE. END SUBROUTINE CD_Motion_End @@ -26431,8 +26501,11 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l INTEGER :: nobj, n, i, j, k, it, inner, info, worst, jk LOGICAL :: ok, only_points REAL(wp) :: sc, rnorm, rnorm_try, mu, step_cap, len_min, dmax, trust, pred + ! the completion line: the deck pose of every point, and the largest turn of a body or rod + REAL(wp), ALLOCATABLE :: pos_deck(:, :) + REAL(wp) :: turn_rot(3, 3), turn_max CHARACTER(1024) :: lin_msg - CHARACTER(24) :: b1 + CHARACTER(24) :: b1, b2 ErrStat = CD_DECKDRV_OK ErrMsg = '' @@ -26832,15 +26905,41 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l END DO END IF END IF + ALLOCATE (pos_deck(3, SIZE(points))) + DO i = 1, SIZE(points) + pos_deck(:, i) = points(i)%pos + END DO CALL apply_state(x, bodies, rods, points) IF (only_points .OR. silent) RETURN + ! The largest move from the deck pose: of a body reference point or rod centre (the + ! translation unknowns) and of every point the objects carry (attachment points, rod ends, + ! Free/Connect points), so a pinned rod that only turns reports its End B's move. The largest + ! turn: the rotation angle |log(R R0^T)| of a body or rod from its deck orientation R0. dmax = CD_ZERO DO k = 1, nobj IF (ndof(k) >= 3) dmax = MAX(dmax, NORM2(x(off(k) + 1:off(k) + 3))) END DO + DO i = 1, SIZE(points) + dmax = MAX(dmax, NORM2(points(i)%pos - pos_deck(:, i))) + END DO + turn_max = CD_ZERO + DO k = 1, nobj + SELECT CASE (okind(k)) + CASE (OBJ_BODY) + turn_rot = MATMUL(CD_Exp_SO3(x(off(k) + 4:off(k) + 6)/lsc(k)), base_rot(:, :, k)) + CASE (OBJ_ROD) + turn_rot = MATMUL(CD_Exp_SO3((x(off(k) + 4)*e1(:, k) + x(off(k) + 5)*e2(:, k))/lsc(k)), base_rot(:, :, k)) + CASE (OBJ_PIN) + turn_rot = MATMUL(CD_Exp_SO3((x(off(k) + 1)*e1(:, k) + x(off(k) + 2)*e2(:, k))/lsc(k)), base_rot(:, :, k)) + CASE DEFAULT + CYCLE + END SELECT + turn_max = MAX(turn_max, NORM2(CD_Log_SO3(MATMUL(turn_rot, TRANSPOSE(base_rot0(:, :, k)))))) + END DO WRITE (b1, '(ES10.3)') dmax + WRITE (b2, '(ES10.3)') turn_max*45.0_wp/QUARTER_PI WRITE (output_unit, '(A)') ' Initial conditions: body/rod static equilibrium ('//TRIM(int_to_str(nobj))// & - ' object(s), largest move '//TRIM(ADJUSTL(b1))//' m) completed.' + ' object(s), largest move '//TRIM(ADJUSTL(b1))//' m, largest turn '//TRIM(ADJUSTL(b2))//' deg) completed.' CONTAINS @@ -31328,6 +31427,18 @@ PURE SUBROUTINE turbine_end_rotation(points, motion, point_id, time_index, dcm, alpha = motion%turb_alpha(:, k, time_index) END SUBROUTINE turbine_end_rotation + PURE FUNCTION deck_current_source(opts) RESULT(src) + !! The deck input that declares the deck's current, for a refusal: the CurrentMod 1 table of + !! its WaterKin file, or its current OPTION. + TYPE(DeckOptions), INTENT(IN) :: opts + CHARACTER(:), ALLOCATABLE :: src + IF (opts%has_waterkin_file .AND. opts%waterkin_current_mode == 1 .AND. opts%has_current_profile) THEN + src = 'WaterKin current table (CurrentMod 1)' + ELSE + src = 'current OPTION' + END IF + END FUNCTION deck_current_source + 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 diff --git a/src/CableDyn_OpenFAST_Aggregate.f90 b/src/CableDyn_OpenFAST_Aggregate.f90 index 8d5007e7..be68b088 100644 --- a/src/CableDyn_OpenFAST_Aggregate.f90 +++ b/src/CableDyn_OpenFAST_Aggregate.f90 @@ -292,7 +292,7 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ptfm_init, external_fluid, coupled_positions, & n_turbines, turbine_ref_pos, farm_ptfm_init, forbid_deck_ambient, run_tmax, & range_files, host_orientation, static_current, prescribed_motion, static_run, & - deck_current) + deck_current, deck_turbines) !! Build the aggregate from ONE mixed deck: partition its lines into {EI=0 mooring} !! and {finite-EI cable}, wrap the mooring subset into a CD_FMF, and own one CD_HFMF !! per cable. Same signature philosophy as CD_FMF_Init_From_Deck (host environment @@ -343,6 +343,9 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi ! deck_current: the caller marches the deck's own current (the standalone driver; see ! CD_Init_Deck_Aggregate): every step samples it at the nodes, at its t_committed LOGICAL, INTENT(IN), OPTIONAL :: deck_current + ! deck_turbines: the standalone driver runs a TURBINES deck, whose TURBINES rows place the + ! Turbine points and whose per-turbine records move them (see CD_Init_Deck_Aggregate) + LOGICAL, INTENT(IN), OPTIONAL :: deck_turbines ! Both bundles (about 70 KB together) are built on the heap: initialisation runs on the ! thread of the calling host, whose stack size CableDyn does not choose. @@ -383,7 +386,8 @@ SUBROUTINE CD_AGG_Init_From_Deck(self, deck_path, dt, ErrStat, ErrMsg, env_gravi forbid_deck_ambient=forbid_deck_ambient, run_tmax=run_tmax, & range_files=range_files, host_orientation=host_orientation, & static_current=static_current, prescribed_motion=prescribed_motion, & - static_run=static_run, deck_current=deck_current) + static_run=static_run, deck_current=deck_current, & + deck_turbines=deck_turbines) IF (PRESENT(external_fluid)) THEN candidate%built_extfluid = external_fluid END IF @@ -1522,7 +1526,9 @@ SUBROUTINE CD_AGG_MotionKinematics(self, time_index, position, velocity, acceler !! DCM (3, 3, ncp_total) with the global-axis angular velocity and acceleration (3, !! ncp_total), and the roll (ncp_total). has_rotation: a vesselMotion table, whose !! orientation and rates the step takes (the fairlead end connection and torsion frames - !! turn with the vessel, as on the standalone cubic-Hermite route); has_roll: a motionFile + !! turn with the vessel, as on the standalone cubic-Hermite route), or the per-turbine + !! records of a TURBINES deck whose lines carry end frames (each column turns with its + !! turbine); has_roll: a motionFile !! roll column the step takes as roll. Without them (motionFile point rows) the frames are !! held and the step takes the translations alone. TYPE(CD_AGG_ModuleType), INTENT(IN) :: self diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index c4a56e8f..595c40d3 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -552,6 +552,12 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er REAL(wp) :: cval, dtC, deck_dtm, dt_moor REAL(wp) :: fair_ten, fair_force(3), fair_incl, fair_decl, fair_azi, force_incl LOGICAL :: has_dtm, has_ptfm, use_extf + ! the coupling step's name on the console: the glue DT, or FAST.Farm's DT_Mooring + CHARACTER(24) :: dtc_name, dtc_short + ! the deck's WaterKin policy takes SeaState waves or current (host_seastate), or a + ! WaterKin current table (host_table); neither is still water + LOGICAL :: host_seastate, host_table + CHARACTER(16) :: host_kin REAL(wp), ALLOCATABLE :: static_cur(:,:) ! the host's steady current for the static start CHARACTER(ChanLen) :: chan_hdr, chan_unt CHARACTER(1024) :: native_root, init_note @@ -559,6 +565,7 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ErrStat = ErrID_None ErrMsg = '' + host_seastate = .FALSE. profile_requested = profile_environment_requested() IF (profile_requested) THEN CALL SYSTEM_CLOCK(prof_c0, prof_rate) @@ -663,6 +670,14 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! endpoint motion into a lagged line interior creates nonphysical stiff-EA chatter. ! ------------------------------------------------------------------------------ dtC = REAL(DTcoupling, wp) + ! In FAST.Farm the coupling step is the farm's mooring step DT_Mooring, not a turbine's DT. + IF (nT > 0_IntKi) THEN + dtc_name = 'FAST.Farm DT_Mooring' + dtc_short = 'DT_Mooring' + ELSE + dtc_name = 'glue DT' + dtc_short = 'DT' + END IF CALL CD_Deck_Query_dtM( TRIM(InitInp%FileName), deck_dtm, has_dtm, es, em, & env_gravity=REAL(InitInp%g, wp), env_rho_water=REAL(InitInp%rhoW, wp), & env_wtrdpth=REAL(InitInp%WtrDepth, wp) ) @@ -678,25 +693,26 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ! documented implicit-solver floor for MoorDyn-migrated explicit dtM values). nsuper = MAX(1_IntKi, FLOOR(deck_dtm/dtC*(1.0_wp + 1.0e-6_wp), IntKi)) IF (deck_dtm < dtC*(1.0_wp - 1.0e-6_wp)) THEN - CALL WrScr( ' CableDyn: deck dtM = '//TRIM(Num2LStr(deck_dtm))//' s is below the glue DT = '// & - TRIM(Num2LStr(dtC))//' s; the implicit mooring step uses dtM = DT.' ) + CALL WrScr( ' CableDyn: deck dtM = '//TRIM(Num2LStr(deck_dtm))//' s is below the '// & + TRIM(dtc_name)//' = '//TRIM(Num2LStr(dtC))//' s; the implicit mooring step uses dtM = '// & + TRIM(dtc_short)//'.' ) ELSE IF (ABS(REAL(nsuper, wp)*dtC - deck_dtm) > 1.0e-6_wp*MAX(dtC, deck_dtm)) THEN CALL SetErrStat( ErrID_Warn, 'CableDyn mooring module: deck dtM = '//TRIM(Num2LStr(deck_dtm))// & - ' s is not an integer multiple of the glue DT = '//TRIM(Num2LStr(dtC))// & + ' s is not an integer multiple of the '//TRIM(dtc_name)//' = '//TRIM(Num2LStr(dtC))// & ' s; using dtM = '//TRIM(Num2LStr(REAL(nsuper, wp)*dtC))//' s ('// & - TRIM(Num2LStr(nsuper))//' x DT), the largest multiple not exceeding the '// & - 'requested step. Set dtM to a multiple of DT to silence this warning.', & - ErrStat, ErrMsg, RoutineName ) + TRIM(Num2LStr(nsuper))//' x '//TRIM(dtc_short)//'), the largest multiple not '// & + 'exceeding the requested step. Set dtM to a multiple of '//TRIM(dtc_short)// & + ' to silence this warning.', ErrStat, ErrMsg, RoutineName ) CALL WrScr( ' WARNING: CableDyn deck dtM = '//TRIM(Num2LStr(deck_dtm))//' s changed to '// & TRIM(Num2LStr(REAL(nsuper, wp)*dtC))//' s ('//TRIM(Num2LStr(nsuper))// & - ' x glue DT = '//TRIM(Num2LStr(dtC))//' s).' ) + ' x '//TRIM(dtc_name)//' = '//TRIM(Num2LStr(dtC))//' s).' ) END IF ELSE nsuper = 1_IntKi END IF dt_moor = REAL(nsuper, wp)*dtC CALL WrScr( ' CableDyn time step dtM = '//TRIM(Num2LStr(dt_moor))//' s ('//TRIM(Num2LStr(nsuper))// & - ' x glue DT'//TRIM(MERGE('; deck dtM ', '; the default', has_dtm))//')' ) + ' x '//TRIM(dtc_name)//TRIM(MERGE('; deck dtM ', '; the default', has_dtm))//')' ) ! The run must END on a mooring boundary: with supercycling, a trailing partial ! interval would take only skipped glue steps, leaving the committed mooring state -- ! and the held (zero-order-hold) loads -- up to dtM stale at TMax, silently. Fail @@ -707,7 +723,8 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er MOD(nglue, nsuper) /= 0_IntKi) THEN CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: TMax = '//TRIM(Num2LStr(InitInp%Tmax))// & ' s is not a whole number of CableDyn steps (dtM = '//TRIM(Num2LStr(dt_moor))// & - ' s = '//TRIM(Num2LStr(nsuper))//' x DT): the run would end inside a mooring '// & + ' s = '//TRIM(Num2LStr(nsuper))//' x '//TRIM(dtc_short)//'): the run would end '// & + 'inside a mooring '// & 'interval with the committed state up to dtM stale. Choose TMax as a multiple '// & 'of dtM, or set the deck OPTIONS dtM accordingly.', ErrStat, ErrMsg, RoutineName ) RETURN @@ -930,8 +947,32 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er ErrStat, ErrMsg, RoutineName ) RETURN END IF - CALL WrScr( ' CableDyn: SeaState wave/current kinematics drive the mooring hydro ('// & - TRIM(Num2LStr(Inst(id)%nfluid))//' sampling nodes, refreshed every mooring step).' ) + ! Say what the lines take, as the deck's WaterKin policy decides it (sample_wavefield): an + ! explicit WaterKin file may take no SeaState component (WaveKinMod 0, CurrentMod 0), and its + ! CurrentMod 1 table gives the current itself. + host_seastate = Inst(id)%agg%host_wave_enabled .OR. Inst(id)%agg%host_current_enabled + host_table = ALLOCATED(Inst(id)%agg%host_current_profile_z) + IF (Inst(id)%agg%host_wave_enabled .AND. Inst(id)%agg%host_current_enabled) THEN + host_kin = 'wave/current' + ELSE IF (Inst(id)%agg%host_wave_enabled) THEN + host_kin = 'wave' + ELSE + host_kin = 'current' + END IF + IF (host_seastate .AND. host_table) THEN + CALL WrScr( ' CableDyn: SeaState '//TRIM(host_kin)//' kinematics drive the mooring hydro ('// & + TRIM(Num2LStr(Inst(id)%nfluid))//' sampling nodes, refreshed every mooring step); '// & + 'the WaterKin current table gives the current.' ) + ELSE IF (host_seastate) THEN + CALL WrScr( ' CableDyn: SeaState '//TRIM(host_kin)//' kinematics drive the mooring hydro ('// & + TRIM(Num2LStr(Inst(id)%nfluid))//' sampling nodes, refreshed every mooring step).' ) + ELSE IF (host_table) THEN + CALL WrScr( ' CableDyn: the WaterKin current table gives the mooring lines their current; '// & + 'no SeaState kinematics are sampled (WaterKin WaveKinMod 0).' ) + ELSE + CALL WrScr( ' CableDyn: the WaterKin file takes no SeaState waves or current (WaveKinMod 0, '// & + 'CurrentMod 0): the mooring lines are in still water.' ) + END IF ! Seed the held fields at t = 0 (the static-IC positions): with supercycling ! (nsuper > 1) the first mooring advance happens only at the END of the first ! interval, and every CalcOutput before it would otherwise serve loads from the @@ -1297,10 +1338,11 @@ SUBROUTINE CD_Init(InitInp, u, p, x, xd, z, other, y, m, DTcoupling, InitOut, Er TRIM(Num2LStr(npoints))//' point(s), '//TRIM(Num2LStr(nsections))//' section(s) [EI=0: '// & TRIM(Num2LStr(nei0))//', finite-EI: '//TRIM(Num2LStr(nfinite))//'].' ) CALL WrScr( ' Initial conditions: Newton static equilibrium with load continuation completed.' ) - IF (use_extf) THEN + IF (use_extf .AND. host_seastate) THEN ! The equilibrium is solved at zero SeaState fields and the SeaState kinematics act ! from t = 0, so the t = 0 outputs below differ from these equilibrium values by - ! the hydrodynamic load of the t = 0 kinematics on the line end nodes. + ! the hydrodynamic load of the t = 0 kinematics on the line end nodes (none when the + ! WaterKin policy takes no SeaState component). CALL WrScr( ' Line results below are at this equilibrium; SeaState kinematics act from t = 0.' ) END IF CALL WrScr( ' Fairlead convention: force is on End A toward End B; inclinations are signed below horizontal.' ) diff --git a/tests/data/msg_pinned_rod_turn.dat b/tests/data/msg_pinned_rod_turn.dat new file mode 100644 index 00000000..6b871001 --- /dev/null +++ b/tests/data/msg_pinned_rod_turn.dat @@ -0,0 +1,36 @@ +--------------------- CableDyn Input File ------------------------------------ +message test: a Pinned rod that its line turns at the static start (bodyIC static) +-- Rod 1 hangs from a fixed pin at End A (0, 0, -10) to End B (0, 0, -30); the rope from End B to +-- the anchor at (80, 0, -60) pulls it aside, so the static solve turns the rod about its pin and +-- moves End B while End A stays put. The completion line reports both the move and the turn. +--------------------- 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) (-) (-) (-) (-) +rope 0.10 20.0 1.0e8 -0.8 0.0 1.2 0.05 1.0 0.0 +--------------------- ROD TYPES ---------------------------------------- +Name Diam Mass Cd Ca CdEnd CaEnd +(-) (m) (kg/m) (-) (-) (-) (-) +arm 0.6 400.0 1.0 1.0 0.0 0.0 +--------------------- RODS --------------------------------------------- +ID RodType Attachment XA YA ZA XB YB ZB NumSegs Outputs +(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-) +1 arm Pinned 0.0 0.0 -10.0 0.0 0.0 -30.0 6 - +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +1 Fixed 80.0 0.0 -60.0 0 0 0 0 +--------------------- LINES -------------------------------------------- +ID LineType AttachA AttachB UnstrLen NumSegs Outputs +(-) (-) (-) (-) (m) (-) (-) +1 rope R1B 1 88.0 20 - +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +100.0 WtrDpth +0.01 dtM +0.02 TMax +static bodyIC +--------------------- OUTPUTS ------------------------------------------ +"Rod1Ry" +"FairTen1" +--------------------- need this line ----------------------------------- diff --git a/tests/test_documentation.py b/tests/test_documentation.py index ca217be3..51f6dab9 100644 --- a/tests/test_documentation.py +++ b/tests/test_documentation.py @@ -199,6 +199,16 @@ def test_windows_release_is_publicly_reproducible(self) -> None: ).read_text(encoding="utf-8") self.assertIn("usefrom CableDyn_Registry.txt", farm_registry) self.assertIn("USE CableDyn_Types", farm_types) + # the CMake route links openfast.exe and FAST.Farm.exe with a stack reserve on Windows + # GNU: MinGW's 2 MiB default overflows while FAST.Farm initialises its turbines + stack_patch = ( + ROOT / "integration" / "openfast" / "patches" / "0022-glue-stack-cmake.patch" + ).read_text(encoding="utf-8") + for target in ("openfast", "FAST.Farm"): + self.assertIn( + f'target_link_options({target} PRIVATE "LINKER:--stack,268435456")', + stack_patch, + ) def test_public_documentation_has_one_source_tree(self) -> None: self.assertFalse( diff --git a/tests/test_mixed_route_torsion.f90 b/tests/test_mixed_route_torsion.f90 index f33803a1..75279167 100644 --- a/tests/test_mixed_route_torsion.f90 +++ b/tests/test_mixed_route_torsion.f90 @@ -42,6 +42,21 @@ !> 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. +!> 9. Run alone (second argument "turbines", ctest mixed_route_turbines): a TURBINES deck (two +!> turbines, PtfmInit offsets and yaws, per-turbine motionFile records of heave and roll from +!> rest) with a finite-EI cable between the turbines, clamped (Rigid) and restrained in torsion +!> at both ends, and an EI = 0 chain from each turbine to an anchor. The driver runs it on the +!> mixed route (it used to stop for want of a farm context) and the deck's cable alone on the +!> standalone cubic-Hermite route and its chains alone on the standalone EI = 0 route, both of +!> which consume the TURBINES rows. The chains' tensions agree to LOAD_TOL of their range; the +!> cable's channels agree to the coupled cable's Newton controls (relative tolerance 5e-3; the +!> standalone route given those controls writes the mixed run's cable byte for byte, about 1e-2 +!> of the range from its own). The aggregate library marched with the standalone controls, as +!> in gate 1, reproduces the cable-only run's cable channels to the printed precision. Each +!> turbine's yaw and roll turn the clamped end on it (End A on turbine 1, End B on turbine 2), +!> so the end bend moments and the torque carry each end's own turbine. The torsion note of +!> the cable-only run gives the line's total twist (Twist1 at t = 0, to 1e-5 of it), which the +!> turbines' PtfmInit yaws turn away from the 30 deg Pretwist(B) - Pretwist(A) it also names. 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, & @@ -66,20 +81,46 @@ PROGRAM test_mixed_route_torsion ! the gate 1 and 2 channels of line 1 (the same in both decks) and the chain's CHARACTER(16), PARAMETER :: OUTS(10) = [LOADS, EXACT(1:3), [CHARACTER(16) :: 'L1N21px', 'L1N21py', 'L1N21pz']] CHARACTER(16), PARAMETER :: CHAIN_OUTS(2) = [CHARACTER(16) :: 'FairTen2', 'Point3pz'] + ! gate 9: the cable's end loads and bend moments (compared to LOAD_TOL), its torque, twist and + ! mid node (to TURB_TOL), and the chains' tensions (to LOAD_TOL) + CHARACTER(16), PARAMETER :: TURB_LOADS(4) = [CHARACTER(16) :: 'FairTen1', 'AnchTen1', 'BendMom1N1', 'BendMom1N41'] + CHARACTER(16), PARAMETER :: TURB_TWIST(4) = [CHARACTER(16) :: 'Torq1N1', 'Twist1', 'L1N21py', 'L1N21pz'] + CHARACTER(16), PARAMETER :: TURB_CABLE(8) = [TURB_LOADS, TURB_TWIST] + CHARACTER(16), PARAMETER :: TURB_CHAINS(4) = [CHARACTER(16) :: 'FairTen2', 'AnchTen2', 'FairTen3', 'AnchTen3'] + ! gate 9: the driver's mixed run against the cable-only run (the coupled cable's Newton controls) + REAL(wp), PARAMETER :: TURB_TOL = 5.0e-2_wp REAL(wp), PARAMETER :: LOAD_TOL = 5.0e-5_wp, POS_TOL = 1.0e-6_wp ! printed precision of ES15.7E3: half a unit in the 8th significant digit of each value, with a ! unit of the 8th digit of the channel's range for a value that crosses zero REAL(wp), PARAMETER :: PRINT_TOL = 6.0e-8_wp, PRINT_FLOOR = 1.0e-7_wp CHARACTER(1024) :: driver + ! the run's gates: 1-8, or with the second argument "turbines" gate 9 alone + CHARACTER(16) :: mode + LOGICAL :: turbines_only CHARACTER(160) :: neutral_t INTEGER :: n_fail = 0 IF (COMMAND_ARGUMENT_COUNT() < 1) ERROR STOP 'usage: test_mixed_route_torsion ' CALL GET_COMMAND_ARGUMENT(1, driver) + ! "turbines": gate 9 alone (its own ctest entry, mixed_route_turbines); the other gates otherwise + turbines_only = .FALSE. + IF (COMMAND_ARGUMENT_COUNT() >= 2) THEN + CALL GET_COMMAND_ARGUMENT(2, mode) + turbines_only = TRIM(mode) == 'turbines' + END IF ! neutral 0.2 m section of test_torsion_deck: EA 1e7, EI 1e6, GAs 1e8, GJ 5e4, Irn 1e-12 WRITE (neutral_t, '(A,ES24.16,A)') 'cab 0.2 ', RHOW*0.25_wp*PI*0.04_wp, & ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + IF (turbines_only) THEN + CALL check_turbines() + IF (n_fail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAIL: ', n_fail, ' mixed-route TURBINES gate(s) failed' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: the standalone TURBINES deck of EI = 0 and finite-EI lines on the mixed route' + STOP + END IF CALL check_vessel_routes() CALL check_roll_routes() CALL check_quasi_static(QS_HELD) @@ -109,10 +150,12 @@ SUBROUTINE require(cond, msg) END IF END SUBROUTINE require - SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, outs, atts) + SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, outs, atts, turbs) CHARACTER(*), INTENT(IN) :: path, types(:), points(:), lines(:), sections(:), endconns(:), options(:), outs(:) ! ATTACHMENTS rows (none when absent) CHARACTER(*), INTENT(IN), OPTIONAL :: atts(:) + ! TURBINES rows (none when absent) + CHARACTER(*), INTENT(IN), OPTIONAL :: turbs(:) INTEGER :: u, i OPEN (NEWUNIT=u, FILE=path, STATUS='REPLACE', ACTION='WRITE') WRITE (u, '(A)') 'mixed-route torsion gate' @@ -128,6 +171,13 @@ SUBROUTINE write_deck(path, types, points, lines, sections, endconns, options, o DO i = 1, SIZE(points) WRITE (u, '(A)') TRIM(points(i)) END DO + IF (PRESENT(turbs)) THEN + WRITE (u, '(A)') '--- TURBINES ---' + WRITE (u, '(A)') 'J X0 Y0 Z0 PtfmSurge PtfmSway PtfmHeave PtfmRoll PtfmPitch PtfmYaw' + DO i = 1, SIZE(turbs) + WRITE (u, '(A)') TRIM(turbs(i)) + END DO + END IF WRITE (u, '(A)') '--- LINES ---' WRITE (u, '(A)') 'ID NodeA NodeB Outputs' WRITE (u, '(A)') '(-) (-) (-) (-)' @@ -330,6 +380,27 @@ LOGICAL FUNCTION log_has(root, text) RESULT(found) CLOSE (u) END FUNCTION log_has + REAL(wp) FUNCTION log_value(root, needle) RESULT(v) + !! The number after needle on the first line of .log that carries it (HUGE when none). + CHARACTER(*), INTENT(IN) :: root, needle + CHARACTER(4096) :: line + INTEGER :: u, ios, k + v = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE=root//'.log', STATUS='OLD', ACTION='READ', IOSTAT=ios) + IF (ios /= 0) RETURN + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + k = INDEX(line, needle) + IF (k > 0) THEN + READ (line(k + LEN(needle):), *, IOSTAT=ios) v + IF (ios /= 0) v = HUGE(1.0_wp) + EXIT + END IF + END DO + CLOSE (u) + END FUNCTION log_value + SUBROUTINE read_out(path, names, vals, nrow) !! The channel names and rows of a driver .out file (Time first). CHARACTER(*), INTENT(IN) :: path @@ -883,4 +954,231 @@ SUBROUTINE check_static_blend() CALL require(log_has('tmrt_blend_d1', 'torsion in a dynamic run needs the force-blended'), & '6: the configuration blend of a dynamic one-end torsion run is named') END SUBROUTINE check_static_blend + + PURE SUBROUTINE smooth_start(amplitude, t, f, df, d2f) + !! f = F (1 - cos w t)^2 / 4 and its rates, w = 2 pi / PERIOD: a motion from rest with no + !! acceleration at t = 0 (f'' = F w^2 (sin^2 w t + (1 - cos w t) cos w t) / 2). + REAL(wp), INTENT(IN) :: amplitude, t + REAL(wp), INTENT(OUT) :: f, df, d2f + REAL(wp) :: w, c, sn + w = 2.0_wp*PI/PERIOD + c = COS(w*t) + sn = SIN(w*t) + f = 0.25_wp*amplitude*(1.0_wp - c)**2 + df = 0.5_wp*amplitude*w*(1.0_wp - c)*sn + d2f = 0.5_wp*amplitude*w*w*(sn*sn + (1.0_wp - c)*c) + END SUBROUTINE smooth_start + + SUBROUTINE turbine_record(j, t, row) + !! Gate 9: the motionFile record of turbine j at time t (time J x y z q0 q1 q2 q3 vx vy vz wx wy + !! wz ax ay az alx aly alz). Turbine 1 at (0, 0, 0) with PtfmInit surge 2 m, heave -0.5 m and + !! yaw 180 deg, turbine 2 at (300, 0, 0) with PtfmInit sway 1 m and yaw 5 deg; from rest, with + !! no acceleration at t = 0 (smooth_start), each heaves 1 m (turbine 2: -0.8 m) and rolls 10 deg + !! (turbine 2: -8 deg) about its own x axis: + !! R = Rz(yaw) Rx(roll), the quaternion [cz cx, cz sx, sz sx, sz cx] of the half angles, the + !! global angular velocity Rz(yaw) (roll', 0, 0) and acceleration Rz(yaw) (roll'', 0, 0). + INTEGER, INTENT(IN) :: j + REAL(wp), INTENT(IN) :: t + REAL(wp), INTENT(OUT) :: row(21) + REAL(wp) :: x0(3), yaw, zh, vz, az, ro, dro, d2ro, ex(3) + IF (j == 1) THEN + x0 = [2.0_wp, 0.0_wp, -0.5_wp] + yaw = 180.0_wp*D2R + CALL smooth_start(1.0_wp, t, zh, vz, az) + CALL smooth_start(10.0_wp*D2R, t, ro, dro, d2ro) + ELSE + x0 = [300.0_wp, 1.0_wp, 0.0_wp] + yaw = 5.0_wp*D2R + CALL smooth_start(-0.8_wp, t, zh, vz, az) + CALL smooth_start(-8.0_wp*D2R, t, ro, dro, d2ro) + END IF + ex = [COS(yaw), SIN(yaw), 0.0_wp] + row = 0.0_wp + row(1) = t + row(2) = REAL(j, wp) + row(3:5) = x0 + [0.0_wp, 0.0_wp, zh] + row(6:9) = [COS(0.5_wp*yaw)*COS(0.5_wp*ro), COS(0.5_wp*yaw)*SIN(0.5_wp*ro), SIN(0.5_wp*yaw)*SIN(0.5_wp*ro), & + SIN(0.5_wp*yaw)*COS(0.5_wp*ro)] + row(10:12) = [0.0_wp, 0.0_wp, vz] + row(13:15) = dro*ex + row(16:18) = [0.0_wp, 0.0_wp, az] + row(19:21) = d2ro*ex + END SUBROUTINE turbine_record + + SUBROUTINE turbine_deck(path, cable, chains) + !! Gate 9: the TURBINES deck (the turbines of turbine_record) with the finite-EI cable (line + !! 1, 300 m, 40 elements) from point 1 on turbine 1 to point 2 on turbine 2, both clamped and + !! restrained in torsion (Pretwist 30 deg at End B), and/or the chains 2 and 3 from points 3 (on + !! turbine 1) and 5 (on turbine 2) to the anchors 4 and 6. Coordinates of a Turbine point and + !! its Ez and Nx are in its turbine's axes. + CHARACTER(*), INTENT(IN) :: path + LOGICAL, INTENT(IN) :: cable, chains + CHARACTER(48) :: pts(6), opts(5) + CHARACTER(96) :: turbs(2), ec(2) + pts(1) = '1 Turbine1 -20.0 0.0 -15.0 0 0 0 0' + pts(2) = '2 Turbine2 -20.0 0.0 -15.0 0 0 0 0' + pts(3) = '3 Turbine1 20.0 0.0 -15.0 0 0 0 0' + pts(4) = '4 Fixed -250.0 0.0 -200.0 0 0 0 0' + pts(5) = '5 Turbine2 20.0 0.0 -15.0 0 0 0 0' + pts(6) = '6 Fixed 550.0 0.0 -200.0 0 0 0 0' + turbs(1) = '1 0.0 0.0 0.0 2.0 0.0 -0.5 0.0 0.0 180.0' + turbs(2) = '2 300.0 0.0 0.0 0.0 1.0 0.0 0.0 0.0 5.0' + ec(1) = '1 A Rigid -1 0 -0.4 Rigid 0 -1 0 0' + ec(2) = '1 B Rigid 1 0 0.4 Rigid 0 1 0 30' + opts = [CHARACTER(48) :: '200.0 WtrDpth', '0.05 dtM', '10.0 TMax', 'tmrt_turb.txt motionFile', '3.0e6 kBot'] + IF (cable .AND. chains) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T, CHAIN_T], pts, & + [CHARACTER(16) :: '1 1 2 -', '2 3 4 -', '3 5 6 -'], & + [CHARACTER(24) :: '1 cab 300.0 40', '2 chain 320.0 20', '3 chain 320.0 20'], ec, opts, & + [TURB_CABLE, TURB_CHAINS], turbs=turbs) + ELSE IF (cable) THEN + CALL write_deck(path, [CHARACTER(96) :: CAB_T], pts(1:2), [CHARACTER(16) :: '1 1 2 -'], & + [CHARACTER(24) :: '1 cab 300.0 40'], ec, opts, TURB_CABLE, turbs=turbs) + ELSE + CALL write_deck(path, [CHARACTER(96) :: CHAIN_T], pts(3:6), [CHARACTER(16) :: '2 3 4 -', '3 5 6 -'], & + [CHARACTER(24) :: '2 chain 320.0 20', '3 chain 320.0 20'], [CHARACTER(8) ::], opts, & + TURB_CHAINS, turbs=turbs) + END IF + END SUBROUTINE turbine_deck + + SUBROUTINE check_turbines() + !! Gate 9. + CHARACTER(32) :: nm(MAXCOL), nc(MAXCOL), nl(MAXCOL) + REAL(wp), ALLOCATABLE :: vm(:, :), vc(:, :), vl(:, :) + REAL(wp) :: row(21), e, e_turb, e_leg + INTEGER :: u, k, j, rm, rc, rl, cm, cx + LOGICAL :: ok + OPEN (NEWUNIT=u, FILE='tmrt_turb.txt', STATUS='REPLACE', ACTION='WRITE') + DO k = 0, NSTEP + DO j = 1, 2 + CALL turbine_record(j, DT*k, row) + WRITE (u, '(F8.3,I3,19ES25.16E3)') row(1), j, row(3:21) + END DO + END DO + CLOSE (u) + CALL turbine_deck('tmrt_turb_m.dat', .TRUE., .TRUE.) + CALL turbine_deck('tmrt_turb_c.dat', .TRUE., .FALSE.) + CALL turbine_deck('tmrt_turb_l.dat', .FALSE., .TRUE.) + CALL run_driver('tmrt_turb_c.dat', 'tmrt_turb_c', ok) + CALL require(ok, '9: the cable of the TURBINES deck runs on the standalone cubic-Hermite route') + CALL run_driver('tmrt_turb_l.dat', 'tmrt_turb_l', ok) + CALL require(ok, '9: the chains of the TURBINES deck run on the standalone EI = 0 route') + CALL run_driver('tmrt_turb_m.dat', 'tmrt_turb_m', ok) + CALL require(ok, '9: the TURBINES deck of the cable and the chains runs on the mixed route') + CALL require(log_has('tmrt_turb_m', 'mixed standalone aggregate'), '9: the TURBINES deck runs on the aggregate') + ALLOCATE (vm(MAXROW, MAXCOL), vc(MAXROW, MAXCOL), vl(MAXROW, MAXCOL)) + CALL read_out('tmrt_turb_m.out', nm, vm, rm) + CALL read_out('tmrt_turb_c.out', nc, vc, rc) + CALL read_out('tmrt_turb_l.out', nl, vl, rl) + CALL require(rm == NSTEP + 1 .AND. rc == NSTEP + 1 .AND. rl == NSTEP + 1, '9: the three runs write every row') + IF (rm /= NSTEP + 1 .OR. rc /= NSTEP + 1 .OR. rl /= NSTEP + 1) RETURN + e_turb = 0.0_wp + DO k = 1, SIZE(TURB_CABLE) + cm = col_of(nm, TURB_CABLE(k)) + cx = col_of(nc, TURB_CABLE(k)) + CALL require(cm > 0 .AND. cx > 0, '9: channel '//TRIM(TURB_CABLE(k))//' in both outputs') + IF (cm == 0 .OR. cx == 0) CYCLE + e = range_error(vc(:, cx), vm(:, cm), rm) + WRITE (*, '(A,A,A,ES10.3,A)') ' 9 TURBINES driver: ', TRIM(TURB_CABLE(k)), ' difference ', e, & + ' of its range (the coupled Newton controls)' + e_turb = MAX(e_turb, e) + END DO + e_leg = 0.0_wp + DO k = 1, SIZE(TURB_CHAINS) + cm = col_of(nm, TURB_CHAINS(k)) + cx = col_of(nl, TURB_CHAINS(k)) + CALL require(cm > 0 .AND. cx > 0, '9: channel '//TRIM(TURB_CHAINS(k))//' in both outputs') + IF (cm == 0 .OR. cx == 0) CYCLE + e = range_error(vl(:, cx), vm(:, cm), rm) + WRITE (*, '(A,A,A,ES10.3,A)') ' 9 TURBINES driver: ', TRIM(TURB_CHAINS(k)), ' difference ', e, ' of its range' + e_leg = MAX(e_leg, e) + END DO + CALL require(e_turb <= TURB_TOL, '9: the cable agrees with the cable-only deck within the coupled Newton controls') + ! the torsion note: the total twist (Twist1), not the Pretwist difference alone + BLOCK + REAL(wp) :: tw_note, tw_out, pre_note + tw_note = log_value('tmrt_turb_c', 'total twist Twist1 =') + pre_note = log_value('tmrt_turb_c', 'Pretwist(B) - Pretwist(A) =') + tw_out = vc(1, col_of(nc, 'Twist1')) + WRITE (*, '(A,3F12.6,A)') ' 9 TURBINES torsion note: total twist, Twist1 at t = 0, pretwist ', tw_note, & + tw_out, pre_note, ' deg' + CALL require(ABS(tw_note - tw_out) <= 1.0e-5_wp*ABS(tw_out), '9: the torsion note gives the total twist Twist1') + CALL require(ABS(pre_note - 30.0_wp) <= 1.0e-9_wp .AND. ABS(tw_note - 30.0_wp) > 1.0_wp, & + '9: the note names the pretwist and a total twist that carries the end frames'' turn') + END BLOCK + CALL require(e_leg <= LOAD_TOL, '9: the chain tensions agree with the legs-only deck') + CALL march_turbines(nc, vc, rc) + END SUBROUTINE check_turbines + + SUBROUTINE march_turbines(nc, vc, rc) + !! Gate 9: the mixed route's march of the TURBINES deck (deck_turbines, the driver's call) + !! through the aggregate library, its cable given the standalone route's Newton controls (as + !! march_library): every cable channel is compared at every step with the cable-only run's + !! output (nc, vc, rc rows) to its printed precision. + CHARACTER(32), INTENT(IN) :: nc(:) + REAL(wp), INTENT(IN) :: vc(:, :) + INTEGER, INTENT(IN) :: rc + TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), load(:, :), orient(:, :, :), omega(:, :), alpha(:, :) + REAL(wp), ALLOCATABLE :: roll(:), got(:, :) + CHARACTER(2048) :: em + INTEGER :: es, n, c, step, k, cx, nch, n_iter + LOGICAL :: turns, rolls, conv, stalled + REAL(wp) :: worst, v + ALLOCATE (agg) + CALL CD_AGG_Init_From_Deck(agg, 'tmrt_turb_m.dat', DT, es, em, forbid_deck_ambient=.TRUE., run_tmax=TMAX, & + host_orientation=.TRUE., prescribed_motion=.TRUE., deck_turbines=.TRUE.) + CALL require(es == CD_AGG_OK .AND. CD_AGG_HasMotion(agg), '9: the aggregate takes the TURBINES deck and its '// & + 'records: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + DO c = 1, agg%ncable + agg%cables(c)%tol = 1.0e-8_wp + agg%cables(c)%max_iter = 30 + agg%cables(c)%line%tangent_reuse = .TRUE. + END DO + n = CD_AGG_NMovingPoints(agg, es, em) + nch = CD_AGG_NumChannels(agg) + ALLOCATE (pos(3, n), vel(3, n), acc(3, n), load(3, n), orient(3, 3, n), omega(3, n), alpha(3, n), roll(n), & + got(NSTEP + 1, nch)) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, load, es, em) + CALL CD_AGG_MotionKinematics(agg, 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + CALL require(turns, '9: the TURBINES records turn the moving columns') + CALL CD_AGG_UpdateStates_Moving(agg, pos, vel, acc, es, em, orientation=orient, angular_velocity=omega, & + angular_acceleration=alpha) + IF (es == CD_AGG_OK) CALL CD_AGG_Refresh_Accelerations(agg, es, em) + CALL require(es == CD_AGG_OK, '9: the first TURBINES records install: '//TRIM(em)) + DO step = 0, NSTEP + IF (step > 0) THEN + CALL CD_AGG_MotionKinematics(agg, step + 1, pos, vel, acc, orient, omega, alpha, roll, turns, rolls, es, em) + CALL CD_AGG_Step_Moving(agg, DT, pos, vel, acc, conv, stalled, n_iter, es, em, t_committed=DT*step, & + orientation=orient, angular_velocity=omega, angular_acceleration=alpha) + IF (es /= CD_AGG_OK .OR. .NOT. conv) THEN + CALL require(.FALSE., '9: library march step: '//TRIM(em)) + EXIT + END IF + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + DO k = 1, nch + CALL CD_AGG_EvalChannel(agg, k, v, es, em) + got(step + 1, k) = v + END DO + END DO + ! the mixed deck's channels are TURB_CABLE then TURB_CHAINS, in OUTPUTS order + worst = HUGE(1.0_wp) + IF (rc == NSTEP + 1) THEN + worst = 0.0_wp + DO k = 1, SIZE(TURB_CABLE) + cx = col_of(nc, TURB_CABLE(k)) + IF (cx > 0) THEN + worst = MAX(worst, print_error(vc(:, cx), got(:, k), rc)) + ELSE + worst = HUGE(1.0_wp) + END IF + END DO + END IF + WRITE (*, '(A,ES10.3,A)') ' 9 TURBINES library march with the standalone Newton controls: largest cable '// & + 'difference ', worst, ' printed units' + CALL require(worst <= 2.0_wp, '9: with the same Newton controls the mixed route reproduces the cable-only deck') + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE march_turbines END PROGRAM test_mixed_route_torsion diff --git a/tests/test_openfast_aggregate.f90 b/tests/test_openfast_aggregate.f90 index 7ffb2192..90d71e7a 100644 --- a/tests/test_openfast_aggregate.f90 +++ b/tests/test_openfast_aggregate.f90 @@ -2727,6 +2727,13 @@ SUBROUTINE case_farm_partition() turbine_ref_pos=refpos, forbid_deck_ambient=.TRUE.) CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'STILL WATER') > 0, & 'farm: forbid_deck_ambient rejects a deck current OPTION') + ! a WaterKin CurrentMod 1 table is named as such, not as a current OPTION the deck lacks + CALL write_farm_deck('agg_farm_wk.dat', plain_coupled=.FALSE., ambient='waterkin') + CALL CD_AGG_Init_From_Deck(agg, 'agg_farm_wk.dat', DT, es, em, n_turbines=2, & + turbine_ref_pos=refpos, forbid_deck_ambient=.TRUE., external_fluid=.FALSE.) + CALL require(es /= CD_AGG_OK .AND. INDEX(em, 'WaterKin current table') > 0 .AND. & + INDEX(em, 'current OPTION') == 0, 'farm: a WaterKin current table is refused by its name: '// & + TRIM(em)) CALL write_farm_deck('agg_farm_wav.dat', plain_coupled=.FALSE., ambient='waves') CALL CD_AGG_Init_From_Deck(agg, 'agg_farm_wav.dat', DT, es, em, n_turbines=2, & turbine_ref_pos=refpos, forbid_deck_ambient=.TRUE.) @@ -4100,6 +4107,34 @@ SUBROUTINE write_farm_deck(path, plain_coupled, y_shift, stock_order, ambient, c WRITE (u, '(A)') 'uniform 0.5 0.0 0.0 current' CASE ('waves') WRITE (u, '(A)') 'airy 2.0 8.0 0.0 waves' + CASE ('waterkin') + ! a WaterKin file without waves and with a CurrentMod 1 depth table + WRITE (u, '(A)') 'agg_farm_wk_kin.dat WaterKin' + BLOCK + INTEGER :: uk + OPEN (NEWUNIT=uk, FILE='agg_farm_wk_kin.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (uk, '(A)') 'WaterKin file: no waves, a current table' + WRITE (uk, '(A)') '-' + WRITE (uk, '(A)') '--- WAVES ---' + WRITE (uk, '(A)') '0 WaveKinMod' + WRITE (uk, '(A)') '"" WaveKinFile' + WRITE (uk, '(A)') '0.0 dtWave' + WRITE (uk, '(A)') '0.0 WaveDir' + WRITE (uk, '(A)') '1 X grid type' + WRITE (uk, '(A)') '0' + WRITE (uk, '(A)') '1 Y grid type' + WRITE (uk, '(A)') '0' + WRITE (uk, '(A)') '1 Z grid type' + WRITE (uk, '(A)') '0' + WRITE (uk, '(A)') '--- CURRENT ---' + WRITE (uk, '(A)') '1 CurrentMod' + WRITE (uk, '(A)') 'z-depth x-current y-current' + WRITE (uk, '(A)') '(m) (m/s) (m/s)' + WRITE (uk, '(A)') '0.0 0.3 0.0' + WRITE (uk, '(A)') '-200.0 0.1 0.0' + WRITE (uk, '(A)') '--- need this line ---' + CLOSE (uk) + END BLOCK END SELECT END IF WRITE (u, '(A)') '--- need this line ---' From 43810b5d1783011d0a4a9f9395e3b945f0b0642a Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 20:56:31 +0900 Subject: [PATCH 35/51] fix(hydro): an EI = 0 line above the surface carries its dry weight without a seabed (#84) ## Summary On a deck without a seabed (no `WtrDpth` or bathymetry), an `EI = 0` line was built without the still-water level. It was modelled fully submerged up to an end above the surface (submerged weight, drag and added mass), with a warning. The same line on a deck with a seabed, and a finite-EI line with or without one, took its dry weight above the surface. - A 42 m chain hung wholly above the surface carried 13 % less than its weight in air. - A chain sagging through the surface differed by 7.7 % from the same deck with a seabed far below. - A 50 t `Connect` clump hung above the surface started 2 cm off. The line model (`init_one_model`), the static-only solve and the force balance of points and objects (`prepare_line`) now take the still-water level on every deck. On the reproducers, the no-seabed decks give exactly the seabed decks' results, and the clump holds its start. The warning is gone. Lines wholly below the surface are unchanged. ## Checks - New test `no_seabed_surface`, 4 gates, every one failing on the old code: 1. weight in air to 1.3e-9 (the output's 8 digits); 2. no seabed against seabed, identical; 3. clump start identical, no move over 2 s; 4. no warning. - ctest 359 of 359; the touched tests on the `Prescott`, `Haswell` and `Zen` kernels; Debug build (`-fcheck=all`) on the touched tests with their own timeouts. - Example A/B 53 of 53 identical, including the no-seabed `connect_weighted_point`. - pre-commit, Sphinx `-W`. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 ++ CMakeLists.txt | 11 ++ doc/theory.rst | 12 +-- src/CableDyn_DeckDriver.f90 | 108 ++++++++----------- tests/test_no_seabed_surface.py | 183 ++++++++++++++++++++++++++++++++ 5 files changed, 252 insertions(+), 71 deletions(-) create mode 100644 tests/test_no_seabed_surface.py diff --git a/CHANGELOG.md b/CHANGELOG.md index fb90fd13..4b4018d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -559,6 +559,15 @@ All notable changes to CableDyn are recorded in this file. The format follows seabed holds its heave to 7e-6 m over 3 s (before it moved 2.8e-3 m), and an `EI = 0` chain between that body 5 m above the surface and a `Connect` clump holds both to the output's 8 digits (before 5.5e-3 m). Lines below the surface are unchanged. +- An `EI = 0` line above the still-water level on a deck without a seabed (no `WtrDpth` or + bathymetry) carries its dry weight, and its drag and added mass act on the wetted part only, as + with a seabed and as on a finite-EI line. It was modelled fully submerged up to an end above + the surface, with a warning: a 42 m chain hung wholly above the surface carried 13 % less than + its weight in air, a chain sagging through the surface differed by 7.7 % from the same deck + with a seabed, and a 50 t `Connect` clump hung above the surface started 2 cm off. The march, + the static start and the force balance of points and objects now take the dry weight; the + three agree with the seabed deck exactly and hold their start (`no_seabed_surface`). The + warning is gone. Lines wholly below the surface are unchanged. - `ATTACHMENTS` above the still-water level kept their buoyancy in the static start of a finite-EI line, while the march loads them with their weight alone. A 500 kg, 0.2 m^3 module 3 m above the surface on a cable hung from 5 m above it moved the fairlead load by up to diff --git a/CMakeLists.txt b/CMakeLists.txt index 27306b1d..9a4b65dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1815,6 +1815,17 @@ if(Python3_Interpreter_FOUND) TIMEOUT 900 ENVIRONMENT "${_cabledyn_python_test_environment}") + # An EI = 0 line above the still-water level on a deck without a seabed carries its dry weight + # (it was modelled fully submerged), as with a seabed and as a finite-EI line. + add_test(NAME no_seabed_surface + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_no_seabed_surface.py + --exe $ + --output ${CMAKE_BINARY_DIR}/no_seabed_surface) + set_tests_properties(no_seabed_surface PROPERTIES + LABELS "python;driver;integration;dynamic" + TIMEOUT 300 + ENVIRONMENT "${_cabledyn_python_test_environment}") + add_test(NAME body_rod_numbering COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_body_rod_numbering.py --exe $ diff --git a/doc/theory.rst b/doc/theory.rst index 12380951..b1be3d2e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1548,21 +1548,19 @@ beyond a :math:`10^{-6}` relative round-off band; a slack element reports zero t A line with no admissible equilibrium fails closed, naming the line, the seeds and stages tried, and the reason. -With a seabed (``WtrDpth`` or a bathymetry) the march gives the part of a line above the -still-water level its dry weight, through the recovery load of *Buoyancy and wetting* above, and -the static start does the same. The recovery depends on the wetted lengths, so the line is +The march gives the part of a line above the still-water level its dry weight, through the +recovery load of *Buoyancy and wetting* above, with or without a seabed, and the static start +does the same; drag and added mass act on the wetted part only. The recovery depends on the wetted lengths, so the line is solved again with the recovery of the last solution as a constant load until its nodes move by less than :math:`10^{-9}` m. This fixed point contracts at the ratio of the recovery's stiffness :math:`\rho g A/\sin\theta` (:math:`\theta` the inclination at the surface) to the line's own, a few :math:`10^{-3}` for a hanging chain. A chain hung from 5 m above the surface then starts in the equilibrium its march holds, and the coupled and standalone starts agree; with its buoyancy kept above the surface it moved by :math:`10^{-3}` of its fairlead load in the first step. A line -wholly below the surface has no recovery and is solved once. Without a seabed the march, and so -the static start, keeps the buoyancy everywhere (the driver warns about a line end above the -surface then). The force balance of ``Connect`` and ``Free`` points and of free bodies and rods +wholly below the surface has no recovery and is solved once. The force balance of ``Connect`` and ``Free`` points and of free bodies and rods below takes its lines with the same dry weight, so these objects start balanced against the march too; a finite-EI line, which enters it without its bending stiffness, takes its dry weight there -with or without a seabed, as its cubic-Hermite cable does. +as its cubic-Hermite cable does. A steady current (uniform, or a depth profile sampled at each node's own elevation as in the march) enters the static equilibrium as Morison drag on the line at rest, so the out-of-plane diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index af3746b7..7290b004 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -9290,7 +9290,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN CALL CD_Profile_Enter(CD_PROF_INIT) END IF - CALL print_static_input_warnings(types, points, lines, sections, opts) + CALL print_static_input_warnings(types, lines, sections, opts) CALL warn_coarse_sections(lines, sections) ! free Rigid6 bodies and rods (jointly with Free/Connect points) start at their static ! equilibrium on every route: static-only, TMax = 0 and the dynamic march (pinned rods turn @@ -9867,20 +9867,21 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er CALL fail(ErrStat, ErrMsg, 'host-driven ambient fluid (external_fluid) requires a seabed '// & '(WtrDpth or bathymetryFile) -- the coupled host always supplies one'); RETURN END IF - IF (opts%has_current .OR. want_wave_cfg .OR. opts%has_wtrdpth .OR. PRESENT(bathymetry)) THEN - ALLOCATE (fluid_velocity(3, SIZE(l0) + 1), drag_waterline(SIZE(l0) + 1)) - DO i = 1, SIZE(l0) + 1 - IF (opts%has_current) THEN - fluid_velocity(:, i) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, l0, i), CD_ZERO, es, em) - IF (es /= CD_HYDRO_OK) THEN - CALL fail(ErrStat, ErrMsg, 'current profile for model init: '//TRIM(em)); RETURN - END IF - ELSE - fluid_velocity(:, i) = CD_ZERO + ! Every line has the still-water level: its drag, added mass and buoyancy act on the wetted + ! part only, with or without a seabed (a line hung above the surface on a deck without a + ! seabed was modelled fully submerged). + ALLOCATE (fluid_velocity(3, SIZE(l0) + 1), drag_waterline(SIZE(l0) + 1)) + DO i = 1, SIZE(l0) + 1 + IF (opts%has_current) THEN + fluid_velocity(:, i) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, l0, i), CD_ZERO, es, em) + IF (es /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'current profile for model init: '//TRIM(em)); RETURN END IF - END DO - drag_waterline = CD_ZERO - END IF + ELSE + fluid_velocity(:, i) = CD_ZERO + END IF + END DO + drag_waterline = CD_ZERO IF (want_wave_cfg) THEN ALLOCATE (fluid_acceleration(3, SIZE(l0) + 1)) fluid_acceleration = CD_ZERO @@ -10066,7 +10067,11 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er added_mass_diameter_elem=hydro_diam, added_mass_can_elem=hydro_can, & added_mass_cat_elem=hydro_cat, buoyancy_waterline_z=waterline, & buoyancy_rho=opts%rhoW, buoyancy_diameter_elem=hydro_diam, buoyancy_gravity=opts%g) - ELSE IF (opts%has_current) THEN + ELSE + ! no seabed (deck waves and a host fluid field need one): the still-water level as on the + ! WtrDpth route above, without the seabed contact + ALLOCATE (waterline(SIZE(l0) + 1)) + waterline = CD_ZERO CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & @@ -10075,13 +10080,11 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & - drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt) - ELSE - CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & - static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & - syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & - ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet) + drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & + added_mass_waterline_z=waterline, added_mass_rho=opts%rhoW, & + added_mass_diameter_elem=hydro_diam, added_mass_can_elem=hydro_can, & + added_mass_cat_elem=hydro_cat, buoyancy_waterline_z=waterline, & + buoyancy_rho=opts%rhoW, buoyancy_diameter_elem=hydro_diam, buoyancy_gravity=opts%g) END IF IF (ErrStat /= CD_MODEL_OK) THEN ErrMsg = 'CableDyn_DeckDriver: model init failed: '//TRIM(ErrMsg) @@ -11679,46 +11682,22 @@ LOGICAL FUNCTION point_moves(ip) RESULT(mv) END FUNCTION point_moves END SUBROUTINE solve_point_equilibrium - SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) + SUBROUTINE print_static_input_warnings(types, lines, sections, opts) !! Standard-output WARNINGS (never failures) for admissible but non-physical or - !! questionable inputs: an EI = 0 line end above the still-water level on a deck without a - !! seabed (the line is then modelled fully submerged; with WtrDpth or a bathymetry, and on - !! a finite-EI line, the part above the surface carries its dry weight), a line type that - !! sinks into the penalty seabed by more than its + !! questionable inputs: a line type that sinks into the penalty seabed by more than its !! diameter (kBot too soft for its submerged weight), a slack anchored line that hangs !! below its anchor on a deck with no seabed (reported after the static solve by !! warn_line_below_anchor), and a line with fewer than three segments (a straight !! chord: a slack coarse line carries no tension). 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 INTEGER :: i, j, k, nseg REAL(wp) :: w, pen - LOGICAL :: dry_weight CHARACTER(32) :: b1, b2 DO i = 1, SIZE(lines) - ! the line's model carries the dry weight above the surface: a finite-EI line always, an - ! EI = 0 line with a seabed (its buoyancy recovery) - dry_weight = opts%has_wtrdpth .OR. opts%has_bathymetry_file - DO j = 1, SIZE(sections) - IF (sections(j)%line_id /= lines(i)%id) CYCLE - IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE - IF (types(sections(j)%ltype)%ei > CD_ZERO) dry_weight = .TRUE. - END DO - DO k = 1, 2 - IF (k == 1) j = find_point(points, lines(i)%nodeA) - IF (k == 2) j = find_point(points, lines(i)%nodeB) - IF (j < 1) CYCLE - IF (points(j)%pos(3) > CD_ZERO .AND. .NOT. dry_weight) THEN - WRITE (b1, '(ES10.3)') points(j)%pos(3) - WRITE (output_unit, '(A)') ' WARNING: LINE '//TRIM(int_to_str(lines(i)%id))//' end POINT '// & - TRIM(int_to_str(points(j)%id))//' is above the still-water level (z = '//TRIM(ADJUSTL(b1))// & - ' m); the line is modelled fully submerged (submerged weight, drag) up to it' - END IF - END DO nseg = 0 DO j = 1, SIZE(sections) IF (sections(j)%line_id == lines(i)%id) nseg = nseg + sections(j)%nsegs @@ -12441,12 +12420,12 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg IF (es /= CD_LINE_OK) THEN CALL fail(ErrStat, ErrMsg, 'seabed stiffness: '//TRIM(em)); RETURN END IF - ! the line's model has a seabed and so the buoyancy recovery of its dry part - ! (init_deck_models_from_parsed): the part above the still-water level takes its dry - ! weight here too, so that the static-only start is the dynamic route's - ALLOCATE (dry_wl(ne + 1)) - dry_wl = CD_ZERO END IF + ! the line's model has the buoyancy recovery of its dry part, with or without a seabed + ! (init_one_model): the part above the still-water level takes its dry weight here too, so + ! that the static-only start is the dynamic route's + ALLOCATE (dry_wl(ne + 1)) + dry_wl = CD_ZERO IF (PRESENT(bathymetry)) THEN IF (opts%has_current) THEN @@ -12474,10 +12453,14 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg END IF ELSE IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, current=cur) + report, es, em, current=cur, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em) + report, es, em, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) END IF IF (es /= CD_STATIC_OK) THEN CALL fail(ErrStat, ErrMsg, 'static solve rejected the input: '//TRIM(em)) @@ -27715,15 +27698,12 @@ SUBROUTINE prepare_line(jl, es_out, em_out) END IF ! The part above the still-water level takes its dry weight here, as in solve_one_line, ! where the line's own model gives it that weight, so that the objects start balanced - ! against the loads the march applies: an EI = 0 line with a seabed (its model's buoyancy - ! recovery, init_deck_models_from_parsed) and a finite-EI line always (its cubic-Hermite - ! cable's dry buoyancy, with or without a seabed). Without a seabed this surrogate of a - ! finite-EI line kept its buoyancy above the surface, while its cable did not. - IF (PRESENT(bathymetry) .OR. opts%has_wtrdpth .OR. line_is_finite_ei(lines(jl), types, sections)) THEN - lc(jl)%dry_d = diam - ALLOCATE (lc(jl)%dry_wl(ne + 1)) - lc(jl)%dry_wl = CD_ZERO - END IF + ! against the loads the march applies: an EI = 0 line through its model's buoyancy + ! recovery (init_one_model) and a finite-EI line through its cubic-Hermite cable's dry + ! buoyancy, both with or without a seabed. + lc(jl)%dry_d = diam + ALLOCATE (lc(jl)%dry_wl(ne + 1)) + lc(jl)%dry_wl = CD_ZERO lc(jl)%ready = .TRUE. END SUBROUTINE prepare_line diff --git a/tests/test_no_seabed_surface.py b/tests/test_no_seabed_surface.py new file mode 100644 index 00000000..57df9f45 --- /dev/null +++ b/tests/test_no_seabed_surface.py @@ -0,0 +1,183 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""An EI = 0 line above the still-water level on a deck without a seabed carries its dry weight. + +Without ``WtrDpth`` or a bathymetry an ``EI = 0`` line was modelled fully submerged (submerged +weight, drag and added mass up to an end above the surface, with a warning), while the same line +on a deck with a seabed, and a finite-EI line with or without one, took its dry weight above the +surface: a 50 m chain hung 10 m above the surface was 13 % light. + +Gates, on the driver's own output (``Point

Fz``, ``Point

pz``): + +1. a chain wholly above the surface, no seabed: its end forces sum to its weight in air (to + 1e-6), at the start and after 2 s; +2. a chain that sags through the surface: the deck without a seabed and the same deck with a + seabed far below give the same end forces (to 1e-9), at the start and after 2 s; +3. a 50 t ``Connect`` clump hung by two chains from points 15 m above the surface, no seabed: it + starts where the deck with a seabed far below starts it (to 1e-9 m) and holds that position + over 2 s (to 1e-6 m), the static start being the march's equilibrium; +4. no "modelled fully submerged" warning. + +usage: test_no_seabed_surface.py --exe --output

+""" + +from __future__ import annotations + +import argparse +import math +import subprocess +import sys +from pathlib import Path + +G = 9.80665 +RHO = 1025.0 +DIAM = 0.2791 +MASS = 480.93 + +HEAD = """--------------------- CableDyn Input File ------------------------------------ +{title} +--------------------- LINE TYPES --------------------------------------- +TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0 +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +{points} +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +{lines} +--------------------- SECTIONS ----------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +{sections} +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +{seabed}0.01 dtM +2.0 TMax +--------------------- OUTPUTS ------------------------------------------ +{outputs} +--------------------- need this line ----------------------------------- +""" + + +def deck(title: str, points: str, lines: str, sections: str, outputs: list[str], seabed: bool) -> str: + return HEAD.format( + title=title, + points=points, + lines=lines, + sections=sections, + seabed="300.0 WtrDpth\n" if seabed else "", + outputs="\n".join(f'"{c}"' for c in outputs), + ) + + +def run(exe: str, out: Path, name: str, text: str) -> tuple[dict[str, list[float]], str]: + path = out / f"{name}.dat" + path.write_text(text, encoding="utf-8", newline="\n") + root = out / name + p = subprocess.run([exe, str(path), str(root)], capture_output=True, text=True, check=False) + log = p.stdout + p.stderr + if p.returncode != 0: + raise RuntimeError(f"{name}: exit {p.returncode}: {log[-600:]}") + rows = [] + header: list[str] = [] + for line in Path(f"{root}.out").read_text(encoding="utf-8").splitlines(): + fields = line.split() + if not fields: + continue + if fields[0].startswith("Time"): + header = fields + continue + try: + rows.append([float(v) for v in fields]) + except ValueError: + continue + cols = {h: [r[i] for r in rows] for i, h in enumerate(header)} + return cols, log + + +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) + failures = [] + logs = [] + + two_points = "1 Coupled 0.0 0.0 10.0 0 0 0 0\n" \ + "2 Fixed 40.0 0.0 10.0 0 0 0 0" + one_line = "1 1 2 -" + + # 1. wholly above the surface: the end forces carry the weight in air + cols, log = run(args.exe, out, "above", deck( + "EI = 0 chain wholly above the still-water level, no seabed", two_points, one_line, + "1 chain 42.0 20", ["Point1Fz", "Point2Fz"], seabed=False)) + logs.append(log) + dry = 42.0 * MASS * G + for k in (0, -1): + total = -(cols["Point1Fz"][k] + cols["Point2Fz"][k]) + rel = abs(total - dry) / dry + print(f"gate 1: t = {cols['Time(s)'][k]:.2f} s: end forces {total:.3f} N, weight in air {dry:.3f} N, " + f"relative {rel:.2e}") + if rel > 1.0e-6: + failures.append(f"gate 1: the end forces {total} N are not the weight in air {dry} N") + + # 2. through the surface: no seabed and a seabed far below agree + res = {} + for sb in (False, True): + cols, log = run(args.exe, out, f"pierce_{'seabed' if sb else 'none'}", deck( + "EI = 0 chain sagging through the still-water level", two_points, one_line, + "1 chain 50.0 20", ["Point1Fz", "Point2Fz"], seabed=sb)) + logs.append(log) + res[sb] = cols + wet = 50.0 * (MASS - RHO * math.pi / 4.0 * DIAM**2) * G + for k in (0, -1): + a = res[False]["Point1Fz"][k] + res[False]["Point2Fz"][k] + b = res[True]["Point1Fz"][k] + res[True]["Point2Fz"][k] + rel = abs(a - b) / abs(b) + print(f"gate 2: t = {res[True]['Time(s)'][k]:.2f} s: no seabed {-a:.3f} N, seabed {-b:.3f} N " + f"(weight in water {wet:.0f} N), relative {rel:.2e}") + if rel > 1.0e-9: + failures.append(f"gate 2: no seabed {-a} N against seabed {-b} N") + + # 3. a Connect clump hung above the surface + clump = "1 Fixed -25.0 0.0 15.0 0 0 0 0\n" \ + "2 Connect 0.0 0.0 5.0 50000.0 2.0 0 0\n" \ + "3 Fixed 25.0 0.0 15.0 0 0 0 0" + two_lines = "1 1 2 -\n2 3 2 -" + two_secs = "1 chain 30.0 15\n2 chain 30.0 15" + res = {} + for sb in (False, True): + cols, log = run(args.exe, out, f"clump_{'seabed' if sb else 'none'}", deck( + "50 t Connect clump hung by two chains above the still-water level", clump, two_lines, two_secs, + ["Point2pz"], seabed=sb)) + logs.append(log) + res[sb] = cols["Point2pz"] + d0 = abs(res[False][0] - res[True][0]) + drift = max(abs(z - res[False][0]) for z in res[False]) + print(f"gate 3: clump start z {res[False][0]:.9f} m (seabed deck {res[True][0]:.9f} m, {d0:.1e} m apart), " + f"largest move over 2 s {drift:.1e} m") + if d0 > 1.0e-9: + failures.append(f"gate 3: the clump starts {d0} m from the seabed deck's start") + if drift > 1.0e-6: + failures.append(f"gate 3: the clump moves {drift} m from its static start") + + # 4. the warning of the old model + if any("modelled fully submerged" in log for log in logs): + failures.append("gate 4: a 'modelled fully submerged' warning is printed") + + for f in failures: + print("FAIL: " + f) + if not failures: + print("PASS: an EI = 0 line above the surface carries its dry weight without a seabed") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main()) From f530efa51e74bc5419569c4234bab9d4ef37c645 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 00:39:37 +0900 Subject: [PATCH 36/51] fix(openfast): linearise from double-precision loads in a single-precision OpenFAST (#85) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary The release `openfast.exe` is built as OpenFAST's Visual Studio `Release` configuration, which is single precision (`ReKi` = 4 bytes). The 0.4.0 linearisation of the line dynamics differenced the `ReKi` output mesh over a 1 µm position step. With fairlead loads of a few MN, the 7-digit mesh cannot resolve the change, so the release executable linearised the mooring wrongly: - the IEA-15 MW UMaine chains' surge stiffness read 3.2e3 N/m against MoorDyn-F's 7.7e4 N/m; - the CableDyn stiffness block was asymmetric by 1.18; - `A` and `B` and the line modes were unaffected; `C` and `D` were off by 4e-4. The gfortran CMake builds this feature was validated with are double precision. `lin_eval` now keeps its coupled loads and deck channels in double precision, and the two linearisation Jacobians pack those (`pack_lin_outputs`) in place of the `ReKi` mesh. A double-precision build packs the same values. ## Checks `validation/scripts/openfast_lin_ab.py` on the IEA-15 MW UMaine twin decks plus the mixed cable deck: | Build | Result | | --- | --- | | Release workflow `openfast.exe` (Intel, single) | FAIL: surge 3.20e3 N/m, symmetry 1.18 | | gfortran, `DOUBLE_PRECISION=OFF`, before | FAIL, identical to the release executable | | gfortran, `DOUBLE_PRECISION=OFF`, after | PASS: surge 7.721e4 vs 7.716e4 N/m, symmetry 7e-6, fairlead blocks to 1.1e-3, cable deck to its static solves to 1e-4 | | gfortran, double (the release tree) | PASS, unchanged | - `RELEASE.md` now asks for the linearisation check on the release executable too. - pre-commit, Sphinx `-W`. - The shell compiles only inside OpenFAST; built here with gfortran in both precisions. The Intel build is the release workflow's, rerun on this change. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 +++- RELEASE.md | 3 +- doc/openfast.rst | 6 +++- src/openfast/CableDyn_OF.f90 | 55 +++++++++++++++++++++++++++++++++--- 4 files changed, 62 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b4018d6..0d5fed4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -143,7 +143,10 @@ All notable changes to CableDyn are recorded in this file. The format follows static stiffness (each matches its deck's static solutions to 7e-5; held, they would read the chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end connection, VIV lines, bodies, rods, buoys and `CONTROL` fail closed with named messages. This - replaces the quasi-static linearisation without states. + replaces the quasi-static linearisation without states. The output differences use + CableDyn's double-precision loads, so a single-precision OpenFAST build (the release + `openfast.exe`, Visual Studio `Release`) linearises as a double-precision one; through its + 7-digit output mesh the UMaine chains' surge stiffness read 3.2e3 instead of 7.7e4 N/m. - Composite Syrope lines: a Syrope polyester section between plain `EI = 0` sections, such as a chain-polyester-chain mooring, in one LINE. The static start puts every Syrope element on the rest curve of its load history with its own secant EA (the tension varies along a sagging diff --git a/RELEASE.md b/RELEASE.md index 19dd0d58..57f76a2b 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -67,7 +67,8 @@ only the `cabledyn` package and its metadata. [DEVELOPMENT.md](DEVELOPMENT.md#openfast-integration)). It builds `openfast.exe` with CableDyn, checks that a coupled run prints the CableDyn banner, and checks that the output is finite. -2. **Linearisation check**: with the built executable, run +2. **Linearisation check**: with the built executable and again with the release workflow's + `openfast.exe` (single precision, the Visual Studio `Release` configuration), run `python validation/scripts/openfast_lin_ab.py --exe --case-dir `, where `` holds the `examples/openfast` IEA-15 UMaine twin decks and the r-test `MD_Shared` turbine-1 ElastoDyn, HydroDyn, SeaState and HydroData diff --git a/doc/openfast.rst b/doc/openfast.rst index 9b170d51..462fe6e7 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -474,7 +474,11 @@ are named ``Cable 1 node 2 Px, m``, ``Cable 1 node 2 Tx, -`` (tangent) and ``Cab differences: at each perturbed state or input, the accelerations are solved without a time step. Positions, tangents and coupled-point displacements are stepped by 1 µm, which stays inside the seabed penetration of a light cable and the stretch of every taut element. Velocities are stepped -by 0.1 m/s, MoorDyn-F's step. +by 0.1 m/s, MoorDyn-F's step. The output differences are taken from CableDyn's own +double-precision loads and channels, not from the OpenFAST output mesh, so a single-precision +OpenFAST build (the Visual Studio ``Release`` configuration, as the release ``openfast.exe``) +linearises as a double-precision one: its mesh carries 7 digits, too few for loads of a few MN +over a 1 µm step. A line restrained in torsion adds the twist angle of every node that its end frames do not hold (all nodes but a torsionally ``Rigid`` end), after the cables' positions and tangents, and their diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 595c40d3..7e817107 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -179,6 +179,11 @@ END FUNCTION cd_cpu_guard_armed REAL(wp), ALLOCATABLE :: ws_pos(:,:), ws_vel(:,:), ws_acc(:,:), ws_fld(:,:), ws_moment(:,:) REAL(wp), ALLOCATABLE :: ws_omega(:,:), ws_alpha(:,:) REAL(wp), ALLOCATABLE :: ws_orient(:,:,:) + ! the coupled loads (3, ncp) and deck channels of the last lin_eval, in double precision: + ! the linearization Jacobians difference these (pack_lin_outputs), not the ReKi output + ! mesh, which a single-precision OpenFAST build (the Visual Studio Release configuration) + ! rounds to 7 digits, too few for loads of order 1e6 N over a 1 um step + REAL(wp), ALLOCATABLE :: lin_fld(:,:), lin_moment(:,:), lin_chan(:) ! saved committed coupled kinematics for the state-const CalcOutput at nsuper = 1 ! (save -> transfer u -> evaluate -> restore; see CD_CalcOutput) REAL(wp), ALLOCATABLE :: sv_pos(:,:), sv_vel(:,:), sv_acc(:,:), sv_orient(:,:,:) @@ -3066,9 +3071,18 @@ SUBROUTINE lin_eval( id, p, m, u, x_in, ErrStat, ErrMsg, dxdt, y_out ) CALL SetErrStat( ErrID_Fatal, 'CableDyn mooring module: '//TRIM(em), ErrStat, ErrMsg, RoutineName ) CALL restore; RETURN END IF + IF (ALLOCATED(Inst(id)%lin_fld)) THEN + IF (SIZE(Inst(id)%lin_fld, 2) /= Inst(id)%ncp .OR. SIZE(Inst(id)%lin_chan) /= p%NumOuts) & + DEALLOCATE (Inst(id)%lin_fld, Inst(id)%lin_moment, Inst(id)%lin_chan) + END IF + IF (.NOT. ALLOCATED(Inst(id)%lin_fld)) & + ALLOCATE (Inst(id)%lin_fld(3, Inst(id)%ncp), Inst(id)%lin_moment(3, Inst(id)%ncp), & + Inst(id)%lin_chan(p%NumOuts)) DO i = 1, Inst(id)%ncp y_out%CoupledLoads(1)%Force(:, i) = REAL(Inst(id)%ws_fld(:, i), ReKi) y_out%CoupledLoads(1)%Moment(:, i) = REAL(Inst(id)%ws_moment(:, i), ReKi) + Inst(id)%lin_fld(:, i) = Inst(id)%ws_fld(:, i) + Inst(id)%lin_moment(:, i) = Inst(id)%ws_moment(:, i) END DO DO i = 1, p%NumOuts CALL CD_AGG_EvalChannel( Inst(id)%agg, i, cval, es, em ) @@ -3078,6 +3092,7 @@ SUBROUTINE lin_eval( id, p, m, u, x_in, ErrStat, ErrMsg, dxdt, y_out ) CALL restore; RETURN END IF y_out%WriteOutput(i) = REAL(cval, ReKi) + Inst(id)%lin_chan(i) = cval END DO END IF CALL restore @@ -3097,6 +3112,38 @@ SUBROUTINE restore() END SUBROUTINE restore END SUBROUTINE lin_eval + SUBROUTINE pack_lin_outputs( id, Vars, y_lin, ValAry ) + !! The outputs of the last lin_eval packed as CD_VarsPackOutput packs y_lin, with the + !! coupled loads and the deck channels taken from lin_eval's double-precision copies: the + !! central differences of the loads over a 1 um position step resolve the stiffness of a + !! fairlead carrying a few MN in every build, the single-precision one included, where + !! the ReKi mesh carries 7 digits (the stiffness of the IEA-15 MW UMaine chains read 3.2e3 + !! instead of 7.7e4 N/m in surge). The other outputs (visualisation meshes) keep y_lin's. + INTEGER(IntKi), INTENT(IN ) :: id + TYPE(ModVarsType), INTENT(IN ) :: Vars + TYPE(CD_OutputType), INTENT(IN ) :: y_lin + REAL(R8Ki), INTENT(INOUT) :: ValAry(:) + INTEGER(IntKi) :: i, n + CALL CD_VarsPackOutput( Vars, y_lin, ValAry ) + IF (.NOT. ALLOCATED(Inst(id)%lin_fld)) RETURN + DO i = 1, SIZE(Vars%y) + n = Vars%y(i)%iLoc(2) - Vars%y(i)%iLoc(1) + 1 + SELECT CASE (Vars%y(i)%DL%Num) + CASE (CD_y_CoupledLoads) + IF (Vars%y(i)%DL%i1 /= 1 .OR. n /= SIZE(Inst(id)%lin_fld)) CYCLE + IF (Vars%y(i)%Field == FieldForce) THEN + ValAry(Vars%y(i)%iLoc(1):Vars%y(i)%iLoc(2)) = PACK(REAL(Inst(id)%lin_fld, R8Ki), .TRUE.) + ELSE IF (Vars%y(i)%Field == FieldMoment) THEN + ValAry(Vars%y(i)%iLoc(1):Vars%y(i)%iLoc(2)) = PACK(REAL(Inst(id)%lin_moment, R8Ki), .TRUE.) + END IF + CASE (CD_y_WriteOutput) + IF (Vars%y(i)%iLB < 1 .OR. Vars%y(i)%iUB > SIZE(Inst(id)%lin_chan) .OR. & + n /= Vars%y(i)%iUB - Vars%y(i)%iLB + 1) CYCLE + ValAry(Vars%y(i)%iLoc(1):Vars%y(i)%iLoc(2)) = REAL(Inst(id)%lin_chan(Vars%y(i)%iLB:Vars%y(i)%iUB), R8Ki) + END SELECT + END DO + END SUBROUTINE pack_lin_outputs + !---------------------------------------------------------------------------------------------------------------------------------- SUBROUTINE CD_End(u, p, x, xd, z, other, y, m, ErrStat , ErrMsg) USE, INTRINSIC :: ISO_FORTRAN_ENV, ONLY: int64 @@ -3306,13 +3353,13 @@ SUBROUTINE CD_JacobianPInput(Vars, t, u, p, x, xd, z, OtherState, y, m, ErrStat, CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) CALL lin_eval( m%CDInst, p, m, m%u_perturb, x, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) IF (Failed()) RETURN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) + CALL pack_lin_outputs( m%CDInst, Vars, m%y_lin, m%Jac%y_pos ) CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_pos ) CALL MV_Perturb( Vars%u(i), j, -1, m%Jac%u, m%Jac%u_perturb ) CALL CD_VarsUnpackInput( Vars, m%Jac%u_perturb, m%u_perturb ) CALL lin_eval( m%CDInst, p, m, m%u_perturb, x, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) IF (Failed()) RETURN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) + CALL pack_lin_outputs( m%CDInst, Vars, m%y_lin, m%Jac%y_neg ) CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_neg ) IF (PRESENT(dYdu)) CALL MV_ComputeCentralDiff( Vars%y, Vars%u(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, & dYdu(:, iCol) ) @@ -3452,14 +3499,14 @@ SUBROUTINE CD_JacobianPContState(Vars, t, u, p, x, xd, z, OtherState, y, m, ErrS CALL lin_eval( m%CDInst, p, m, u, m%x_perturb, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_pos ) + CALL pack_lin_outputs( m%CDInst, Vars, m%y_lin, m%Jac%y_pos ) CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_pos ) CALL MV_Perturb( Vars%x(i), j, -1, m%Jac%x, m%Jac%x_perturb ) CALL CD_VarsUnpackContState( Vars, m%Jac%x_perturb, m%x_perturb ) CALL lin_eval( m%CDInst, p, m, u, m%x_perturb, ErrStat2, ErrMsg2, dxdt=m%dxdt_lin, y_out=m%y_lin ) CALL SetErrStat( ErrStat2, ErrMsg2, ErrStat, ErrMsg, RoutineName ) IF (ErrStat >= AbortErrLev) RETURN - CALL CD_VarsPackOutput( Vars, m%y_lin, m%Jac%y_neg ) + CALL pack_lin_outputs( m%CDInst, Vars, m%y_lin, m%Jac%y_neg ) CALL CD_VarsPackContStateDeriv( Vars, m%dxdt_lin, m%Jac%x_neg ) IF (PRESENT(dYdx)) CALL MV_ComputeCentralDiff( Vars%y, Vars%x(i)%Perturb, m%Jac%y_pos, m%Jac%y_neg, & dYdx(:, iCol) ) From bb1722e49fa173514b075fa2a07085d42ac0343e Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 21:04:52 +0900 Subject: [PATCH 37/51] chore(release): prepare CableDyn 0.4.0 Version 0.4.0 (2026-11-03) in CMake, the banner, the OpenFAST module, the C API and header (0.4.0, C ABI 1.3), the Python package, the citation, the manual and the READMEs. The release notes of [Unreleased] are condensed into the 0.4.0 section (Added, Changed, Fixed, Upgrading, with the speed against 0.3.0 on the 51 example decks both run). The README capability table and the C ABI boundary page name the 0.4.0 features. The library and driver compile without warnings again: the exact real comparisons are written as absolute differences, the impure predicates of rod points and connected ends are evaluated before their operands, the integer bound of the C block size is taken in 64 bits, and the pass variables of the body balance and the failing object index start defined. Results are unchanged (53 of 53 example decks identical). The Holcombe record reproduces byte for byte with the 0.4.0 GNU build; its provenance names v0.4.0. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 787 ++---------------- CITATION.cff | 4 +- CMakeLists.txt | 2 +- README.md | 20 +- RELEASE.md | 4 +- doc/capi.rst | 8 +- doc/citing.rst | 6 +- doc/coupling_boundary.md | 8 +- doc/index.rst | 6 +- doc/installation.rst | 28 +- doc/openfast.rst | 2 +- doc/quickstart.rst | 4 +- doc/tutorial_openfast.rst | 2 +- examples/openfast/README.md | 2 +- integration/openfast/README.md | 4 +- pyproject.toml | 2 +- python/README.md | 2 +- python/cabledyn/__init__.py | 2 +- python/pyproject.toml | 2 +- release/check_release_metadata.py | 4 +- src/CableDyn_Banner.f90 | 2 +- src/CableDyn_CAPI.f90 | 6 +- src/CableDyn_CAPI.h | 2 +- src/CableDyn_DeckDriver.f90 | 27 +- src/CableDyn_HermiteCableDynamic.f90 | 8 +- src/CableDyn_Static.f90 | 2 +- src/openfast/CableDyn_OF.f90 | 2 +- tests/test_c_api.f90 | 2 +- .../experiments/holcombe/provenance.json | 6 +- 29 files changed, 181 insertions(+), 775 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d5fed4f..7b97b60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,711 +8,101 @@ All notable changes to CableDyn are recorded in this file. The format follows ## [Unreleased] +## [0.4.0] - 2026-11-04 + ### Added -- Deck currents on the standalone mixed `EI = 0` + finite-EI deck: a `current` OPTION (uniform or - profile), a WaterKin `CurrentMod 1` table and MoorDyn-C `Currents 1`/`2`/`5`, which the mixed - route refused, are taken in the static start of the chains and cables and sampled at every node - before each step with the single-line routes' updaters. Against the single-line routes on a - chain and a cable in a cross current: the static start agrees exactly for the chain and to - 4.9e-6 of the range for the cable (the coupled build's static polish), the march with the - same Newton controls to 4.9e-6 (cable) and 2.1e-5 (chain); a `Currents 2` table wrapping past - its last sample equals the unrolled table bit for bit; a uniform `Currents 1` profile and a - uniform `Currents 5` grid equal `uniform` to round-off (at most 3.9e-8); a correction rewind repeats the - step bit for bit; the march allocates nothing per step. Deck waves stay refused; the coupled - route keeps taking the host's field. -- 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); 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 - torsion and a `Rigid` end connection turn with the host, as on the coupled OpenFAST route; a - torsion deck, refused by `CableDyn_InitDeck`/`InitDeckAt`, runs there. - `CableDyn_GetCoupledMoments` returns the moments the lines apply to the host. On a straight - line rolled at 60 deg/s the coupled torque is the quasi-static `GJ phi / L` to 3e-6 N m, and - `SaveState`/`RestoreState` carry the rotations. Python: `CableDyn.init_deck_rotating`, - `update_rotations`, `coupled_moments`. -- `ATTACHMENTS` on a finite-EI line restrained in torsion: the torsion stage of the static start - runs on the discrete equilibrium, after the attachment polish, with the modules' net weights - and current drag (to a fixed point) as nodal loads. A lazy wave with 25 buoyancy modules and - one turn of pretwist, in still water and in a cross-flow current, keeps its torque, twist and - fairlead tension over a still 10 s run to the output precision (a torsion stage before the - polish would ring by 3e-3 of the torque); neutral modules reproduce the bare line's GJ Phi / L. -- `CoupledPinned`/`VesselPinned` bodies in OpenFAST, as MoorDyn-F's coupled pinned body: the - body reference point is a node of the coupling mesh that takes the platform position only, the - body turns about it with its own three rotations, and the node returns the body's net load - less its inertia, with no moment. `PtfmInit` moves and turns the body, `bodyIC static` balances - it about its node, and the checkpoint state and correction rewind carry it. A dry compound - pendulum keeps the elliptic-integral period to 1.6e-4 at `dt = T/100`, a body with a - `CoupledPinned` rod's mass and inertia follows the rod to 2e-12, and against MoorDyn-F - (`inertialF 1`) a pendulum swinging through 120 deg agrees to 0.09 deg (0.15 deg when its node - surges). Outside a coupled host, without inertias, and in linearisation the body fails closed - by name. -- Active line control (`CONTROL`, OpenFAST `CableDeltaL`/`CableDeltaLdot`) of a Syrope - polyester segment, which stopped at initialisation before. As in MoorDyn-F and MoorDyn-C the - segment's slow stretch carries over the length change (its slow strain is read at the new - length) and the running maximum is kept. On a taut 100 m line whose fairlead segment is paid - out by 0.5 m, hauled in to -1 m and paid back, the tension follows the rest curve of its load - history (working curve, OWC, then the working curve of the new maximum) to 2.5e-4 along the - ramps and 6e-7 at rest; after a length step it is MoorDyn's at the carried stretch to 1e-15 - (carrying the strain instead would be off by 0.4 to 2.4 %); a restart in the ramp continues - bit for bit; a polyester-chain line with a Syrope fairlead segment and a - chain-polyester-chain line run. -- Active line control of a viscoelastic segment (`Es|Ed` and `Es|alphaMBL|vbeta`), which - stopped at initialisation before. As in MoorDyn-F and MoorDyn-C the slow-branch stretch - `dl_1` is left as it is and read at the new length. On the same taut line and cycle the - tension follows the static law `Es` times the strain to 1.7e-4 along the ramps (4.6e-4 - load-dependent) and 4e-9 at rest; after a length step it is MoorDyn's at the carried stretch - to 4e-16 (carrying the strain instead would be off by 0.4 to 4.6 %); a restart in the ramp - continues bit for bit. -- OpenFAST linearisation of finite-EI lines restrained in torsion: the twist angles of the nodes - the end frames do not hold, and their rates, are continuous states (`Cable 1 node 2 twist, - rad`); the coupled point's orientation turns the torsion frame of the line's coupled - (host-driven) end, its angular velocity and acceleration reach the torsional damping and the - held end section's inertia, and the fairlead - moment carries the torque. A straight line's torsional modes from the eigenvalues of `A` are - the lumped chain's to 5e-14 (the continuum's `nπ/L √(GJ/Irn)` less the discretisation error, - 1.6e-4 for the first mode at 50 elements) and its roll stiffness `D − C A⁻¹ B` is `GJ/L` to - 1.5e-14; a 90° twisted lazy wave matches the deck's static solutions for a rolled and a moved - fairlead to 4.9e-4. In a `Linearize = True` run every input Jacobian, those of the time march - included, steps the coupled-point rotation by 1e-4 rad instead of 0.1 rad, which changes the - rotation columns of a deck with a hang-off spring by up to 0.17 %. -- Prescribed motion and torsion on the standalone mixed deck (`EI = 0` and finite-EI lines between - `Fixed`/`Coupled`/`Vessel` points, run on the coupled aggregate): the driver marches a - `motionFile` or `vesselMotion` as on the cubic-Hermite route, row 1 installed before `t = 0` - (also with `TMax = 0`). A vessel turns the end connection and torsion frames of the cables on - its points, and the roll column imposes the twist of a line restrained in torsion, which these - decks no longer refuse. - Under vessel roll, pitch and heave, or a surge with the roll column, a clamped line gives the - single-line route's torque, twist and node positions to the printed eight digits and its end - tensions and bend moment within 8.2e-6 of their range (the coupled cables' Newton tolerance; with - the single-line route's, every channel to the printed digits). These figures are for motions - that start from rest; a start with a jump in velocity differs by several percent of the range - (3 to 11 % in the cases tried) under the coupled Newton tolerance. A straight line rolled - slowly gives `Torq = GJ Phi / L` to 5e-6 N m. A static mixed run (`TMax = 0`) with torsion - takes `False alpha_force_blend`, as the single-line route and the Python reader do. - `vesselRAO` stays refused with the deck waves. 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 - velocities, with `A`, `B`, `C` and `D` by central differences of the accelerations solved at the - perturbed state. On the UMaine chains the stiffness `D - C A^-1 B` matches MoorDyn-F's to 0.1 % - and the lowest nine line-mode frequencies to 0.3 %; with a lazy-wave power cable every coupled - point matches the deck's own static solutions to 3e-4, also with a hang-off spring. The - reduction is the static stiffness at an operating point whose coupled points do not - accelerate: the coupled load includes the line's inertia, so at the accelerating `t = 0` - platform the lazy wave's force per unit rotation reads 1.2 % off, and 2.7e-4 with the platform - DOFs disabled (`doc/openfast.rst`). A cable end connection with a numeric stiffness now - linearises. The viscoelastic slow-branch stretch - and the Syrope slow strain are first-order states, so the reduction gives these ropes' relaxed - static stiffness (each matches its deck's static solutions to 7e-5; held, they would read the - chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end - connection, VIV lines, bodies, rods, buoys and `CONTROL` fail closed with named messages. This - replaces the quasi-static linearisation without states. The output differences use - CableDyn's double-precision loads, so a single-precision OpenFAST build (the release - `openfast.exe`, Visual Studio `Release`) linearises as a double-precision one; through its - 7-digit output mesh the UMaine chains' surge stiffness read 3.2e3 instead of 7.7e4 N/m. -- Composite Syrope lines: a Syrope polyester section between plain `EI = 0` sections, such as a - chain-polyester-chain mooring, in one LINE. The static start puts every Syrope element on the - rest curve of its load history with its own secant EA (the tension varies along a sagging - section), so the dynamics start in the static equilibrium; the chains keep their `BA` damping, - 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. -- Torsional inertia and damping of finite-EI lines: in the dynamics a line restrained in torsion - carries a twist angle at every node, against directors that follow the node tangents by the - smallest rotation over each step, with the polar rotary inertia `Irn` of its LINE TYPES row and - the torsional damping `Bt` of a new third part of the `GJ` column (`GJ|K|Bt`, negative for a - damping ratio). The torque now varies along the line (`TorqN` is the node's) and - travels as a torsional wave; the statics stay condensed, and in the limit of a negligible - inertia the dynamics reproduce the condensed torsion. The step solves the angles with the - cable in one band of half-width 13; the twist state joins the snapshot, the recovering step - and the OpenFAST checkpoint mirror. Decks with torsion whose `Irn` was a placeholder (the - column was unused before) need the section's real value. The Python deck reader and builder - take `GJ|K|Bt` (builder `gj=(GJ, K, Bt)`). -- Active line control (`CONTROL`) of a finite-EI cable restrained in torsion, which was refused: - the torsional compliance, the nodal twist's `GJ`/l and `Bt`/l, the torque–tension coupling and - the polar inertia take the new lengths, a `-ζ` torsional damping keeps its `ζ`, and the damping - acts on the rate of the twist per length. A taut line paid out and hauled in carries - `GJ Φ/L(t) + K (H − L)/L` to 1.5e-12 and its tension to 4e-6; a constant pay-out carries the - Kelvin–Voigt torque to 6e-6 N m of its 0.64 N m damping share; a pay-out under a ringing twist - balances the energy to 8e-5 of the work done; restarts mid-ramp (snapshot, checkpoint mirror, - a coupled deck) are bit-identical. The checkpoint mirror of a line with the nodal twist gains - one value, its committed torque. -- Modal analysis (`nModes`) of finite-EI lines restrained in torsion: the modes carry the twist - angle of every node, as the dynamics do, with the lumped polar inertia and the second variation - of the twist energy at the static torque. A clamped straight line's torsional modes match - `nπ/L √(GJ/Irn)` within the lumped chain's own error (2.6e-4 on the first), elastic ends and - the torque–tension coupling their continuum solutions to 1e-3, and under a torque its lateral - modes match the clamped Greenhill cable to 3e-7; eliminating the angles reproduces the - condensed static tangent to 1e-16. `.modes.out` adds `PolarShare` and `dTwist` when a - line carries twist. -- Torsion of a finite-EI line restrained at one end only, the other free to twist (`TorsStiffness` - `Free` there, or no row): solved where a line restrained at both ends is and its LINE TYPES - rows give `GJ`, instead of being ignored. The free end carries no torque and turns with the - twist of the line: statically `Twist = −Σ (K/GJ)(l − L)` under `GJ|K` (End B relative to - End A; to 1e-8 on a stretched straight cable, the moving end free or the anchored one), and in - the dynamics with torsional waves that reflect at it. A straight line held rigidly at the other end rings at the - clamped–free frequencies `(2n − 1) π/(2L) √(GJ/Irn)` (3e-4 and 3e-3 for n = 1, 2), and a roll - of the restrained end gives the continuum's free-end turn `A/cos kL` and reaction - `GJ A k tan kL` to 0.5 % below and above the first mode, in the standalone driver and on the - coupled aggregate. The `Torq`/`Twist` channels and range columns work on such a line, and - its `CurvX`/`CurvY` axes follow its twist. Results change on such decks: the dynamics carry - the twist (on a swaying lazy-wave cable with `GJ|K` the tensions move by up to 1.5e-4, 7e-8 - in a planar heave), and a line restrained at End A on a Rigid6 body joins the static body - balance of the clamped ends: bending-Pinned there, its body's static moment now balances - (Body1My −103.9 N m to 1e-6 on a buoy, FairTen1 126885 to 126857 N, 2.2e-4, Body1Ry - 0.3004 to 0.2984 deg; the march then differs by up to 2.6 % at dtM 0.05 s, 0.5 % at - 0.0125 s); clamped there, by about 1e-7. OpenFAST checkpoints of such decks written before - this change do not reload: the cable's state mirror now carries the nodal twist, and the - rebuild stops at a mirror-extent check (`... mirror extends past the state vector`). A line - restrained at one end that misses a rule (no `GJ`, two moving ends, the configuration blend, - a restrained End A on a free, pinned or Coupled rod end or a non-Rigid6 body) is solved - without torsion as before, with a note naming the rule; a solved one's restrained `Pretwist` - is held within 1000 turns. -- Torsion at a rod end: a line restrained in torsion may hang from an end of a `Fixed` rod (an - I-tube or J-tube), whose frame holds the End A torsion frame, with `Nx` in the rod's deck - axes. Two turns on an inclined J-tube give `GJ Phi / L` to 1.2e-9, the same torque as from a - held Coupled point, and `RodM` the torque along the line axis; the line written anchor - first (MoorDyn's order) runs bit for bit as written rod first. On a rod fixed to a rolling Rigid6 - body the torque follows `GJ (Phi - theta)/L` to 4e-11, and `RodM` of a rod fixed to a body - now includes the connection moment of a cable clamped at its end (it read 0). Free, pinned - and Coupled rods refuse the torsion by name, and so does `staggered bodyScheme` on a body or - rod (it drove the cable end by translation, so the torsion frame did not turn); a line between - two rods is refused as ending on a rod end, not as having two moving ends. -- The torsion routes combined: a line restrained in torsion at one end only takes `ATTACHMENTS`, - `CONTROL`, `nModes` and a `Fixed` rod end, which left it unsolved in torsion. With modules of - net weights 14.6, −9.1 and 5.8 kN on a vertical cable its free end turns by `−(K/GJ)(H − L)` - to 8.5e-9 and its mid-line node with the module tensions to 3.9e-4 (a first-order mesh - error); a paid-out fairlead turns it by `−(K/GJ)(H − L(t))` to 4e-11 with no torque; its modes - and the eigenvalues of the OpenFAST `A` are the clamped–free chain's to 8e-10 and 2e-14 and - the quarter-wave `(2n − 1)π/(2L) √(GJ/Irn)` within the lumped-inertia error, with no roll - stiffness. The modal twist Hessian no longer takes a free end for an elastic one of infinite - stiffness. `ATTACHMENTS` on a line restrained at both ends run on the mixed `EI = 0` + - finite-EI route and on a `Fixed` rod end as on the single-line route (to the printed digits). -- Torque–tension coupling of finite-EI cables: the 14-column LINE TYPES row's `GJ` column takes - `GJ|K`, with `K` the coupling of an armoured cable or wire rope (`T = EA ε + K τ`, - `M = GJ τ + K ε`). The cable carries the axial stiffness `EA − K²/GJ` of a section free to twist. - 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 - (the torsion normal, or the static start's upper normal), turn with a clamped hang-off, are - carried along the line by parallel transport and turn with the twist of a line restrained in - torsion; `CurvX^2 + CurvY^2 = Curv^2`. On a line twisted 90 degrees the carried axes reach - End B within 3e-6 rad of its pretwisted normal. `EI = 0` lines and finite-EI lines with two - moving ends refuse the channels. -- Cross-flow vortex-induced vibration of `EI = 0` lines in the standalone driver: MoorDyn v2's - LINE TYPES columns `Cl` or `Cl dF cF` switch on the synchronisation model of Thorsen et al., - with the same phase start and running-RMS window (`VIVrmsWindow`, default 500 steps of - `dtM`). On a taut 100 m line in a uniform current it follows MoorDyn-F's lock-in amplitude - and frequency to two to three digits through mode-1 and mode-3 lock-in, at any `dtM` from - 5e-4 to 1e-2 s. The phases start from the deck's End A as MoorDyn's do, also on a line - written anchor first, which the reader turns around, and at the deck nodes of a refined - finite-EI mesh. MoorDyn-C's own VIV case, the catenary riser of Thorsen et al., reproduces - its mean tension and tension range and the measured lock-in frequency (period within 1 %). - The Python deck tools read and keep the columns. -- Cross-flow VIV of finite-EI cables in the standalone driver: the same LINE TYPES columns on an - `EI > 0` type give a distributed lift, Gauss-integrated over each cubic-Hermite element with - exact tangents, and a shedding phase at each node driven along the node's own tangent. A taut - line with `EI` near zero reproduces the `EI = 0` lock-in to three digits, at any `dtM` from - 5e-4 to 1e-2 s without smoothing; a bending-stiff line matches the string of equal first-mode - frequency in mode-1 lock-in and stays in mode 1 where that string jumps to mode 2. The - multibody march carries it too (a cable on a Rigid6 body or rod, or beside free points), with - the same lock-in. A finite-EI line with two moving ends refuses `Cl > 0`. -- LINES Outputs flag `V` (MoorDyn's): the cross-flow VIV lift force at the nodes of a line, - written to `.Line.V.out` on dynamic runs of the standalone routes that carry VIV. On - a finite-EI line each element's lift is lumped to its nodes; at the interior nodes of a taut - line in lock-in it matches the `EI = 0` line's within 0.1 %. Upper case only, as in MoorDyn, - whose `v` (node velocities) CableDyn does not write. -- Cross-flow VIV on the coupled routes: OpenFAST (`CompMooring = 5`), FAST.Farm and the - standalone runner of a mixed `EI = 0` / finite-EI deck carry the lift on both line kinds, with - the host's fluid field. The phases, running mean squares and averaging time are part of the - checkpoint state and of the correction rewind, so a restart continues bit for bit. A riser and - a cable in a 0.15 m/s host current lock in at A/D 0.665 and 0.292 Hz, MoorDyn-F's 0.662 and - 0.293 Hz. -- Bend stiffeners (`STIFFENERS` table): a tapered polyurethane sleeve over an end of a finite-EI - line, given as conical segments from the root outward (outer diameters, bore, modulus, - density). Each element it covers takes the compliance average of the cable-plus-sleeve - bending stiffness and the sleeve's mass, buoyancy and drag; standalone and coupled, with the - Python reader and builder. A hang-off clamped through a 5 m stiffener follows an independent - solution of the planar elastica within 0.2 % of the root moment, and its curvature follows - OrcaFlex 11.6d within 0.8 %. Initialisation notes name a stiffener spanning fewer than 10 - elements and one at a pinned end. Example `lazy_wave_bend_stiffener.dat`. -- Output channels `StfMomN`, the share of the section moment a bend stiffener carries, - and `FairDefl`/`AnchDefl`, the deflection of the end force from the direction a held - END CONNECTIONS row declares (with the end tension, a stiffener's load case). -- MoorDyn-C time-varying and gridded currents on the standalone routes: `Currents 2` (the depth - profile in time `current_profile_dynamic.txt`) and `Currents 5` (the grid in x, y, z and time - `current_profile_4d.txt`), read and interpolated as MoorDyn-C v2.7.1 does (resampled at the - smallest time interval, repeating past the last sample, held beyond the grid, no fluid - acceleration) at every node's position and time, the static start included. At 739 points and - times the current is identical to MoorDyn-C v2.7.1's; a constant table equals `Currents 1` and a - grid uniform in x and y equals `Currents 2`; on a 70 m rope the tension change of a time-varying - and of a sheared current matches MoorDyn-C's within 0.9 %, and the static start in a sheared grid - holds the tensions to 1.4e-7 of the change the current makes. The C API, without a clock, - refuses a table that varies in time. +- Full torsion of finite-EI lines: in the dynamics a twist angle at every node, with the polar + inertia `Irn` and torsional damping (`GJ|K|Bt`), so the torque varies along the line and + travels as a torsional wave; the statics stay condensed. Lines restrained at one end only + (the other free to twist), lines hanging from a `Fixed` rod end (I-tube, J-tube), `CONTROL`, + `ATTACHMENTS` and modal analysis all take torsion. Torsional modes match the continuum within + the lumped-inertia error (2.6e-4 on the first). +- Torque–tension coupling of armoured cables and wire ropes (`GJ|K`: `T = EA ε + K τ`, + `M = GJ τ + K ε`) in statics, dynamics, linearisation and the tensile audits; `GJ|0` is the + uncoupled cable bit for bit. +- OpenFAST linearisation with the line dynamics, as MoorDyn-F's: interior node positions and + velocities of `EI = 0` lines, the free degrees of freedom of finite-EI cables, and the twist + angles of lines restrained in torsion. On the UMaine chains the reduced stiffness matches + MoorDyn-F's to 0.1 % and the lowest nine line-mode frequencies to 0.3 %. Replaces the + quasi-static linearisation without states. A single-precision OpenFAST (the release + `openfast.exe`) linearises from CableDyn's double-precision loads, as a double-precision one. +- Section-frame curvature channels `CurvXN`/`CurvYN` on finite-EI lines, for the + fatigue of an armour wire or conductor at a fixed point of the section; the axes follow the + twist. +- Cross-flow VIV (the Thorsen et al. model of MoorDyn v2, LINE TYPES `Cl`, `dF`, `cF`) on + `EI = 0` lines and, as a distributed lift, on finite-EI cables, standalone and on the coupled + routes, with the LINES output flag `V`. Lock-in follows MoorDyn-F to two to three digits. +- Bend stiffeners (`STIFFENERS`): a tapered linear-elastic sleeve over a finite-EI line end; + a clamped hang-off follows the planar elastica within 0.2 % of the root moment and OrcaFlex + 11.6d's curvature within 0.8 %. Channels `StfMom`, `FairDefl`/`AnchDefl`. +- Finite-EI lines with two moving ends (a cable shared by two floaters, a FAST.Farm shared + line) standalone, in OpenFAST, FAST.Farm and the C API; and between two objects on the + multibody march. The retired Cosserat compatibility route no longer runs them. +- `CoupledPinned`/`VesselPinned` bodies in OpenFAST, as MoorDyn-F's coupled pinned body. +- Active line control (`CONTROL`) of Syrope and viscoelastic segments and of finite-EI cables + restrained in torsion; composite Syrope lines (chain–polyester–chain). +- Deck currents, prescribed motion, torsion and `TURBINES` rows on the standalone mixed + `EI = 0` + finite-EI deck; MoorDyn-C `Currents 2` and `5` (time-varying and gridded) on the + standalone routes, identical to MoorDyn-C v2.7.1 at 739 points and times. +- C API host rotations (ABI 1.3, `CableDyn_InitDeckRotating`, `CableDyn_UpdateRotations`, + `CableDyn_GetCoupledMoments`), so torsion decks and `Rigid` end connections run there; Python + `init_deck_rotating`. ### Changed -- Every Intel ifx build compiles CableDyn with the value-safe floating-point model, - `/fp:precise` (`-fp-model precise` off Windows): the static Windows release and wheel, every - other CMake build and configuration with ifx (with or without OpenMP, including the core that - the OpenFAST CMake route builds, and its adapter), and every configuration of the OpenFAST - Visual Studio project. The ifx default, `/fp:fast`, reassociates sums, divides by - multiplying with the reciprocal and flushes subnormals to zero, differently at every inlined - call site, so the gates that hold two routes to the same bits failed (a zero control command - against an uncontrolled cable, a held Coupled End B against a Fixed one, a committed against a - re-derived torque), subnormal deck values read as zero and the clamped-cable elastica secant - stalled. Results of ifx builds change at round-off; gfortran builds are unchanged. -- The macOS wheel needs macOS 15 or newer on Apple silicon (0.3.0: macOS 14). It is built on - the macOS 15 runner, as GitHub retires the macOS 14 runner image on 2 November 2026, and its - Homebrew gfortran and OpenBLAS support no older macOS. On macOS 14, build from source. -- With a `motionFile` or `vesselMotion`, the single-line finite-EI route writes `.static.out` - before it installs the first motion row, so the file holds the static solve; before, it showed - the fairlead already moved to row 1. A deck whose row 1 is off the deck fairlead changes - `.static.out` only (a 2 cm offset changed the fairlead x by 0.02 m and its tension from 3.5 MN - back to the static 29 kN); the example decks are unchanged. -- 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 - `TMax = 0`, where the range graphs hold the `t = 0` row. A standalone deck without `TMax` that - asks for the march now says so: its error ends "to check a dynamic deck's static start only, - give dtM with TMax = 0". -- Deck waves from a WaterKin elevation history (`WaveKinMod 1`) run two to four times faster. - Below the surface, the velocity and acceleration sums stop once the components still to come, - too short to reach that depth, cannot change them beyond round-off. On a 1024-element lazy-wave - cable over 300 s, a record at `dtWave` 0.25 s (600 components) runs in 103 s instead of 226 s, - and one at 0.1 s in 189 s instead of about 660 s, with output identical to the printed digits. - A `jonswap` sea changes at round-off. -- An elevation record (WaterKin `WaveKinMod 1`) keeps only its Fourier components up to the new - `WvHiCOff` option, in rad/s as in SeaState, by default 0.5 Hz (MoorDyn-C's fixed cut for - `WaveKin 3`, which now follows the option too); `none WvHiCOff` keeps them up to the Nyquist - frequency of `dtWave`, as MoorDyn-F and earlier CableDyn did. A one-hour record at `dtWave` - 0.1 s drops from 18,000 components to 1,800. On the 300 s lazy-wave case both records then run - in 72 s, and every output channel's standard deviation moves by at most 0.002 %. A record with - no component at or below the cut-off is refused by name. -- Waves run faster under every compiler: the wave kinematics evaluate their phase sines and cosines - and depth exponentials in blocks of plain arithmetic that vectorise under any value-safe - floating-point model (`CableDyn_WaveMath`: one argument reduction for each sine-cosine pair, - polynomials, the power of two from its bits) in place of one library call per component, which ifx - makes under `/fp:precise`. At one thread, best of five, an irregular sea runs 31 to 33 % faster - with ifx (`chain_two_train_sea` 1.83 s to 1.22 s, `chain_torsethaugen_spread` 1.64 s to 1.13 s) - and 20 to 21 % faster with gfortran (4.09 s to 3.22 s, 3.56 s to 2.86 s); the VolturnUS line-break - decks 14 % (ifx, 31.0 s to 26.8 s) and 9 % (gfortran); `lazy_wave_vessel_rao` and - `lazy_wave_bend_stiffener` 9 % with ifx and within 1 % of before with gfortran; decks without - waves run as before. This recovers about two thirds of what `/fp:precise` cost the Windows release - (`chain_two_train_sea` +83 % over `/fp:fast` before, +24 % now). The sines and cosines are within - 2.4 ulp (within 9e-26 next to their zeros) and the exponentials within 1.1 ulp of quadruple - precision, so wave decks change at round-off: 49 of the 53 example decks give identical files, two - lazy-wave decks differ by one unit in the last printed digit (7e-8 of a tension's scale), and in - the two VolturnUS line-break decks the drifting platform amplifies round-off after t = 860 s to - 0.15 to 0.21 of the anchor-2 tension's scale, as much as the gfortran and ifx builds of the - unchanged code differ by. -- Coupled OpenFAST runs start from the equilibrium in SeaState's steady current (`CurrMod 1`), - as standalone decks start in their `current` option, instead of from the still-water shape. - The current is evaluated at SeaState's vertical grid levels for the static solves only; the - dynamics take the SeaState field alone. On the IEA-15 MW mixed example in a 0.5 m/s cross - current, the lazy-wave cable starts 29 m across at its deepest monitored node and moves less - than 0.6 m over the first 30 s, where the still-water start has reached a third of that offset. - `CurrMod 2` and InflowWind currents keep the still-water start, with a note. -- Syrope polyester lines take the seabed, Morison drag and added mass, deck current and waves, - a coupled host's fluid field, a `bathymetryFile` and VIV, as every `EI = 0` line does and as - MoorDyn's do; before, they ran without hydrodynamics and refused current, waves, host fluid - and bathymetry. The static initial condition includes the current's drag. A taut polyester - line whose fairlead sways 2 m in water matches MoorDyn-C's fairlead tension within 11 N on a - 45 kN range (1.03 MN mean); without drag and added mass the range is 5 % larger. -- Under a bend stiffener, `BendMomN` (and the `BendMoment` columns of the static profile, - range graphs and element file) report the cable's own moment, the line type's EI times the - curvature; lines without stiffeners are unchanged. -- A run whose outputs name line nodes (`LN…`, `TenN` and the other node channels, or a - LINES `Outputs` flag) notes that CableDyn numbers line nodes from 1 at End A while MoorDyn - numbers them from 0, so a MoorDyn deck's `N` is CableDyn's `N`, or `N` on - a line written anchor-first. The numbering itself is unchanged; the outputs and migration pages - state it. -- The run banner, README, manual, citation and package descriptions call CableDyn what it is: a - geometrically exact finite-element solver for the statics and dynamics of mooring lines and - dynamic power cables (its strain and curvature are the exact large-deformation measures), in - place of "geometrically nonlinear cable & mooring dynamics". +- Coupled OpenFAST runs start from the equilibrium in SeaState's steady current (`CurrMod 1`) + instead of the still-water shape. +- A finite-EI cable on the coupled aggregate (mixed decks, OpenFAST, FAST.Farm, the C API) steps + to the deck's `dynamic_solver` tolerance instead of a fixed 5e-3. The looser step gave wrong + tensions (a fairlead peak of 4.3e5 N against 1.9e4 N) and a coupled cable that did not damp + out its residual; the routes now agree to 5e-8 of the peak tension. +- A finite-EI cable pinned to a light moving object is coupled implicitly in the multibody step + (it was explicit and diverged on light objects). +- Waves: `WvHiCOff` (default 0.5 Hz) cuts an elevation record's components, and the wave + kinematics vectorise (irregular seas 20 to 33 % faster); `WaveKinMod 1` decks run two to four + times faster. +- Every Intel ifx build uses the value-safe floating-point model (`/fp:precise`) and automatic + local variables; ifx results change at round-off. +- Syrope lines take the seabed, Morison loads, current, waves, host fluid and VIV. +- The macOS wheel needs macOS 15 or newer on Apple silicon. +- `TURBINES` decks read and turn finite-EI end frames in each turbine's axes, as FAST.Farm does. +- The CableDyn-enabled `openfast.exe` names itself `OpenFAST-v5.0.0-CableDyn-0.4.0`. +- Speed: on the 51 example decks that 0.3.0 also runs, 0.4.0 is 6 % faster (geometric mean of + the per-deck times; gfortran, one thread), the wave decks 16 to 30 %. Two decks are slower for + the fixes above: `mixed_body_rods_points` 52 % (the implicit coupling of a pinned cable) and + `torsion_lazy_wave_hangoff_twist` 25 % (the nodal twist), and a coupled finite-EI cable step + costs about 38 % more (the deck tolerance). ### Fixed -- A finite-EI cable pinned to a light moving object no longer throws it off its static start in - the monolithic multibody step. Such a cable (pinned at a Rigid6 body point or a free or pinned - rod end, the other end held) was stepped once per step with the predicted motion of its - attachment and its end force held through the iterations, an explicit coupling that diverges - once the cable's dynamic end stiffness times `dtM^2` exceeds about 0.85 of the object's mass - along the cable. It is now re-stepped at every outer iteration with its end stiffness in the - Newton matrix, as a clamped cable already was. A 3 t free rod spar with a 55 m cable (EA 5e8 N) - pinned at either rod end, at `dtM` 0.01 s: the cable tension rose from 11 kN past 1 MN in - 0.7 s and the rod end moved 6.3 to 6.5 m in 2 s (5.4 m in a current, 6.1 m with the cable from - a fixed rod's end); it now holds to 2e-10 m and 3e-8 of the tension (6e-4 m in the current, - as on the staggered scheme), and the monolithic and staggered schemes agree to 2e-10 m. With a - 1500 kg clump on that cable the rod moved 15 m in 3 s; it holds to 1.1e-6 m (`line_attachments` - 11 and 12 march at `dtM` 0.01 s again). A 4 t buoy with a pinned keel cable moved 0.22 m and - its cable tension reached 38 times its start; it now holds to 1e-9 m. Decks with a pinned cable - on a heavy body change at the accuracy of the old coupling: on the `mixed_body_rods_points` - example (150 t buoy) the body motion changes by 3.5e-5 m, its error against a run at `dtM` / 4 - falling from 3.7e-5 m to 1.6e-6 m, and the cable top tension by 0.6 N of 8.1 kN; that deck runs - about 45 % longer. -- A finite-EI cable whose End A rests on the seabed below its End B (a cable written from a seabed - termination, such as a fixed rod's end, up to a floater) takes the catenary-continuation static - route again. Its catenary seed refused the line (the fairlead, End A, must sit above the bed), - so the mesh-sequenced route alone solved it, and its branch depended on platform round-off: a - 55 m cable from a fixed rod's end on the seabed to a free spar rod solved on Windows and - reached a kinked state (max h kappa 1.96) on Linux gfortran, which failed the deck. The seed - is now laid from End A, the line seen from its other end, and its nodes put back in order. The - deck starts at the same equilibrium as before on Windows (1e-7 m, 6e-4 N), and moving the fixed - rod by 1 ulp either way or 1e-12 m up leaves the rod's start unchanged (0 m). -- `CableDyn_Close` no longer pauses the OpenMP runtime of the whole process under the Intel and - LLVM OpenMP runtimes (ifx and other non-GNU builds with OpenMP). Every close called - `omp_pause_resource_all` (since 0.1.0) to join the calling thread's pool, a fix for GNU - OpenMP's process exit on MinGW-w64; libiomp5 and libomp pause the runtime of every thread - instead, so closing one handle paused the OpenMP of every other handle and of the host, and the - next parallel region on another thread deadlocked resuming it. An ifx build with OpenMP that - stepped a handle on a second thread after a close hung every time (the threading gate, 20 of - 20 runs); it now passes 20 of 20 with 1 and with 4 OpenMP threads. GNU builds keep the pool join. -- A non-static ifx build (a plain CMake build with ifx, or the core of the OpenFAST CMake route) - kept run-time-sized arrays and array temporaries on the stack, as only the static Windows - release compiled with `/heap-arrays`: the 2835-node mixed IEA-15 MW deck and a fine-mesh deck of - the statics matrix overflowed the 1 MiB stack of an MSVC-linked program. Every ifx build now - compiles with `/heap-arrays:1024` (`-heap-arrays 1024` off Windows), as the static release and - the OpenFAST Visual Studio project did; the static release is unchanged. -- A finite-EI cable on the coupled aggregate (a mixed `EI = 0` + finite-EI standalone deck, - OpenFAST `CompMooring = 5`, FAST.Farm and the C API) stepped to a fixed relative Newton - tolerance of 5e-3 (200 iterations) whatever the deck's `dynamic_solver` row said, and its static - start to 1e-6; the same cable alone in a deck stepped to the deck's tolerance (default 1e-8, 30 - iterations). Every route now takes the deck's `rel` and `max_iter` and the static tolerance - `min(1e-6, rel)`. A lazy cable beside a chain, both fairleads moved 3.5 m from rest: at - `rhoInf` 1, `dtM` 0.05 s the mixed route's fairlead tension peaked at 4.3e5 N (anchor 5.5e5 N) - against 1.9e4 N (2.1e3 N) for the cable alone; at `dtM` 0.1 s it fell to 8307 N against - 10799 N and the fairlead bend moment rose to 1612 against 3.9 N m. The routes, and the C API, - OpenFAST and FAST.Farm builds driven through the same motion, now agree to 5e-8 of the peak - tension. The loose steps also made the coupled cable non-dissipative: held at both ends in still - water, the residual each step left grew at `rhoInf` 0.4 into a sustained oscillation (+-2.1 N on - 1.5e4 N in 10 s on that cable; +-14 N at 8 Hz on 1.2e4 N on the IEA-15 MW mixed cable, also in - OpenFAST `CompMooring = 5`), and at `rhoInf` 1 a seeded march diverged; the held cable - now stays at its static tensions to 6e-5 N and a seeded one decays as on the single-line route. - On the default `rhoInf` 0.4 under motion the difference was 4.7e-4 of the anchor tension, and - the IEA-15 MW mixed example in a 60 s platform motion changes by 1.6e-6 of its cable tension. - Cost: a coupled cable step takes about 2.0 tangent factorisations instead of 1.1, and the - aggregate step of that example (chains included) 38 % more CPU time (the D03 deck: 19 %). -- A held line under strong torque-tension coupling stays still in its dynamics. With - `K >= 0.85 sqrt(EA GJ)` (and at `-0.8` with one end free in torsion) a line in exact static - equilibrium failed its step within 0.05-0.9 s ("Newton did not converge, ||G|| = 2.4e-8 > - tol = 1e-8"): the round-off floor of the step's convergence norm took only the kernel's - `EA - K^2/GJ`, not the coupling's share of the axial force and of the torque. It now takes - both; at `K` up to `0.99 sqrt(EA GJ)` in either sense the held line holds at the default `dtM` - and tolerance (`torsion_coupling_still`), and lines with `|K| <= 0.8 sqrt(EA GJ)` step as before. -- The static passes of a finite-EI cable restrained in torsion between two Rigid6 bodies - converge at every pretwist. They compared the change of the cable's end loads with 1e-10 of - their scale, below the resolution of the core's body balance (1e-9 of the bodies' net weight), - so at 360 deg (Rigid ends) and 300 deg (Pinned) they stalled near 2e-9 and the deck stopped, - with advice (`bodyIC deck`) that was not the remedy. They now stop at the resolution the core - leaves: the Rigid 360 deg case converges in 6 passes (torque 4886.24 N m), and the - pretwist sweep 120-720 deg of both end kinds converges (`torsion_body_passes`). -- A lazy wave restrained in torsion starts in an in-plane current. In a 0.5 m/s current its - untwisted static state, solved in its vertical plane, is unstable out of that plane on its mesh - (one negative stiffness mode), which the deck without torsion accepts with a note; the torsion - stage refused the twisted state as unstable although the twist added no negative mode ("torsion - continuation stalled at Phi = 0 (target 0)" at pretwist 0, an unstable equilibrium after a - failed Newton solve at 360 deg). A twisted state with no more negative modes than its untwisted - one is now kept, and the note names the instability as the untwisted state's - (`torsion_current_start`). Its start also depended on the pretwist and on the round-off of the - BLAS kernel: the coarse branch-selection build of a line restrained in torsion twisted it, and - that twisted state seeded the untwisted solve on the deck mesh (pretwist 180 deg stopped in the - attachment polish, 360 deg needed the polish's fallbacks and stopped with - `OPENBLAS_CORETYPE=Prescott`); and each pass of the attachment fixed point after the first - applied the drag of the last twisted shape in full at the untwisted start (270 deg and more - stopped before any twist). The static helper builds now solve the untwisted line, and the - change of the attachment loads is ramped with the imposed twist: pretwists from 0 to 720 deg - start with the same torques on every kernel, proportional to the pretwist. -- The "unresolved/kinked equilibrium" refusal names the element and the factor to refine its - section's `NumSegs` by. -- Console messages that said something untrue now say what happens: - - OpenFAST: "SeaState wave/current kinematics drive the mooring hydro" is printed only when the - deck's `WaterKin` policy takes a SeaState component (a `WaterKin` file with `WaveKinMod 0` and - `CurrentMod 0` gives still water and says so); - - the body/rod static start reports the largest turn of a body or rod and the move of every - point the objects carry, so a pinned rod that only rotated no longer reads "largest move - 0.000E+00 m"; - - a mixed or FAST.Farm deck refused for a deck current names the input that declares it (the - `CurrentMod 1` table of its `WaterKin` file, or the `current` OPTION), not always "the current - OPTION"; - - the torsion note reports the line's total twist `Twist` at the static state, beside the - imposed `Pretwist(B) - Pretwist(A)` and with the end frames' turn (a `PtfmInit` or `TURBINES` - rotation) and the shape's geometric twist, not the pretwist alone; - - in FAST.Farm the time-step messages name the farm's `DT_Mooring`, not a "glue DT". -- A standalone `TURBINES` deck that mixes `EI = 0` lines and finite-EI cables (a power cable - shared by two turbines beside their chain legs, the usual farm deck) runs. It stopped with the - internal message `no farm init was given (pass n_turbines + turbine_ref_pos)`: the mixed route - did not take the `TURBINES` rows. It now places the `Turbine` points from them and moves the - points and turns the cable end frames with the per-turbine `motionFile` records, as the decks of - the cables alone and of the `EI = 0` lines alone do. The IEA 15 MW two-turbine deck (a 1530 m - cable restrained in torsion and four chains, 60 s of FAST.Farm platform motion) reproduces those - two decks to 3.2e-6 of the channel maxima and the FAST.Farm `Mod_SharedMooring = 5` run to - 2.3e-5. On a two-turbine test deck whose turbines heave and roll, the chains match their deck - bit for bit and the cable, marched with the single-cable route's Newton controls, matches its - deck to 0.44 of the last printed digit. A `Turbine` point in a run without a farm - (single-turbine OpenFAST, the C API) is now refused by point, naming FAST.Farm and the - `TURBINES` section. -- A coupled deck with both bodies and rods stopped at init with `a coupled deck mixing RODs and - Rigid6/point3 bodies is not supported (the aggregate marches one body/rod family per step)`, - a limit the OpenFAST and capability pages did not state. The message now says what the coupled - route takes (bodies or rods, a rod fixed to a body counting as a rod) and where such a deck runs - (MoorDyn `CompMooring = 3`, the standalone driver); the OpenFAST, capability and troubleshooting - pages state the limit, and the Python validator (`caller_driven=True`) refuses the deck. -- `FAST.Farm.exe` built through the CMake route of `integration/openfast` with the GNU compilers - on Windows stopped at start with `0xC00000FD` (stack overflow) while initialising the first - turbine: MinGW links it with a 2 MiB stack. The new patch `0022` gives `openfast.exe` and - `FAST.Farm.exe` a 256 MiB stack reserve on that toolchain, and the shared-mooring farm (two IEA - 15 MW turbines) runs to normal termination. -- 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. -- The static start of a neutral finite-EI line whose length equals its span (straight at zero - strain, so with neither weight nor tension) failed with neutral `ATTACHMENTS` or with - attachments that only carry a drag area: the attachment polish stalled at the round-off of the - axial forces, 7.6e-8 N, against a tolerance of 1e-8 times the solver's 1 N force floor, at - every load step. For a line whose chord is at least its length the force scale of the - convergence test now includes that round-off floor over the tolerance - (`16 eps max(EA/L0) |x| / tol`, as on the `EI = 0` path), so these lines start straight and - unloaded, also between two moving ends, restrained in torsion at one or both ends, and with a - chord 1e-8 longer than the line (its 0.1 N tension to 2.2e-7 N); slack lines and lines that - carry weight or tension above the floor are unchanged. -- The Newton tangent of the finite-EI static solve in a depth-profile current or a current grid - carries the current's gradient: the drag samples the current at the node positions, so it moves - with them. The drag part of the tangent now matches central differences of the residual to - 8e-10 (before off by 5e-2 to 0.2 in sheared profiles). Newton takes up to a third fewer - iterations on a light cable in a strong shear (16 instead of 23); the equilibria are unchanged - within the solver tolerance. -- The static start of an `EI = 0` line held above the still-water level kept the buoyancy of its - dry part, while the march (with `WtrDpth` or a bathymetry) gives that part its dry weight. The - start was not the march's equilibrium: a chain hung from 5 m above the surface onto the - seabed moved by 1e-3 of its fairlead load in the first step, and the coupled start differed - from the standalone one by 2.4e-4. The static solve now carries the dry weight (a fixed point - on the wetted lengths): the start holds to 1e-10, the two routes agree to 1.4e-8, and a - vertical chain's end loads sum to its weight to 1.5e-8 (before 1.4 % low). The force balance - of `Connect` and `Free` points and free bodies and rods takes the same dry weight: a 50 t - `Connect` point hung by two chains from 10 m above the surface holds its position to the - output's 8 digits over 2 s (before it sank 1.1e-2 m). There a finite-EI line, carried without - its bending stiffness, takes its dry weight with or without a seabed, as its cubic-Hermite - cable does: a stiff body with a light cable pinned 5 m above the surface on a deck without a - seabed holds its heave to 7e-6 m over 3 s (before it moved 2.8e-3 m), and an `EI = 0` chain - between that body 5 m above the surface and a `Connect` clump holds both to the output's 8 - digits (before 5.5e-3 m). Lines below the surface are unchanged. -- An `EI = 0` line above the still-water level on a deck without a seabed (no `WtrDpth` or - bathymetry) carries its dry weight, and its drag and added mass act on the wetted part only, as - with a seabed and as on a finite-EI line. It was modelled fully submerged up to an end above - the surface, with a warning: a 42 m chain hung wholly above the surface carried 13 % less than - its weight in air, a chain sagging through the surface differed by 7.7 % from the same deck - with a seabed, and a 50 t `Connect` clump hung above the surface started 2 cm off. The march, - the static start and the force balance of points and objects now take the dry weight; the - three agree with the seabed deck exactly and hold their start (`no_seabed_surface`). The - warning is gone. Lines wholly below the surface are unchanged. -- `ATTACHMENTS` above the still-water level kept their buoyancy in the static start of a - finite-EI line, while the march loads them with their weight alone. A 500 kg, 0.2 m^3 module - 3 m above the surface on a cable hung from 5 m above it moved the fairlead load by up to - 6.1 % in the first second, and as much on the same cable restrained in torsion. The - attachment polish and the torsion stage after it now give each attachment the load of its side - of the surface (a fixed point that repeats the solve until none changes side); both starts - hold to the output's 8 digits. An attachment that its weight in air takes below the surface - and its weight in water above it (a net-buoyant module that would float) has no static - position and fails closed, naming the attachment that crossed the surface. -- A bending-pinned finite-EI line with `ATTACHMENTS` from a Rigid6 body or a rod end left its - attachments out of the body static balance, which carries such a line as a cable without - bending stiffness: on a moored body with a 2 t clump 50 m along a pinned cable the body started - at the pose of the line without the clump and drifted by up to 2.9e-2 m and 0.20 deg in 5 s. - Such a line now takes the static passes of a connected end, which balance the body on the - cubic-Hermite cable's end loads; the body holds its pose to the output's 8 digits. Their - passes are Anderson-mixed, as those of a line between two objects, and the core cable of the - passes carries the line's `ATTACHMENTS` smeared, so the passes correct only the lumped, - side-of-the-surface and bending differences: on a free spar rod with a 1500 kg clump on a cable - pinned at its upper end the plain passes on a core cable without the clump diverged (the deck - stopped), and Anderson-mixed ones converged in 26 passes or stopped by round-off (a 1-ulp - change of an anchor coordinate; the Linux build stopped). They now converge in 6, the same - for those 1-ulp changes, and the rod holds its pose to 8 digits. The mixing drops history - columns that add less than 1e-6 of a new direction (1e-10 before), which had let round-off - columns drive the mixed loads to 1e6 N. Across a sweep of the rod deck (clump 0 to 4 t, cable - 50 to 70 m, rod mass, clump position, start offsets, 1-ulp changes) 42 of 45 decks converge - (34 before), the three left with no stable equilibrium found on either core cable. -- A bending-pinned finite-EI line on a Rigid6 body or a rod end without `ATTACHMENTS` was left to - the body static solve's cable without bending stiffness, whose end force lacks the bending's - share: a free spar rod with a 55 m pinned cable (EI 2e4 N m^2) started 5.7e-2 m off its - equilibrium, drifted 7e-2 m in 3 s and moved a leg tension by 2.3 %. Such a line now takes the - static passes too (4 here); the rod holds its pose to the output's 8 digits. -- Diagnostic counts that concurrent models shared: the adaptive-substep fallbacks of an `EI = 0` - system and the assembly and modified-Newton counts of the finite-EI Cosserat solver were - process-wide (and lost increments without OpenMP); they are now kept per system and per solver - workspace. The count of finite-EI intervals recovered by substeps is reported only by the opt-in - run profile (`CABLEDYN_PROFILE`), whose figures stay process-wide by design; each model keeps its - own. No result changes. -- A failing `OPEN` of a file name of about 600 characters or more (the extended-length spelling of - a path beyond the Windows limit) ended an ifx-built program or the wheel's DLL with - `STATUS_STACK_BUFFER_OVERRUN` inside the Intel Fortran run-time, for example an output root in - a folder that does not exist. Every `OPEN` of a user-supplied name now first asks the system - whether the file opens (`CD_Path_Openable`) and reports the failure without attempting the - `OPEN`; the messages are unchanged. -- Concurrent steps of separate handles crashed the ifx builds with access violations: an `EI = 0` - line model passed its load and added-mass callbacks to the integrator as internal procedures, - and ifx calls such a closure through a trampoline kept in memory every thread shares, so two - threads stepping distinct models called each other's half-written trampolines (a 40-line - reproducer crashes with two threads under every ifx option). The model now hands its loads to - the integrator as an object (`CD_Cable_Step_Loads`); results are unchanged. Seven decks - stepped together on 28 threads (`c_api_threads_mixed`) failed every run before and pass 50 of - 50. -- Separate handles used on several threads at once failed in the Windows wheel and the release - binaries (Intel ifx without OpenMP): ifx kept the fixed-size local arrays and `CHARACTER` locals - of every procedure in static storage, which all threads share, so an initialisation that ran - while other handles stepped stopped with "tangent assembly failed" or "band scatter" errors - (gfortran builds were not affected: `-fopenmp` makes every local automatic). Every build now - makes local variables automatic, `/Qauto` (`-auto`) with ifx and `-frecursive` with gfortran, - which `-fopenmp` already implied, so the default gfortran build is unchanged, and so does every - configuration of the OpenFAST Visual Studio project (`LocalVariableStorage`). The release - benchmark decks run as fast or faster (0.3 to 21 %); ifx results change at round-off (with - `/fp:precise` every example is bit-identical). -- 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 - were solved. They are now solved when the module initialises (and, before the first step, at a - committed step-start transfer and in new host fluid fields, so a SeaState current or wave starts - them in that field), and the line ends on a CoupledPinned object move with them. - An object in its static equilibrium changes at round-off (1e-12 m and 1e-6 deg over 10 s); one - started out of balance (`bodyIC deck`) changes by the first step's velocity error, 0.02 m/s and - 0.05 deg for a hanging Pinned rod and up to 0.6 m/s for bodies and rods released far out of - balance. The committed host kinematics at the first step are those of the initial state, so a - host acceleration at `t = 0` enters neither version. -- MoorDyn-F's `inertialF` option was an unknown keyword; `inertialF 1` (CableDyn's behaviour) - is now accepted, and `0` and `2` are rejected by name. -- A Syrope line held at its running maximum (the fairlead pulled out and held) under - `False alpha_force_blend` stopped with "Syrope backward-Euler state solve did not converge": - next to the top sample of the working curve the Newton step's difference quotient straddled - the kink and crept along one side of the bracket. The solve now finishes by bisection there, - and where a light rope's steep residual (BA_s|BA_d = 1e4|1e3) changes sign between two - adjacent reals it returns that root to machine precision. Over 440,000 fuzzed states every - solve that converged before is bit-identical, and the 26 that failed now converge. -- The static start of an `EI = 0` line now carries a deck current that is zero along the - straight chord between its ends but not where the line sags (a depth profile or a current - grid): it was solved in still water and the march drifted toward the current's equilibrium. - On a 70 m rope with its ends at z = -20 m in 0.8 m/s below z = -32 m the start now holds to - machine precision (it drifted 192 N in 4 s) and agrees with the finite-EI route within 0.14 %. - The static tangent takes the current's gradient along the line, so the Newton iteration also - converges in a current sheared across the line. A later `current` row now discards the levels - of an earlier profile row. -- The modal analysis of finite-EI lines ignored the end connections and the discrete - attachments: a clamped end was solved pinned (the first twelve frequencies of the lazy wave - of `torsion_lazy_wave_hangoff_twist.dat`, untwisted, rise by 0.1 % to 3.8 % with its clamps) - 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`. -- Reading a WaterKin `WaveKinFile` no longer slows with the square of its length: the rows grow - by doubling instead of copying the whole record per row. A 10 s run on a 168,000-row record - took 107 s and now takes 3.5 s. -- A weightless or near-neutral taut finite-EI line (a neutrally buoyant cable, a tendon) failed - its static solve, even straight along its chord: the convergence test scaled the residual by - the line's weight alone, far below the round-off of its axial forces. A taut line's scale now - includes the tension its stretched chord implies; slack lines are unchanged. -- The anchor force of a finite-EI line resting on a sloped seabed (`bathymetryFile`). The floor - took the whole downward part of the end force, so a cable laid down the slope from its anchor - lost the down-slope pull: on a 10° slope `AnchTen` read 1.5 % low and `AnchFz`/`Point

Fz` - read 0. The floor now takes only the part pressing into it along its normal, and on a - frictional seabed the along-floor part of the end node's weight up to the friction it can - hold; flat seabeds are unchanged. -- OpenFAST's native `.CD.out` wrote a channel value below 1e-99 or from 1e100 on as a - field of asterisks (`ES15.6E2`): the round-off noise of a zero component, such as the y - position or tangent azimuth of a line in the x-z plane, broke every reader. Channel values now - have a three-digit exponent (`ES15.6E3`, same width). The mixed `EI = 0` + finite-EI `.out`, - the modal results, the static driver's mesh file and the OpenFAST module driver, which wrote - such values without the exponent letter, do too. -- `openfast -restart` with a finite-EI cable continues the run bit for bit. The rebuild moved the - cable's fairlead to the restored input mesh, whose last bits differ from the boundary the - uninterrupted run committed, and the cable's `.CD.out` channels drifted by up to 1e-6 - (relative) within seconds. The checkpoint now carries the cable's committed boundary. -- A finite-EI line longer than its span with no net weight, or too little for its bending - stiffness (0.001 N/m on a 120 m line with `EI` 1e4 N m²), failed its static solve: both routes - reached the compressed straight strut or stalled at the round-off of the axial forces. Such a - line is now solved heavier and carried back to its own weight in the vertical plane of its - chord. A weightless line bows as the Euler elastica (end thrust and bow to 3e-5 of the exact - solution); nothing in the deck chooses the side of its bow, so it is solved bowed downward and - a note says so. With its ends one above the other it is still refused, by name. -- A line along +X reported its tangent azimuth (`LNAzi`, the static profile's `Azimuth`) - at 0 or about 360 from one row to the next as it swayed a fraction of a degree to either - side, or by the sign of a round-off component: in OpenFAST about half the rows of a cable in - the x-z plane read 359.9x. A line whose chord heads within 45° of +X now reports its azimuths - in (−180, 180], every other line in [0, 360) as before. -- The CableDyn-enabled `openfast.exe` named itself `OpenFAST-v5.0.0-dirty`: OpenFAST stamps its - version with `git describe --dirty`, and the integration patches modify the checkout. Built - through the Visual Studio solution or through CMake it now reads - `OpenFAST-v5.0.0-CableDyn-`, the describe of the unpatched OpenFAST base and - the CableDyn version, and the release build fails unless `openfast.exe -v` prints exactly that. +- Thread safety of the Intel builds: concurrent handles crashed (shared closure trampolines, + static local storage), and `CableDyn_Close` paused the OpenMP runtime of the whole process. +- Static starts that failed or depended on round-off: a cable whose End A rests on the seabed, + a lazy wave restrained in torsion in current (at any pretwist, on every BLAS kernel), torsion + between two bodies, neutral, weightless and straight lines, pinned and attachment-carrying + cables on bodies and rods. +- Physics: an `EI = 0` line above the still-water level on a deck without a seabed was modelled + fully submerged (13 % light in air); lines and attachments above the surface now carry their + dry weight in the static start; the anchor force on a sloped seabed; the static start in a + sheared current; modal analysis with end connections and attachments. +- OpenFAST: restarts with a finite-EI cable continue bit for bit; Free and pinned objects start + from their solved acceleration; channel values below 1e-99 no longer print as asterisks. +- Stack overflows of non-static ifx builds and of `FAST.Farm.exe` built with MinGW, and a crash + of the ifx run-time on a failing `OPEN` of a long path. +- Messages that said something untrue (SeaState kinematics, body/rod start moves, deck current + source, torsion twist, FAST.Farm `DT_Mooring`), and a coupled deck mixing bodies and rods now + says where it runs. + +### Upgrading + +- OpenFAST checkpoints written by 0.3.0 for decks with finite-EI lines restrained in torsion do + not reload. +- Decks with torsion need the section's real polar inertia `Irn` (the column was unused). +- Results change beyond round-off on decks with torsion, pinned cables on bodies, coupled + finite-EI cables (the tolerance), coupled runs in a SeaState current (the static start), + `TURBINES` decks with rotated turbines, elevation records with components above `WvHiCOff`, + and `EI = 0` lines above the surface without a seabed. ## [0.3.0] - 2026-10-23 @@ -1291,7 +681,8 @@ Corrections made during the pre-release review. values of the shipped example decks and states which tension (end element or `FairTen` end force) each comparison uses. -[Unreleased]: https://github.com/SMI-Lab-Inha/CableDyn/compare/v0.3.0...HEAD +[Unreleased]: https://github.com/SMI-Lab-Inha/CableDyn/compare/v0.4.0...HEAD +[0.4.0]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.4.0 [0.3.0]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.3.0 [0.2.0]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.2.0 [0.1.1]: https://github.com/SMI-Lab-Inha/CableDyn/releases/tag/v0.1.1 diff --git a/CITATION.cff b/CITATION.cff index da0c3bda..f5681351 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -23,8 +23,8 @@ authors: repository-code: "https://github.com/SMI-Lab-Inha/CableDyn" url: "https://github.com/SMI-Lab-Inha/CableDyn" license: Apache-2.0 -version: 0.3.0 -date-released: 2026-10-23 +version: 0.4.0 +date-released: 2026-11-04 keywords: - mooring dynamics - cable dynamics diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a4b65dd..f6bb883d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,7 @@ # cmake_minimum_required(VERSION 3.20) # VERSION is a bare numeric triple matching the release version. -project(CableDynCore VERSION 0.3.0 LANGUAGES C Fortran +project(CableDynCore VERSION 0.4.0 LANGUAGES C Fortran DESCRIPTION "CableDyn geometrically exact cable/mooring solver — Fortran core") option(CABLEDYN_ENABLE_COVERAGE "Instrument the GNU Fortran core for gcov/gcovr source coverage" OFF) diff --git a/README.md b/README.md index caa9e719..c8581bc1 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ in the MoorDyn v2 format and solves them with two line formulations: - **Finite-bending lines** (finite-EI): cubic-Hermite elements for dynamic power cables, including lazy-wave configurations, with continuous centreline curvature. -The current stable release is `v0.3.0`. Interfaces are +The current stable release is `v0.4.0`. Interfaces are versioned and may change before `1.0.0`. ## Capabilities @@ -32,12 +32,12 @@ versioned and may change before `1.0.0`. | Area | Features | |---|---| | Statics | Catenary seeding, Newton solution, load continuation, mesh sequencing, adaptive meshing | -| Dynamics | Implicit generalised-alpha integration, prescribed support motion, consistent mass, automatic step subdivision | +| Dynamics | Implicit generalised-alpha integration, prescribed support motion, consistent mass, automatic step subdivision, torsion with a twist angle and rotary inertia at every node, cross-flow vortex-induced vibration | | Environment | Buoyancy, Morison drag, added mass, Froude–Krylov loading, regular and irregular waves, current profiles, seabed contact with friction | -| Materials | Linear axial stiffness, Kelvin–Voigt damping, viscoelastic (series-Kelvin; MoorDyn `ElasticMod` 2/3), Syrope polyester model | -| Topology | Fixed, coupled, free, and connected points; clump weights; rigid bodies and rods; end rotational stiffness; active line-length control; line failure | -| Outputs | Effective tension, position, velocity, acceleration, curvature, bending moment, end angles, contact response, solver diagnostics | -| Interfaces | Standalone driver, OpenFAST and FAST.Farm, C ABI, Python package | +| Materials | Linear axial stiffness, Kelvin–Voigt damping, viscoelastic (series-Kelvin; MoorDyn `ElasticMod` 2/3), Syrope polyester model, torsional stiffness with torque–tension coupling, tapered bend stiffeners | +| Topology | Fixed, coupled, free, and connected points; clump weights; buoyancy modules along cables; rigid bodies and rods; end rotational stiffness; cables between two moving ends; active line-length control; line failure | +| Outputs | Effective tension, position, velocity, acceleration, curvature (also on the section's own axes), bending moment, torque and twist, end angles, contact response, natural modes, solver diagnostics | +| Interfaces | Standalone driver, OpenFAST and FAST.Farm (with linearisation of the line dynamics), C ABI, Python package | Section and keyword names follow MoorDyn v2; unsupported combinations stop with a named error rather than running approximately. @@ -51,8 +51,8 @@ a named error rather than running approximately. |---|---| | `CableDyn_driver.exe` | Standalone solver for Windows x64 (AVX2 processor) | | `openfast.exe` | OpenFAST with CableDyn available as `CompMooring = 5` | - | `cabledyn-0.3.0-py3-none-any.whl` | Python package (pre- and post-processing, batch runs) | - | `cabledyn-0.3.0.tar.gz` | Python source distribution | + | `cabledyn-0.4.0-py3-none-any.whl` | Python package (pre- and post-processing, batch runs) | + | `cabledyn-0.4.0.tar.gz` | Python source distribution | | `SHA256SUMS.txt` | Checksums for the assets above | Both executables are statically linked, need no installer, compiler, or runtime @@ -90,7 +90,7 @@ a named error rather than running approximately. cabledyn-run examples\wd0050_chain.dat wd0050 ``` - The pure Python wheel on the release page (`cabledyn-0.3.0-py3-none-any.whl`) + The pure Python wheel on the release page (`cabledyn-0.4.0-py3-none-any.whl`) carries no driver: `cabledyn-run` then needs `--executable .\CableDyn_driver.exe`, the `CABLEDYN_DRIVER` environment variable, or the driver on `PATH`. A source build names the driver `cabledyn` (see [Build from source](#build-from-source)); @@ -157,7 +157,7 @@ If you use CableDyn in academic work, please cite: > offshore wind. *Ocean Engineering* 368 (Part 2), 128332, 2026. > -To identify the software version, also cite the release (CableDyn 0.3.0). +To identify the software version, also cite the release (CableDyn 0.4.0). The [citation file](https://cabledyn.readthedocs.io/en/latest/citing.html) contains both entries (GitHub **Cite this repository**); BibTeX is on the manual's [How to cite](https://cabledyn.readthedocs.io/en/latest/citing.html) page. diff --git a/RELEASE.md b/RELEASE.md index 57f76a2b..11714b5a 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -104,7 +104,7 @@ The build fails if either executable imports a non-system DLL or lacks the UTF-8 active-code-page manifest (`release/check_static_windows_binary.ps1`), or if the standalone and `CompMooring = 5` smoke cases fail with a system-only `PATH` or from a folder named in mixed scripts. It also fails unless `openfast.exe -v` names the -executable `OpenFAST-v5.0.0-CableDyn-0.3.0`: the OpenFAST base and the CableDyn version, +executable `OpenFAST-v5.0.0-CableDyn-0.4.0`: the OpenFAST base and the CableDyn version, never a `-dirty` describe of the patched tree. The release workflow (`.github/workflows/release-windows-static.yml`) produces @@ -140,7 +140,7 @@ python release/smoke_test_wheel.py examples/dynamic_chain_current.dat --expect-b Tag only the commit that passed every check: ```powershell -$ReleaseVersion = "0.2.0" +$ReleaseVersion = "0.4.0" git tag -s "v$ReleaseVersion" -m "CableDyn v$ReleaseVersion" git push origin "v$ReleaseVersion" ``` diff --git a/doc/capi.rst b/doc/capi.rst index 3f582ec8..5fac1f83 100644 --- a/doc/capi.rst +++ b/doc/capi.rst @@ -116,12 +116,12 @@ files directly, as shown below. - Library files - Header * - Linux - - ``lib/libcabledyn.so.0.3.0``, the soname link ``libcabledyn.so.1``, and the development + - ``lib/libcabledyn.so.0.4.0``, the soname link ``libcabledyn.so.1``, and the development link ``libcabledyn.so``. ``lib`` is the platform ``CMAKE_INSTALL_LIBDIR``, which can be ``lib64`` or a multiarch directory. - ``include/CableDyn_CAPI.h`` * - macOS - - ``lib/libcabledyn.0.3.0.dylib``, ``lib/libcabledyn.1.dylib``, ``lib/libcabledyn.dylib`` + - ``lib/libcabledyn.0.4.0.dylib``, ``lib/libcabledyn.1.dylib``, ``lib/libcabledyn.dylib`` - ``include/CableDyn_CAPI.h`` * - Windows, GNU toolchain - ``bin/libcabledyn.dll`` and the import library ``lib/libcabledyn.dll.a``. The GNU @@ -251,7 +251,7 @@ ABI and versioning - the same four numbers, reported by the loaded library * - ``CableDyn_GetVersionString`` - runtime - - ``"CableDyn 0.3.0 C-ABI 1"`` + - ``"CableDyn 0.4.0 C-ABI 1"`` * - shared-library ``SOVERSION`` - 1 - soname ``libcabledyn.so.1`` or install name ``libcabledyn.1.dylib``. The Windows DLL @@ -770,7 +770,7 @@ Version queries - ``char *`` - ``version_len`` - yes: no-op - - receives ``"CableDyn 0.3.0 C-ABI 1"``, truncated to ``version_len - 1`` characters and + - receives ``"CableDyn 0.4.0 C-ABI 1"``, truncated to ``version_len - 1`` characters and ``NUL``-terminated * - ``version_len`` - in diff --git a/doc/citing.rst b/doc/citing.rst index bde7a978..eb5be3a5 100644 --- a/doc/citing.rst +++ b/doc/citing.rst @@ -37,7 +37,7 @@ Software release ---------------- Seo, J. H. (2026). *CableDyn: Geometrically exact finite-element statics and dynamics of -mooring lines and dynamic power cables for floating offshore wind* (version 0.3.0) [Computer +mooring lines and dynamic power cables for floating offshore wind* (version 0.4.0) [Computer software]. https://github.com/SMI-Lab-Inha/CableDyn .. code-block:: bibtex @@ -46,14 +46,14 @@ software]. https://github.com/SMI-Lab-Inha/CableDyn author = {Seo, Jae Hoon}, title = {{CableDyn}: Geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables for floating offshore wind}, - version = {0.3.0}, + version = {0.4.0}, year = {2026}, url = {https://github.com/SMI-Lab-Inha/CableDyn}, license = {Apache-2.0} } When results depend on a particular release, quote the version reported in the solver banner -(``CableDyn v0.3.0``) together with the options recorded for the run. +(``CableDyn v0.4.0``) together with the options recorded for the run. Relation to the journal article ------------------------------- diff --git a/doc/coupling_boundary.md b/doc/coupling_boundary.md index d2276308..16950b31 100644 --- a/doc/coupling_boundary.md +++ b/doc/coupling_boundary.md @@ -77,8 +77,9 @@ on `t + dt` and the host time grid is unchanged. In OpenFAST the module may adva The public header declares the complete interface of C ABI version 1, including the object queries of its minor extension 1 (ABI 1.1; check `CableDyn_GetAbiMinor() >= 1` before calling -them) and the host-coupling calls of its minor extension 2 (ABI 1.2; check -`CableDyn_GetAbiMinor() >= 2`). Signatures and examples are in the [C API guide](capi.rst), +them), the host-coupling calls of its minor extension 2 (ABI 1.2; check +`CableDyn_GetAbiMinor() >= 2`) and the host-rotation calls of its minor extension 3 (ABI 1.3; +check `CableDyn_GetAbiMinor() >= 3`). Signatures and examples are in the [C API guide](capi.rst), whose section "Coupling a host (CFD) solver" gives the call sequence of a CFD host. | Group | Functions | @@ -91,6 +92,7 @@ whose section "Coupling a host (CFD) solver" gives the call sequence of a CFD ho | Queries | `CableDyn_NCoupledDOF`, `CableDyn_NPoints`, `CableDyn_NLines`, `CableDyn_GetLastError` | | Object queries (ABI 1.1) | `CableDyn_GetAbiMinor`, `CableDyn_NObjects`, `CableDyn_GetObjectInfo`, `CableDyn_GetLineValues`, `CableDyn_GetPointState`, `CableDyn_GetBodyState`, `CableDyn_GetRodState`, `CableDyn_EvalChannel`: the model's lines, points, bodies and rods, their committed state, and any `OUTPUTS` channel | | Host coupling (ABI 1.2) | `CableDyn_InitDeckAt` (`CableDyn_InitDeck` with the statics solved at the host's positions of the `Coupled` points), `CableDyn_SaveState`, `CableDyn_RestoreState` (a one-slot in-memory save of the whole model for outer correctors), `CableDyn_GetCoupledLayout` (the deck point id and type of every block of the coupled vector) | +| Host rotations (ABI 1.3) | `CableDyn_InitDeckRotating` (`CableDyn_InitDeck` for a host that turns its coupled points, so torsion and `Rigid` end connections turn with it), `CableDyn_UpdateRotations` (each coupled point's global-to-body DCM, angular velocity and acceleration), `CableDyn_GetCoupledMoments` (the moments the lines apply to the host) | Rules shared by every entry point: @@ -110,7 +112,7 @@ Rules shared by every entry point: The interface ships as the versioned shared library `libcabledyn` (`cabledyn.dll` in an Intel Fortran and MSVC build; CMake target `cabledyn_shared`) with the installed header; it reports -CableDyn 0.3.0 and C ABI version 1, minor extension 2. The Python package uses the same library. +CableDyn 0.4.0 and C ABI version 1, minor extension 3. The Python package uses the same library. ### Concurrency diff --git a/doc/index.rst b/doc/index.rst index fa0d24ad..121a98d7 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -14,7 +14,7 @@ with MoorDyn-C, MoorDyn-F, and OrcaFlex on common reference cases. .. admonition:: Release status :class: note - CableDyn ``v0.3.0`` is the current stable release. It is on PyPI with wheels that carry the + CableDyn ``v0.4.0`` is the current stable release. It is on PyPI with wheels that carry the solver (``pip install cabledyn``), runs 13-33 % faster in the release build, extrapolates the coupled loads between OpenFAST solves at a ``dtM`` above ``DT``, restarts bit for bit at any ``dtM``, and recovers node tension through touchdown on coarse meshes. @@ -53,8 +53,8 @@ Download to first result in five minutes ---------------------------------------- #. Download ``CableDyn_driver.exe``, ``SHA256SUMS.txt``, and **Source code (zip)** (for the - ``examples`` folder) from the `v0.3.0 release - `_ and verify the checksum — + ``examples`` folder) from the `v0.4.0 release + `_ and verify the checksum — :doc:`installation`. No installer and no runtime DLLs. #. Put ``CableDyn_driver.exe`` in a working folder, unzip the source archive, and copy its ``examples`` folder next to the executable. diff --git a/doc/installation.rst b/doc/installation.rst index c264d5a9..1bc8b1e6 100644 --- a/doc/installation.rst +++ b/doc/installation.rst @@ -6,8 +6,8 @@ Installation There are two ways to get CableDyn: * **Windows release (recommended for users).** Two single-file executables and a Python wheel, - attached to the `v0.3.0 GitHub release - `_. No installer, no compiler, + attached to the `v0.4.0 GitHub release + `_. No installer, no compiler, and no runtime DLLs. Start here if you want a first result in five minutes. * **Build from source** (Windows, Linux, macOS). Needed for the C/Python in-process API, for development, and on every platform other than Windows x64. @@ -35,11 +35,11 @@ What is on the release page - OpenFAST v5.0.0 (maintained by NLR, the National Laboratory of the Rockies, formerly NREL) with CableDyn built in as ``CompMooring = 5``; stock MoorDyn (``CompMooring = 3``) is still available in the same binary (:doc:`openfast`). It names - itself ``OpenFAST-v5.0.0-CableDyn-0.3.0`` (``openfast.exe -v`` and the start of every run). - * - ``cabledyn-0.3.0-py3-none-any.whl`` + itself ``OpenFAST-v5.0.0-CableDyn-0.4.0`` (``openfast.exe -v`` and the start of every run). + * - ``cabledyn-0.4.0-py3-none-any.whl`` - the pure-Python package: deck editing, case generation, driver automation, result readers, fatigue and spectral post-processing (:doc:`python`) - * - ``cabledyn-0.3.0.tar.gz`` + * - ``cabledyn-0.4.0.tar.gz`` - the Python source distribution (same package as the wheel) * - ``SHA256SUMS.txt`` - SHA-256 checksums of the four files above @@ -65,7 +65,7 @@ Download and verify ~~~~~~~~~~~~~~~~~~~ 1. Create a folder, for example ``C:\CableDyn``, and download into it ``CableDyn_driver.exe``, - ``openfast.exe`` (only if you will couple with OpenFAST), ``cabledyn-0.3.0-py3-none-any.whl`` + ``openfast.exe`` (only if you will couple with OpenFAST), ``cabledyn-0.4.0-py3-none-any.whl`` (only if you will use Python), ``SHA256SUMS.txt``, and ``Source code (zip)``. 2. Verify every downloaded asset against ``SHA256SUMS.txt`` in PowerShell: @@ -85,8 +85,8 @@ Download and verify OK CableDyn_driver.exe OK openfast.exe - OK cabledyn-0.3.0-py3-none-any.whl - not downloaded cabledyn-0.3.0.tar.gz + OK cabledyn-0.4.0-py3-none-any.whl + not downloaded cabledyn-0.4.0.tar.gz ``not downloaded`` only reports an asset you chose to skip. @@ -95,7 +95,7 @@ Download and verify ``(Get-FileHash .\CableDyn_driver.exe -Algorithm SHA256).Hash`` with its line in ``SHA256SUMS.txt`` (the comparison is case-insensitive). -3. Unzip ``Source code (zip)``. It expands to a folder such as ``CableDyn-0.3.0``; copy (or move) +3. Unzip ``Source code (zip)``. It expands to a folder such as ``CableDyn-0.4.0``; copy (or move) its ``examples`` folder into ``C:\CableDyn`` so the layout is:: C:\CableDyn\ @@ -121,7 +121,7 @@ Check that it runs .. code-block:: text =================================================================== - CableDyn v0.3.0 + CableDyn v0.4.0 Geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables for floating offshore wind ------------------------------------------------------------------- @@ -177,8 +177,8 @@ the CableDyn shared library and the standalone driver, so the package runs decks release executables. On another platform pip builds from the source distribution, which needs a Fortran compiler and LAPACK. -The pure Python wheel on the release page (``cabledyn-0.3.0-py3-none-any.whl``) carries no -solver; install it with ``py -m pip install .\cabledyn-0.3.0-py3-none-any.whl``. The package +The pure Python wheel on the release page (``cabledyn-0.4.0-py3-none-any.whl``) carries no +solver; install it with ``py -m pip install .\cabledyn-0.4.0-py3-none-any.whl``. The package finds the driver in this order: #. an explicit path, ``CableDynDriver(r"C:\CableDyn\CableDyn_driver.exe")`` or @@ -202,7 +202,7 @@ Check the installation from a new terminal: .. code-block:: text - 0.3.0 C:\CableDyn\CableDyn_driver.exe + 0.4.0 C:\CableDyn\CableDyn_driver.exe The in-process API (``cabledyn.CableDyn``, stepping the solver from Python without a subprocess) additionally needs the shared library from a source build; see :doc:`python`. @@ -273,7 +273,7 @@ The script downloads the LAPACK source from its release tag and verifies its SHA integration to OpenFAST itself (do not pre-apply it), builds both executables, rejects any non-system DLL import, runs a standalone and a coupled ``CompMooring = 5`` / ``CompMooring = 3`` smoke case with a system-only ``PATH``, and writes -``SHA256SUMS.txt`` into ``build-static-release\dist``. The v0.3.0 assets were built from +``SHA256SUMS.txt`` into ``build-static-release\dist``. The v0.4.0 assets were built from OpenFAST revision ``2895884d2be01862173c88d70f86b358d2f1a50a`` and smoke-tested against ``r-test`` revision ``dd5feaaaa500ba7283140107806300d551cff0a7``. diff --git a/doc/openfast.rst b/doc/openfast.rst index 462fe6e7..9fd39544 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -217,7 +217,7 @@ Run and confirm Before trusting a run, confirm in the console: -#. ``Running CableDyn (v0.3.0, ...)`` and ``Parsing CableDyn input file: ``; +#. ``Running CableDyn (v0.4.0, ...)`` and ``Parsing CableDyn input file: ``; #. the ``dtM`` line and the model inventory (``Created CableDyn model: ... line object(s)``); #. for every line, the converged fairlead effective tension, force vector, inclination, declination, and azimuth at the static equilibrium — printed unconditionally, whether or not diff --git a/doc/quickstart.rst b/doc/quickstart.rst index 8d35cbed..d9d43faa 100644 --- a/doc/quickstart.rst +++ b/doc/quickstart.rst @@ -18,7 +18,7 @@ and the ``examples`` folder (from the release's **Source code (zip)**) side by s .. code-block:: powershell Set-Location C:\CableDyn - .\CableDyn_driver.exe --version # prints the v0.3.0 banner, exit code 0 + .\CableDyn_driver.exe --version # prints the v0.4.0 banner, exit code 0 2. Solve a mooring line ----------------------- @@ -38,7 +38,7 @@ The run takes well under a second: .. code-block:: text =================================================================== - CableDyn v0.3.0 + CableDyn v0.4.0 Geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables for floating offshore wind ------------------------------------------------------------------- diff --git a/doc/tutorial_openfast.rst b/doc/tutorial_openfast.rst index 156ce2f6..b0a0ea9f 100644 --- a/doc/tutorial_openfast.rst +++ b/doc/tutorial_openfast.rst @@ -168,7 +168,7 @@ The CableDyn part of the console (other modules' lines trimmed): .. code-block:: text - Running CableDyn (v0.3.0, 2026-10-23). + Running CableDyn (v0.4.0, 2026-11-04). CableDyn: geometrically exact finite-element statics and dynamics of mooring lines and dynamic power cables. ... CableDyn time step dtM = 2.50000E-02 s (1 x glue DT; deck dtM) diff --git a/examples/openfast/README.md b/examples/openfast/README.md index 3877ae62..5054654d 100644 --- a/examples/openfast/README.md +++ b/examples/openfast/README.md @@ -70,7 +70,7 @@ Grid sizing is described in the manual's OpenFAST page (SeaState grid). .\openfast.exe IEA-15-UMaine_CompMooring3_MoorDyn.fst # MoorDyn ``` -The CableDyn run log identifies the module with `Running CableDyn (v0.3.0, 2026-10-23)` and +The CableDyn run log identifies the module with `Running CableDyn (v0.4.0, 2026-11-04)` and prints the converged fairlead state of each line, as the standalone driver does: ```text diff --git a/integration/openfast/README.md b/integration/openfast/README.md index 9cc201ac..037a63d9 100644 --- a/integration/openfast/README.md +++ b/integration/openfast/README.md @@ -9,7 +9,7 @@ who only run coupled cases should use the released `openfast.exe` and the The patches in [`patches/`](patches/) apply to the public OpenFAST upstream commit `2895884d2be01862173c88d70f86b358d2f1a50a` (the OpenFAST v5.0.0 release, used by -CableDyn v0.3.0). They add only the OpenFAST host integration; the CableDyn sources come from +CableDyn v0.4.0). They add only the OpenFAST host integration; the CableDyn sources come from this repository. | File | Purpose | @@ -67,7 +67,7 @@ ifx default, `/fp:fast`, may reassociate sums and flush subnormals to zero. OpenFAST names its version with `git describe --dirty`, which would read `v5.0.0-dirty` on the patched tree. A CableDyn-enabled executable names itself `OpenFAST--CableDyn-` instead, here -`OpenFAST-v5.0.0-CableDyn-0.3.0` (printed by `openfast.exe -v` and at the start of every run). +`OpenFAST-v5.0.0-CableDyn-0.4.0` (printed by `openfast.exe -v` and at the start of every run). The OpenFAST part is `git describe --tags --abbrev=8` of the checked-out commit, the unpatched base; the CableDyn part is the project version in the CableDyn `CMakeLists.txt`. Patch `0021` sets it in the CMake build, and `integrate_openfast_vs_solution.ps1` in the diff --git a/pyproject.toml b/pyproject.toml index 4b6ea160..b11093ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,7 +12,7 @@ build-backend = "scikit_build_core.build" [project] name = "cabledyn" -version = "0.3.0" +version = "0.4.0" description = "Python tools for CableDyn, a geometrically exact finite-element solver for mooring lines and dynamic power cables" readme = "python/README.md" requires-python = ">=3.10" diff --git a/python/README.md b/python/README.md index 3941ae29..1e094cc4 100644 --- a/python/README.md +++ b/python/README.md @@ -25,7 +25,7 @@ Fortran compiler and LAPACK. The pure Python wheel attached to each [GitHub release](https://github.com/SMI-Lab-Inha/CableDyn/releases/latest) -(`cabledyn-0.3.0-py3-none-any.whl`) carries no solver. `CableDynDriver` finds the +(`cabledyn-0.4.0-py3-none-any.whl`) carries no solver. `CableDynDriver` finds the driver from an explicit path, then the `CABLEDYN_DRIVER` environment variable, then the driver inside the package, then `PATH`; the in-process `CableDyn` class uses the library inside the package, or one named by `CABLEDYN_LIBRARY` or found in diff --git a/python/cabledyn/__init__.py b/python/cabledyn/__init__.py index fd926e14..26720afd 100644 --- a/python/cabledyn/__init__.py +++ b/python/cabledyn/__init__.py @@ -282,7 +282,7 @@ "upcrossing_maxima", ] -__version__ = "0.3.0" +__version__ = "0.4.0" def __getattr__(name: str) -> Any: diff --git a/python/pyproject.toml b/python/pyproject.toml index 9d12e9f6..d487c85f 100644 --- a/python/pyproject.toml +++ b/python/pyproject.toml @@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta" [project] name = "cabledyn" -version = "0.3.0" +version = "0.4.0" description = "Python tools for CableDyn, a geometrically exact finite-element solver for mooring lines and dynamic power cables" readme = "README.md" requires-python = ">=3.10" diff --git a/release/check_release_metadata.py b/release/check_release_metadata.py index e3e44e8d..ae9172e7 100644 --- a/release/check_release_metadata.py +++ b/release/check_release_metadata.py @@ -26,8 +26,8 @@ def capture(relative_path: str, pattern: str, label: str) -> str: return match.group(1) -# Spellings that name a CableDyn release: "CableDyn 0.3.0", "CableDyn v0.3.0", "v0.3.0", -# "cabledyn-0.3.0-py3-none-any.whl", ".../releases/tag/v0.3.0" and "libcabledyn.so.0.3.0". +# Spellings that name a CableDyn release: "CableDyn 0.4.0", "CableDyn v0.4.0", "v0.4.0", +# "cabledyn-0.4.0-py3-none-any.whl", ".../releases/tag/v0.4.0" and "libcabledyn.so.0.4.0". VERSION_REFERENCE = re.compile( r"(?i)(?:cabledyn[ _-]+v?|cabledyn-|releases/tag/v|libcabledyn\.(?:so\.)?|(? Minor extension level of ABI 1: 1 adds the in-process object queries, 2 the host-coupling !> calls (initialization at host positions, state save/restore, the coupled layout query), 3 !> the host rotations (initialization for a host that turns its coupled points, their @@ -2000,7 +2000,7 @@ SUBROUTINE CableDyn_UpdateRotations(handle, dcm_ptr, omega_ptr, alpha_ptr, n_blo 'with CableDyn_InitDeckRotating)', err_stat) RETURN END IF - IF (n_block < 0_C_INT .OR. n_block > HUGE(n_block)/9_C_INT) THEN + IF (n_block < 0_C_INT .OR. 9_INT64*INT(n_block, INT64) > INT(HUGE(n_block), INT64)) THEN CALL set_status(h, CD_C_BAD_INPUT, 'CableDyn_UpdateRotations: n_block does not match '// & 'CableDyn_NCoupledDOF / 3', err_stat) RETURN diff --git a/src/CableDyn_CAPI.h b/src/CableDyn_CAPI.h index 484be890..2ce3bef7 100644 --- a/src/CableDyn_CAPI.h +++ b/src/CableDyn_CAPI.h @@ -44,7 +44,7 @@ #define CD_C_NOT_INITIALIZED 5 #define CABLEDYN_CAPI_VERSION_MAJOR 0 -#define CABLEDYN_CAPI_VERSION_MINOR 3 +#define CABLEDYN_CAPI_VERSION_MINOR 4 #define CABLEDYN_CAPI_VERSION_PATCH 0 #define CABLEDYN_CAPI_ABI_VERSION 1 diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 7290b004..c86ee353 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -26815,6 +26815,7 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l CYCLE END IF unstable = .FALSE. + kbad = 0 IF (MAXVAL(ABS(r)) <= 1.0e-6_wp*sc) unstable = .NOT. equilibrium_stable(kbad) IF (phase == 1 .AND. (unstable .OR. MAXVAL(ABS(r)) > 1.0e-6_wp*sc) .AND. ANY(ndof(1:nobj) > 3)) THEN phase = 2 @@ -27794,7 +27795,7 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) CALL CD_Static_Line_Dry_Load(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%dry_wl, opts%rhoW, opts%g, lc(jl)%dry_d, & f_dry, es_l, em_l) IF (es_l /= CD_STATIC_OK) conv = .FALSE. - IF (conv .AND. ANY(f_dry /= CD_ZERO)) THEN + IF (conv .AND. ANY(ABS(f_dry) > CD_ZERO)) THEN conv = .FALSE. DO kd = 1, 50 q_prev = q @@ -28135,7 +28136,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, REAL(wp), ALLOCATABLE :: ext_fm(:, :), new_fm(:, :), fs(:, :), ext_km(:, :, :), ext_rot(:, :, :) REAL(wp), ALLOCATABLE :: new_km(:, :, :), new_rot(:, :, :), fsb(:, :) INTEGER :: j, pa, e, pass, ncl, eworst, pb, ne, nb - LOGICAL :: only_points, held + LOGICAL :: only_points, held, on_object ! the passes are Anderson-mixed (lines between two objects, pinned lines with ATTACHMENTS) LOGICAL :: mix ! the lines the core solve carries (lines_core: with or without their ATTACHMENTS), the @@ -28167,7 +28168,9 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, 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 + on_object = starts_with(TRIM(points(pb)%ptype), 'body') + IF (.NOT. on_object) on_object = is_rod_point_type(points(pb)%ptype) + IF (on_object) THEN cl = [cl, j] clb = [clb, j] CYCLE @@ -28201,8 +28204,11 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, REAL(wp) :: rclamp(3, 3), dclamp(3) 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.) + IF (ErrStat == CD_DECKDRV_OK) THEN + IF (connected_end(cl(e), .TRUE.)) & + CALL clamp_object_frame(lines(cl(e)), points, bodies, rods, rclamp, dclamp, ErrStat, ErrMsg, & + end_b=.TRUE.) + END IF END BLOCK IF (ErrStat /= CD_DECKDRV_OK) RETURN END DO @@ -28275,6 +28281,10 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, ext_rot(2, 2, e) = CD_ONE ext_rot(3, 3, e) = CD_ONE END DO + ! defined if no pass runs (the passes then report that they did not converge) + scale = CD_ONE + change = HUGE(CD_ONE) + eworst = 1 DO pass = 1, max_pass_eff bodies = bodies0 rods = rods0 @@ -28461,7 +28471,9 @@ LOGICAL FUNCTION connected_end(jl, at_b) RESULT(yes) 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 + IF (.NOT. starts_with(TRIM(points(ip)%ptype), 'body')) THEN + IF (.NOT. is_rod_point_type(points(ip)%ptype)) RETURN + END IF 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 @@ -38207,7 +38219,8 @@ LOGICAL FUNCTION end_b_holds_frame(ptype) RESULT(ok) !! 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) + starts_with(TRIM(ptype), 'body') + IF (.NOT. ok) ok = is_rod_point_type(ptype) END FUNCTION end_b_holds_frame LOGICAL FUNCTION endpoint_type_supported_dynamic(ptype) RESULT(ok) diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 6c030390..6b16ccbe 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -7047,7 +7047,7 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom IF (PRESENT(curvature_vector) .AND. section_moment/model%EI(e) > curvature) & curvature_vector = m_perp/model%EI(e) curvature = MAX(curvature, section_moment/model%EI(e)) - IF (model%EI_line(e) == model%EI(e)) THEN + IF (ABS(model%EI_line(e) - model%EI(e)) <= CD_ZERO) THEN cable_moment = MAX(cable_moment, section_moment) ELSE cable_moment = MAX(cable_moment, model%EI_line(e)*(section_moment/model%EI(e))) @@ -7060,7 +7060,7 @@ SUBROUTINE node_values(model, node, fm, mm, fp, mp, tension, curvature, bend_mom END IF IF (PRESENT(curvature_vector) .AND. trace > curvature) curvature_vector = kv curvature = MAX(curvature, trace) - IF (model%EI_line(e) == model%EI(e)) THEN + IF (ABS(model%EI_line(e) - model%EI(e)) <= CD_ZERO) THEN cable_moment = MAX(cable_moment, section_moment) ELSE cable_moment = MAX(cable_moment, model%EI_line(e)*trace) @@ -9167,7 +9167,7 @@ SUBROUTINE assemble_twist(model, q_cfg, v_cfg, want_residual, want_tangent, R, K IF (want_residual) model%tw_R = CD_ZERO model%tw_tsum = CD_ZERO om = MERGE(model%tw_som, model%tw_om, model%tors_use_step) - turning = ANY(om /= CD_ZERO) .AND. ALLOCATED(model%torsion%bt) + turning = ANY(ABS(om) > CD_ZERO) .AND. ALLOCATED(model%torsion%bt) DO e = 1, model%ne kd = CD_ZERO IF (ALLOCATED(model%torsion%bt)) kd = model%torsion%bt(e)/model%l0(e) @@ -9654,7 +9654,7 @@ SUBROUTINE tw_frame_rates(model, dt) model%tw_som = CD_ZERO IF (.NOT. dt > CD_ZERO) RETURN DO k = 1, 2 - IF (ALL(model%tors_step_ends(:, 2*k - 1:2*k) == model%torsion%ends(:, 2*k - 1:2*k))) CYCLE + IF (ALL(ABS(model%tors_step_ends(:, 2*k - 1:2*k) - model%torsion%ends(:, 2*k - 1:2*k)) <= CD_ZERO)) CYCLE r0(:, 1:2) = model%torsion%ends(:, 2*k - 1:2*k) r0(:, 3) = tw_cross(r0(:, 1), r0(:, 2)) r1(:, 1:2) = model%tors_step_ends(:, 2*k - 1:2*k) diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 6fd697ba..5afd5b3e 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -1698,7 +1698,7 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh CALL dry_recovery(q, f_dry) IF (ErrStat /= CD_STATIC_OK) RETURN ! fully submerged: no recovery, the solution stands as solved - IF (ALL(f_dry == CD_ZERO)) RETURN + IF (ALL(ABS(f_dry) <= CD_ZERO)) RETURN f_scale = MAXVAL(ABS(f_ext)) n_it = report%n_iter DO k = 1, DRY_MAX diff --git a/src/openfast/CableDyn_OF.f90 b/src/openfast/CableDyn_OF.f90 index 7e817107..14bb6997 100644 --- a/src/openfast/CableDyn_OF.f90 +++ b/src/openfast/CableDyn_OF.f90 @@ -141,7 +141,7 @@ MODULE CableDyn ! the kinds of first-order linearization state (lin_state_map) INTEGER(IntKi), PARAMETER :: LIN1_VE = 1, LIN1_SYROPE = 2 - TYPE(ProgDesc), PARAMETER :: CableDyn_ProgDesc = ProgDesc( 'CableDyn', 'v0.3.0', '2026-10-23' ) + TYPE(ProgDesc), PARAMETER :: CableDyn_ProgDesc = ProgDesc( 'CableDyn', 'v0.4.0', '2026-11-04' ) INTERFACE ! 1 when the CableDyn core targets x86-64-v3 (CABLEDYN_TARGET_AVX2) and carries the ! start-up processor check of src/cabledyn_cpu_guard.c; the reference also keeps that diff --git a/tests/test_c_api.f90 b/tests/test_c_api.f90 index 2b9c3691..03decc8b 100644 --- a/tests/test_c_api.f90 +++ b/tests/test_c_api.f90 @@ -58,7 +58,7 @@ SUBROUTINE case_version() abi_version = -1_C_INT msg = 'x' CALL CableDyn_GetVersion(major, minor, patch, abi_version) - CALL require(major == 0_C_INT .AND. minor == 3_C_INT .AND. patch == 0_C_INT .AND. abi_version == 1_C_INT, & + CALL require(major == 0_C_INT .AND. minor == 4_C_INT .AND. patch == 0_C_INT .AND. abi_version == 1_C_INT, & 'c-api-version:tuple') CALL CableDyn_GetVersionString(C_LOC(msg), INT(SIZE(msg), C_INT)) CALL require(INDEX(c_text(msg), 'CableDyn') == 1 .AND. INDEX(c_text(msg), 'C-ABI 1') > 0, & diff --git a/validation/experiments/holcombe/provenance.json b/validation/experiments/holcombe/provenance.json index 9836b3d6..b0b380c9 100644 --- a/validation/experiments/holcombe/provenance.json +++ b/validation/experiments/holcombe/provenance.json @@ -1,8 +1,8 @@ { - "CableDyn_release": "v0.3.0", - "validation_date": "2026-10-23", + "CableDyn_release": "v0.4.0", + "validation_date": "2026-11-03", "executable_name": "cabledyn.exe", - "executable_sha256": "5f1d3b15b414ce7b7eb884db76e50901da6a0094c5548489f58cbfed7ac0546a", + "executable_sha256": "d6603f989f41b01e7921dc52c1c9e580182208c99b45e6ebdd93377b4cbc289f", "compiler": "GNU Fortran 16.2.0", "build_type": "Release", "platform": "Windows 11 x86-64", From 7e16590378c57bc434a5da5de5d4467c604c8a0c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Tue, 3 Nov 2026 22:58:25 +0900 Subject: [PATCH 38/51] chore(release): rerun the Bergdahl record with 0.4.0 The 30 primary conditions and the four refinement runs were rerun with the 0.4.0 GNU Release build. The line's upper end lies 0.3 m above the still-water level, so 0.4.0's dry weight of the part above the surface changes the results: RMSE 1.583 to 1.577 N, MAPE 3.13 % to 3.11 %, mean bias +0.46 to +0.47 N (Pearson 0.993 and Lin 0.989 unchanged); the refinement differences are 0.29 % (mesh) and 0.27 % (step), and the 0.625 ms maxima lie 1.2 % above the converged ones (2.4 % before). The waveform comparison was not rerun: the supplement's expData.dat was not available. Its files and metrics stay those of the 0.3.0 run, which provenance.json, the README and VALIDATION.md state; so are the `off ei0_substeps` and 1.25 ms figures the record quotes. Signed-off-by: Jae Hoon Seo --- VALIDATION.md | 15 ++--- validation/experiments/bergdahl/README.md | 20 ++++--- .../bergdahl/aggregate_metrics.json | 18 +++--- .../bergdahl/comparison_summary.csv | 60 +++++++++---------- .../experiments/bergdahl/provenance.json | 18 +++--- .../bergdahl/refinement_summary.csv | 4 +- .../bergdahl/refinement_summary.json | 40 ++++++------- 7 files changed, 91 insertions(+), 84 deletions(-) diff --git a/VALIDATION.md b/VALIDATION.md index 4143f3a5..05a2b0a4 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -80,7 +80,7 @@ article's methods, are compared in | **L3-7** | 1-hour VolturnUS-S mooring dynamic | OrcaFlex 11.6d | `FairTen` mean 0.27%, std 0.26%, min/max 0.50/0.43%, Fourier 0.27/1.14% | ≤5% | Pass | | **L3-8** | Bend stiffener at a clamped hang-off (5 m tapered polyurethane) | OrcaFlex 11.6d (stiffener attachment) / planar elastica | curvature 0.74% of root; cable moment 0.74%, section moment 0.18%, deflection angle 0.003° | <1.5% / <2%, 0.05° | Pass | | **L3-H** | Holcombe static lazy-wave experiment | measured marker geometry | position RMSE 1.07–1.89% of suspended length; peak marker-curvature error 0.34–5.54% | end-restraint bracket | Pass | -| **L3-B** | Bergdahl chain experiment, 30 orbit conditions | measured upper-end force | RMSE 1.58 N; MAPE 3.13%; Pearson 0.993; Lin concordance 0.989 | full published matrix | Pass | +| **L3-B** | Bergdahl chain experiment, 30 orbit conditions | measured upper-end force | RMSE 1.58 N; MAPE 3.11%; Pearson 0.993; Lin concordance 0.989 | full published matrix | Pass | | **L-fig** | Along-arc curvature overlay (CableDyn / OrcaFlex / MoorDyn-F ±4×) | 3-code committed record | CableDyn peak 0.11% from OrcaFlex | <0.5% | Pass | | **L4-1** | Coupled platform + mooring | synthetic reference | bit-for-bit | — | Pass | | **L4-1b** | VolturnUS-S coupled platform + power cable | OpenFAST v5.0.0 (CompMooring 5 vs 3) | platform DOFs <0.6% (3-seed DLC-1.1); fairlead and anchor <0.001% static | <3% platform | Pass | @@ -310,15 +310,16 @@ scripts, results, and source provenance are in - **L3-B Bergdahl dynamic chain test** ([Bergdahl et al., 2016](https://cabledyn.readthedocs.io/en/latest/references.html#ref-bergdahl2016)): over the full 30-condition period-radius matrix, cycle-maximum upper-end force - has RMSE 1.58 N, mean absolute percentage error 3.13%, Pearson correlation - 0.993, and Lin concordance 0.989. Two phase-averaged measured histories have - waveform RMSEs of 5.93% and 2.56% of their force ranges. Halving the mesh length - and the time step changes the mean cycle maximum by at most 0.56% and 0.19%. The + has RMSE 1.58 N, mean absolute percentage error 3.11%, Pearson correlation + 0.993, and Lin concordance 0.989. Two phase-averaged measured histories had + waveform RMSEs of 5.93% and 2.56% of their force ranges with 0.3.0 (not rerun for 0.4.0). + Halving the mesh length and the time step changes the mean cycle maximum by at most + 0.29% and 0.27%. The 0.3125 ms step resolves the segment axial modes that the snap loads excite (and the axial wave over a segment, so the matrix takes no rotation- and snap-resolved sub-step and equals the run taken as given bit for bit); at - 0.625 ms the T = 1.25 s maxima are 2.4% higher (6.5% with every step taken as given), and - at 1.25 ms they are 2–15% higher and vary from cycle to cycle. + 0.625 ms the T = 1.25 s maxima are 1.2% higher (with 0.3.0, 6.5% with every step taken as + given), and with 0.3.0 at 1.25 ms they were 2–15% higher and varied from cycle to cycle. ## L4 coupled OpenFAST diff --git a/validation/experiments/bergdahl/README.md b/validation/experiments/bergdahl/README.md index b6686d67..96032209 100644 --- a/validation/experiments/bergdahl/README.md +++ b/validation/experiments/bergdahl/README.md @@ -71,11 +71,15 @@ committed summary file (`sha256sum`, or `Get-FileHash` in PowerShell). `comparison_summary.csv`, `aggregate_metrics.json` and `provenance.json` hold the compact results and the checksum of the executable used. The calculated force is `FairTen1`, the force at the upper line end. Across the 30 conditions, the cycle maxima have an RMSE of 1.58 N, a -mean absolute percentage error of 3.13%, a mean bias of +0.46 N, a Pearson correlation of 0.993 -and a Lin concordance coefficient of 0.989. For the two waveform conditions, halving the nominal -element length and the time step changes the mean cycle maximum by no more than 0.56% and -0.19%, respectively, and the phase-averaged force histories have RMSEs of 5.93% and 2.56% of -the measured force range. The waveform CSVs carry the measured phase averages computed from the +mean absolute percentage error of 3.11%, a mean bias of +0.47 N, a Pearson correlation of +0.993 and a Lin concordance coefficient of 0.989. For the two waveform +conditions, halving the nominal element length and the time step changes the mean cycle maximum +by no more than 0.29% and 0.27%, respectively. The phase-averaged force histories had RMSEs +of 5.93% and 2.56% of the measured force range with 0.3.0; that comparison was not rerun for +0.4.0 (its waveform files and metrics are the 0.3.0 run's, `provenance.json`). The line's upper +end lies 0.3 m above the still-water level, so 0.4.0's dry weight of the part above the surface +changed the results: the RMSE from 1.583 N to 1.577 N and the mean absolute percentage +error from 3.13% to 3.11%. The waveform CSVs carry the measured phase averages computed from the supplement's `expData.dat`. ## Time step @@ -85,13 +89,13 @@ modes up to about 2c/l ≈ 3500 rad/s. The force maxima are snap loads, which co step only once the step resolves these modes, roughly dtM ≲ l/(2c) ≈ 0.29 ms (see "Snap loads on slack lines" in the [modelling guide](https://cabledyn.readthedocs.io/en/latest/modeling.html)). At a coarser step the maxima do not settle: at the T = 1.25 s, 0.20 m condition they are -69.5 N at 0.625 ms (72.2 N with every step taken as given, `off ei0_substeps`), against -68.0 N at 0.3125 ms and 67.8 N at 0.15625 ms. At 0.3125 ms and below the step resolves the +68.7 N at 0.625 ms, against 68.1 N at 0.3125 ms and 67.9 N at 0.15625 ms (with 0.3.0, +72.2 N at 0.625 ms with every step taken as given, `off ei0_substeps`). At 0.3125 ms and below the step resolves the axial wave over a 0.2 m segment, so the rotation- and snap-resolved sub-steps of `ei0_substeps auto` take no part in the primary matrix (its results equal those taken as given); the 0.1 m mesh at 0.3125 ms and the 0.625 ms step use them. Coarse steps also leave the maxima sensitive to the Newton tolerance and to small changes in the solver's -iteration path. With a 1.25 ms step and a relative tolerance of 1e-5, the five cycle maxima of +iteration path. With 0.3.0, a 1.25 ms step and a relative tolerance of 1e-5, the five cycle maxima of a condition have standard deviations of up to 1.6 N, their means are 2–15% above the converged values, and the 30-condition RMSE is 3.7 N. At the 0.3125 ms step the standard deviation is at most 0.19 N. diff --git a/validation/experiments/bergdahl/aggregate_metrics.json b/validation/experiments/bergdahl/aggregate_metrics.json index 7e090b78..eafb32e3 100644 --- a/validation/experiments/bergdahl/aggregate_metrics.json +++ b/validation/experiments/bergdahl/aggregate_metrics.json @@ -1,12 +1,12 @@ { "completed_cases": 30, - "mean_bias_N": 0.4616683466666679, - "mean_bias_percent_of_measured": 1.5855886766627234, - "mae_N": 1.327560893333332, - "mape_percent": 3.1267980284256174, - "rmse_N": 1.5827470765235303, - "maximum_absolute_error_percent": 7.717337853107351, - "pearson_correlation": 0.9932561631491675, - "correlation_r_squared": 0.9865578056338057, - "lin_concordance_correlation": 0.9891388894227845 + "mean_bias_N": 0.4682263800000007, + "mean_bias_percent_of_measured": 1.596721433936495, + "mae_N": 1.3186648599999997, + "mape_percent": 3.1109261757182893, + "rmse_N": 1.5765834980908213, + "maximum_absolute_error_percent": 7.724655932203389, + "pearson_correlation": 0.9933081725437557, + "correlation_r_squared": 0.9866611256422155, + "lin_concordance_correlation": 0.9892319678075987 } diff --git a/validation/experiments/bergdahl/comparison_summary.csv b/validation/experiments/bergdahl/comparison_summary.csv index cb97a7df..a9d70d07 100644 --- a/validation/experiments/bergdahl/comparison_summary.csv +++ b/validation/experiments/bergdahl/comparison_summary.csv @@ -1,31 +1,31 @@ case,period_s,radius_m,measured_maximum_N,dt_s,number_of_elements,element_length_m,total_cycles,ramp_cycles,rho_inf,published_ground_modulus_Pa_per_m,published_ground_damping_ratio,published_contact_diameter_m,equivalent_volume_diameter_m,kbot_Pa_per_m,cbot_Pa_s_per_m,contact_coefficients_overridden,ba_N_s,friction_mu,solver_relative_tolerance,analysis_start_s,deck_sha256,motion_sha256,samples_analysed,predicted_mean_N,predicted_minimum_N,predicted_absolute_maximum_N,predicted_mean_cycle_maximum_N,predicted_cycle_maximum_std_N,predicted_range_N,maximum_error_N,maximum_error_percent -bergdahl_T1p25_R0p075_h0p200_dt0p0003,1.25,0.075,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,9a15c83cd584db2d41b7425c2464d45b951e064312e22d2bd5f2bdc5d62c78be,200c532b956836233ff1706360190a636fa05d658c6e4dc8b0eeda6ac38665d7,20001,22.75729029778711,0.84961577,41.55663,41.518083000000004,0.0364163607119109,40.70701423,-0.9819169999999957,-2.3103929411764605 -bergdahl_T1p25_R0p100_h0p200_dt0p0003,1.25,0.1,46.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,35f623bef1aa930eca217ccf056b72d26a2a3003af68a8efbce83fadb8921146,deb435829efdb15fd5c8f0b8db9dd0c83cfa10aab269a24dcd1fae02d0156547,20001,23.423043792491978,0.080218397,47.463795,47.3005878,0.10685080749437453,47.383576602999995,0.5005878000000052,1.0696320512820625 -bergdahl_T1p25_R0p125_h0p200_dt0p0003,1.25,0.125,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,3db8b8c41f6fd9b122135c92bb6311db9c79ed022cea0e9341c82e382ea2d8c4,350bd646ce87b6afcfec808548ada2624a25186efabbcd00dc72864f1b20fbf0,20001,24.476081125954803,0.080218397,53.264162,53.1698942,0.0748986296049524,53.183943602999996,-0.9301057999999998,-1.7192343807763397 -bergdahl_T1p25_R0p150_h0p200_dt0p0003,1.25,0.15,60.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,6db3b6e1e3a34c320567820a2b227905aea57c8940efdebb14afb0b1a4bb6b8b,a8a5c083de018445740094b398496386e405db1c896d75c8e01c6acd0c985d3c,20001,25.732057802401027,0.080218397,58.343019,58.232365200000004,0.0759659228615041,58.262800602999995,-2.1676347999999948,-3.588799337748336 -bergdahl_T1p25_R0p200_h0p200_dt0p0003,1.25,0.2,70.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,79b6ad075892ffbad6f63343cb55454aa2380387002b23c95dd63ec99ad89757,a3f02e630a2f80e08b9367d4362b4bb09c37f3fb5935ecdc3f548d38fb0f22da,20001,28.52452245713629,0.047432814,68.254513,67.9673104,0.20436951680913815,68.207080186,-2.332689599999995,-3.3181928876244595 -bergdahl_T1p50_R0p075_h0p200_dt0p0003,1.5,0.075,41.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,c84e640a68f2f9a806a08b3afb2b220a49025cf6cf3f75a4439df1e5007eb536,c93b19181604134c73d29a1e343dadd769c4cf5510d2214a929e96ad98bab6d7,24001,22.592768295391856,2.1826476,39.942296,39.862761,0.06165540456034704,37.759648399999996,-1.137239000000001,-2.7737536585365876 -bergdahl_T1p50_R0p100_h0p200_dt0p0003,1.5,0.1,45.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,89df9b353f05c33ad5b47160fb17b0ef2fb9aaaddc5f9c1bb6faa1aa651345b0,08aff391d95ba06a6e36de8101f986e34725034f826dcb56c079f6de0e8c63db,24001,23.099262985012874,0.080218397,46.163762,45.9797466,0.12750091794885285,46.083543602999995,0.6797466000000014,1.5005443708609303 -bergdahl_T1p50_R0p125_h0p200_dt0p0003,1.5,0.125,51.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,b08f6f7411a4c6bf6c51479886cdd5e5ec05048995f7df56b314f38602a6ac68,8da6cf5077f315d1445f9fa86597eb0c45f4a47ea564b2a14f53dbfcb12d70c0,24001,24.037791008454146,0.080218397,51.738263,51.5905316,0.10014122989208964,51.658044603,0.09053159999999849,0.17578951456310388 -bergdahl_T1p50_R0p150_h0p200_dt0p0003,1.5,0.15,59.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4adab994765aca18aa52757ef82e30d15cd9ad09a908cf44bae00cd890218bcb,d399fa50a0dcd35fa3a55d5e8cfddae96652df14bc08b3707dae3766fb725531,24001,25.22877844669226,0.080218397,56.421491,56.337508400000004,0.07367940691129274,56.341272603,-2.6624915999999956,-4.512697627118636 -bergdahl_T1p50_R0p200_h0p200_dt0p0003,1.5,0.2,68.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4087f2ecb4c0dc5d8d29440397162646e11ea24585c1bff5229079b1c9e4bda0,80096d02b10970eabc9320273215f978a016c2ea4add6012ca7ecd21c68c2851,24001,27.95913363490667,0.049391599,67.036091,66.92867720000001,0.09692043402812402,66.986699401,-1.0713227999999901,-1.5754747058823384 -bergdahl_T2p00_R0p075_h0p200_dt0p0003,2.0,0.075,36.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,788d6c963eaccba31443ed29b33d8dd37dcde8e5945ac02f4c63728f4bcede11,06b2ee6b12d716e9c4757c91d6e330d7985b118f411d8673f0e3be1317cd10b7,32001,22.50825846114497,7.1153458,36.047917,36.035346999999994,0.011414748069932139,28.932571199999998,0.035346999999994466,0.09818611111109574 -bergdahl_T2p00_R0p100_h0p200_dt0p0003,2.0,0.1,39.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,66b4e4070897810cc0c2db78a9da33350dbf480ff297311b5ade518c36518e72,7cfeecfbc7673140d72af2c7a475ead3ce77736e54552c663e5df1b72cf6afdd,32001,22.725582901798692,0.20156104,41.949945,41.8937148,0.043681995812919115,41.74838396,2.393714799999998,6.060037468354425 -bergdahl_T2p00_R0p125_h0p200_dt0p0003,2.0,0.125,47.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,11d53518b7f6d58facee9b5d62e582bbdc94a289098bbf6d3ac61defaf82c7e8,b2a8c64acddab4c852169269cca4e60bb258479eda2a6495d094c99f39cf76d3,32001,23.438071037375487,0.080218397,47.713108,47.5727352,0.1101758711342915,47.632889602999995,0.07273519999999678,0.1531267368420985 -bergdahl_T2p00_R0p150_h0p200_dt0p0003,2.0,0.15,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,d423c8a5aeb69a63655c03060d6f2b45742420795e5d8004b716da8908cd126d,71ae7988f4e286c2a5c4f8b21cbdf9cf0c5138bb68f74c9e2e7083d2bd8a9c39,32001,24.44123775418168,0.080218397,53.034022,52.9313364,0.08391372617039487,52.953803603,-1.1686636000000021,-2.160191497227361 -bergdahl_T2p00_R0p200_h0p200_dt0p0003,2.0,0.2,62.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,a640e7f76fa6bb1ae074d28e43f3958084d3e75bf7d9d368fd414b9849f14e25,5211abe84187c30899ee1759f47f60ddd307427b5aaa577a132c9269b8d0b0f1,32001,26.998362808274205,0.069770449,63.216109,63.1520804,0.03968285901746634,63.146338551,0.8520804000000055,1.3677052969502497 -bergdahl_T2p50_R0p075_h0p200_dt0p0003,2.5,0.075,31.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,87645fbd5487107bb7b4710a95d6eebc3da8d0309ba5de053694f17590581d35,b3a5ceda599c59b5516c7f95d48a53c5a9082ba4573eb87d0f4ebdb816c9918d,40001,22.573128677483066,10.591124,33.062585,33.0596916,0.003054553044227603,22.471460999999998,1.9596915999999993,6.301259163987136 -bergdahl_T2p50_R0p100_h0p200_dt0p0003,2.5,0.1,35.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,9898a74d88ffedf8e9585d680862587b7382f129aa1cbf90dcec137bcd6f3f7d,69865be17566563fed41360b3b26602dd059e960ddf492a02bb8474239fe8617,40001,22.64237321955451,4.7312149,38.136158,38.1319376,0.002738401960999871,33.404943100000004,2.731937600000002,7.7173378531073515 -bergdahl_T2p50_R0p125_h0p200_dt0p0003,2.5,0.125,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6c1845719020a1b825f0878b9722de394658a468d2576549e8ac44e3854c1943,4606eb29aac566ef9436af19d60063e21915d8e535ee1a29cb8164bf36832ac1,40001,23.06203512397165,0.080218397,43.671052,43.619687400000004,0.03978410596331384,43.590833603,1.1196874000000037,2.634558588235303 -bergdahl_T2p50_R0p150_h0p200_dt0p0003,2.5,0.15,49.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6ebf7ca718808043f57a87bb177c1d5a25f86e13ebcf6a1129e7ef8d9f73fe77,f96b5df08fdfbafbf1a73f3a476ab4bd83f366340e729a555fff4abfbdcb128f,40001,23.951691448754932,0.080218397,48.966114,48.918578600000004,0.03350533006552719,48.885895602999994,-0.08142139999999642,-0.1661661224489723 -bergdahl_T2p50_R0p200_h0p200_dt0p0003,2.5,0.2,57.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,2d0261069c6689ebe857731f237f70a2883a5980112b9f277246377d0230c9cf,da167b278b0560de961de703952a1e36a22f7e4ff637e7a8453f90eeada7281d,40001,26.27020682526119,0.074341225,59.599114,59.5508086,0.03514053619112935,59.524772775,2.2508086000000063,3.928112739965107 -bergdahl_T3p00_R0p075_h0p200_dt0p0003,3.0,0.075,29.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,302324da0849af35df6392af12635f08555aba2a6e69de515e79fb9705bbab04,d9ad6838f7015b0e7d32a70eb86534166089bd80a096e0a2989cf5cef41dbd05,48001,22.653205223224518,13.239237,31.054133,31.053350599999998,0.0007923962392643522,17.814896,1.5533505999999981,5.265595254237282 -bergdahl_T3p00_R0p100_h0p200_dt0p0003,3.0,0.1,33.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,eb00be510264d4ead391c24cc9a240da7dec29658c898bbc9b481e894d73bd07,8a90048a3f3bab35a054f704a11342f580f746ec87972031da7d49d02217f6cc,48001,22.68028505046978,7.8264702,35.57996,35.577183000000005,0.0018532568629307379,27.7534898,2.4771830000000037,7.483936555891249 -bergdahl_T3p00_R0p125_h0p200_dt0p0003,3.0,0.125,39.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,ced08cb707dbc660e07d97949e7422b7326d083dc99d18a5ae84378a21fc84ef,bde9b1a9923f0d4e4c3158d7df37ba31838710c39d672bb8241ec6cab8e55722,48001,22.90058616806525,1.1527348,40.40689,40.401079200000005,0.005300698180428831,39.2541552,1.101079200000008,2.80172824427483 -bergdahl_T3p00_R0p150_h0p200_dt0p0003,3.0,0.15,45.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,47aa51d93408ca527f8a8ac85613ab9b0f7a4f9a2459ec9bca396e62de32dfb2,402811dda2da329a55b8e7816c5134f5aecb0a59bdbefc6b13eeb232cb4fb15b,48001,23.530885720303036,0.080218397,45.358404,45.3450974,0.010693752699590463,45.278185603,-0.45490259999999694,-0.9932371179039235 -bergdahl_T3p00_R0p200_h0p200_dt0p0003,3.0,0.2,54.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,96e1dda1aa324b9669d601026fb6ad0831cadaf6dcc32492235ee05cd7d7d3b5,f03dc52610fa2de64c497f78321355d34ea6fad14109005aafde665c707b0e35,48001,25.689062797173765,0.080218397,55.736209,55.698312599999994,0.03162717803250884,55.655990603,1.6983125999999942,3.1450233333333224 -bergdahl_T3p50_R0p075_h0p200_dt0p0003,3.5,0.075,27.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,235d4acffaff2133c0833b4dde65d4f746a980e483bf1a184fbda1789d26d32b,832f1074f37014ce95341e0baea190a6c995ca381de72b85ef1d8e4ffbecc7ed,56001,22.741663554740096,15.199221,29.866848,29.8664992,0.0004117046271295802,14.667627000000001,2.066499199999999,7.433450359712226 -bergdahl_T3p50_R0p100_h0p200_dt0p0003,3.5,0.1,31.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,dfd71b038e2016e837ca8d2976ff4dabbdbc579d663b3e4d6cc02c867bde1e35,d70c6750c97b8271d7f0604166e62a41a1e57b583932f16598c4ebe75de573aa,56001,22.765204520883554,10.515801,33.721231,33.7197632,0.001419329313444277,23.205430000000003,2.2197632000000027,7.0468673015873105 -bergdahl_T3p50_R0p125_h0p200_dt0p0003,3.5,0.125,37.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,0c91662ea48cc2fa12539fc97fc123c1b3dff743ead2bace86bdf2ac3ac53997,2fe336ce9ff36b4af7c8d698c3e68f372b762b8127ecdda730fb5e07c46f68ea,56001,22.890783096641133,5.7432455,38.029771,38.027166,0.002623257802807864,32.286525499999996,0.5271660000000011,1.405776000000003 -bergdahl_T3p50_R0p150_h0p200_dt0p0003,3.5,0.15,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,f2a0f779cd4f722e64114a1d24d297d7b71ce71b3234ebf98d0ee02349768a0e,fd49ce4e3dce2c1d034faeedf52a60633dfb26a3a6cfbc935c66a29ea7297d3c,56001,23.270828354333318,0.38777922,42.77665,42.75414859999999,0.026079876654231008,42.38887078,0.2541485999999935,0.5979967058823377 -bergdahl_T3p50_R0p200_h0p200_dt0p0003,3.5,0.2,50.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,7bdf322dbff579b866971969ad11b066c3aa1da0fb8bd19bf7f64c3e05b85e00,de9d5e2bf50d61ca47a1fb69f0cfabab511139a97cff5ccdf79fc257b156f438,56001,25.18984178717771,0.080218397,52.364122,52.35406759999999,0.00952333220569378,52.283903603,2.254067599999992,4.499136926147688 +bergdahl_T1p25_R0p075_h0p200_dt0p0003,1.25,0.075,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,9a15c83cd584db2d41b7425c2464d45b951e064312e22d2bd5f2bdc5d62c78be,200c532b956836233ff1706360190a636fa05d658c6e4dc8b0eeda6ac38665d7,20001,22.76071962456677,0.5812308,41.682949,41.5631264,0.12044439306501448,41.1017182,-0.9368735999999984,-2.2044084705882314 +bergdahl_T1p25_R0p100_h0p200_dt0p0003,1.25,0.1,46.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,35f623bef1aa930eca217ccf056b72d26a2a3003af68a8efbce83fadb8921146,deb435829efdb15fd5c8f0b8db9dd0c83cfa10aab269a24dcd1fae02d0156547,20001,23.422225931882654,0.089864175,47.621673,47.35303259999999,0.17351686673145245,47.531808825,0.5530325999999945,1.181693589743578 +bergdahl_T1p25_R0p125_h0p200_dt0p0003,1.25,0.125,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,3db8b8c41f6fd9b122135c92bb6311db9c79ed022cea0e9341c82e382ea2d8c4,350bd646ce87b6afcfec808548ada2624a25186efabbcd00dc72864f1b20fbf0,20001,24.478315429535574,0.080218397,53.326758,53.181224,0.1283956635151671,53.246539602999995,-0.9187760000000011,-1.6982920517560094 +bergdahl_T1p25_R0p150_h0p200_dt0p0003,1.25,0.15,60.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,6db3b6e1e3a34c320567820a2b227905aea57c8940efdebb14afb0b1a4bb6b8b,a8a5c083de018445740094b398496386e405db1c896d75c8e01c6acd0c985d3c,20001,25.734290326960803,0.080218397,58.285559,58.1977886,0.07107862298398791,58.205340602999996,-2.202211399999996,-3.646045364238404 +bergdahl_T1p25_R0p200_h0p200_dt0p0003,1.25,0.2,70.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,8.75,79b6ad075892ffbad6f63343cb55454aa2380387002b23c95dd63ec99ad89757,a3f02e630a2f80e08b9367d4362b4bb09c37f3fb5935ecdc3f548d38fb0f22da,20001,28.528287033225634,0.046278597,68.296382,68.06661,0.17947827166122232,68.250103403,-2.23339,-3.176941678520626 +bergdahl_T1p50_R0p075_h0p200_dt0p0003,1.5,0.075,41.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,c84e640a68f2f9a806a08b3afb2b220a49025cf6cf3f75a4439df1e5007eb536,c93b19181604134c73d29a1e343dadd769c4cf5510d2214a929e96ad98bab6d7,24001,22.592588550172906,2.4415786,39.969939,39.8840858,0.057923680729039966,37.5283604,-1.1159141999999989,-2.7217419512195096 +bergdahl_T1p50_R0p100_h0p200_dt0p0003,1.5,0.1,45.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,89df9b353f05c33ad5b47160fb17b0ef2fb9aaaddc5f9c1bb6faa1aa651345b0,08aff391d95ba06a6e36de8101f986e34725034f826dcb56c079f6de0e8c63db,24001,23.096564572991124,0.12335236,46.243642,46.0175654,0.17799075588018604,46.12028964,0.7175654000000051,1.5840295805739628 +bergdahl_T1p50_R0p125_h0p200_dt0p0003,1.5,0.125,51.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,b08f6f7411a4c6bf6c51479886cdd5e5ec05048995f7df56b314f38602a6ac68,8da6cf5077f315d1445f9fa86597eb0c45f4a47ea564b2a14f53dbfcb12d70c0,24001,24.052205877027163,0.080218397,51.792248,51.57071559999999,0.15275896153843269,51.712029603,0.07071559999999266,0.13731184466017993 +bergdahl_T1p50_R0p150_h0p200_dt0p0003,1.5,0.15,59.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4adab994765aca18aa52757ef82e30d15cd9ad09a908cf44bae00cd890218bcb,d399fa50a0dcd35fa3a55d5e8cfddae96652df14bc08b3707dae3766fb725531,24001,25.232239030195448,0.080218397,56.462288,56.40285120000001,0.056751006094167195,56.382069603,-2.5971487999999923,-4.401947118644054 +bergdahl_T1p50_R0p200_h0p200_dt0p0003,1.5,0.2,68.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,10.5,4087f2ecb4c0dc5d8d29440397162646e11ea24585c1bff5229079b1c9e4bda0,80096d02b10970eabc9320273215f978a016c2ea4add6012ca7ecd21c68c2851,24001,27.954108408742055,0.049639845,67.074252,66.98452280000001,0.0702767432562159,67.024612155,-1.0154771999999923,-1.4933488235294003 +bergdahl_T2p00_R0p075_h0p200_dt0p0003,2.0,0.075,36.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,788d6c963eaccba31443ed29b33d8dd37dcde8e5945ac02f4c63728f4bcede11,06b2ee6b12d716e9c4757c91d6e330d7985b118f411d8673f0e3be1317cd10b7,32001,22.508131774091435,7.2548321,36.041562,36.0280968,0.012067791894130027,28.786729899999997,0.028096800000000144,0.07804666666666707 +bergdahl_T2p00_R0p100_h0p200_dt0p0003,2.0,0.1,39.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,66b4e4070897810cc0c2db78a9da33350dbf480ff297311b5ade518c36518e72,7cfeecfbc7673140d72af2c7a475ead3ce77736e54552c663e5df1b72cf6afdd,32001,22.723211326262934,0.40613379,42.099528,41.9130574,0.12174452586995366,41.69339421,2.4130573999999996,6.109006075949366 +bergdahl_T2p00_R0p125_h0p200_dt0p0003,2.0,0.125,47.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,11d53518b7f6d58facee9b5d62e582bbdc94a289098bbf6d3ac61defaf82c7e8,b2a8c64acddab4c852169269cca4e60bb258479eda2a6495d094c99f39cf76d3,32001,23.434807653425985,0.080218397,47.623368,47.5476638,0.05845428765026536,47.543149602999996,0.047663800000002254,0.10034484210526791 +bergdahl_T2p00_R0p150_h0p200_dt0p0003,2.0,0.15,54.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,d423c8a5aeb69a63655c03060d6f2b45742420795e5d8004b716da8908cd126d,71ae7988f4e286c2a5c4f8b21cbdf9cf0c5138bb68f74c9e2e7083d2bd8a9c39,32001,24.445313651546016,0.080218397,52.916699,52.86804199999999,0.029431651083485826,52.836480603,-1.231958000000013,-2.2771866913124086 +bergdahl_T2p00_R0p200_h0p200_dt0p0003,2.0,0.2,62.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,14.0,a640e7f76fa6bb1ae074d28e43f3958084d3e75bf7d9d368fd414b9849f14e25,5211abe84187c30899ee1759f47f60ddd307427b5aaa577a132c9269b8d0b0f1,32001,26.99432516930452,0.068042574,63.15241,63.1082134,0.027959332955207514,63.084367426,0.8082133999999996,1.2972927768860347 +bergdahl_T2p50_R0p075_h0p200_dt0p0003,2.5,0.075,31.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,87645fbd5487107bb7b4710a95d6eebc3da8d0309ba5de053694f17590581d35,b3a5ceda599c59b5516c7f95d48a53c5a9082ba4573eb87d0f4ebdb816c9918d,40001,22.573418771605713,10.488355,33.065015,33.0607998,0.002819613040828046,22.576660000000004,1.9607997999999967,6.3048225080385745 +bergdahl_T2p50_R0p100_h0p200_dt0p0003,2.5,0.1,35.4,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,9898a74d88ffedf8e9585d680862587b7382f129aa1cbf90dcec137bcd6f3f7d,69865be17566563fed41360b3b26602dd059e960ddf492a02bb8474239fe8617,40001,22.64199611162721,4.7983632,38.138737,38.1345282,0.004729726123149344,33.3403738,2.7345281999999997,7.724655932203389 +bergdahl_T2p50_R0p125_h0p200_dt0p0003,2.5,0.125,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6c1845719020a1b825f0878b9722de394658a468d2576549e8ac44e3854c1943,4606eb29aac566ef9436af19d60063e21915d8e535ee1a29cb8164bf36832ac1,40001,23.064165036329346,0.19093024,43.613054,43.5951608,0.0226399904858632,43.42212376,1.0951608000000022,2.5768489411764754 +bergdahl_T2p50_R0p150_h0p200_dt0p0003,2.5,0.15,49.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,6ebf7ca718808043f57a87bb177c1d5a25f86e13ebcf6a1129e7ef8d9f73fe77,f96b5df08fdfbafbf1a73f3a476ab4bd83f366340e729a555fff4abfbdcb128f,40001,23.95026671398398,0.080218397,48.966017,48.936281799999996,0.021807911435991534,48.885798603,-0.06371820000000383,-0.13003714285715068 +bergdahl_T2p50_R0p200_h0p200_dt0p0003,2.5,0.2,57.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,17.5,2d0261069c6689ebe857731f237f70a2883a5980112b9f277246377d0230c9cf,da167b278b0560de961de703952a1e36a22f7e4ff637e7a8453f90eeada7281d,40001,26.272210319876454,0.080218397,59.600812,59.573548200000005,0.03341144857230607,59.520593602999995,2.2735482000000076,3.9677979057591757 +bergdahl_T3p00_R0p075_h0p200_dt0p0003,3.0,0.075,29.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,302324da0849af35df6392af12635f08555aba2a6e69de515e79fb9705bbab04,d9ad6838f7015b0e7d32a70eb86534166089bd80a096e0a2989cf5cef41dbd05,48001,22.65336700443741,13.238802,31.055678,31.052939600000002,0.0024582989647322505,17.816876,1.552939600000002,5.264202033898312 +bergdahl_T3p00_R0p100_h0p200_dt0p0003,3.0,0.1,33.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,eb00be510264d4ead391c24cc9a240da7dec29658c898bbc9b481e894d73bd07,8a90048a3f3bab35a054f704a11342f580f746ec87972031da7d49d02217f6cc,48001,22.679989857223806,7.9950605,35.579455,35.57673,0.0017802805958620157,27.584394500000002,2.4767299999999963,7.482567975830804 +bergdahl_T3p00_R0p125_h0p200_dt0p0003,3.0,0.125,39.3,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,ced08cb707dbc660e07d97949e7422b7326d083dc99d18a5ae84378a21fc84ef,bde9b1a9923f0d4e4c3158d7df37ba31838710c39d672bb8241ec6cab8e55722,48001,22.900346294548033,1.0663439,40.403297,40.3929732,0.006445350044799983,39.3369531,1.092973200000003,2.7811022900763436 +bergdahl_T3p00_R0p150_h0p200_dt0p0003,3.0,0.15,45.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,47aa51d93408ca527f8a8ac85613ab9b0f7a4f9a2459ec9bca396e62de32dfb2,402811dda2da329a55b8e7816c5134f5aecb0a59bdbefc6b13eeb232cb4fb15b,48001,23.530716851055395,0.080218397,45.386687,45.358890200000005,0.02332520485869307,45.306468603,-0.44110979999999245,-0.963121834061119 +bergdahl_T3p00_R0p200_h0p200_dt0p0003,3.0,0.2,54.0,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,21.0,96e1dda1aa324b9669d601026fb6ad0831cadaf6dcc32492235ee05cd7d7d3b5,f03dc52610fa2de64c497f78321355d34ea6fad14109005aafde665c707b0e35,48001,25.68932680798088,0.080218397,55.738108,55.7085506,0.019051458547836943,55.657889602999994,1.7085506000000024,3.163982592592597 +bergdahl_T3p50_R0p075_h0p200_dt0p0003,3.5,0.075,27.8,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,235d4acffaff2133c0833b4dde65d4f746a980e483bf1a184fbda1789d26d32b,832f1074f37014ce95341e0baea190a6c995ca381de72b85ef1d8e4ffbecc7ed,56001,22.74167530636953,15.200255,29.868272,29.8672488,0.0007384400449606316,14.668017,2.067248799999998,7.436146762589921 +bergdahl_T3p50_R0p100_h0p200_dt0p0003,3.5,0.1,31.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,dfd71b038e2016e837ca8d2976ff4dabbdbc579d663b3e4d6cc02c867bde1e35,d70c6750c97b8271d7f0604166e62a41a1e57b583932f16598c4ebe75de573aa,56001,22.765110787378795,10.527135,33.72129,33.7200428,0.0011058854823181455,23.194155000000002,2.2200428000000016,7.047754920634926 +bergdahl_T3p50_R0p125_h0p200_dt0p0003,3.5,0.125,37.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,0c91662ea48cc2fa12539fc97fc123c1b3dff743ead2bace86bdf2ac3ac53997,2fe336ce9ff36b4af7c8d698c3e68f372b762b8127ecdda730fb5e07c46f68ea,56001,22.89092232136569,5.611489,38.028906,38.0267948,0.0018352618886691564,32.417417,0.5267947999999976,1.404786133333327 +bergdahl_T3p50_R0p150_h0p200_dt0p0003,3.5,0.15,42.5,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,f2a0f779cd4f722e64114a1d24d297d7b71ce71b3234ebf98d0ee02349768a0e,fd49ce4e3dce2c1d034faeedf52a60633dfb26a3a6cfbc935c66a29ea7297d3c,56001,23.270326166448992,0.53383197,42.720007,42.69810540000001,0.025683169923122445,42.18617503,0.19810540000000998,0.4661303529412 +bergdahl_T3p50_R0p200_h0p200_dt0p0003,3.5,0.2,50.1,0.0003125,165,0.2,12,3,0.4,3000000000.0,1.0,0.0022,0.003654133499998645,1806173748.168327,402155.67857087706,False,0.0,0.3,1e-08,24.5,7bdf322dbff579b866971969ad11b066c3aa1da0fb8bd19bf7f64c3e05b85e00,de9d5e2bf50d61ca47a1fb69f0cfabab511139a97cff5ccdf79fc257b156f438,56001,25.190656469420546,0.080218397,52.374506,52.3576014,0.01113738978845356,52.294287602999994,2.2576013999999986,4.5061904191616735 diff --git a/validation/experiments/bergdahl/provenance.json b/validation/experiments/bergdahl/provenance.json index 1d647c48..1db994ab 100644 --- a/validation/experiments/bergdahl/provenance.json +++ b/validation/experiments/bergdahl/provenance.json @@ -1,8 +1,8 @@ { - "CableDyn_release": "v0.3.0", - "validation_date": "2026-10-23", + "CableDyn_release": "v0.4.0", + "validation_date": "2026-11-03", "executable_name": "cabledyn.exe", - "executable_sha256": "5f1d3b15b414ce7b7eb884db76e50901da6a0094c5548489f58cbfed7ac0546a", + "executable_sha256": "d6603f989f41b01e7921dc52c1c9e580182208c99b45e6ebdd93377b4cbc289f", "compiler": "GNU Fortran 16.2.0", "build_type": "Release", "platform": "Windows 11 x86-64", @@ -12,13 +12,15 @@ "completed_cases": 30, "nonlinear_misses": 0, "refinement_cases": 8, - "maximum_spatial_refinement_difference_percent": 0.5580722740928493, - "maximum_temporal_refinement_difference_percent": 0.18888172026785752, - "force_maxima_sha256": "978889378964c6d6749bc27c11d99d6584956e3c8eac146ae79bf5f7a05e2e95", - "aggregate_metrics_sha256": "35d800fa34137a3a1500cbd0081a490bc1b61cf636cfef5a923b5c18947ba1a7", + "maximum_spatial_refinement_difference_percent": 0.2923050211789211, + "maximum_temporal_refinement_difference_percent": 0.2699356319214836, + "force_maxima_sha256": "ebeaa2627e16506cc6689284791b437f4dc4d27f0f2fc039f7fd2ef09d35ea38", + "aggregate_metrics_sha256": "ad9a9baeb9cfe5dcd19af0a8dee5f02a5c942d0bc1d4b7560858860eb52aeb5b", "case_manifest_sha256": "8da5e7b4a8a92755363807902aba48e0ff42abab04ac44912041853db9e56604", "waveform_T1p25_sha256": "e6fad502f89d8796f2f7868dc9c9ca8e2ebc6969f4ebc3aa36e2bf30498a4522", "waveform_T3p50_sha256": "a21956ee9d7c0a41c0948eb2cae7fa1f25c0b8dc26714a4dce95fa0236e5434e", "waveform_metrics_sha256": "0fb6015cb30aa2bbb1cd8951b603f9201af50372ee6d3633a72fc70ea5280d1a", - "refinement_summary_sha256": "9039f6c9b91ed2d15d7c609dd8d2300eef34d0363700487a8dfc0a8f15be1087" + "refinement_summary_sha256": "75342ed4f3ebe2d7acb19af56394e24e6ce909bb3df7445bf3a1d884280f9eb6", + "waveform_comparison_release": "v0.3.0", + "waveform_comparison_note": "not rerun with 0.4.0: the supplement expData.dat was not available when the record was rerun; the waveform files and metrics are those of the v0.3.0 run" } diff --git a/validation/experiments/bergdahl/refinement_summary.csv b/validation/experiments/bergdahl/refinement_summary.csv index 24985b11..5d798bc8 100644 --- a/validation/experiments/bergdahl/refinement_summary.csv +++ b/validation/experiments/bergdahl/refinement_summary.csv @@ -1,3 +1,3 @@ period_s,radius_m,force_h0p400_dt0p0003125_N,force_h0p200_dt0p0003125_N,force_h0p100_dt0p0003125_N,force_h0p200_dt0p00015625_N,force_h0p200_dt0p000625_N,spatial_difference_h0p400_dt0p0003125_percent,spatial_difference_h0p200_dt0p0003125_percent,temporal_difference_h0p200_dt0p0003125_percent,temporal_difference_h0p200_dt0p000625_percent -1.25,0.2,68.15018140000001,67.9673104,68.3487458,67.8391746,69.497535,-0.2905165232746598,-0.5580722740928493,0.18888172026785752,2.4445468415236173 -3.5,0.2,52.3714018,52.35406759999999,52.342603399999994,52.3533266,53.2401192,0.05501904400881702,0.021902234996585834,0.0014153828383290867,1.6938610353749701 +1.25,0.2,68.29057320000001,68.06661,68.2661554,67.8833686,68.695316,0.03576852959850298,-0.2923050211789211,0.2699356319214836,1.196091792062317 +3.5,0.2,52.37618620000001,52.3576014,52.346908,52.348888,53.453302799999996,0.05593109721018739,0.02042794963171648,0.016644861682635476,2.1097196945233936 diff --git a/validation/experiments/bergdahl/refinement_summary.json b/validation/experiments/bergdahl/refinement_summary.json index 26d26521..021b23b2 100644 --- a/validation/experiments/bergdahl/refinement_summary.json +++ b/validation/experiments/bergdahl/refinement_summary.json @@ -4,34 +4,34 @@ "temporal_reference_time_step_s": 0.00015625, "primary_nominal_element_length_m": 0.2, "primary_time_step_s": 0.0003125, - "maximum_primary_spatial_difference_percent": 0.5580722740928493, - "maximum_primary_temporal_difference_percent": 0.18888172026785752, + "maximum_primary_spatial_difference_percent": 0.2923050211789211, + "maximum_primary_temporal_difference_percent": 0.2699356319214836, "rows": [ { "period_s": 1.25, "radius_m": 0.2, - "force_h0p400_dt0p0003125_N": 68.15018140000001, - "force_h0p200_dt0p0003125_N": 67.9673104, - "force_h0p100_dt0p0003125_N": 68.3487458, - "force_h0p200_dt0p00015625_N": 67.8391746, - "force_h0p200_dt0p000625_N": 69.497535, - "spatial_difference_h0p400_dt0p0003125_percent": -0.2905165232746598, - "spatial_difference_h0p200_dt0p0003125_percent": -0.5580722740928493, - "temporal_difference_h0p200_dt0p0003125_percent": 0.18888172026785752, - "temporal_difference_h0p200_dt0p000625_percent": 2.4445468415236173 + "force_h0p400_dt0p0003125_N": 68.29057320000001, + "force_h0p200_dt0p0003125_N": 68.06661, + "force_h0p100_dt0p0003125_N": 68.2661554, + "force_h0p200_dt0p00015625_N": 67.8833686, + "force_h0p200_dt0p000625_N": 68.695316, + "spatial_difference_h0p400_dt0p0003125_percent": 0.03576852959850298, + "spatial_difference_h0p200_dt0p0003125_percent": -0.2923050211789211, + "temporal_difference_h0p200_dt0p0003125_percent": 0.2699356319214836, + "temporal_difference_h0p200_dt0p000625_percent": 1.196091792062317 }, { "period_s": 3.5, "radius_m": 0.2, - "force_h0p400_dt0p0003125_N": 52.3714018, - "force_h0p200_dt0p0003125_N": 52.35406759999999, - "force_h0p100_dt0p0003125_N": 52.342603399999994, - "force_h0p200_dt0p00015625_N": 52.3533266, - "force_h0p200_dt0p000625_N": 53.2401192, - "spatial_difference_h0p400_dt0p0003125_percent": 0.05501904400881702, - "spatial_difference_h0p200_dt0p0003125_percent": 0.021902234996585834, - "temporal_difference_h0p200_dt0p0003125_percent": 0.0014153828383290867, - "temporal_difference_h0p200_dt0p000625_percent": 1.6938610353749701 + "force_h0p400_dt0p0003125_N": 52.37618620000001, + "force_h0p200_dt0p0003125_N": 52.3576014, + "force_h0p100_dt0p0003125_N": 52.346908, + "force_h0p200_dt0p00015625_N": 52.348888, + "force_h0p200_dt0p000625_N": 53.453302799999996, + "spatial_difference_h0p400_dt0p0003125_percent": 0.05593109721018739, + "spatial_difference_h0p200_dt0p0003125_percent": 0.02042794963171648, + "temporal_difference_h0p200_dt0p0003125_percent": 0.016644861682635476, + "temporal_difference_h0p200_dt0p000625_percent": 2.1097196945233936 } ] } From edd0d6239b56a8c6de47c681576ceabe77b64a4c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 01:18:18 +0900 Subject: [PATCH 39/51] test: the GNU build of the test programs has no warnings RELEASE.md asks for Release and Debug builds with no compiler warnings. The solver core met that, but the test programs gave 216 GNU warnings, most from tests added after the per-test suppression list was written. Three tests read a variable in the same expression as an impure call that sets it, or might drop the call (-Wfunction-elimination): the call now comes first (test_coupled_cable_tolerance, test_coupled_torsion, test_openfast_pinned_rod). An unused variable, an unused import and an unused function are removed. The intended patterns are now suppressed for every test executable in one rule at the end of CMakeLists.txt, in place of the hand-kept lists: exact real comparisons, integer divisions of node counts, guarded loop indices, callback dummies the interface requires, and GCC's uninitialized-descriptor diagnostics. The solver core keeps every warning. Clean GNU Release build: 0 warnings; ctest 359 of 359 passed. Signed-off-by: Jae Hoon Seo --- CMakeLists.txt | 53 +++++++++++--------------- tests/test_coupled_cable_tolerance.f90 | 6 ++- tests/test_coupled_torsion.f90 | 5 ++- tests/test_hermite_cable_static.f90 | 2 +- tests/test_openfast_pinned_body.f90 | 6 --- tests/test_openfast_pinned_rod.f90 | 3 +- tests/test_parity_integration.f90 | 2 +- 7 files changed, 34 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6bb883d..4b0703b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3104,36 +3104,6 @@ target_link_libraries(test_endconn_dynamic PRIVATE cabledyn_core) add_test(NAME endconn_dynamic COMMAND test_endconn_dynamic) set_tests_properties(endconn_dynamic PROPERTIES LABELS "fortran;endconnection;dynamic;integration") -# These regression programs deliberately assert bit identity and exact-zero limits. GNU's -# -Wcompare-reals warning is useful in the solver core but not for those stated test contracts. -# GCC 15 also diagnoses allocatable descriptors nested in a default-initialized aggregate as -# uninitialized even though Fortran initializes every allocatable component as unallocated. -if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") - foreach(_cabledyn_exact_real_test IN ITEMS - test_hermite_cable - test_hermite_drag_dynamics - test_hermite_axial_damping - test_hermite_cable_control - test_control_torsion - test_endconn_spring - test_torsion_coupling - test_torsion_one_end - test_two_moving_ends - test_wave_math) - target_compile_options(${_cabledyn_exact_real_test} PRIVATE -Wno-compare-reals) - endforeach() - target_compile_options(test_openfast_aggregate PRIVATE - -Wno-compare-reals - -Wno-uninitialized - -Wno-maybe-uninitialized) - target_compile_options(test_torsion_deck PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) - target_compile_options(test_torsion_one_end PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) - target_compile_options(test_hermite_cable_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) - target_compile_options(test_syrope_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) - target_compile_options(test_viscoelastic_control PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) - target_compile_options(test_control_torsion PRIVATE -Wno-uninitialized -Wno-maybe-uninitialized) -endif() - if(CABLEDYN_ENABLE_COVERAGE) find_program(CABLEDYN_GCOVR gcovr) if(CABLEDYN_GCOVR) @@ -3344,3 +3314,26 @@ foreach(_any_test IN LISTS _all_tests) set_tests_properties(${_any_test} PROPERTIES TIMEOUT 1800) endif() endforeach() + +# GNU warnings in the test programs. The solver core builds with no warning; these flags apply +# to the test executables only, where the diagnosed patterns are intended: exact real +# comparisons (bit identity and exact-zero limits are stated test contracts), integer +# divisions of node counts, loops whose out-of-range indices sit in guarded branches, and +# callback dummies the interface requires. GCC 15+ also reports allocatable descriptors nested +# in a default-initialized aggregate as uninitialized, although Fortran initializes every +# allocatable component as unallocated. +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + get_property(_cabledyn_targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS) + foreach(_cabledyn_target IN LISTS _cabledyn_targets) + get_target_property(_cabledyn_target_type ${_cabledyn_target} TYPE) + if(_cabledyn_target MATCHES "^test_" AND _cabledyn_target_type STREQUAL "EXECUTABLE") + target_compile_options(${_cabledyn_target} PRIVATE + $<$:-Wno-compare-reals> + $<$:-Wno-uninitialized> + $<$:-Wno-maybe-uninitialized> + $<$:-Wno-integer-division> + $<$:-Wno-do-subscript> + $<$:-Wno-unused-dummy-argument>) + endif() + endforeach() +endif() diff --git a/tests/test_coupled_cable_tolerance.f90 b/tests/test_coupled_cable_tolerance.f90 index e8230ef1..411ab5d8 100644 --- a/tests/test_coupled_cable_tolerance.f90 +++ b/tests/test_coupled_cable_tolerance.f90 @@ -400,7 +400,7 @@ SUBROUTINE check_host(route) TYPE(CD_AGG_ModuleType), ALLOCATABLE :: agg CHARACTER(KIND=C_CHAR), TARGET :: c_path(64), c_tok(16), msg(512) TYPE(C_PTR) :: handle - INTEGER(C_INT) :: ces, n_iter + INTEGER(C_INT) :: ces, n_iter, ndof LOGICAL(C_BOOL) :: cconv, cstall REAL(C_DOUBLE), TARGET :: q(3), v(3), a(3) REAL(C_DOUBLE) :: cval @@ -433,7 +433,9 @@ SUBROUTINE check_host(route) em(i:i) = msg(i) END DO END IF - CALL require(ces == 0_C_INT .AND. CableDyn_NCoupledDOF(handle, ces) == 3_C_INT, & + ndof = -1_C_INT + IF (ces == 0_C_INT) ndof = CableDyn_NCoupledDOF(handle, ces) + CALL require(ces == 0_C_INT .AND. ndof == 3_C_INT, & 'C API: the cable deck initialises with one coupled point: '//TRIM(em)) IF (ces /= 0_C_INT) THEN CALL CableDyn_Close(handle, ces); RETURN diff --git a/tests/test_coupled_torsion.f90 b/tests/test_coupled_torsion.f90 index 72b8c94c..aabfa5b9 100644 --- a/tests/test_coupled_torsion.f90 +++ b/tests/test_coupled_torsion.f90 @@ -184,13 +184,14 @@ SUBROUTINE init_agg(agg, path, ok) TYPE(CD_AGG_ModuleType), INTENT(INOUT) :: agg CHARACTER(*), INTENT(IN) :: path LOGICAL, INTENT(OUT) :: ok - INTEGER :: es + INTEGER :: es, nmp CHARACTER(512) :: em CALL CD_AGG_Init_From_Deck(agg, path, DT, es, em, host_orientation=.TRUE.) ok = es == CD_AGG_OK CALL require(ok, 'coupled torsion deck builds on the aggregate: '//TRIM(em)) IF (ok) THEN - ok = agg%ncable == 1 .AND. CD_AGG_NMovingPoints(agg, es, em) == 1 + nmp = CD_AGG_NMovingPoints(agg, es, em) + ok = agg%ncable == 1 .AND. nmp == 1 CALL require(ok, 'the deck is one coupled cable with one moving point') END IF END SUBROUTINE init_agg diff --git a/tests/test_hermite_cable_static.f90 b/tests/test_hermite_cable_static.f90 index d3d4aae8..4746616e 100644 --- a/tests/test_hermite_cable_static.f90 +++ b/tests/test_hermite_cable_static.f90 @@ -520,7 +520,7 @@ SUBROUTINE check_end_support_energy_gradient() !! (w l0^2/12) (dS/dgap) m_z, here near 1 MN: no potential of R. INTEGER, PARAMETER :: NE = 20, NN = NE + 1, NDIR = 4 REAL(wp), PARAMETER :: H = 1.0e-5_wp - REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), qa(6*NN), q(6*NN), c(NN), res, r0(6*NN) + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(6*NN), qa(6*NN), c(NN), res, r0(6*NN) REAL(wp) :: trib(NN), kn, floor_z, gap, normal, normal_gap, share, dshare, ep, em_, rd, fd, fd_free, d(6*NN) INTEGER :: fixed(6 + 2*NN), nfix, i, es, it, k CHARACTER(512) :: em diff --git a/tests/test_openfast_pinned_body.f90 b/tests/test_openfast_pinned_body.f90 index d47deb78..8c6c1737 100644 --- a/tests/test_openfast_pinned_body.f90 +++ b/tests/test_openfast_pinned_body.f90 @@ -547,12 +547,6 @@ SUBROUTINE host_columns(k, p0, p, v, a) END DO END SUBROUTINE host_columns - FUNCTION host_rest(time) RESULT(k) - REAL(wp), INTENT(IN) :: time - REAL(wp) :: k(9) - k = 0.0_wp*time - END FUNCTION host_rest - FUNCTION host_const(time) RESULT(k) !! The node accelerating uniformly along +x from rest: a = 2 m/s^2. REAL(wp), INTENT(IN) :: time diff --git a/tests/test_openfast_pinned_rod.f90 b/tests/test_openfast_pinned_rod.f90 index 530d4ae5..b832f23c 100644 --- a/tests/test_openfast_pinned_rod.f90 +++ b/tests/test_openfast_pinned_rod.f90 @@ -476,7 +476,8 @@ SUBROUTINE case_pendulum_and_held_host() CALL CD_AGG_Init_From_Deck(held, 'pinrod_pendulum_held.dat', dt, es, em) CALL require(es == CD_AGG_OK, 'held:init: '//TRIM(em)) IF (es /= CD_AGG_OK) RETURN - CALL require(CD_AGG_HasRod(pinned) .AND. CD_AGG_NMovingPoints(pinned, es, em) == 1, & + n = CD_AGG_NMovingPoints(pinned, es, em) + CALL require(CD_AGG_HasRod(pinned) .AND. n == 1, & 'pendulum:a Pinned rod adds no host node') n = CD_AGG_NMovingPoints(held, es, em) CALL require(n == 2, 'held:one host node for the CoupledPinned rod after the fairlead') diff --git a/tests/test_parity_integration.f90 b/tests/test_parity_integration.f90 index 9e58d579..0e5f611e 100644 --- a/tests/test_parity_integration.f90 +++ b/tests/test_parity_integration.f90 @@ -30,7 +30,7 @@ PROGRAM test_parity_integration USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & CD_AGG_Step_Moving, CD_AGG_Apply_LineControl, CD_AGG_NFluidNodes, & CD_AGG_SetFluidFields, CD_AGG_End, CD_AGG_OK - USE CableDyn_System, ONLY: CD_System_Line_NElem, CD_Get_System_Line_Tension, CD_SYSTEM_OK + USE CableDyn_System, ONLY: CD_System_Line_NElem, CD_Get_System_Line_Tension USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_IS_FINITE IMPLICIT NONE From 4cbd24b5c35bcb50550d7562df48b3c24efbabcc Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 01:37:43 +0900 Subject: [PATCH 40/51] docs: the nitpicky Sphinx build resolves the Stiffener row class sphinx-build -W -n failed on the return type of DeckModel.add_stiffener: Stiffener, like the other cabledyn.builder row classes, is described by the method that creates it and joins their nitpick_ignore list. Signed-off-by: Jae Hoon Seo --- doc/conf.py | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/conf.py b/doc/conf.py index 809d6334..44b39d5b 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -164,6 +164,7 @@ def _cmake_project_version() -> str: "RodEnd", "RodType", "Section", + "Stiffener", "SyropeIC", "Turbine", ) From 88ebb610b29e633c7d50a4a97c6c2a4536fc3f5f Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 02:15:05 +0900 Subject: [PATCH 41/51] chore(release): the 0.4.0 release record validation/RELEASE_0_4_0.md records the source and pins, toolchains, the local, kernel-sweep, experimental, bodies and linearisation results, the Windows gates of run 41672938269, the clean-machine test and the asset and preflight wheel hashes. The validation index lists the 0.3.0 and 0.4.0 records. Signed-off-by: Jae Hoon Seo --- validation/README.md | 4 +- validation/RELEASE_0_4_0.md | 98 +++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 validation/RELEASE_0_4_0.md diff --git a/validation/README.md b/validation/README.md index 797b0b72..ff577aba 100644 --- a/validation/README.md +++ b/validation/README.md @@ -10,7 +10,9 @@ redistributed. | Path | Contents | | --- | --- | -| [`RELEASE_0_2_0.md`](RELEASE_0_2_0.md) | Toolchains, test results, dependency revisions and asset hashes for v0.2.0 | +| [`RELEASE_0_4_0.md`](RELEASE_0_4_0.md) | Toolchains, test results, dependency revisions and asset hashes for v0.4.0 | +| [`RELEASE_0_3_0.md`](RELEASE_0_3_0.md) | The same for v0.3.0 | +| [`RELEASE_0_2_0.md`](RELEASE_0_2_0.md) | The same for v0.2.0 | | [`RELEASE_0_1_1.md`](RELEASE_0_1_1.md) | The same for v0.1.1 | | [`RELEASE_0_1_0.md`](RELEASE_0_1_0.md) | The same for v0.1.0 | | [`bodies/`](bodies/README.md) | Rigid-body, rod and shared-anchor cases with MoorDyn-C twins, stored references and pass limits | diff --git a/validation/RELEASE_0_4_0.md b/validation/RELEASE_0_4_0.md new file mode 100644 index 00000000..6a0ec34d --- /dev/null +++ b/validation/RELEASE_0_4_0.md @@ -0,0 +1,98 @@ + + +# CableDyn v0.4.0 release record + +This record lists what was built and tested for the v0.4.0 release: the source commit, +toolchains, dependency pins, test results and asset hashes. Case definitions and pass criteria +are in [`VALIDATION.md`](../VALIDATION.md). The OpenFAST and r-test pins and the reference +LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows from 20 to 22. + +## Source and pins + +| Item | Value | +| --- | --- | +| CableDyn | `0.4.0` (2026-11-04), C ABI 1, minor extension 3 | +| Source | The release-preparation tree (`release/0.4.0` at `edd0d62`): dev with #48 to #85 and the version, documentation and test-build changes of the release. The assets and the Windows gates were produced from this tree; afterwards only `doc/conf.py` (a Sphinx cross-reference setting) and this record changed, which no build reads | +| OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 22 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | +| OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | +| Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422`, built with IFX for x86-64-v3 (`/fp:precise /arch:CORE-AVX2`) | + +## Toolchains + +| Item | Version | +| --- | --- | +| GNU Fortran (test builds) | conda-forge GCC 16.2.0, with OpenBLAS 0.3.34 and LAPACK from the conda environment | +| Intel Fortran (Windows release) | IFX 2025.3.2, `/fp:precise /arch:CORE-AVX2 /Qfma-` (value-safe floating point, x86-64-v3, no contraction into fused multiply-adds), `/Qauto` (thread-safe local storage) | +| Microsoft C/C++ | Visual Studio 2022 (release workflow) | +| Python wheels | scikit-build-core; cibuildwheel v4.3.3 (Linux `manylinux_2_28`, macOS arm64); IFX static build on Windows (`release/build_windows_wheel.ps1`) | +| Python and packaging | Python 3.13.17, build 1.6.1, Twine 7.0.0 (release workflow) | + +## Test results + +| Gate | Result | +| --- | --- | +| GNU Release CTest, including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed on the release tree; 0 compiler warnings | +| GNU Debug CTest (`-fcheck=all`), including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed; 0 compiler warnings | +| Round-off fragility (GNU Release build of the release tree on the OpenBLAS kernels Prescott, Nehalem, Sandybridge, Haswell, SkylakeX and Zen, through `OPENBLAS_CORETYPE`) | on each kernel the full CTest passes 359 of 359, the two kernel-pinned tests (`openfast_touchdown`, `hermite_node_reaction`) pass unpinned, and all 53 shipped example decks run with no fallback, stall or relaxed-tolerance note and the same exit status | +| Python package tests (local, native library and driver of the release tree) | 2162 passed, 47 skipped (platform- and tool-dependent cases) | +| CI matrix of #85 (the last change before the release tree) | Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks | +| Sphinx documentation (`-W -n`) | built with no warnings | +| pre-commit, all files | passed | +| Release metadata | `check_release_metadata.py` passed (CableDyn v0.4.0, 2026-11-04) | +| Release-tree audit | worktree and `git archive` of the release tree: 921 files, the same SHA-256 | +| Experimental comparisons ([`experiments`](experiments/README.md)) | Holcombe (12 cases) and Bergdahl (30 primary and 8 refinement cases) re-run with a GNU Release build of the release-preparation tree (`cabledyn.exe` SHA-256 `d6603f989f41b01e7921dc52c1c9e580182208c99b45e6ebdd93377b4cbc289f`). Holcombe reproduces every summary and metric byte for byte. Bergdahl changes because the upper line end lies above the still-water level and 0.4.0 carries the dry weight of that part: RMSE 1.583 to 1.577 N, MAPE 3.13 % to 3.11 %. The Bergdahl waveform comparison was not re-run (its measured series was not available); its files and metrics are those of v0.3.0, as `provenance.json` states | +| Bodies suite (102 metrics) | 102 of 102 pass with a GNU Release build of the release tree | +| OpenFAST linearisation (`validation/scripts/openfast_lin_ab.py`, IEA-15 MW UMaine twin decks and a mixed cable deck) | passed with the release `openfast.exe` (single precision): CableDyn mooring block symmetric to 7.2e-6; surge stiffness 7.721e4 N/m against MoorDyn-F's 7.716e4 N/m; fairlead blocks to 1.1e-3 and the platform 6×6 stiffness to 1.0e-3 of MoorDyn-F's quasi-static reduction; the lowest nine line-mode frequencies to 0.3 %; the mixed cable deck's point stiffness to its static solves to 1.1e-4 | +| Wall time of the shipped examples, v0.3.0 vs dev during the release checks (GNU, same host, one thread, OpenBLAS Haswell kernel) | over the 51 decks both run, the geometric-mean ratio is 0.938 and the total falls from 213.0 to 196.5 s | + +## Windows executable gates + +Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, +run 41672938269). The smoke runs used a system-only `PATH`. + +| Gate | Result | +| --- | --- | +| Compiler | IFX 2025.3.2 (minimum 2025.3) | +| OpenFAST solution build | one pass: 34 projects succeeded, 0 failed | +| `CableDyn_driver.exe` imports | `KERNEL32.dll`, `SHELL32.dll` and `imagehlp.dll` only; stack reserve 268,435,456 bytes; `--version` reports `Build x86-64-v3 (AVX2)` | +| `openfast.exe` imports | `KERNEL32.dll` and `imagehlp.dll` only; `-v` reports `OpenFAST-v5.0.0-CableDyn-0.4.0`; reports `CableDyn build: x86-64-v3 (AVX2).` | +| Processor check | both executables stop at start with exit 3 and the message on a simulated missing x86-64-v3 feature | +| Standalone smoke | the shallow-chain static deck (`chain_catenary_shallow_30m.dat`) converges | +| Memory growth over a 10x longer run | 2.6 -> 2.6 MiB (`dynamic_chain_current.dat`), 35.3 -> 20.7 MiB (`lozon_gomex80_power_cable.dat`); limit +16 MiB | +| Exit contract | a run states the exit contract after the banner; a refused input ends stderr with the closing line | +| `CompMooring = 5` smoke | CableDyn banner, `dtM` 0.025 s (one glue step), equilibrium fairlead tensions 2.436 MN, normal termination | + +## Clean-machine test + +A self-contained check ran the release assets from a folder whose path holds spaces, an accented +letter and Hangul, with a system-only `PATH`. It checks the checksums of the four files and the +manifest, the start of both executables (both name 0.4.0), every shipped example deck (53) with +the release `CableDyn_driver.exe`, three `CompMooring = 5` runs (a 70 s JONSWAP sea with mixed +chains and a cable, a 400 s line failure, and a checkpoint at 30 s with a restart whose last +10 s of output, 400 rows, must be bit-identical), and the Python wheel in a new virtual +environment, where it imports as 0.4.0 and runs the release driver. All 12 checks passed. + +## Python distribution + +The PyPI distribution is built by `.github/workflows/wheels.yml`; each wheel is installed into a +clean environment and smoke-tested on its own platform (the library and the driver it carries +load and run a deck, and the driver reports the expected build). The preflight run (41672945382) +built the files below; the release run rebuilds them from the tag before the upload. The 0.4.0 +dry run through TestPyPI installed the Windows wheel into a new environment and passed the same +smoke test. + +| File | SHA-256 (preflight) | +| --- | --- | +| `cabledyn-0.4.0.tar.gz` | `f9c259133bf2b83d635656fbf533f4e29867c505a5828640271a8d9e4351e0bd` | +| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `61d05cdd8a048633f2559809afaf094558b6893d1a1e247bbe10ee2c1490e3d5` | +| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `568cb1e7d81a41a46c8c3c7186f4b354521a528ebf398271b54dfdfa4944b5c4` | +| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `b491d167b501c134519c4dbaff8f17fb01667005362dafbc71aad45b58b0febc` | + +## Assets + +| File | SHA-256 | +| --- | --- | +| `CableDyn_driver.exe` | `c20385caa8badf4947f3c3485489768eed74d3aa60c913003564a81eb5b9c04f` | +| `openfast.exe` | `7322948dd7bbf24c32847d0213d31bd2e12706360015c5e5e6128851214b68b9` | +| `cabledyn-0.4.0-py3-none-any.whl` | `dbc879d96fb9501532c718144f2d22ec80bdd33e46464c8463c9529c3dc5fd7a` | +| `cabledyn-0.4.0.tar.gz` | `bc54da985d797fdb98e65722ced1fe5282edc75f8611290112f6df90177f34a8` | From 8e40e33fc8e58410b43f1b447a34f6a7c4f8dac9 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 02:47:32 +0900 Subject: [PATCH 42/51] fix(python): renaming a line carries its CurvX and CurvY channels The line-channel pattern of the deck object model listed Curv but not the section-frame CurvXN and CurvYN channels of 0.4.0, so DeckModel.rename() left them on the old line id (validate() then reported an unknown line, or a reused id silently reported another line) and removal did not see them. Both prefixes are now in the pattern; a test renames and cascade-removes a finite-EI line with all four curvature and moment channels. Signed-off-by: Jae Hoon Seo --- python/cabledyn/builder.py | 5 ++++- python/tests/test_builder.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index ae8d59fa..d73f3f31 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -112,7 +112,10 @@ ), ), ("line", re.compile(r"(tdp)([0-9]+)(s|x|y|z|lay|exc|grd)", re.IGNORECASE)), - ("line", re.compile(r"(ten|curv|bendmom|stfmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE)), + ( + "line", + re.compile(r"(ten|curvx|curvy|curv|bendmom|stfmom|torq)([0-9]+)(n[0-9]+)", re.IGNORECASE), + ), ("line", re.compile(r"(twist)([0-9]+)(n[0-9]+|)", re.IGNORECASE)), ("line", re.compile(r"(l)([0-9]+)(n[0-9]+(?:[pva][xyz]|dec|azi))", re.IGNORECASE)), ("point", re.compile(r"(point|con)([0-9]+)(p[xyz])", re.IGNORECASE)), diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index d3d28f19..8685f609 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -421,6 +421,16 @@ def _finite_ei_model() -> DeckModel: return model +def test_section_curvature_channels_follow_rename_and_removal() -> None: + model = _finite_ei_model() + model.outputs.add("CurvX1N2", "curvy1n2", "Curv1N2", "BendMom1N2") + model.rename(model.lines[1], 3) + assert list(model.outputs)[-4:] == ["CurvX3N2", "curvy3n2", "Curv3N2", "BendMom3N2"] + model.validate() + model.remove(model.lines[3], cascade=True) + assert not any(name.lower().startswith(("curv", "bendmom")) for name in model.outputs) + + def test_end_connections_attachments_and_equivalent_buoyancy() -> None: model = _finite_ei_model() model.add_end_connection(1, "EndA", 2.0e4, (-0.25, 0.0, -0.97)) From c7da9324da84cb80b99262d00fc5e322896341e5 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 03:26:57 +0900 Subject: [PATCH 43/51] chore(release): record the assets rebuilt with the CurvX fix The Python deck-model fix changes the wheels and the sdist, so the release assets (run 41687653164) and the wheels (run 41687659235) were rebuilt from 8e40e33. The record carries their hashes; the clean-machine test (12 of 12) and the linearisation check passed again on the rebuilt assets, and the Python suite was re-run (2163 passed). Signed-off-by: Jae Hoon Seo --- validation/RELEASE_0_4_0.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/validation/RELEASE_0_4_0.md b/validation/RELEASE_0_4_0.md index 6a0ec34d..7156eae0 100644 --- a/validation/RELEASE_0_4_0.md +++ b/validation/RELEASE_0_4_0.md @@ -12,7 +12,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro | Item | Value | | --- | --- | | CableDyn | `0.4.0` (2026-11-04), C ABI 1, minor extension 3 | -| Source | The release-preparation tree (`release/0.4.0` at `edd0d62`): dev with #48 to #85 and the version, documentation and test-build changes of the release. The assets and the Windows gates were produced from this tree; afterwards only `doc/conf.py` (a Sphinx cross-reference setting) and this record changed, which no build reads | +| Source | The release-preparation tree (`release/0.4.0` at `8e40e33`): dev with #50 to #85 and the version, documentation, test-build and Python deck-model changes of the release. The assets and the Windows gates were produced from this tree; afterwards only this record changed, which no build reads. The local CTest, Debug and kernel-sweep runs below used `edd0d62`; the two later commits change only `doc/conf.py` and the Python deck model, whose suite was re-run at `8e40e33` | | OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 22 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | | OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | | Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422`, built with IFX for x86-64-v3 (`/fp:precise /arch:CORE-AVX2`) | @@ -34,7 +34,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro | GNU Release CTest, including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed on the release tree; 0 compiler warnings | | GNU Debug CTest (`-fcheck=all`), including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed; 0 compiler warnings | | Round-off fragility (GNU Release build of the release tree on the OpenBLAS kernels Prescott, Nehalem, Sandybridge, Haswell, SkylakeX and Zen, through `OPENBLAS_CORETYPE`) | on each kernel the full CTest passes 359 of 359, the two kernel-pinned tests (`openfast_touchdown`, `hermite_node_reaction`) pass unpinned, and all 53 shipped example decks run with no fallback, stall or relaxed-tolerance note and the same exit status | -| Python package tests (local, native library and driver of the release tree) | 2162 passed, 47 skipped (platform- and tool-dependent cases) | +| Python package tests (local, native library and driver of the release tree) | 2163 passed, 47 skipped (platform- and tool-dependent cases) | | CI matrix of #85 (the last change before the release tree) | Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks | | Sphinx documentation (`-W -n`) | built with no warnings | | pre-commit, all files | passed | @@ -48,7 +48,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro ## Windows executable gates Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, -run 41672938269). The smoke runs used a system-only `PATH`. +run 41687653164). The smoke runs used a system-only `PATH`. | Gate | Result | | --- | --- | @@ -58,7 +58,7 @@ run 41672938269). The smoke runs used a system-only `PATH`. | `openfast.exe` imports | `KERNEL32.dll` and `imagehlp.dll` only; `-v` reports `OpenFAST-v5.0.0-CableDyn-0.4.0`; reports `CableDyn build: x86-64-v3 (AVX2).` | | Processor check | both executables stop at start with exit 3 and the message on a simulated missing x86-64-v3 feature | | Standalone smoke | the shallow-chain static deck (`chain_catenary_shallow_30m.dat`) converges | -| Memory growth over a 10x longer run | 2.6 -> 2.6 MiB (`dynamic_chain_current.dat`), 35.3 -> 20.7 MiB (`lozon_gomex80_power_cable.dat`); limit +16 MiB | +| Memory growth over a 10x longer run | 2.6 -> 2.6 MiB (`dynamic_chain_current.dat`), 20.7 -> 20.7 MiB (`lozon_gomex80_power_cable.dat`); limit +16 MiB | | Exit contract | a run states the exit contract after the banner; a refused input ends stderr with the closing line | | `CompMooring = 5` smoke | CableDyn banner, `dtM` 0.025 s (one glue step), equilibrium fairlead tensions 2.436 MN, normal termination | @@ -76,23 +76,23 @@ environment, where it imports as 0.4.0 and runs the release driver. All 12 check The PyPI distribution is built by `.github/workflows/wheels.yml`; each wheel is installed into a clean environment and smoke-tested on its own platform (the library and the driver it carries -load and run a deck, and the driver reports the expected build). The preflight run (41672945382) +load and run a deck, and the driver reports the expected build). The preflight run (41687659235) built the files below; the release run rebuilds them from the tag before the upload. The 0.4.0 dry run through TestPyPI installed the Windows wheel into a new environment and passed the same smoke test. | File | SHA-256 (preflight) | | --- | --- | -| `cabledyn-0.4.0.tar.gz` | `f9c259133bf2b83d635656fbf533f4e29867c505a5828640271a8d9e4351e0bd` | -| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `61d05cdd8a048633f2559809afaf094558b6893d1a1e247bbe10ee2c1490e3d5` | -| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `568cb1e7d81a41a46c8c3c7186f4b354521a528ebf398271b54dfdfa4944b5c4` | -| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `b491d167b501c134519c4dbaff8f17fb01667005362dafbc71aad45b58b0febc` | +| `cabledyn-0.4.0.tar.gz` | `8a007c0f0b9f5e5de5bf63465c7473adfc2412d5825fa018782865783bdc24b7` | +| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `1058350e848459c19d1053f5561bb1f71eac4f7c7be9adcd2d799eb9917ed050` | +| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `c1b3c45c6282d1032312fd53fdba526324efb8056de88f2f6aa9f2c054972371` | +| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `c0a5e8b8748598771b5f7962c1b1f634f9293303f3473bbed080ea68d3da14fb` | ## Assets | File | SHA-256 | | --- | --- | -| `CableDyn_driver.exe` | `c20385caa8badf4947f3c3485489768eed74d3aa60c913003564a81eb5b9c04f` | -| `openfast.exe` | `7322948dd7bbf24c32847d0213d31bd2e12706360015c5e5e6128851214b68b9` | -| `cabledyn-0.4.0-py3-none-any.whl` | `dbc879d96fb9501532c718144f2d22ec80bdd33e46464c8463c9529c3dc5fd7a` | -| `cabledyn-0.4.0.tar.gz` | `bc54da985d797fdb98e65722ced1fe5282edc75f8611290112f6df90177f34a8` | +| `CableDyn_driver.exe` | `65c7b30790e447ba1b8bf000451d37c07c103e00b0d6bba6f474817c982a58bf` | +| `openfast.exe` | `79942e44a9d7fc8e98c64baf1fc90dd8c724f690388b4c7cc880528c96965682` | +| `cabledyn-0.4.0-py3-none-any.whl` | `bf8867075b0988c722237083a5103f82ad4301ba426c5ebe60faf1a013f85d58` | +| `cabledyn-0.4.0.tar.gz` | `46a4e3d56c8ed60d7c9bf8510482aa9619995acaff6b5004ae434ade4bd09385` | From 79760e09744004d6eaae683ec19c1d6da96946d6 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 04:57:31 +0900 Subject: [PATCH 44/51] fix(driver): an output root never overwrites an input named like a V or modes output check_input_not_output() refuses an output root whose files would replace the deck or a file the deck reads, but its list missed two of the names a run writes: .Line.V.out, the VIV lift output of 0.4.0, and .modes.out, the modal-analysis output. An input named like either was opened with STATUS=REPLACE and destroyed. The numbered suffix check now takes .V.out on lines and the fixed list .modes.out; every other name the driver writes was already covered. check_driver_paths.cmake runs a deck named clash.Line2.V.out and one named clash.modes.out with the root clash, expects the refusal and checks the deck is unchanged; it fails on the previous driver. Signed-off-by: Jae Hoon Seo --- app/cabledyn.f90 | 15 +++++++++------ tests/check_driver_paths.cmake | 10 ++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/app/cabledyn.f90 b/app/cabledyn.f90 index 4c51b0fa..841b9cc3 100644 --- a/app/cabledyn.f90 +++ b/app/cabledyn.f90 @@ -287,8 +287,9 @@ END SUBROUTINE check_output_root SUBROUTINE check_input_not_output(input, root, root_spelling, what, input_spelling) !! Stop before any solve when the input file (the deck or a file the deck names) !! is one the run would overwrite. The run writes .out, .static.out, - !! .elements.out, .Line.p.out / .t.out / .range.out, .Rod.p.out, plus - !! the transient .write_check.tmp probe and the .cabledyn.lock lock. + !! .elements.out, .modes.out, .Line.p.out / .t.out / .V.out / .range.out, + !! .Rod.p.out, plus the transient .write_check.tmp probe and the + !! .cabledyn.lock lock. !! Each fixed name is compared with the input by file identity; the numbered !! per-line and per-rod names are recognized from the input's own name and then !! confirmed by identity, so every spelling of one file (relative, absolute, @@ -296,7 +297,8 @@ SUBROUTINE check_input_not_output(input, root, root_spelling, what, input_spelli CHARACTER(*), INTENT(IN) :: input, root, root_spelling, what CHARACTER(*), INTENT(IN), OPTIONAL :: input_spelling ! The fixed output suffixes, blank-separated. - CHARACTER(*), PARAMETER :: FIXED = '.out .static.out .elements.out .write_check.tmp '//LOCK_SUFFIX//' ' + CHARACTER(*), PARAMETER :: FIXED = '.out .static.out .elements.out .modes.out .write_check.tmp '// & + LOCK_SUFFIX//' ' CHARACTER(:), ALLOCATABLE :: spelling, base_in, base_root, suffix CHARACTER(512) :: why INTEGER :: stat, first, last @@ -339,8 +341,9 @@ SUBROUTINE check_input_not_output(input, root, root_spelling, what, input_spelli END SUBROUTINE check_input_not_output PURE LOGICAL FUNCTION is_numbered_output_suffix(suffix) RESULT(yes) - !! True for ".line.p.out", ".line.t.out", ".line.range.out" and - !! ".rod.p.out" (lower case), the per-line and per-rod output names. + !! True for ".line.p.out", ".line.t.out", ".line.v.out", + !! ".line.range.out" and ".rod.p.out" (lower case), the per-line and + !! per-rod output names. CHARACTER(*), INTENT(IN) :: suffix INTEGER :: first, n yes = .FALSE. @@ -366,7 +369,7 @@ PURE LOGICAL FUNCTION is_numbered_output_suffix(suffix) RESULT(yes) IF (VERIFY(suffix(first:n - 6), '0123456789') /= 0) RETURN IF (suffix(n - 5:n) == '.p.out') THEN yes = .TRUE. - ELSE IF (suffix(n - 5:n) == '.t.out') THEN + ELSE IF (suffix(n - 5:n) == '.t.out' .OR. suffix(n - 5:n) == '.v.out') THEN yes = suffix(1:5) == '.line' END IF END FUNCTION is_numbered_output_suffix diff --git a/tests/check_driver_paths.cmake b/tests/check_driver_paths.cmake index 67b53205..a36f08ee 100644 --- a/tests/check_driver_paths.cmake +++ b/tests/check_driver_paths.cmake @@ -132,6 +132,16 @@ file(READ "${WORK}/clash.Line3.t.out" after) if(NOT after STREQUAL static_text) message(FATAL_ERROR "the refused run modified its deck") endif() +# the VIV lift output of a line and the modal-analysis output +foreach(clash_name IN ITEMS "clash.Line2.V.out" "clash.modes.out") + file(WRITE "${WORK}/${clash_name}" "${static_text}") + run_driver("${clash_name}" "clash") + expect_refusal("deck named like ${clash_name}" "would overwrite the input deck") + file(READ "${WORK}/${clash_name}" after) + if(NOT after STREQUAL static_text) + message(FATAL_ERROR "the refused run modified its deck ${clash_name}") + endif() +endforeach() file(WRITE "${WORK}/auxclash.static.out" "-100 -100 100\n1000 -100 100\n-100 100 100\n1000 100 100\n") string(REPLACE "100.0 WtrDpth" "auxclash.static.out bathymetryFile" clash_text "${static_text}") file(WRITE "${WORK}/auxclash_deck.dat" "${clash_text}") From 09200058a4db0966e4e06ae3cba4a4f0a357a2e7 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 05:00:50 +0900 Subject: [PATCH 45/51] fix(python): an overwrite keeps and restores the lift, range and modal outputs CableDynDriver.run(overwrite=True) moves the previous results of the root aside and restores them if the new run fails, but its list of result files held only .out, .static.out, .elements.out and the .Line.p/.t and .Rod.p files. The .Line.V.out lift output of 0.4.0, the .Line.range.out range output and .modes.out were not moved: a failing rerun overwrote them with partial files, and a successful one that no longer writes them left stale ones beside the new results. They are now result files of the root; DriverResult.line_outputs keeps its documented .p/.t files. Two tests, failing before: a rerun that writes partial lift, range and modal files and fails restores the previous ones, and a successful rerun removes the stale ones. Signed-off-by: Jae Hoon Seo --- python/cabledyn/driver.py | 23 +++++++++++++++++------ python/tests/test_cli.py | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/python/cabledyn/driver.py b/python/cabledyn/driver.py index d1e7f6bb..ee6ab8df 100644 --- a/python/cabledyn/driver.py +++ b/python/cabledyn/driver.py @@ -384,16 +384,27 @@ def _merged_environment(overrides: Mapping[str, str]) -> dict[str, str]: def _result_files(root: Path) -> list[Path]: - """Return every existing native result file of ``root``.""" - candidates = [Path(f"{root}.{suffix}") for suffix in ("out", "static.out", "elements.out")] - candidates.extend(_auxiliary_outputs(root, "Line")) + """Return every existing native result file of ``root``. + + These are the files a run with ``overwrite`` moves aside and restores: every name the + driver writes under the root, the VIV lift (``.Line.V.out``), range + (``.Line.range.out``) and modal (``.modes.out``) outputs included. + """ + fixed = ("out", "static.out", "elements.out", "modes.out") + candidates = [Path(f"{root}.{suffix}") for suffix in fixed] + candidates.extend(_auxiliary_outputs(root, "Line", r"(?:[pt]|V|range)")) candidates.extend(_auxiliary_outputs(root, "Rod")) return [path for path in candidates if path.is_file()] -def _auxiliary_outputs(root: Path, object_name: str) -> tuple[Path, ...]: - """Find literal ``.*.out`` files without glob expansion.""" - flag = {"Line": "[pt]", "Rod": "p"}[object_name] +def _auxiliary_outputs(root: Path, object_name: str, flag: str | None = None) -> tuple[Path, ...]: + """Find literal ``.*.out`` files without glob expansion. + + ``flag`` is the regular expression of the part before ``.out``; by default the + node-position and tension files (``p``/``t`` for lines, ``p`` for rods). + """ + if flag is None: + flag = {"Line": "[pt]", "Rod": "p"}[object_name] pattern = re.compile(rf"{re.escape(root.name)}\.{object_name}-?\d+\.{flag}\.out") return tuple( sorted( diff --git a/python/tests/test_cli.py b/python/tests/test_cli.py index d3ee91c8..09b9e815 100644 --- a/python/tests/test_cli.py +++ b/python/tests/test_cli.py @@ -116,6 +116,42 @@ def test_successful_overwrite_replaces_and_removes_stale_auxiliary_files( assert not list(deck.parent.glob(".base.previous-*")) +_LIFT_RANGE_MODES = ("base.Line1.V.out", "base.Line2.range.out", "base.modes.out") + + +def test_failed_overwrite_restores_lift_range_and_modal_outputs(fake_driver, deck, monkeypatch): + driver = CableDynDriver(fake_driver) + driver.run(deck, "base") + previous = {} + for name in _LIFT_RANGE_MODES: + (deck.parent / name).write_text(f"previous {name}\n", encoding="ascii") + previous[name] = (deck.parent / name).read_bytes() + + def fails_after_writing(*args, **kwargs): + # the run writes partial lift, range and modal files over the previous ones, then fails + for name in _LIFT_RANGE_MODES: + (deck.parent / name).write_text("partial", encoding="ascii") + return subprocess.CompletedProcess(args[0], 3, "", "CableDyn_driver: synthetic failure") + + monkeypatch.setattr(subprocess, "run", fails_after_writing) + with pytest.raises(DriverExecutionError): + driver.run(deck, "base", overwrite=True) + assert {name: (deck.parent / name).read_bytes() for name in _LIFT_RANGE_MODES} == previous + assert not list(deck.parent.glob(".base.previous-*")) + + +def test_successful_overwrite_removes_stale_lift_range_and_modal_outputs( + fake_driver, deck, monkeypatch +): + driver = CableDynDriver(fake_driver) + driver.run(deck, "base") + for name in _LIFT_RANGE_MODES: + (deck.parent / name).write_text(f"previous {name}\n", encoding="ascii") + driver.run(deck, "base", overwrite=True) + assert not [name for name in _LIFT_RANGE_MODES if (deck.parent / name).exists()] + assert not list(deck.parent.glob(".base.previous-*")) + + def test_interrupted_overwrite_restores_previous_results(fake_driver, deck, monkeypatch): driver = CableDynDriver(fake_driver) driver.run(deck, "base") From 476e2c5392d555f3c23aadcaee0d5dfc6435cecc Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 05:06:30 +0900 Subject: [PATCH 46/51] fix(python): read_output reads a VIV lift file The .Line.V.out lift output of 0.4.0 names its channels NodeLiftX/Y/Z(N); read_output took every Node-led table for a node-position history and refused it (malformed dynamic line-node channels). A table whose channels are all lift channels is now a TimeHistory. A test reads one with and without the DeckNode line, and every V.out of the test suite reads. doc/cli.rst states the file checks of this release: the driver input guard covers .modes.out and .V.out, and an overwrite keeps aside every file a run writes. The CHANGELOG records these output-file fixes. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 +++++ doc/cli.rst | 16 ++++++---------- python/cabledyn/results.py | 15 +++++++++++---- python/tests/test_results.py | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b97b60f..cdabcc25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -93,6 +93,11 @@ All notable changes to CableDyn are recorded in this file. The format follows - Messages that said something untrue (SeaState kinematics, body/rod start moves, deck current source, torsion twist, FAST.Farm `DT_Mooring`), and a coupled deck mixing bodies and rods now says where it runs. +- Output files: the driver refuses an output root whose `.modes.out` or `.Line.V.out` would + overwrite an input; the Python `overwrite` run keeps aside and restores the `.V.out`, + `.range.out` and `.modes.out` files as well (an existing one now needs `overwrite`); + `read_output` reads a `.V.out` lift file; renaming a line in `DeckModel` carries its + `CurvX`/`CurvY` channels. ### Upgrading diff --git a/doc/cli.rst b/doc/cli.rst index 5036ac73..ff588248 100644 --- a/doc/cli.rst +++ b/doc/cli.rst @@ -102,10 +102,9 @@ Before the deck is solved, the driver rejects, with exit code 1 and a message on * an output root one of whose result files would be the deck, however spelled (``CableDyn_driver: output root "" would overwrite the input deck``), or a file the deck reads (``… would overwrite the input file "" that the deck reads``). The check - covers ``.out``, ``.static.out``, ``.elements.out``, the per-line ``.Line.p.out`` / - ``.t.out`` / ``.range.out`` and per-rod ``.Rod.p.out`` files, the probe, and the lock. - The modal table ``.modes.out`` (written only when ``nModes`` is set) is not checked, so do - not choose an output root whose ``.modes.out`` name is one of your input files; + covers every file a run writes: ``.out``, ``.static.out``, ``.elements.out``, the modal + table ``.modes.out``, the per-line ``.Line.p.out`` / ``.t.out`` / ``.V.out`` / + ``.range.out`` and per-rod ``.Rod.p.out`` files, the probe, and the lock; * an output location that cannot be written — a missing directory or one without write permission (``CableDyn_driver: cannot write output files at "" (check that the directory exists and is writable)``). The check creates and removes a probe file @@ -391,12 +390,9 @@ readable main output table. **Files written.** The native driver writes ``.out`` and, depending on the deck, ``.static.out``, ``.elements.out``, ``.Line.p.out``, -``.Line.t.out``, ``.Line.range.out``, ``.Rod.p.out`` and -``.modes.out`` (see :doc:`outputs`). If any of ``.out``, ``.static.out``, -``.elements.out``, or a ``.Line.p.out``, ``.Line.t.out`` or ``.Rod.p.out`` file -of that root already exists, the run is refused unless ``--overwrite`` is given. The range -graphs ``.Line.range.out`` and the modal table ``.modes.out`` are not part of this check: an -existing file of that name is replaced by the new run and is not restored if it fails. With +``.Line.t.out``, ``.Line.V.out``, ``.Line.range.out``, +``.Rod.p.out`` and ``.modes.out`` (see :doc:`outputs`). If any of these files of +that root already exists, the run is refused unless ``--overwrite`` is given. With ``--overwrite`` the previous files are moved into a temporary directory ``..previous-`` beside them while the solver runs. They are deleted once the new run has succeeded; if the rerun fails for any reason (non-zero exit, timeout, missing or diff --git a/python/cabledyn/results.py b/python/cabledyn/results.py index b9cf14b7..4c766ac1 100644 --- a/python/cabledyn/results.py +++ b/python/cabledyn/results.py @@ -853,6 +853,7 @@ def plot( # Indices are capped at nine digits so int() never meets an unbounded string. _NODE_CHANNEL = re.compile(r"Node([1-9][0-9]{0,8})([XYZ])\(([^()]*)\)") _SEGMENT_CHANNEL = re.compile(r"Segment([1-9][0-9]{0,8})Tension\(([^()]*)\)") +_LIFT_CHANNEL = re.compile(r"Node([1-9][0-9]{0,8})Lift([XYZ])\(([^()]*)\)") @dataclass(frozen=True) @@ -1708,10 +1709,16 @@ def read_output(path: str | os.PathLike[str]) -> OutputTable: first = channels[0].lower() if first in {"time", "time(s)"}: remaining = channels[1:] - node_like = remaining and ( - any(_NODE_CHANNEL.fullmatch(channel) for channel in remaining) - or all(channel.startswith("Node") for channel in remaining) - or re.search(r"\.Line[1-9][0-9]*\.p\.out$", table_path.name) is not None + # A VIV lift file (.Line.V.out, NodeLiftX/Y/Z in N) is a plain time history. + lift_like = bool(remaining) and all(_LIFT_CHANNEL.fullmatch(c) for c in remaining) + node_like = ( + not lift_like + and remaining + and ( + any(_NODE_CHANNEL.fullmatch(channel) for channel in remaining) + or all(channel.startswith("Node") for channel in remaining) + or re.search(r"\.Line[1-9][0-9]*\.p\.out$", table_path.name) is not None + ) ) segment_like = remaining and ( any(_SEGMENT_CHANNEL.fullmatch(channel) for channel in remaining) diff --git a/python/tests/test_results.py b/python/tests/test_results.py index 22a9bdb0..681a76c4 100644 --- a/python/tests/test_results.py +++ b/python/tests/test_results.py @@ -553,6 +553,24 @@ def test_line_node_coordinates_are_read_only_and_time_is_validated(tmp_path): assert table.arc_length(0.0)[-1] == pytest.approx(math.sqrt(9 + 16 + 16)) +@pytest.mark.parametrize("deck_nodes", [False, True]) +def test_viv_lift_file_is_read_as_a_time_history(tmp_path, deck_nodes): + # .Line.V.out (LINES Outputs flag V): NodeLiftX/Y/Z(N), no units row + channels = [f"Node{i}Lift{axis}(N)" for i in (1, 2) for axis in "XYZ"] + text = "# CableDyn dynamic line VIV lift force at the nodes; public node order EndA -> EndB\n" + if deck_nodes: + text += "# DeckNode\t1\t0\n" + text += "\t".join(["Time(s)", *channels]) + "\n" + text += "0.0\t0\t0\t0\t0\t0\t0\n0.1\t0\t1.5\t0\t0\t-2.5\t0\n" + path = tmp_path / "run.Line1.V.out" + path.write_text(text, encoding="ascii") + table = read_output(path) + assert type(table) is TimeHistory + assert table.channels == ("Time(s)", *channels) + assert table.values.shape == (2, 7) + assert table.values[1, 2] == 1.5 + + def test_line_node_history_rejects_bad_channels(tmp_path): with pytest.raises(OutputFormatError, match="malformed dynamic line-node channels"): LineNodeHistory(tmp_path / "p.out", "", ("Time(s)",), None, np.zeros((1, 1))) From 48faf7039719b1a5bda97f6822239298cd789e74 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 05:49:55 +0900 Subject: [PATCH 47/51] chore(release): record the assets rebuilt with the output-file fixes The driver output guard and the Python output-file fixes change the executables and the wheels, so the release assets (run 41709562272) and the wheels (run 41709568758) were rebuilt from 476e2c5. The record carries their hashes and the commits each local check ran on; the clean-machine test (12 of 12) and the linearisation check passed again, and the release driver refuses decks named like a lift or modal output. Signed-off-by: Jae Hoon Seo --- validation/RELEASE_0_4_0.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/validation/RELEASE_0_4_0.md b/validation/RELEASE_0_4_0.md index 7156eae0..6f81f51e 100644 --- a/validation/RELEASE_0_4_0.md +++ b/validation/RELEASE_0_4_0.md @@ -12,7 +12,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro | Item | Value | | --- | --- | | CableDyn | `0.4.0` (2026-11-04), C ABI 1, minor extension 3 | -| Source | The release-preparation tree (`release/0.4.0` at `8e40e33`): dev with #50 to #85 and the version, documentation, test-build and Python deck-model changes of the release. The assets and the Windows gates were produced from this tree; afterwards only this record changed, which no build reads. The local CTest, Debug and kernel-sweep runs below used `edd0d62`; the two later commits change only `doc/conf.py` and the Python deck model, whose suite was re-run at `8e40e33` | +| Source | The release-preparation tree (`release/0.4.0` at `476e2c5`): dev with #50 to #85 and the version, documentation, test-build, driver output-guard and Python changes of the release. The assets and the Windows gates were produced from this tree; afterwards only this record changed, which no build reads. The Debug CTest, the kernel sweep and the bodies suite below used `edd0d62`, the Release CTest `79760e0` (the driver output guard); the later commits change only the Python package, whose suite was re-run at `476e2c5` | | OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 22 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | | OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | | Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422`, built with IFX for x86-64-v3 (`/fp:precise /arch:CORE-AVX2`) | @@ -31,10 +31,10 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro | Gate | Result | | --- | --- | -| GNU Release CTest, including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed on the release tree; 0 compiler warnings | +| GNU Release CTest, including the slow tier (Windows, local; a fresh build directory at `edd0d62`, rebuilt at `79760e0`) | 359 of 359 passed at both; 0 compiler warnings | | GNU Debug CTest (`-fcheck=all`), including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed; 0 compiler warnings | | Round-off fragility (GNU Release build of the release tree on the OpenBLAS kernels Prescott, Nehalem, Sandybridge, Haswell, SkylakeX and Zen, through `OPENBLAS_CORETYPE`) | on each kernel the full CTest passes 359 of 359, the two kernel-pinned tests (`openfast_touchdown`, `hermite_node_reaction`) pass unpinned, and all 53 shipped example decks run with no fallback, stall or relaxed-tolerance note and the same exit status | -| Python package tests (local, native library and driver of the release tree) | 2163 passed, 47 skipped (platform- and tool-dependent cases) | +| Python package tests (local, native library and driver of the release tree) | 2167 passed, 47 skipped (platform- and tool-dependent cases) | | CI matrix of #85 (the last change before the release tree) | Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks | | Sphinx documentation (`-W -n`) | built with no warnings | | pre-commit, all files | passed | @@ -48,7 +48,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro ## Windows executable gates Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, -run 41687653164). The smoke runs used a system-only `PATH`. +run 41709562272). The smoke runs used a system-only `PATH`. | Gate | Result | | --- | --- | @@ -76,23 +76,23 @@ environment, where it imports as 0.4.0 and runs the release driver. All 12 check The PyPI distribution is built by `.github/workflows/wheels.yml`; each wheel is installed into a clean environment and smoke-tested on its own platform (the library and the driver it carries -load and run a deck, and the driver reports the expected build). The preflight run (41687659235) +load and run a deck, and the driver reports the expected build). The preflight run (41709568758) built the files below; the release run rebuilds them from the tag before the upload. The 0.4.0 dry run through TestPyPI installed the Windows wheel into a new environment and passed the same smoke test. | File | SHA-256 (preflight) | | --- | --- | -| `cabledyn-0.4.0.tar.gz` | `8a007c0f0b9f5e5de5bf63465c7473adfc2412d5825fa018782865783bdc24b7` | -| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `1058350e848459c19d1053f5561bb1f71eac4f7c7be9adcd2d799eb9917ed050` | -| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `c1b3c45c6282d1032312fd53fdba526324efb8056de88f2f6aa9f2c054972371` | -| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `c0a5e8b8748598771b5f7962c1b1f634f9293303f3473bbed080ea68d3da14fb` | +| `cabledyn-0.4.0.tar.gz` | `ad0e5e10fd7d6c8ed2788bc58f6d2328500bad16eb1d39984521b461a4a777a8` | +| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `bd08167a311ed1098dbf63052547d922275b46b055c31a220a80d1fcc819e3dc` | +| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `390759cb3b15fc2f86a4d6d21f6d9ae24fc765d54f91be9dac608e4fe866bf7a` | +| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `d35868bdda8a07bdc052b1372b60e88bf788087e3c5eca01400d357fed328839` | ## Assets | File | SHA-256 | | --- | --- | -| `CableDyn_driver.exe` | `65c7b30790e447ba1b8bf000451d37c07c103e00b0d6bba6f474817c982a58bf` | -| `openfast.exe` | `79942e44a9d7fc8e98c64baf1fc90dd8c724f690388b4c7cc880528c96965682` | -| `cabledyn-0.4.0-py3-none-any.whl` | `bf8867075b0988c722237083a5103f82ad4301ba426c5ebe60faf1a013f85d58` | -| `cabledyn-0.4.0.tar.gz` | `46a4e3d56c8ed60d7c9bf8510482aa9619995acaff6b5004ae434ade4bd09385` | +| `CableDyn_driver.exe` | `470c07fbcbd293b0b38012eb3a55ee919604736b6e6eef13c7900a77fe251502` | +| `openfast.exe` | `02ca8ffd36ecc9a5d47b58df6c028878683dd8e41837bb84c9bc22116980fa77` | +| `cabledyn-0.4.0-py3-none-any.whl` | `c43a37581377699e0337f2178953d33905477ce4beff810dbbb6cfcfb07ea4a9` | +| `cabledyn-0.4.0.tar.gz` | `20398e8cee8fe35547b5f7064470ff9172adeb2dcc9af8ffff1a9013dd6c1bfa` | From 27ce301fd5774042cfb6b7c7ae652263febba7f7 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 07:43:45 +0900 Subject: [PATCH 48/51] fix(study): reserve the lift, range and modal output suffixes in case names A study writes every case into one directory, so a case named base.Line1.V, base.Line1.range or base.modes would overwrite the .V.out, .range.out or .modes.out file of a case base. The collision check now covers every ..out name the driver writes. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 5 +++-- doc/cli.rst | 3 ++- python/cabledyn/study.py | 4 +++- python/tests/test_study.py | 13 ++++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdabcc25..6a57e352 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,8 +96,9 @@ All notable changes to CableDyn are recorded in this file. The format follows - Output files: the driver refuses an output root whose `.modes.out` or `.Line.V.out` would overwrite an input; the Python `overwrite` run keeps aside and restores the `.V.out`, `.range.out` and `.modes.out` files as well (an existing one now needs `overwrite`); - `read_output` reads a `.V.out` lift file; renaming a line in `DeckModel` carries its - `CurvX`/`CurvY` channels. + `read_output` reads a `.V.out` lift file; a study refuses a case name such as + `base.Line1.V`, `base.Line1.range` or `base.modes` beside a case `base`; renaming a line in + `DeckModel` carries its `CurvX`/`CurvY` channels. ### Upgrading diff --git a/doc/cli.rst b/doc/cli.rst index ff588248..6003ec44 100644 --- a/doc/cli.rst +++ b/doc/cli.rst @@ -1145,7 +1145,8 @@ remaining cases. **Preflight.** Before any solver process starts, the command verifies the manifest schema, that the source deck and every generated deck exist and match their recorded SHA-256, that case names are safe and unique and deck paths distinct, that no case name collides with the output files -of another case (for example ``base`` and ``base.static``), and the option values above. It +of another case (for example ``base`` and ``base.static``, ``base.modes``, ``base.Line1.V`` or +``base.Line1.range``), and the option values above. It refuses a non-empty output directory without ``--overwrite``, locates the driver, records its SHA-256, and queries its ``--version`` banner (10 s limit). diff --git a/python/cabledyn/study.py b/python/cabledyn/study.py index a03aaf41..6c721f2c 100644 --- a/python/cabledyn/study.py +++ b/python/cabledyn/study.py @@ -37,7 +37,9 @@ "current_profile_4d.txt", } ) -_OUTPUT_SUFFIX = re.compile(r"\.(?:static|elements|Line\d+\.[pt]|Rod-?\d+\.p)$", re.IGNORECASE) +_OUTPUT_SUFFIX = re.compile( + r"\.(?:static|elements|modes|Line-?\d+\.(?:[pt]|V|range)|Rod-?\d+\.p)$", re.IGNORECASE +) def _sha256(path: Path) -> str: diff --git a/python/tests/test_study.py b/python/tests/test_study.py index 860d07a1..61cdeb71 100644 --- a/python/tests/test_study.py +++ b/python/tests/test_study.py @@ -227,7 +227,18 @@ def test_study_preserves_zero_exit_invalid_output_as_postprocess_failure(tmp_pat assert good.status == "completed" -@pytest.mark.parametrize("derived", ["base.static", "BASE.elements", "base.Line2.t", "base.Rod1.p"]) +@pytest.mark.parametrize( + "derived", + [ + "base.static", + "BASE.elements", + "base.modes", + "base.Line2.t", + "base.Line1.V", + "base.Line3.range", + "base.Rod1.p", + ], +) def test_study_rejects_case_names_that_alias_another_cases_outputs(tmp_path, derived): manifest = _case_manifest(tmp_path, ("base", derived)) driver = _driver(tmp_path) From e859c79a6701e87f79df697c9eb9c82165a890fb Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 08:15:30 +0900 Subject: [PATCH 49/51] fix(deck): accept VIV on an EI = 0 line without a seabed The native driver builds every EI = 0 line with the still-water Morison drag, with or without WtrDpth or bathymetry, so its VIV lift needs no seabed and the driver runs such a deck (a dry deck and a MoorDyn-C Currents 1 profile without a depth row both run to completion). The Python validation still refused them as "no water"; the check is removed so DeckFile, DeckModel and study generation accept the decks the driver accepts. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 2 ++ python/cabledyn/deck_file.py | 23 ----------------------- python/tests/test_deck_file.py | 24 ++++++++++++++++++------ 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a57e352..345466ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -99,6 +99,8 @@ All notable changes to CableDyn are recorded in this file. The format follows `read_output` reads a `.V.out` lift file; a study refuses a case name such as `base.Line1.V`, `base.Line1.range` or `base.modes` beside a case `base`; renaming a line in `DeckModel` carries its `CurvX`/`CurvY` channels. +- Python deck validation accepts VIV on an EI = 0 line without a seabed (for example in a + MoorDyn-C `Currents` profile), as the driver does: the line has its still-water drag either way. ### Upgrading diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index bfe968c5..7ea1388a 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -2725,9 +2725,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: line_type_scales: dict[str, tuple[float, float]] = {} # name -> (BA, max Cd/Ca) line_type_meta: dict[str, tuple[float, float, float, float]] = {} line_type_gj: dict[str, float] = {} # name -> explicit GJ of a 14-column row, else 0 - # Cl > 0 on an EI = 0 row (native init_one_model, which needs the line's Morison drag in - # water) - has_viv_ei0 = False viv_type_names: set[str] = set() for row in self.line_types: for index in (1, 2, *range(5, len(row.tokens))): @@ -2813,7 +2810,6 @@ def numeric(token: str, row: DeckRecord, field: str) -> float: f"{self._at(row)}: LINE TYPES VIV synchronisation band needs cF > 0 " "and 0 <= dF < cF" ) - has_viv_ei0 = has_viv_ei0 or (cl > 0.0 and not ei > 0.0) if cl > 0.0: viv_type_names.add(row.tokens[0].lower()) if ei > 0.0 and (is_syrope or len(ea_parts) > 1): @@ -3742,25 +3738,6 @@ def end_key(token: str) -> str: "the deck with MoorDyn (CompMooring = 3) or, without CoupledPinned objects, " "with the standalone driver, whose multibody march takes both" ) - if has_viv_ei0 and not self.caller_driven: - # native init_one_model: the lift acts with the line's Morison drag, which the - # deck switches on with water (a depth or bathymetry, a current, or waves); on the - # coupled route the host supplies the water - waterkin_option = option_by_key.get("waterkin") - waterkin_text = "" if waterkin_option is None else waterkin_option.values[0] - has_water = ( - has_depth - or has_bathymetry - or has_waves - or bool(trains) - or (current is not None and current.values[0].lower() != "none") - or waterkin_text.lower() not in {"", "0", "none", "seastate"} - ) - if not has_water: - raise DeckFormatError( - f"{self._label}: VIV (LINE TYPES Cl > 0) acts with the line's Morison drag " - "in water: declare WtrDpth (or bathymetryFile), a current or waves" - ) if mixed_route and not self.caller_driven: n_modes_value = option_by_key.get("n_modes") if n_modes_value is not None and round(_native_float(n_modes_value.values[0])) != 0: diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 49d0dda6..bac4331f 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -7,6 +7,7 @@ import math import os import re +import shutil from pathlib import Path import pytest @@ -4780,12 +4781,23 @@ def test_viv_is_accepted_on_the_coupled_route(): DeckFile.from_text(_edit(text, ("50.0 WtrDpth\n", "")), caller_driven=True) -def test_viv_needs_water_on_an_ei0_line(): - text = _edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8"), ("50.0 WtrDpth\n", "")) - with pytest.raises(DeckFormatError, match="acts with the line's Morison drag in water"): - DeckFile.from_text(text) - # without the lift the same dry deck stays valid - DeckFile.from_text(_edit(_STATIC, ("50.0 WtrDpth\n", ""))) +def test_viv_on_an_ei0_line_needs_no_seabed(tmp_path): + # native init_one_model builds every EI = 0 line with the still-water Morison drag (the + # surface at z = 0), with or without a seabed, so its lift needs no WtrDpth either + DeckFile.from_text(_edit(_STATIC, (_VIV_ROW, _VIV_ROW + " 0.8"), ("50.0 WtrDpth\n", ""))) + # a MoorDyn-C Currents 1 profile without a depth row + source = ROOT / "tests" / "data" / "currents_mdc" / "c1" + for name in ("currents.dat", "current_profile.txt", "points.txt"): + shutil.copy(source / name, tmp_path / name) + row = ( + "chain 0.1 50.0 1.0e7 0.0 0 1.2 1.0 0.2 0.0" + ) + deck = tmp_path / "currents.dat" + text = deck.read_text(encoding="utf-8") + depth = "50 WtrDpth water depth (m)\n" + assert row in text and depth in text + deck.write_text(text.replace(depth, "").replace(row, row + " 0.8"), encoding="utf-8") + DeckFile.read(deck) def test_finite_ei_viv_is_accepted_on_the_multibody_march(): From 0979ba7ac9f16f32e9904a7775a2ef8bc8de7711 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 08:15:30 +0900 Subject: [PATCH 50/51] test(ci): reserve four processors for torsion_current_start The test runs its four pretwists at once but reserved one CTest processor, so on a four-core runner with ctest --parallel 4 it shared the cores with three other tests. The ubuntu Debug job took 475-895 s on pull requests and timed out at 900 s on the last three dev pushes. PROCESSORS 4 makes it run alone, and the timeout is 1800 s. Signed-off-by: Jae Hoon Seo --- CMakeLists.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b0703b7..ad56bfd6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1804,7 +1804,9 @@ if(Python3_Interpreter_FOUND) # 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. # A lazy wave restrained in torsion starts in an in-plane current (its untwisted state's - # out-of-plane instability is kept, not refused by the torsion stage). + # out-of-plane instability is kept, not refused by the torsion stage). The four pretwists run + # at once: PROCESSORS reserves them, so no other test shares the cores (on a four-core runner + # the Debug build took up to 900 s when it did). add_test(NAME torsion_current_start COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_torsion_current_start.py --exe $ @@ -1812,7 +1814,8 @@ if(Python3_Interpreter_FOUND) --output ${CMAKE_BINARY_DIR}/torsion_current_start) set_tests_properties(torsion_current_start PROPERTIES LABELS "python;driver;integration;static" - TIMEOUT 900 + PROCESSORS 4 + TIMEOUT 1800 ENVIRONMENT "${_cabledyn_python_test_environment}") # An EI = 0 line above the still-water level on a deck without a seabed carries its dry weight From 3d04008f5bd7721283fc028c086e32f8588dc3de Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Wed, 4 Nov 2026 09:05:33 +0900 Subject: [PATCH 51/51] chore(release): record the assets rebuilt with the study and VIV fixes Assets run 41737729420 and wheels run 41737734726 at 0979ba7: the clean-machine check (12 of 12), the driver output guard and the linearisation check on the release openfast.exe pass as before; the Python suite passes 2170 tests. Signed-off-by: Jae Hoon Seo --- validation/RELEASE_0_4_0.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/validation/RELEASE_0_4_0.md b/validation/RELEASE_0_4_0.md index 6f81f51e..65bdb2fa 100644 --- a/validation/RELEASE_0_4_0.md +++ b/validation/RELEASE_0_4_0.md @@ -12,7 +12,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro | Item | Value | | --- | --- | | CableDyn | `0.4.0` (2026-11-04), C ABI 1, minor extension 3 | -| Source | The release-preparation tree (`release/0.4.0` at `476e2c5`): dev with #50 to #85 and the version, documentation, test-build, driver output-guard and Python changes of the release. The assets and the Windows gates were produced from this tree; afterwards only this record changed, which no build reads. The Debug CTest, the kernel sweep and the bodies suite below used `edd0d62`, the Release CTest `79760e0` (the driver output guard); the later commits change only the Python package, whose suite was re-run at `476e2c5` | +| Source | The release-preparation tree (`release/0.4.0` at `0979ba7`): dev with #50 to #85 and the version, documentation, test-build, driver output-guard, Python and CI test changes of the release. The assets and the Windows gates were produced from this tree; afterwards only this record changed, which no build reads. The Debug CTest, the kernel sweep and the bodies suite below used `edd0d62`, the Release CTest `79760e0` (the driver output guard); the later commits change only the Python package, whose suite was re-run at `0979ba7`, and the CTest properties of `torsion_current_start` (four reserved processors, a 1800 s timeout: it timed out at 900 s on the four-core Linux Debug runner), which passes at `0979ba7` | | OpenFAST base | `2895884d2be01862173c88d70f86b358d2f1a50a`; the 22 patches of [`integration/openfast/patches`](../integration/openfast/patches) applied to a clean checkout by `prepare_openfast_source.ps1` | | OpenFAST r-test | `dd5feaaaa500ba7283140107806300d551cff0a7` | | Reference LAPACK/BLAS | 3.12.1, release-tag archive with SHA-256 `2ca6407a001a474d4d4d35f3a61550156050c48016d949f0da0529c0aa052422`, built with IFX for x86-64-v3 (`/fp:precise /arch:CORE-AVX2`) | @@ -34,7 +34,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro | GNU Release CTest, including the slow tier (Windows, local; a fresh build directory at `edd0d62`, rebuilt at `79760e0`) | 359 of 359 passed at both; 0 compiler warnings | | GNU Debug CTest (`-fcheck=all`), including the slow tier (Windows, local, fresh build directory) | 359 of 359 passed; 0 compiler warnings | | Round-off fragility (GNU Release build of the release tree on the OpenBLAS kernels Prescott, Nehalem, Sandybridge, Haswell, SkylakeX and Zen, through `OPENBLAS_CORETYPE`) | on each kernel the full CTest passes 359 of 359, the two kernel-pinned tests (`openfast_touchdown`, `hermite_node_reaction`) pass unpinned, and all 53 shipped example decks run with no fallback, stall or relaxed-tolerance note and the same exit status | -| Python package tests (local, native library and driver of the release tree) | 2167 passed, 47 skipped (platform- and tool-dependent cases) | +| Python package tests (local, native library and driver of the release tree) | 2170 passed, 47 skipped (platform- and tool-dependent cases) | | CI matrix of #85 (the last change before the release tree) | Linux and Windows, Release and Debug; Python on three platforms with coverage and strict type checks | | Sphinx documentation (`-W -n`) | built with no warnings | | pre-commit, all files | passed | @@ -48,7 +48,7 @@ LAPACK are those of [v0.3.0](RELEASE_0_3_0.md); the OpenFAST patch set grows fro ## Windows executable gates Every gate of `build_static_windows.ps1` passed in the release workflow (`release-windows-static.yml`, -run 41709562272). The smoke runs used a system-only `PATH`. +run 41737729420). The smoke runs used a system-only `PATH`. | Gate | Result | | --- | --- | @@ -76,23 +76,23 @@ environment, where it imports as 0.4.0 and runs the release driver. All 12 check The PyPI distribution is built by `.github/workflows/wheels.yml`; each wheel is installed into a clean environment and smoke-tested on its own platform (the library and the driver it carries -load and run a deck, and the driver reports the expected build). The preflight run (41709568758) +load and run a deck, and the driver reports the expected build). The preflight run (41737734726) built the files below; the release run rebuilds them from the tag before the upload. The 0.4.0 dry run through TestPyPI installed the Windows wheel into a new environment and passed the same smoke test. | File | SHA-256 (preflight) | | --- | --- | -| `cabledyn-0.4.0.tar.gz` | `ad0e5e10fd7d6c8ed2788bc58f6d2328500bad16eb1d39984521b461a4a777a8` | -| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `bd08167a311ed1098dbf63052547d922275b46b055c31a220a80d1fcc819e3dc` | -| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `390759cb3b15fc2f86a4d6d21f6d9ae24fc765d54f91be9dac608e4fe866bf7a` | -| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `d35868bdda8a07bdc052b1372b60e88bf788087e3c5eca01400d357fed328839` | +| `cabledyn-0.4.0.tar.gz` | `5cca2f5f7ec6570566a2b2bc592e30e1af0adc9f1bb10fdc4de6e2b8c29d2825` | +| `cabledyn-0.4.0-py3-none-win_amd64.whl` | `10bd506fbbcfe4c54f2b5192454b0b61746a8404ca3e70bf18aed168469ac253` | +| `cabledyn-0.4.0-py3-none-macosx_15_0_arm64.whl` | `ea5cbfb7a3b6ec410cf7cd69a3f076937d18fdbc3c769da826fbea2407c0c3b6` | +| `cabledyn-0.4.0-py3-none-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl` | `46b55d4f8350586f9619b4d2ea48252d920bfffe4bbbce0e0831e05fbac23fad` | ## Assets | File | SHA-256 | | --- | --- | -| `CableDyn_driver.exe` | `470c07fbcbd293b0b38012eb3a55ee919604736b6e6eef13c7900a77fe251502` | -| `openfast.exe` | `02ca8ffd36ecc9a5d47b58df6c028878683dd8e41837bb84c9bc22116980fa77` | -| `cabledyn-0.4.0-py3-none-any.whl` | `c43a37581377699e0337f2178953d33905477ce4beff810dbbb6cfcfb07ea4a9` | -| `cabledyn-0.4.0.tar.gz` | `20398e8cee8fe35547b5f7064470ff9172adeb2dcc9af8ffff1a9013dd6c1bfa` | +| `CableDyn_driver.exe` | `3d3a91c53c57f616cb39780fb72d97f817b68c90cb50dc9ad9bbc8dd90f30f2a` | +| `openfast.exe` | `ce2069ddc1ee88f823c9aaa1f99c156f9a2dce685c2a6ca2efd3900c3d6e928d` | +| `cabledyn-0.4.0-py3-none-any.whl` | `b97aacbb708d79b5d1e17f963100ced29140824fb7b48f00adcc20bee1c161b1` | +| `cabledyn-0.4.0.tar.gz` | `dc604a85188ec69cb739d0a9357cccd84e4bce7336c54bf915234234d8e9279b` |