From 1cef1e39b719eb5290225219bb43836a0a4bd5cc Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 20:14:33 +0900 Subject: [PATCH 01/10] feat(statics): OrcaFlex "as laid" seabed friction in statics Seabed friction had no effect on the static solve: the friction springs are anchored to the frictionless still-water layout, so a grounded run on a slope with tan(theta) < mu, or laid with surplus length, still slid or folded (an EI = 0 line on a 5 deg slope with mu = 1 folded 24 m past its anchor, exactly as with mu = 0). The new option staticsFriction asLaid follows OrcaFlex's "As laid" policy: the line is assumed laid from its lower end along a lay azimuth (default from anchor to fairlead, layAzimuth / layAzimuth) at an as-laid tension (asLaidTension / asLaidTension, default 0), and friction resists displacement from those positions in the static solve, with the regularised law of the dynamics (isotropic and anisotropic). The dynamics continue from the static friction anchors. Both line families, the coupled aggregate and the C API share it. With asLaid, the 5 deg EI = 0 line holds where it is laid (FairTen 714.2 -> 622.9 kN, friction within mu N at every grounded node, held runs drift by 1.5e-10 of FairTen), and a 650 m finite-EI cable on a 10 deg slope, which failed, solves and holds. On a flat seabed laid at its run tension the result equals the frictionless one (FairTen within 6e-6). As an illustration, the IEA-15 mixed example with asLaid has a chain AnchTen of 368.2 kN instead of 1351.6 kN: friction holds back a run laid slack and pulled taut. The default is staticsFriction none, the previous behaviour and that of MoorDyn, which is conservative for anchor loads; every example and test deck is byte-identical under it. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 22 ++ CMakeLists.txt | 13 + doc/driver_format.md | 5 +- doc/modeling.rst | 8 + doc/options.rst | 43 ++- doc/theory.rst | 92 +++++- doc/troubleshooting.rst | 18 ++ examples/cabledyn_options_reference.dat | 7 + src/CableDyn_DeckDriver.f90 | 361 +++++++++++++++++++++++- src/CableDyn_HermiteCableStatic.f90 | 48 +++- src/CableDyn_Model.f90 | 116 +++++++- src/CableDyn_Static.f90 | 276 ++++++++++++++++-- tests/test_static_friction_as_laid.py | 248 ++++++++++++++++ 13 files changed, 1186 insertions(+), 71 deletions(-) create mode 100644 tests/test_static_friction_as_laid.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d5d89754..ae172275 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,28 @@ All notable changes to CableDyn are recorded in this file. The format follows ### Added +- Seabed friction in the static solve, toward the as-laid position (OrcaFlex's *as laid* + statics seabed friction policy, opt-in): `asLaid staticsFriction`. Every grounded node is + held by a friction spring toward the position at which the line was laid from its anchor + along the lay azimuth on the seabed, with the regularised Coulomb law of the dynamics + (isotropic or axial/lateral, capped at `mu N`), in still water and in a current, on `EI = 0` + and finite-EI lines, standalone, coupled OpenFAST and through the C API; the march continues + the static springs, so a held run stays at rest. New OPTIONS `staticsFriction none|asLaid`, + `layAzimuth` and `layAzimuth` (default: each line's anchor → fairlead direction), + `asLaidTension` and `asLaidTension` (default 0). The default stays `none`, as in MoorDyn: + frictionless statics in still water (friction from the still-water equilibrium in a current), + conservative for anchor loads, and every deck without the new rows runs as before. With + `asLaid`, a 700 m chain on a 5° slope with `frictionMu 1`, which the frictionless static + folds 24.0 m back past its anchor, holds where it was laid (friction up to 0.087 `mu N`, the + slope; FairTen 714.2 → 622.9 kN; held for 2 s to 1.5e-10 of FairTen), and a 650 m finite-EI + cable on a 10° slope, rejected as too long for its span, solves. As an illustration of the + effect on anchor loads, `asLaid` in `iea15mw_umaine_mixed_cabledyn.dat` lowers the chains' + AnchTen from 1351.6 to 368.2 kN (FairTen +0.16 %) and the laid cable's from 1230 N to 0.36 N: + runs laid slack and pulled taut are held back by friction. A run laid at the tension it + carries (`asLaidTension`) mobilises none: on a flat seabed FairTen equals the frictionless + one to 6e-6 and AnchTen to 0.4 %. A finite-EI line laid past the point under its fairlead has + no static solution yet (its touchdown hook is not reached); a lay azimuth across the span + solves it. See the theory page (Friction in statics). - Run-time profile of the standalone driver. With the environment variable `CABLEDYN_PROFILE=1`, the driver prints at the end of the run how its wall time divides between input parsing, initialisation and statics, and the dynamic march. The march is split diff --git a/CMakeLists.txt b/CMakeLists.txt index 57752120..f3fbb945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1393,6 +1393,19 @@ if(Python3_Interpreter_FOUND) TIMEOUT 900 ENVIRONMENT "${_cabledyn_python_test_environment}") + # Static seabed friction toward the as-laid position: a run on a slope below the friction + # angle holds (EI = 0 and finite EI), the march continues the static springs at rest, a + # line laid at its run tension reproduces the frictionless statics, and the inputs are + # checked. + add_test(NAME static_friction_as_laid + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_static_friction_as_laid.py + --exe $ + --output ${CMAKE_BINARY_DIR}/static_friction_as_laid) + set_tests_properties(static_friction_as_laid PROPERTIES + LABELS "python;static;seabed" + TIMEOUT 600 + ENVIRONMENT "${_cabledyn_python_test_environment}") + # Finite-EI generalised-alpha blends: force-blend dtM convergence under prescribed surge. add_test(NAME hermite_force_blend_dt COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_hermite_force_blend_dt.py diff --git a/doc/driver_format.md b/doc/driver_format.md index cb048610..8fa87e2c 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -992,8 +992,11 @@ syntax form. The most frequently edited keywords are: | `kBot` | seabed penalty stiffness base [Pa/m = N/m³], scaled per line node and rod contact station by diameter × tributary length, and by a fixed 1 m² reference area at a Rigid6 reference point (only with `WtrDpth`/`bathymetryFile`) | 1.0e5 | | `cBot` | seabed normal damping base [Pa·s/m = N·s/m³], scaled like `kBot`; active only on contacting nodes moving downward | 1.0e4 | | `bodyIC` | `static`: free `Rigid6` bodies and free rods, with `Free`/`Connect` points, start at their static equilibrium; `deck`: they start at their deck pose (for example a free-decay test) | `static` | -| `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | +| `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape, or toward the as-laid position with `staticsFriction asLaid`), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | | `frictionMuAxial` / `frictionMuLateral` | anisotropic line friction: the coefficients along and across the local line axis (OrcaFlex axial/normal); an omitted one takes `frictionMu`; both positive or both zero; rods and bodies use the lateral one | `frictionMu` | +| `staticsFriction` | statics seabed friction policy (OrcaFlex): `none` solves frictionless statics (in a deck current, friction from the still-water equilibrium); `asLaid` holds every grounded node toward its as-laid position (laid from the anchor along `layAzimuth` at `asLaidTension`) with the regularised Coulomb law | `none` | +| `layAzimuth`, `layAzimuth` | lay azimuth (deg, from +x toward +y) of every line, or of line `ID` | anchor → fairlead | +| `asLaidTension`, `asLaidTension` | as-laid effective tension (N, ≥ 0) of every line, or of line `ID` | 0 | | `dtM` | dynamic time step [s] | — | | `TMax` | dynamic end time [s]; an integer multiple of `dtM` | — | | `rhoInf` | generalised-α spectral radius | 0.4 | diff --git a/doc/modeling.rst b/doc/modeling.rst index ecaaf2d0..3ce96628 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -154,6 +154,14 @@ fallback) rather than by artificial drag-scaled relaxation. A converged solver is necessary but not sufficient: reject a result with the wrong touchdown side, impossible tension gradient, penetrated seabed, broken symmetry, or unresolved curvature peak. +With seabed friction (``frictionMu``) the static solve is frictionless in still water by +default, as in MoorDyn, which is conservative for anchor loads. ``asLaid staticsFriction`` +holds the grounded run toward the position in which the line was laid, as OrcaFlex's *as laid* +policy does: then decide how the line was laid (``layAzimuth``, by default from the anchor +toward the fairlead) and at what tension (``asLaidTension``, by default slack), because the +anchor tension depends on it: a run laid slack and pulled taut is held back by friction. See +:ref:`static-friction`. + 7. Configure dynamics and forcing ---------------------------------- diff --git a/doc/options.rst b/doc/options.rst index 2794e0b2..8bd32a73 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -105,7 +105,8 @@ Environment and seabed - finite, ≥ 0, or ``none``. A positive value needs ``WtrDpth`` or ``bathymetryFile``, and ``dtM``/``TMax`` in the standalone driver. Line nodes carry stick-slip friction springs; in a current the static solve holds the line with friction springs from its still-water laid - shape, and the march continues them. The isotropic shorthand of + shape, and the march continues them (``staticsFriction asLaid`` holds it toward its + as-laid position instead, in still water too). The isotropic shorthand of ``frictionMuAxial``/``frictionMuLateral``. Not supported (the deck is rejected) with a ``FAILURE`` section, on a deck with ``Connect``/``Free`` points or ``Point3`` buoys, or on a deck whose lines attach to ``Rigid6`` bodies or rods unless it runs on the default @@ -126,6 +127,46 @@ Environment and seabed ``frictionMuNormal``, ``frictionMu_normal`` for the lateral one. See :doc:`theory` - both, within the limits of ``frictionMu`` - ``0.2 frictionMuAxial`` + * - ``staticsFriction`` / ``statics_friction`` / ``staticsSeabedFrictionPolicy`` / + ``seabedFrictionPolicy`` + - word + - ``none`` + - ``none`` or ``asLaid`` (also ``as_laid``, ``as-laid``), case-insensitive; OrcaFlex's + statics seabed friction policy. ``none``: the static solve is frictionless in still water + (in a deck current, friction springs from the still-water equilibrium hold the line), and + the friction anchors of the march start at the static node positions. ``asLaid``: the + static solve resists the horizontal displacement of every grounded node from its as-laid + position (the line laid from its anchor along ``layAzimuth`` on the seabed at + ``asLaidTension``, its top end then moved to the fairlead) with the regularised Coulomb + law of the dynamics, capped at ``mu N``, in still water and in a current, so a run on a + slope with ``tan(slope) < mu`` holds and surplus length rests where it was laid; the + march continues the springs. ``none`` is the default, as in MoorDyn: a run laid slack + and pulled taut is held back by its friction, so the as-laid statics lowers anchor + tensions (by up to ``mu w`` times the grounded length), and the frictionless statics is + the conservative choice for anchor loads unless the as-laid layout and tension are + known. Used only with ``frictionMu > 0`` and a seabed. See :ref:`static-friction` + - both + - ``asLaid staticsFriction`` + * - ``layAzimuth`` / ``lay_azimuth``, and ``layAzimuth`` + - real, deg + - absent: each line's anchor → fairlead direction + - finite. Horizontal direction, from global +x toward +y, in which the line was laid from + its anchor (its lower end): the as-laid reference of ``staticsFriction asLaid``. + ``layAzimuth`` sets every line; ``layAzimuth`` (the line ID appended, e.g. + ``layAzimuth2``) sets line ``ID`` and overrides it. A direction off the vertical plane of + the line ends puts the finite-EI static solve in 3D. An ID that names no line is + rejected + - both + - ``225.0 layAzimuth2`` + * - ``asLaidTension`` / ``as_laid_tension``, and ``asLaidTension`` + - real, N + - ``0`` + - finite, ≥ 0. Effective tension with which the line was laid: the as-laid node spacing is + the unstretched one times ``1 + asLaidTension/EA``, so a run whose static tension equals + it carries no friction force. ``asLaidTension`` sets line ``ID`` alone, as for + ``layAzimuth`` + - both + - ``2.0e5 asLaidTension1`` Clock and initial condition --------------------------- diff --git a/doc/theory.rst b/doc/theory.rst index f8dee70b..f58a17a9 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -751,24 +751,89 @@ failed or subdivided step, join the aggregate snapshot, and are part of the Open checkpoint. The force and its position and velocity Jacobians (through :math:`N`) are exact. Unlike a velocity-regularised Coulomb law, the spring holds its force at rest. -In statics without a current the anchors are the static node positions and carry no force. In -a deck current the static solve carries friction springs from a reference position, capped -smoothly at :math:`\mu N`, +.. _static-friction: + +**Friction in statics.** With seabed friction a static equilibrium is not unique: a grounded +run can rest anywhere its friction holds it. Like OrcaFlex, CableDyn resolves this by assuming +the position in which the line was originally laid and letting friction act toward it. +OrcaFlex (Orcina's documentation, *Line data: statics*, +https://www.orcina.com/webhelp/OrcaFlex/Content/html/Linedata,Statics.htm, and *Friction +theory*, https://www.orcina.com/webhelp/OrcaFlex/Content/html/Frictiontheory.htm) offers the +statics seabed friction policies *none*, *as laid* and *restart*. As laid, with a step 1 +statics method other than *prescribed*, the line is assumed laid starting with its bottom end +at its position, in the *lay azimuth* direction away from it, following the seabed profile, and +its top end then moved slowly to its position; the friction targets are spaced along the +seabed by the unstretched segment lengths and the *as laid tension*, so a line with every node +on its target carries that tension throughout. Friction applies in statics only to line-seabed +contact and only when the policy is not *none*; each node's force acts toward its target and +is capped at :math:`\mu R`, and dynamics then starts from the target positions of statics. +OrcaFlex warns that a lay azimuth far from the vertical plane through the line ends makes the +statics harder to converge. The documentation consulted does not state the defaults of these +three data items. + +CableDyn implements the *as laid* and *none* policies (``staticsFriction``; *restart* has no +counterpart, and there is no prescribed starting shape). *None* is the default, as in MoorDyn: +the static solve is frictionless in still water, and in a deck current the friction springs +below hold the line from its still-water equilibrium (the same line solved without the current +first). It is conservative for anchor loads, since an as-laid run pulled taut is held back by +its friction (below). With ``asLaid`` the reference of +node :math:`i` is the as-laid position: the line is laid from its anchor (its lower end) along +the azimuth :math:`\alpha` (``layAzimuth``; by default the horizontal anchor → fairlead +direction, the vertical plane through the line ends) on the seabed at the tension +:math:`T_\text{laid}` (``asLaidTension``, default 0), so that the seabed path from the anchor +to node :math:`i` is :math:`s_i = \sum_{e`). A converged diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 9fd5209f..553cdfb9 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -464,6 +464,24 @@ but a few geometries are genuinely hard: turning angles; a finite-EI line carries compression there instead, which the driver notes. With 5 m elements on steep trench walls the end tensions of a pile still change by about 1 % on a mesh four times finer: refine the line over the trench when they matter. +- **A grounded run that slides down a slope, or anchor tension with as-laid friction.** By default + (``staticsFriction none``) the static solve is frictionless in still water, so a grounded run + on a slope slides down it whatever ``frictionMu`` is, and a line longer than its span folds or + is rejected. ``asLaid staticsFriction`` holds every grounded node toward its as-laid position + (see :ref:`static-friction`), so the run rests where it was laid. A line laid slack + (``asLaidTension 0``) and pulled taut by its fairlead is then held back by friction along its + grounded run, and its anchor tension is lower than the frictionless static's by up to + ``mu w`` times the grounded length (an 850 m chain in 200 m of water with ``frictionMu 0.35``: + 1352 → 368 kN). If the run was laid at a known tension, give it as ``asLaidTension`` (or + ``asLaidTension``): a run laid at the tension it carries mobilises no friction. +- **A finite-EI line laid past the point under its fairlead** (``asLaid staticsFriction``). A line + longer than the seabed run + from its anchor to the point under its fairlead plus its hang is laid beyond that point, and + its suspended part turns back over the grounded run at the touchdown. On an ``EI = 0`` line + this fold solves; a finite-EI line must round it into a hook of its bending length, which the + static solve may not reach (it then fails with its route diagnostics, for example ``too long + for its span``). Lay the line across the span (``layAzimuth``, e.g. 90° from the + anchor → fairlead direction), shorten it, or move the anchor. - **A twisted finite-EI line.** ``torsion continuation stalled at Phi = ... (target ...)`` reports the imposed twist the static ramp reached: beyond it the line has no nearby static equilibrium on the path, typically because a loop is forming (hockling), which needs a diff --git a/examples/cabledyn_options_reference.dat b/examples/cabledyn_options_reference.dat index 5b931ff4..a4223f66 100644 --- a/examples/cabledyn_options_reference.dat +++ b/examples/cabledyn_options_reference.dat @@ -77,6 +77,11 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- 3 WaterKin - MoorDyn-C WaveKin 3/7: wave_elevation.txt / wave_frequencies.txt in the deck folder -- 0.5 frictionMuAxial - Seabed friction along the line axis {>=0} [default: frictionMu] -- 0.5 frictionMuLateral - Seabed friction across the line axis {>=0} [default: frictionMu] +-- asLaid staticsFriction - Statics seabed friction policy {none; asLaid} [default: none] +-- 0.0 layAzimuth - Lay azimuth of every line from +x toward +y (deg) [default: anchor -> fairlead] +-- 225.0 layAzimuth2 - Lay azimuth of line 2 alone (deg) [default: layAzimuth] +-- 0.0 asLaidTension - As-laid effective tension of every line (N) [default: 0] +-- 2.0e5 asLaidTension2 - As-laid effective tension of line 2 alone (N) [default: asLaidTension] -- 0 nModes - Modal analysis: lowest natural modes per line {0=off; 1 to 1000} [default: 0] -- "WaterKin.dat" WaterKin - MoorDyn-F WaterKin file (standalone file modes or coupled host selectors) -- SEASTATE WaterKin - Full host SeaState field (OpenFAST aggregate only) @@ -92,6 +97,8 @@ none waves - Wave model and parameters (m, s, deg) {none; airy; -- 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 +-- staticsFriction = statics_friction = staticsSeabedFrictionPolicy = seabedFrictionPolicy +-- layAzimuth = lay_azimuth; asLaidTension = as_laid_tension -- dtM = dt; rhoInf = rho_inf; modified_newton = modifiedNewton; adaptive_mesh = adaptiveMesh -- cable_statics = cableStatics; alpha_force_blend = alphaForceBlend -- maxStrain = max_strain; WaveSeed = wave_seed; rampTime = ramp_time = tRamp diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index b57ea388..a9b44de7 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -37,7 +37,8 @@ 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_OK, CD_STATIC_BADINPUT, CD_Static_As_Laid_Reference, & + 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, & CD_Bathymetry_Floor_Gradient, CD_Bathymetry_Grid_Floor, CD_BATHY_OK @@ -85,6 +86,7 @@ MODULE CableDyn_DeckDriver CD_HermiteResolutionType, CD_HC_HKAPPA_TARGET, CD_HC_REFINE_CAP, & CD_HermiteCable_Refine_Mesh, CD_HermiteStaticCurrentType, & CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Mean_Axial_Extremes, & + CD_HermiteCable_Friction_Reference, & CD_HC_KINK_LIMIT, CD_HermiteCable_Static_Solve_Continuation, & CD_HermiteCable_Branch_Audit, CD_HermiteBranchAuditType, & CD_HC_AUDIT_BACKTRACK, CD_HC_AUDIT_COMPRESSION, CD_HC_AUDIT_KINK, & @@ -537,6 +539,16 @@ MODULE CableDyn_DeckDriver ! the one along the line; -1 = isotropic (frictionMu alone). REAL(wp) :: friction_mu_axial = -1.0_wp REAL(wp) :: friction_mu_axial_row = -1.0_wp, friction_mu_lateral_row = -1.0_wp + ! Static seabed friction (staticsFriction, layAzimuth, asLaidTension rows): the policy + ! (CD_STATIC_FRICTION_NONE, the default, or _AS_LAID), the lay azimuth [deg] for every + ! line (has_lay_azimuth; otherwise each line's anchor -> fairlead direction) and the + ! as-laid tension [N], with per-line overrides (layAzimuth, asLaidTension). + INTEGER :: static_friction = CD_STATIC_FRICTION_NONE + LOGICAL :: has_lay_azimuth = .FALSE. + REAL(wp) :: lay_azimuth_deg = CD_ZERO + REAL(wp) :: as_laid_tension = CD_ZERO + INTEGER, ALLOCATABLE :: lay_azimuth_line(:), as_laid_tension_line(:) + REAL(wp), ALLOCATABLE :: lay_azimuth_line_deg(:), as_laid_tension_line_value(:) LOGICAL :: has_wtrdpth = .FALSE. LOGICAL :: has_bathymetry_file = .FALSE. LOGICAL :: has_dtm = .FALSE., has_tmax = .FALSE. @@ -1558,11 +1570,11 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, LOGICAL :: tensile_error CHARACTER(400) :: note_text CHARACTER(512) :: limit_text - ! Steady deck current for the static solve (unallocated: no current). + ! Steady deck current for the static solve (unallocated: no current and no static friction). TYPE(CD_HermiteStaticCurrentType), ALLOCATABLE :: cur_obj, cur_exact - ! Seabed friction holding the line against the deck current (static springs to - ! the still-water laid shape, continued by elastic-plastic springs in the dynamics). - LOGICAL :: static_friction + ! Static seabed friction toward the as-laid position (static springs, continued by + ! elastic-plastic springs in the dynamics); a still-water deck carries it on cur_obj. + LOGICAL :: static_friction, as_laid REAL(wp), ALLOCATABLE :: fr_anchor(:, :), fr_force(:, :) INTEGER :: pass CHARACTER(1024) :: em, primary_msg, sequence_msg, planar_primary_msg, planar_sequence_msg, coarse_msg @@ -1967,16 +1979,33 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, dry_b = opts%rhoW*opts%g*QUARTER_PI*diam**2 ! A deck current loads the line at rest: the static equilibrium includes its steady drag ! (the drag of the dynamic path at zero velocity), so a run starts at rest in the current. - static_friction = .FALSE. - IF (opts%has_current) THEN + ! Static seabed friction. With staticsFriction asLaid (the OrcaFlex "as laid" policy) + ! every grounded node is held by a friction spring toward its as-laid position -- the + ! line laid from the anchor along the lay azimuth on the seabed at the as-laid tension -- + ! capped at mu N, in still water and in a current alike; the springs ride on the current + ! object, whose drag is zero in still water. With staticsFriction none (the default) a + ! frictional seabed resists only a deck current, from the still-water laid shape: the + ! line is first solved without the current, and that equilibrium is the reference of the + ! 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 + 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) CALL hermite_static_current(ln, sections, types, opts, l0, frame_cs, cur_obj) - ! A frictional seabed resists the current from the still-water laid shape (the - ! OrcaFlex convention): the line is first solved without the current, and that - ! equilibrium is the reference of the friction springs, whose forces then seed the - ! stick-slip anchors of the march (standalone and coupled alike). - static_friction = contact_enabled .AND. opts%has_friction - IF (static_friction) THEN + IF (.NOT. opts%has_current) THEN + cur_obj%velocity = CD_ZERO + 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) + END IF + IF (as_laid) THEN + CALL as_laid_reference(es, em) + IF (es /= CD_DECKDRV_OK) THEN + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI as-laid reference for the seabed friction: '// & + TRIM(em)); RETURN + END IF + ELSE IF (static_friction) THEN CALL still_water_reference(es, em) IF (es /= CD_DECKDRV_OK) THEN CALL fail_solve(ErrStat, ErrMsg, 'finite-EI still-water reference for the seabed friction: '// & @@ -3811,6 +3840,76 @@ SUBROUTINE still_water_reference(esr, emr) CALL CD_HFMF_End(sw_cable) END SUBROUTINE still_water_reference + SUBROUTINE as_laid_reference(esr, emr) + !! Friction reference of the static solve (CD_Static_As_Laid_Reference): the line laid + !! from its anchor (node 1) along the lay azimuth on the seabed at the as-laid tension, + !! as (x, y) offsets from node 1 in the solve frame along the unstretched arc length of + !! the deck mesh. A lay azimuth off the vertical plane of the chord puts the reference + !! out of that plane, so the static solve then runs in 3D. + INTEGER, INTENT(OUT) :: esr + CHARACTER(*), INTENT(OUT) :: emr + REAL(wp), ALLOCATABLE :: lay_az_opt, ref_g(:, :) + REAL(wp) :: laid_t, az, dg(2), a_g(3), f_g(3), dir_l(2) + INTEGER :: k, ne_r + esr = CD_DECKDRV_OK + emr = '' + ne_r = SIZE(l0) + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) + a_g = points(pa)%pos + f_g = points(pb)%pos + az = CD_ZERO + IF (NORM2(f_g(1:2) - a_g(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(f_g - a_g))) & + az = ATAN2(f_g(2) - a_g(2), f_g(1) - a_g(1)) + IF (ALLOCATED(lay_az_opt)) az = lay_az_opt + ALLOCATE (ref_g(2, ne_r + 1)) + IF (PRESENT(bathymetry)) THEN + BLOCK + ! static penalty penetration factor w_i/k_i of every node (the nodal contact + ! stiffness of the solve, kBot Diam l0 lumped to the nodes) + REAL(wp) :: wn(ne_r + 1), kn_r(ne_r + 1) + wn = CD_ZERO + kn_r = CD_ZERO + DO k = 1, ne_r + wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) + kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) + END DO + WHERE (kn_r > CD_ZERO) + wn = MAX(wn, CD_ZERO)/kn_r + ELSEWHERE + wn = CD_ZERO + END WHERE + CALL CD_Static_As_Laid_Reference(a_g(1:2), az, l0, ea, laid_t, ref_g, esr, emr, bathymetry=bathymetry, & + sink=wn) + END BLOCK + ELSE + CALL CD_Static_As_Laid_Reference(a_g(1:2), az, l0, ea, laid_t, ref_g, esr, emr) + END IF + IF (esr /= CD_STATIC_OK) THEN + esr = CD_DECKDRV_BADINPUT + RETURN + END IF + ALLOCATE (cur_obj%friction) + cur_obj%friction%mu = opts%friction_mu + cur_obj%friction%mu_axial = opts%friction_mu_axial + cur_obj%friction%as_laid = .TRUE. + ALLOCATE (cur_obj%friction%ref_s(ne_r + 1), cur_obj%friction%ref_xy(2, ne_r + 1)) + cur_obj%friction%ref_s(1) = CD_ZERO + DO k = 2, ne_r + 1 + cur_obj%friction%ref_s(k) = cur_obj%friction%ref_s(k - 1) + l0(k - 1) + END DO + DO k = 1, ne_r + 1 + dg = ref_g(:, k) - ref_g(:, 1) + cur_obj%friction%ref_xy(:, k) = [frame_cs(1)*dg(1) + frame_cs(2)*dg(2), -frame_cs(2)*dg(1) + frame_cs(1)*dg(2)] + END DO + IF (ALLOCATED(lay_az_opt)) THEN + dir_l = [frame_cs(1)*COS(az) + frame_cs(2)*SIN(az), -frame_cs(2)*COS(az) + frame_cs(1)*SIN(az)] + IF (ABS(dir_l(2)) > 64.0_wp*EPSILON(CD_ONE)) require_3d_static = .TRUE. + ELSE + ! the default azimuth is the chord's own heading: the reference lies in its plane + cur_obj%friction%ref_xy(2, :) = CD_ZERO + END IF + END SUBROUTINE as_laid_reference + SUBROUTINE fine_mesh_note(note) !! Sets note when some element is shorter than sqrt(EI/EA) (see its call). CHARACTER(*), INTENT(OUT) :: note @@ -4202,7 +4301,7 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia CHARACTER(400) :: walk_msg_c REAL(wp) :: walk_d, a_seed(3) CHARACTER(512) :: walk_msg - LOGICAL :: tensile, refine_all, planar_bed, walk_needed + 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 REAL(wp) :: lambda0, ratio, span(2), span_len, t, xg, yg, zf, sx, sz, sxx, sxz, xl, yl @@ -4312,10 +4411,30 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia ErrMsg = 'the bow behind the fairlead is traced over a flat seabed only' RETURN END IF + ! Static seabed friction toward an as-laid position: the seed is the EI = 0 equilibrium + ! of the same mesh with that friction (laid_seed_positions), which rests the grounded run + ! where the friction holds it; no catenary seed, and no anchor walk, is needed. Without + ! that equilibrium the catenary seed below is used, as on a mesh finer than sqrt(EI/EA) + ! somewhere, which the route fails closed on by name (the seed is not built for it). + laid = .FALSE. + IF (contact_enabled .AND. .NOT. fold .AND. PRESENT(cur_obj)) THEN + IF (ALLOCATED(cur_obj%friction)) THEN + IF (cur_obj%friction%as_laid .AND. cur_obj%friction%mu > CD_ZERO) THEN + IF (.NOT. ANY(ei > CD_ZERO .AND. ea > CD_ZERO .AND. l0 < SQRT(MAX(ei, CD_ZERO)/MAX(ea, TINY(CD_ONE))))) & + CALL laid_seed_positions(laid) + END IF + END IF + END IF walk_d = CD_ZERO a_seed = a_l walk_msg = '' seed_walk: DO k_walk = 0, WALK_MAX_TRIES + IF (laid) THEN + ErrStat = CD_HCSTAT_OK + ErrMsg = '' + inadmissible = .FALSE. + EXIT seed_walk + END IF IF (k_walk > 0) THEN ! First retreat: the length the line exceeds its span plus rise by, and a tenth of ! the line; then half as far again each time. @@ -4599,6 +4718,74 @@ RECURSIVE SUBROUTINE hermite_static_primary(anchor, fairlead, l0, ea, ei, w, dia CONTAINS + SUBROUTINE laid_seed_positions(ok) + !! Seed positions pos (translated solve frame) of a line with static seabed friction + !! toward its as-laid position: the tension-only EI = 0 equilibrium of the same mesh, + !! weight and seabed with that friction (CD_Static_Line_Equilibrium, solved in global + !! coordinates, where the bathymetry is queried). ok = .FALSE. when it has none. + LOGICAL, INTENT(OUT) :: ok + TYPE(CableCurrentLoad) :: fr_ld + TYPE(CableSolverConfig) :: cfg_ld + TYPE(CD_StaticLineReport) :: rep_ld + INTEGER, ALLOCATABLE :: conn_ld(:, :) + REAL(wp), ALLOCATABLE :: f_ld(:), kn_ld(:), q_ld(:), ref_l(:, :) + REAL(wp) :: c, s, a_g(3), f_g(3), xl_, yl_ + INTEGER :: e_, k_, es_ld + LOGICAL :: conv_ld + CHARACTER(512) :: em_ld + ok = .FALSE. + c = frame_cs(1) + s = frame_cs(2) + a_g = [c*anchor(1) - s*anchor(2), s*anchor(1) + c*anchor(2), anchor(3)] + f_g = [c*fairlead(1) - s*fairlead(2), s*fairlead(1) + c*fairlead(2), fairlead(3)] + ALLOCATE (conn_ld(2, ne), f_ld(3*nnode), kn_ld(nnode), q_ld(3*nnode), ref_l(2, nnode)) + f_ld = CD_ZERO + kn_ld = CD_ZERO + DO e_ = 1, ne + conn_ld(:, e_) = [e_, e_ + 1] + f_ld(3*e_) = f_ld(3*e_) - 0.5_wp*w(e_)*l0(e_) + f_ld(3*e_ + 3) = f_ld(3*e_ + 3) - 0.5_wp*w(e_)*l0(e_) + kn_ld(e_) = kn_ld(e_) + 0.5_wp*opts%kbot*diam(e_)*l0(e_) + kn_ld(e_ + 1) = kn_ld(e_ + 1) + 0.5_wp*opts%kbot*diam(e_)*l0(e_) + END DO + IF (.NOT. ALL(kn_ld > CD_ZERO)) RETURN + ! the as-laid reference on this mesh, from the solve frame to global coordinates + CALL CD_HermiteCable_Friction_Reference(cur_obj%friction, l0, anchor(1:2), ref_l, es_ld, em_ld) + IF (es_ld /= CD_HCSTAT_OK) RETURN + fr_ld%drag = .FALSE. + fr_ld%friction_mu = cur_obj%friction%mu + fr_ld%friction_mu_axial = cur_obj%friction%mu_axial + ALLOCATE (fr_ld%friction_ref(2, nnode)) + DO k_ = 1, nnode + fr_ld%friction_ref(:, k_) = [c*ref_l(1, k_) - s*ref_l(2, k_), s*ref_l(1, k_) + c*ref_l(2, k_)] + END DO + IF (PRESENT(bathymetry)) THEN + CALL CD_Static_Line_Equilibrium(a_g, f_g, conn_ld, l0, ea, w, f_ld, cfg_ld, .TRUE., q_ld, conv_ld, rep_ld, & + es_ld, em_ld, seabed_kn=kn_ld, bathymetry=bathymetry, current=fr_ld) + ELSE + CALL CD_Static_Line_Equilibrium(a_g, f_g, conn_ld, l0, ea, w, f_ld, cfg_ld, .TRUE., q_ld, conv_ld, rep_ld, & + es_ld, em_ld, seabed_z_floor=contact_z, seabed_kn=kn_ld, current=fr_ld) + END IF + IF (es_ld /= CD_STATIC_OK .OR. .NOT. conv_ld) RETURN + IF (.NOT. ALL(IEEE_IS_FINITE(q_ld))) RETURN + ! An element collapsed well below its length is a fold of the tension-only line (the + ! line laid past the point under the fairlead turns back over its grounded run, and + ! the slack elements at the turn bunch up): no seed for the bending-stiffness + ! continuation, whose hook would start from a kink. The catenary seed is used then. + DO e_ = 1, ne + IF (NORM2(q_ld(3*e_ + 1:3*e_ + 3) - q_ld(3*e_ - 2:3*e_)) < 0.99_wp*l0(e_)) RETURN + END DO + DO k_ = 1, nnode + xl_ = c*q_ld(3*k_ - 2) + s*q_ld(3*k_ - 1) + yl_ = -s*q_ld(3*k_ - 2) + c*q_ld(3*k_ - 1) + pos(3*k_ - 2:3*k_) = [xl_ - origin(1), yl_ - origin(2), q_ld(3*k_)] + END DO + ! the held ends exactly where the solve holds them + pos(1:3) = a_l + pos(3*nnode - 2:3*nnode) = f_l + ok = .TRUE. + END SUBROUTINE laid_seed_positions + LOGICAL FUNCTION planar_run_diagnosed(msg) RESULT(yes) !! Whether msg carries the frictionless grounded-run diagnosis of a current (the !! current drives the run on the seabed into compression) for this line held in its @@ -7168,6 +7355,31 @@ END SUBROUTINE CD_Deck_Equilibrium_Jacobian_Check ! per-line static solve (multi-section) ! ! --------------------------------------------------------------------------- ! + SUBROUTINE line_static_friction(opts, line_id, lay_az, laid_t) + !! Static seabed friction settings of one deck line: the lay azimuth [rad] when the deck + !! sets one (layAzimuth, else layAzimuth; unallocated otherwise, the line's anchor + !! -> fairlead direction) and the as-laid tension [N] (asLaidTension, else + !! asLaidTension, default 0). + TYPE(DeckOptions), INTENT(IN) :: opts + INTEGER, INTENT(IN) :: line_id + REAL(wp), ALLOCATABLE, INTENT(OUT) :: lay_az + REAL(wp), INTENT(OUT) :: laid_t + REAL(wp), PARAMETER :: DEG2RAD = 3.14159265358979323846264338327950288_wp/180.0_wp + INTEGER :: k + IF (opts%has_lay_azimuth) lay_az = opts%lay_azimuth_deg*DEG2RAD + IF (ALLOCATED(opts%lay_azimuth_line)) THEN + DO k = 1, SIZE(opts%lay_azimuth_line) + IF (opts%lay_azimuth_line(k) == line_id) lay_az = opts%lay_azimuth_line_deg(k)*DEG2RAD + END DO + END IF + laid_t = opts%as_laid_tension + IF (ALLOCATED(opts%as_laid_tension_line)) THEN + DO k = 1, SIZE(opts%as_laid_tension_line) + IF (opts%as_laid_tension_line(k) == line_id) laid_t = opts%as_laid_tension_line_value(k) + END DO + 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. TYPE(DeckLine), INTENT(IN) :: ln @@ -7194,11 +7406,16 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err INTEGER :: j, i, e, es LOGICAL :: want_wave_cfg CHARACTER(200) :: em + ! static seabed friction of this line: lay azimuth override [rad] (unallocated: the + ! default, the anchor -> fairlead direction) and as-laid tension [N] + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: laid_t ErrStat = CD_DECKDRV_OK ErrMsg = '' CALL gather_line_inputs(ln, sections, types, points, lts, secs, anchor, fairlead, ErrStat, ErrMsg) IF (ErrStat /= CD_DECKDRV_OK) RETURN + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) dynamic_cfg%rho_inf = opts%rho_inf dynamic_cfg%rel_tol = opts%dynamic_rel_tol @@ -7328,6 +7545,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + 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, & @@ -7355,6 +7574,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + 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, & @@ -7380,6 +7601,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + 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, & @@ -7406,6 +7629,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + 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, & @@ -7434,6 +7659,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + 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, & @@ -7460,6 +7687,8 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err seabed_kbot=opts%kbot, seabed_contact_diameter=diam, & seabed_cn_over_kn=opts%cbot/opts%kbot, & seabed_mu=opts%friction_mu, seabed_mu_axial=opts%friction_mu_axial, ba=ba, & + static_friction=opts%static_friction, lay_azimuth=lay_az_opt, & + 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, & @@ -7523,9 +7752,13 @@ SUBROUTINE init_one_syrope_model(types, syt, ln, lts, secs, anchor, fairlead, l0 INTEGER :: ne, e, es, n_owc, iter CHARACTER(200) :: 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 CALL fail(ErrStat, ErrMsg, 'a Syrope line must be a single section (composite Syrope lines are '// & 'not supported yet)'); RETURN @@ -7705,6 +7938,8 @@ SUBROUTINE build_model(with_syrope) 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 @@ -7714,6 +7949,8 @@ SUBROUTINE build_model(with_syrope) 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., & @@ -12687,6 +12924,21 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) CALL rd(val, opts%friction_mu, ErrStat, ErrMsg) opts%has_friction = (ErrStat == 0 .AND. opts%friction_mu > CD_ZERO) END IF + CASE ('staticsfriction', 'statics_friction', 'staticsseabedfrictionpolicy', 'seabedfrictionpolicy') + ! OrcaFlex's statics seabed friction policy: "as laid" (the default) or "none" + SELECT CASE (to_lower(TRIM(strip_quotes(val)))) + CASE ('aslaid', 'as_laid', 'as-laid') + opts%static_friction = CD_STATIC_FRICTION_AS_LAID + CASE ('none') + opts%static_friction = CD_STATIC_FRICTION_NONE + CASE DEFAULT + CALL fail(ErrStat, ErrMsg, 'OPTION '//TRIM(kw)//' must be asLaid or none (got "'//TRIM(val)//'")') + END SELECT + CASE ('layazimuth', 'lay_azimuth') + CALL rd(val, opts%lay_azimuth_deg, ErrStat, ErrMsg) + opts%has_lay_azimuth = ErrStat == 0 + CASE ('aslaidtension', 'as_laid_tension') + CALL rd(val, opts%as_laid_tension, ErrStat, ErrMsg) CASE ('mu_kt', 'mu_ka') ! MoorDyn-F seabed friction coefficients: named, so a stock deck is pointed at the ! CableDyn keywords rather than failing as an unknown keyword @@ -12812,9 +13064,58 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) 'supported; use Currents 1 or the "current" option') END SELECT CASE DEFAULT - CALL fail(ErrStat, ErrMsg, 'unknown OPTION keyword "'//TRIM(kw)//'"') + ! per-line static friction rows: layAzimuth, asLaidTension (line ID suffix) + BLOCK + CHARACTER(LEN(kw)) :: kl + INTEGER :: lid, ios_l, np + REAL(wp) :: xv + kl = to_lower(TRIM(kw)) + np = 0 + IF (LEN_TRIM(kl) > 10) THEN + IF (kl(1:10) == 'layazimuth') np = 10 + END IF + IF (LEN_TRIM(kl) > 13) THEN + IF (kl(1:13) == 'aslaidtension') np = 13 + END IF + ios_l = 1 + IF (np > 0) THEN + IF (VERIFY(TRIM(kl(np + 1:)), '0123456789') == 0) READ (kl(np + 1:), *, IOSTAT=ios_l) lid + END IF + IF (ios_l /= 0) THEN + CALL fail(ErrStat, ErrMsg, 'unknown OPTION keyword "'//TRIM(kw)//'"') + ELSE + CALL rd(val, xv, ErrStat, ErrMsg) + IF (ErrStat == 0) THEN + IF (np == 10) THEN + CALL set_line_value(opts%lay_azimuth_line, opts%lay_azimuth_line_deg, lid, xv) + ELSE + CALL set_line_value(opts%as_laid_tension_line, opts%as_laid_tension_line_value, lid, xv) + END IF + END IF + END IF + END BLOCK END SELECT IF (ErrStat == 0) CALL check_option_row_value(kw, val, ErrStat, ErrMsg) + CONTAINS + SUBROUTINE set_line_value(ids, vals, lid, xv) + !! Record (or replace: the last row wins) the per-line value xv of line lid. + INTEGER, ALLOCATABLE, INTENT(INOUT) :: ids(:) + REAL(wp), ALLOCATABLE, INTENT(INOUT) :: vals(:) + INTEGER, INTENT(IN) :: lid + REAL(wp), INTENT(IN) :: xv + INTEGER :: k + IF (.NOT. ALLOCATED(ids)) THEN + ALLOCATE (ids(0), vals(0)) + END IF + DO k = 1, SIZE(ids) + IF (ids(k) == lid) THEN + vals(k) = xv + RETURN + END IF + END DO + ids = [ids, lid] + vals = [vals, xv] + END SUBROUTINE set_line_value END SUBROUTINE apply_option SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) @@ -12842,6 +13143,10 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) CASE ('frictionmuaxial', 'frictionmu_axial', 'mu_axial', 'muaxial', 'frictionmulateral', 'frictionmu_lateral', & 'mu_lateral', 'mulateral', 'frictionmunormal', 'frictionmu_normal') rule = 'non-negative' + CASE ('aslaidtension', 'as_laid_tension') + rule = 'non-negative' + CASE ('layazimuth', 'lay_azimuth') + rule = 'finite' CASE ('rhoinf', 'rho_inf') rule = 'unit' CASE ('kbot', 'kb', 'cbot', 'cb', 'dtic', 'tmaxic', 'cdscaleic', 'threshic', 'writelog', 'dtout') @@ -13447,6 +13752,32 @@ SUBROUTINE finalize_checks(types, bodies, rod_types, rods, points, lines, sectio CALL fail(ErrStat, ErrMsg, 'OPTION frictionMu requires WtrDpth or bathymetryFile'); RETURN END IF END IF + ! per-line static friction rows: a line that exists, a finite azimuth, a tension >= 0 + IF (ALLOCATED(opts%lay_azimuth_line)) THEN + DO i = 1, SIZE(opts%lay_azimuth_line) + IF (find_line(lines, opts%lay_azimuth_line(i)) < 1) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION layAzimuth'//TRIM(int_to_str(opts%lay_azimuth_line(i)))// & + ' names no LINE'); RETURN + END IF + IF (.NOT. IEEE_IS_FINITE(opts%lay_azimuth_line_deg(i))) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION layAzimuth'//TRIM(int_to_str(opts%lay_azimuth_line(i)))// & + ' must be finite'); RETURN + END IF + END DO + END IF + IF (ALLOCATED(opts%as_laid_tension_line)) THEN + DO i = 1, SIZE(opts%as_laid_tension_line) + IF (find_line(lines, opts%as_laid_tension_line(i)) < 1) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION asLaidTension'//TRIM(int_to_str(opts%as_laid_tension_line(i)))// & + ' names no LINE'); RETURN + END IF + IF (.NOT. (IEEE_IS_FINITE(opts%as_laid_tension_line_value(i)) .AND. & + opts%as_laid_tension_line_value(i) >= CD_ZERO)) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION asLaidTension'//TRIM(int_to_str(opts%as_laid_tension_line(i)))// & + ' must be finite and >= 0'); RETURN + END IF + END DO + END IF IF (.NOT. (IEEE_IS_FINITE(opts%rho_inf) .AND. opts%rho_inf >= CD_ZERO .AND. opts%rho_inf <= CD_ONE)) THEN CALL fail(ErrStat, ErrMsg, 'OPTIONS rhoInf must be finite and in [0, 1]'); RETURN END IF diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 72b20cdc..07e5d693 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -70,7 +70,7 @@ MODULE CableDyn_HermiteCableStatic PUBLIC :: CD_HermiteCable_Prolong_Arc PUBLIC :: CD_HermiteCable_Static_Solve_AutoMesh PUBLIC :: CD_HermiteCable_Current_Load - PUBLIC :: CD_HermiteCable_Friction_Anchors + PUBLIC :: CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Friction_Reference PUBLIC :: CD_HermiteCable_Mean_Axial_Extremes 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 @@ -169,7 +169,7 @@ MODULE CableDyn_HermiteCableStatic ! position, capped at mu times the normal contact force. The reference is a profile ! along the unstretched arc length (ref_s ascending; ref_xy(1:2, :) the solve-frame ! offsets from node 1, the held first end), interpolated at each node, so it survives - ! mesh refinement and a translated solve origin: the still-water laid shape. + ! mesh refinement and a translated solve origin: the as-laid position of the line. ! frozen_capacity (optional, one entry per node of the solved mesh) holds the capacities ! fixed: the springs are then conservative (the energy-minimising step applies), as the ! frozen drag of a fixed-point pass. @@ -181,6 +181,9 @@ MODULE CableDyn_HermiteCableStatic REAL(wp) :: mu_axial = -1.0_wp REAL(wp), ALLOCATABLE :: ref_s(:), ref_xy(:, :) REAL(wp), ALLOCATABLE :: frozen_capacity(:) + ! the reference is the as-laid position (staticsFriction asLaid; otherwise the still-water + ! equilibrium of a current deck) + LOGICAL :: as_laid = .FALSE. END TYPE CD_HermiteStaticFrictionType TYPE, PUBLIC :: CD_HermiteStaticCurrentType @@ -189,6 +192,8 @@ 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] + ! 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(:, :) REAL(wp), ALLOCATABLE :: arc_end(:), diam(:), cdn(:), cdt(:) ! Seabed friction held by the line against the current (allocated: active). @@ -2874,6 +2879,13 @@ SUBROUTINE CD_HermiteCable_Mean_Axial_Extremes(l0, EA, q, t_min, t_max, e_min, s END DO END SUBROUTINE CD_HermiteCable_Mean_Axial_Extremes + PURE LOGICAL FUNCTION current_has_drag(cur) RESULT(has) + !! Whether a static current object carries a flow (a zero-velocity one only carries the + !! static seabed friction of a line in still water): the current diagnoses apply then only. + TYPE(CD_HermiteStaticCurrentType), INTENT(IN) :: cur + has = cur%drag + END FUNCTION current_has_drag + FUNCTION current_compression_note(l0, EA, qx, seabed_z, flat, frictional, frictionless_run) RESULT(note) !! Diagnosis of a current that has no tension-only equilibrium on the traced branch: !! empty unless the state qx (the last one reached) carries an element-mean axial force @@ -3044,11 +3056,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ ! A current rides along the stiffness homotopy as the drag frozen at the last accepted ! configuration (drag_homotopy); if that path fails, the still-water homotopy is traced ! and the drag is then brought in by load steps at full stiffness. - ! Seabed friction holds the line against the current relative to its still-water laid - ! shape (the reference of its springs). The springs are memoryless, so the equilibrium - ! does not depend on the path that reaches it: they ride along the homotopy with the - ! drag, their capacities frozen at the same configuration (fric_stage). The still-water - ! homotopy of the fallback path runs without them. + ! Seabed friction holds the line relative to its as-laid position (the reference of its + ! springs; in still water a zero-velocity current carries it). The springs are + ! memoryless, so the equilibrium does not depend on the path that reaches it: they ride + ! along the homotopy with the drag, their capacities frozen at the same configuration + ! (fric_stage). The frictionless homotopy of the fallback path runs without them. use_fric = .FALSE. IF (PRESENT(current)) THEN IF (ALLOCATED(current%friction)) use_fric = current%friction%mu > CD_ZERO @@ -3312,6 +3324,9 @@ LOGICAL FUNCTION frictionless_run_limit(qx) RESULT(run_limit) CHARACTER(512) :: note LOGICAL :: flat flat = .NOT. PRESENT(bathymetry) + run_limit = .FALSE. + IF (.NOT. PRESENT(current)) RETURN + IF (.NOT. current_has_drag(current)) RETURN note = current_compression_note(l0, EA, qx, seabed_z, flat, use_fric, run_limit) END FUNCTION frictionless_run_limit @@ -3321,6 +3336,9 @@ FUNCTION compression_note(qx) RESULT(note) CHARACTER(512) :: note LOGICAL :: flat flat = .NOT. PRESENT(bathymetry) + note = '' + IF (.NOT. PRESENT(current)) RETURN + IF (.NOT. current_has_drag(current)) RETURN note = current_compression_note(l0, EA, qx, seabed_z, flat, use_fric) END FUNCTION compression_note @@ -6219,9 +6237,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs END IF IF (es /= CD_HCSTAT_OK) THEN ! Diagnosed on the last converged (parent-mesh) state, not on the unconverged iterate. - IF (PRESENT(current)) emloc = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z, & - .NOT. PRESENT(bathymetry), & - ALLOCATED(current%friction)))//TRIM(emloc) + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) & + emloc = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z,.NOT. PRESENT(bathymetry), & + ALLOCATED(current%friction)))//TRIM(emloc) + END IF ErrStat = es; ErrMsg = 'CD_HermiteCable_Static_Solve_AutoMesh: refined-mesh polish failed: '//TRIM(emloc) RETURN END IF @@ -6330,9 +6350,11 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs ! In a current, name the limit the compression of this state shows (the grounded run ! pushed into its end, or into a friction-held touchdown): the driver's out-of-plane ! retry of a planar current needs it, as for the other routes' failures. - IF (PRESENT(current)) wbuf = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z, & - .NOT. PRESENT(bathymetry), & - ALLOCATED(current%friction)))//TRIM(wbuf) + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) & + wbuf = TRIM(current_compression_note(l0_out, EA_out, q_out, seabed_z,.NOT. PRESENT(bathymetry), & + ALLOCATED(current%friction)))//TRIM(wbuf) + END IF ErrMsg = wbuf RETURN END IF diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 4d2855c9..a96304e7 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -31,7 +31,8 @@ MODULE CableDyn_Model CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, & CD_Bathymetry_Seabed_Load, CD_End_Bathymetry, CD_BATHY_OK USE CableDyn_Static, ONLY: CableSolverConfig, CableCurrentLoad, CD_StaticLineReport, CD_Static_Line_Equilibrium, & - CD_Static_Friction_Anchors, & + CD_Static_Friction_Anchors, CD_Static_As_Laid_Reference, & + CD_STATIC_FRICTION_AS_LAID, CD_STATIC_FRICTION_NONE, & CD_STATIC_OK USE CableDyn_Assemble, ONLY: CD_Assemble_Cable_Internal_Force, CD_Assemble_Cable_Mass, & CD_Assemble_Cable_Tangent_Force, CD_Compute_Cable_Tension @@ -1269,7 +1270,8 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra seabed_kbot, seabed_contact_diameter, seabed_cn_over_kn, & 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) + current_profile_z, current_profile_velocity, & + static_friction, lay_azimuth, as_laid_tension) !! 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, @@ -1342,12 +1344,23 @@ 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(:, :) + ! Static seabed friction (with seabed_mu > 0 on a seabed): the policy + ! (CD_STATIC_FRICTION_AS_LAID, the default, or CD_STATIC_FRICTION_NONE), the lay azimuth + ! [rad, from global +x toward +y; default: the horizontal anchor -> fairlead direction, + ! +x for a vertical chord] and the as-laid effective tension [N, default 0] of + ! CD_Static_As_Laid_Reference. As laid, the static solve resists every grounded node's + ! horizontal displacement from its as-laid position with the friction springs, and the + ! stick-slip anchors of the dynamics continue their forces; with none the static solve + ! is frictionless and the anchors start at the static node positions. + INTEGER, INTENT(IN), OPTIONAL :: static_friction + REAL(wp), INTENT(IN), OPTIONAL :: lay_azimuth, as_laid_tension 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(:) - INTEGER :: n_elem, n_dof, e, es, istat - LOGICAL :: dyn_to + INTEGER :: n_elem, n_dof, e, es, istat, fr_policy + LOGICAL :: dyn_to, friction_static + REAL(wp) :: laid_az, laid_t LOGICAL :: reverse_line, converged, use_current LOGICAL :: use_seabed, use_seabed_damping, use_seabed_friction, use_damping CHARACTER(200) :: em @@ -1471,6 +1484,33 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra dyn_to = tension_only IF (PRESENT(dynamic_tension_only)) dyn_to = dynamic_tension_only + ! Static seabed friction policy, lay azimuth and as-laid tension (validated even when + ! the line has no friction, so a bad value never passes silently). + fr_policy = CD_STATIC_FRICTION_NONE + IF (PRESENT(static_friction)) fr_policy = static_friction + IF (fr_policy /= CD_STATIC_FRICTION_AS_LAID .AND. fr_policy /= CD_STATIC_FRICTION_NONE) THEN + CALL fail(ErrStat, ErrMsg, 'line model static_friction must be CD_STATIC_FRICTION_AS_LAID or _NONE') + RETURN + END IF + laid_t = CD_ZERO + IF (PRESENT(as_laid_tension)) laid_t = as_laid_tension + IF (.NOT. CD_Is_Finite(laid_t) .OR. laid_t < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'line model as_laid_tension must be finite and non-negative') + RETURN + END IF + ! default lay azimuth: the vertical plane through the line ends (anchor -> fairlead) + laid_az = CD_ZERO + IF (NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(fairlead - anchor))) & + laid_az = ATAN2(fairlead(2) - anchor(2), fairlead(1) - anchor(1)) + IF (PRESENT(lay_azimuth)) laid_az = lay_azimuth + IF (.NOT. CD_Is_Finite(laid_az)) THEN + CALL fail(ErrStat, ErrMsg, 'line model lay_azimuth must be finite') + RETURN + 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 + ! Static initial condition: the shared robust line initializer (the same one the ! static-only deck route uses). The equilibrium obeys the committed model's constitutive ! law (dyn_to): a tension-only line gets its tension-only equilibrium, never a compressed @@ -1503,10 +1543,11 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra cur%profile_velocity = current_profile_velocity END IF IF (PRESENT(drag_waterline_z)) cur%node_waterline = drag_waterline_z - ! A frictional seabed holds the line against the current from its still-water laid - ! shape: solve the line without the current first; that equilibrium is the reference - ! of the static friction springs, and their forces seed the stick-slip anchors below. - IF (use_seabed .AND. use_seabed_friction) THEN + ! 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 + ! equilibrium is the reference of the static friction springs, and their forces seed + ! the stick-slip anchors below. + IF (use_seabed .AND. use_seabed_friction .AND. .NOT. friction_static) THEN 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, & @@ -1525,6 +1566,44 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra END DO END IF END IF + ELSE + ! still water: the object carries only the static seabed friction (if any) + cur%drag = .FALSE. + END IF + ! Static seabed friction (the OrcaFlex "as laid" policy): every grounded node is held + ! by a friction spring toward its as-laid position -- the line laid from the anchor + ! along the lay azimuth on the seabed at the as-laid tension -- capped at mu N; the + ! spring forces then seed the stick-slip anchors of the march below. + IF (friction_static) THEN + cur%friction_mu = seabed_mu + cur%friction_as_laid = .TRUE. + IF (PRESENT(seabed_mu_axial)) cur%friction_mu_axial = seabed_mu_axial + ALLOCATE (cur%friction_ref(2, n_elem + 1)) + BLOCK + ! static penalty penetration factor w_i/k_i of every node (see the routine) + REAL(wp) :: sink(n_elem + 1) + DO istat = 1, n_elem + 1 + sink(istat) = MAX(-f_ext(3*istat), CD_ZERO)/seabed_kn(istat) + END DO + IF (fairlead(3) < anchor(3)) THEN + ! the line is laid from its bottom end, here the last node (the default azimuth + ! then points from it toward node 1) + IF (.NOT. PRESENT(lay_azimuth)) laid_az = ATAN2(-SIN(laid_az), -COS(laid_az)) + CALL CD_Static_As_Laid_Reference(fairlead(1:2), laid_az, l0(n_elem:1:-1), ea(n_elem:1:-1), laid_t, & + cur%friction_ref, es, em, bathymetry=bathymetry, & + sink=sink(n_elem + 1:1:-1)) + cur%friction_ref = cur%friction_ref(:, n_elem + 1:1:-1) + ELSE + CALL CD_Static_As_Laid_Reference(anchor(1:2), laid_az, l0, ea, laid_t, cur%friction_ref, es, em, & + bathymetry=bathymetry, sink=sink) + END IF + END BLOCK + IF (es /= CD_STATIC_OK) THEN + CALL fail(ErrStat, ErrMsg, 'line model seabed friction: '//TRIM(em)) + RETURN + END IF + END IF + IF (use_current .OR. friction_static) 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, current=cur, & @@ -1547,11 +1626,26 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra BLOCK REAL(wp), ALLOCATABLE :: q_sw(:) TYPE(CD_StaticLineReport) :: report_sw + TYPE(CableCurrentLoad) :: cur_sw LOGICAL :: conv_sw ALLOCATE (q_sw(SIZE(q_static))) - 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) + IF (friction_static) THEN + ! still water with the same as-laid seabed friction + cur_sw%drag = .FALSE. + cur_sw%friction_mu = cur%friction_mu + cur_sw%friction_mu_axial = cur%friction_mu_axial + cur_sw%friction_ref = cur%friction_ref + cur_sw%friction_as_laid = .TRUE. + 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) + 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) + END IF IF (es == CD_STATIC_OK .AND. conv_sw) THEN IF (ALLOCATED(cur%friction_ref)) THEN ErrMsg = 'CableDyn_Model: the line has a still-water equilibrium but none in the current: '// & diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 19aa16c8..9ab816ef 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -16,9 +16,10 @@ MODULE CableDyn_Static !! penalty contact force + its residual-Jacobian term are recomputed inside every !! residual/tangent evaluation (grounded catenary / mooring equilibrium); when !! absent it is the constant-f_ext solve, bit-for-bit unchanged. An OPTIONAL - !! steady current adds configuration-dependent Morison drag (CableCurrentLoad), and with - !! it the seabed friction that holds the line against the current (friction springs from - !! the still-water laid shape). Damping and wave loads belong to the dynamic path. + !! steady current adds configuration-dependent Morison drag (CableCurrentLoad), and the + !! same object carries the static seabed friction (friction springs from the as-laid + !! position, CD_Static_As_Laid_Reference), with or without the drag. Damping and wave + !! loads belong to the dynamic path. !! !! Conventions match the other modules: q is the flat (3 n_nodes) positions-only !! state [x1,y1,z1, x2,y2,z2, ...]; node nd owns DOFs 3*nd-2:3*nd; fixed_dofs are @@ -48,6 +49,7 @@ MODULE CableDyn_Static PUBLIC :: CD_Static_Line_End_Forces PUBLIC :: CD_Static_Anchor_Seabed_Tolerance PUBLIC :: CD_Static_Friction_Anchors + PUBLIC :: CD_Static_As_Laid_Reference TYPE :: CableSolverConfig !! Newton / Armijo policy and its default tolerances. @@ -88,13 +90,19 @@ 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(:, :) - ! Seabed friction held against the current (friction_mu > 0 with friction_ref - ! allocated, on a line with seabed contact): each node in contact carries a horizontal - ! spring of its seabed stiffness from its reference position friction_ref(1:2, node), - ! capped smoothly at friction_mu times its normal reaction (CD_Seabed_Friction_Spring). - ! The reference is the still-water laid shape of the same line. + ! 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. + ! Static seabed friction (friction_mu > 0 with friction_ref allocated, on a line with + ! seabed contact): each node in contact carries a horizontal spring of its seabed + ! stiffness from its reference position friction_ref(1:2, node), capped smoothly at + ! friction_mu times its normal reaction (CD_Seabed_Friction_Spring). The reference is the + ! still-water equilibrium in a current (staticsFriction none), or the as-laid position of + ! the line (friction_as_laid, CD_Static_As_Laid_Reference), which also selects the + ! as-laid seed. REAL(wp) :: friction_mu = CD_ZERO REAL(wp), ALLOCATABLE :: friction_ref(:, :) + LOGICAL :: friction_as_laid = .FALSE. ! friction_mu_axial > 0 and different from friction_mu: anisotropic friction, with ! friction_mu the lateral coefficient (CD_Seabed_Friction_Aniso, line axis = chord ! through the neighbouring nodes). @@ -116,6 +124,10 @@ MODULE CableDyn_Static INTEGER, PARAMETER, PUBLIC :: CD_STATIC_OK = 0 INTEGER, PARAMETER, PUBLIC :: CD_STATIC_BADINPUT = 1 INTEGER, PARAMETER, PUBLIC :: CD_STATIC_SINGULAR = 2 + ! Static seabed friction policies (OrcaFlex "statics seabed friction policy"): none, or + ! friction toward the as-laid position (CD_Static_As_Laid_Reference). + INTEGER, PARAMETER, PUBLIC :: CD_STATIC_FRICTION_NONE = 0 + INTEGER, PARAMETER, PUBLIC :: CD_STATIC_FRICTION_AS_LAID = 1 CONTAINS @@ -312,12 +324,14 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix END IF ! --- optional steady-current Morison drag (configuration-dependent, ramp-scaled) --- + ! (a friction-only object, drag = .FALSE., carries no drag) current_active = PRESENT(current) + IF (current_active) current_active = current%drag profile_active = .FALSE. cf = CD_ONE IF (PRESENT(current_load_factor)) THEN ! A ramp factor without a current is a caller error: it would silently do nothing. - IF (.NOT. current_active) THEN + IF (.NOT. PRESENT(current)) THEN CALL fail(ErrStat, ErrMsg, 'current_load_factor given without a current load') RETURN END IF @@ -415,7 +429,7 @@ SUBROUTINE CD_Static_Cable_Solve(q0, elem_conn, l0, ea, tension_only, f_ext, fix ALLOCATE (drag_f(n_dof), drag_fz(n_dof), source=CD_ZERO) END IF friction_active = .FALSE. - IF (current_active .AND. seabed_active) THEN + IF (PRESENT(current) .AND. seabed_active) THEN ! Check finiteness before the mu > 0 gate: a NaN coefficient must fail closed, not ! silently disable (or make isotropic) the friction. IF (.NOT. (CD_Is_Finite(current%friction_mu) .AND. CD_Is_Finite(current%friction_mu_axial))) THEN @@ -1300,6 +1314,205 @@ SUBROUTINE CD_Static_Friction_Anchors(q, current, seabed_kn, anchors, ErrStat, E END DO END SUBROUTINE CD_Static_Friction_Anchors + SUBROUTINE CD_Static_As_Laid_Reference(origin, azimuth, l0, ea, laid_tension, ref, ErrStat, ErrMsg, bathymetry, & + sink) + !! As-laid position of a line on the seabed, the reference of its static seabed friction + !! (OrcaFlex's "as laid" statics seabed friction policy): the line is laid from its + !! bottom end (node 1, horizontal position origin) in the horizontal direction azimuth + !! [rad, from global +x toward +y], following the seabed profile, at the effective + !! tension laid_tension [N]. Node i then lies at the stretched arc length + !! s_i = sum_{e < i} l0_e (1 + laid_tension/ea_e) from node 1 along the seabed, so + !! ref(1:2, i) = origin + d_i (cos, sin)(azimuth), where the seabed path over the + !! horizontal distance d_i is s_i long: d_i = s_i on a level floor (no bathymetry), + !! and on a bathymetry the path is integrated in sub-steps of at most 1 m with the + !! midpoint slope along the azimuth. If every node rested at its reference, the line + !! would carry laid_tension throughout. + !! sink (optional, per node, on a bathymetry): the static penalty penetration factor + !! w_i/k_i of each node (its submerged weight over its seabed stiffness). A laid node + !! sinks into the penalty seabed along the surface normal, which on a slope moves it + !! horizontally by w_i (z_x, z_y)/k_i; its reference moves with it, so the line laid at + !! rest on a slope carries no friction force (a deflection normal to the seabed is not a + !! friction deflection, as in OrcaFlex's in-plane friction). + REAL(wp), INTENT(IN) :: origin(2), azimuth, l0(:), ea(:), laid_tension + REAL(wp), INTENT(OUT) :: ref(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), INTENT(IN), OPTIONAL :: sink(:) + INTEGER :: n_elem, e, j, nsub, es + REAL(wp) :: dir(2), d, ds, step, x, y, zf, gx, gy, g, dshort + CHARACTER(120) :: em + + ErrStat = CD_STATIC_OK + ErrMsg = '' + n_elem = SIZE(l0) + IF (n_elem < 1 .OR. SIZE(ea) /= n_elem .OR. SIZE(ref, 1) /= 2 .OR. SIZE(ref, 2) /= n_elem + 1) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: inconsistent shapes') + RETURN + END IF + IF (.NOT. (CD_All_Finite(origin) .AND. CD_Is_Finite(azimuth) .AND. CD_Is_Finite(laid_tension) .AND. & + CD_All_Finite(l0) .AND. CD_All_Finite(ea))) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: inputs must be finite') + RETURN + END IF + IF (ANY(l0 <= CD_ZERO) .OR. ANY(ea <= CD_ZERO) .OR. laid_tension < CD_ZERO) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: l0 and ea must be positive and laid_tension non-negative') + RETURN + END IF + dir = [COS(azimuth), SIN(azimuth)] + ref(:, 1) = origin + d = CD_ZERO + DO e = 1, n_elem + ds = l0(e)*(CD_ONE + laid_tension/ea(e)) + IF (PRESENT(bathymetry)) THEN + ! the horizontal advance is ds less the shortening of the sloped sub-steps, so a + ! level patch advances by exactly ds, bit-for-bit as on a flat floor + nsub = MAX(1, CEILING(ds)) + step = ds/REAL(nsub, wp) + dshort = CD_ZERO + DO j = 1, nsub + ! midpoint slope along the azimuth (at the level-floor midpoint of the sub-step) + x = origin(1) + (d + REAL(j - 1, wp)*step - dshort + 0.5_wp*step)*dir(1) + y = origin(2) + (d + REAL(j - 1, wp)*step - dshort + 0.5_wp*step)*dir(2) + CALL CD_Bathymetry_Floor_Gradient(bathymetry, x, y, zf, gx, gy, es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + g = gx*dir(1) + gy*dir(2) + dshort = dshort + step*(CD_ONE - CD_ONE/SQRT(CD_ONE + g*g)) + END DO + d = d + (ds - dshort) + ELSE + d = d + ds + END IF + ref(:, e + 1) = origin + d*dir + END DO + IF (PRESENT(sink) .AND. PRESENT(bathymetry)) THEN + IF (SIZE(sink) /= n_elem + 1 .OR. .NOT. CD_All_Finite(sink)) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: sink must be finite, one entry per node') + RETURN + END IF + ! node 1 is held: its reference stays at origin + DO j = 2, n_elem + 1 + IF (.NOT. (sink(j) > CD_ZERO)) CYCLE + CALL CD_Bathymetry_Floor_Gradient(bathymetry, ref(1, j), ref(2, j), zf, gx, gy, es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + ref(:, j) = ref(:, j) + sink(j)*[gx, gy] + END DO + END IF + END SUBROUTINE CD_Static_As_Laid_Reference + + SUBROUTINE CD_Static_As_Laid_Seed(anchor, fairlead, l0, ea, weight, ref, q, ok, seabed_z_floor, bathymetry) + !! As-laid seed of a line with static seabed friction (OrcaFlex's picture: the line laid + !! from its anchor, node 1, and its top end then moved to the fairlead, node n): nodes + !! 1..k rest on the seabed at their as-laid positions ref(1:2, :) (the friction + !! reference, CD_Static_As_Laid_Reference), and nodes k..n form the fully suspended + !! elastic catenary from node k to the fairlead. k is the first node at which the + !! suspended span leaves the seabed at or above the local seabed angle along its own + !! heading (tangent lift-off), found by bisection; a line laid past the point under its + !! fairlead turns back there, over its grounded run. q holds the positions (3 n_nodes); + !! ok = .FALSE. when no node qualifies. One of seabed_z_floor or bathymetry is given. + REAL(wp), INTENT(IN) :: anchor(3), fairlead(3), l0(:), ea(:), weight(:), ref(:, :) + REAL(wp), INTENT(OUT) :: q(:) + LOGICAL, INTENT(OUT) :: ok + REAL(wp), INTENT(IN), OPTIONAL :: seabed_z_floor + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + INTEGER :: n_nodes, k_lo, k_hi, k_mid, it + REAL(wp) :: f_lo, f_hi, f_mid + LOGICAL :: v_lo, v_hi, v_mid + + ok = .FALSE. + q = CD_ZERO + n_nodes = SIZE(l0) + 1 + IF (SIZE(q) /= 3*n_nodes .OR. SIZE(ref, 1) /= 2 .OR. SIZE(ref, 2) /= n_nodes .OR. SIZE(ea) /= n_nodes - 1 & + .OR. SIZE(weight) /= n_nodes - 1) RETURN + IF (.NOT. (PRESENT(seabed_z_floor) .OR. PRESENT(bathymetry))) RETURN + k_lo = 1 + CALL laid_at(k_lo, f_lo, v_lo) + IF (v_lo .AND. f_lo >= CD_ZERO) THEN + ok = .TRUE. + RETURN + END IF + k_hi = n_nodes - 1 + CALL laid_at(k_hi, f_hi, v_hi) + IF (.NOT. (v_hi .AND. f_hi >= CD_ZERO)) RETURN + DO it = 1, 64 + IF (k_hi - k_lo <= 1) EXIT + k_mid = (k_lo + k_hi)/2 + CALL laid_at(k_mid, f_mid, v_mid) + IF (v_mid .AND. f_mid >= CD_ZERO) THEN + k_hi = k_mid + ELSE + k_lo = k_mid + END IF + END DO + CALL laid_at(k_hi, f_hi, v_hi) + ok = v_hi + + CONTAINS + + SUBROUTINE laid_at(k, mismatch, valid) + !! The seed with lift-off node k into q; mismatch is the elevation angle of the first + !! suspended element minus the seabed angle along its horizontal heading at the + !! lift-off point (>= 0: the span leaves the seabed tangent or steeper). + INTEGER, INTENT(IN) :: k + REAL(wp), INTENT(OUT) :: mismatch + LOGICAL, INTENT(OUT) :: valid + INTEGER :: i, es_d + REAL(wp) :: zf, gx, gy, g, p(3), h_s, g_s, u(3), uh + REAL(wp), ALLOCATABLE :: q_sus(:) + CHARACTER(200) :: em_d + + valid = .FALSE. + mismatch = -HUGE(CD_ONE) + q(1:3) = anchor + DO i = 2, k + CALL floor_at(ref(1, i), ref(2, i), zf, gx, gy, es_d) + IF (es_d /= 0) RETURN + q(3*i - 2:3*i) = [ref(1, i), ref(2, i), zf] + END DO + p = q(3*k - 2:3*k) + IF (fairlead(3) <= p(3)) RETURN + ALLOCATE (q_sus(3*(n_nodes - k + 1))) + CALL CD_Catenary_Seed(p, fairlead, l0(k:), ea(k:), weight(k:), q_sus, h_s, g_s, es_d, em_d, & + suspended=.TRUE.) + IF (es_d /= CD_CAT_OK) RETURN + IF (.NOT. CD_All_Finite(q_sus)) RETURN + q(3*k - 2:) = q_sus + u = q_sus(4:6) - q_sus(1:3) + IF (NORM2(u) <= CD_ZERO) RETURN + uh = NORM2(u(1:2)) + g = CD_ZERO + IF (uh > CD_ZERO) THEN + CALL floor_at(p(1), p(2), zf, gx, gy, es_d) + IF (es_d /= 0) RETURN + g = (gx*u(1) + gy*u(2))/uh + END IF + mismatch = ATAN2(u(3), MAX(uh, TINY(CD_ONE))) - ATAN(g) + valid = .TRUE. + END SUBROUTINE laid_at + + SUBROUTINE floor_at(x, y, zf, gx, gy, es_f) + !! Seabed elevation and gradient under (x, y): the flat floor or the bathymetry. + REAL(wp), INTENT(IN) :: x, y + REAL(wp), INTENT(OUT) :: zf, gx, gy + INTEGER, INTENT(OUT) :: es_f + CHARACTER(120) :: em_f + es_f = 0 + gx = CD_ZERO + gy = CD_ZERO + IF (PRESENT(bathymetry)) THEN + CALL CD_Bathymetry_Floor_Gradient(bathymetry, x, y, zf, gx, gy, es_f, em_f) + ELSE + zf = seabed_z_floor + END IF + END SUBROUTINE floor_at + END SUBROUTINE CD_Static_As_Laid_Seed + PURE FUNCTION friction_chord(q, node) RESULT(axis) !! Horizontal line axis at a node for anisotropic friction: the chord through its !! neighbours (one-sided at the ends), the axis of CableDyn_Model's dynamics. @@ -1340,7 +1553,10 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh !! H -> 0 limit (a straight hanging leg with the excess on the seabed, folded back where !! the seabed keeps falling); the other catenary variant; and a two-leg polyline of the !! right length that never compresses the line. Seed nodes deeper below the seabed than - !! their static penetration are lifted onto it. + !! their static penetration are lifted onto it. With static seabed friction (current + !! carrying friction_ref, CD_Static_As_Laid_Reference) the as-laid seed is tried first: + !! the nodes up to a lift-off node rest at their as-laid positions, and the rest hang as + !! the suspended catenary to the fairlead (the line laid, then its top end moved). !! For each seed: !! A. Newton (plain, then Levenberg-Marquardt) with the compression-capable law, first at !! the full load, then by load continuation. Accepted when it converges and (for a @@ -1378,7 +1594,10 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh REAL(wp), ALLOCATABLE :: ramp(:) INTEGER :: n_dof, n_elem, n_nodes, iseed, iorder, n_it, n_st, es INTEGER, PARAMETER :: SEED_ORDER(6) = [1, 5, 6, 2, 3, 4] - INTEGER, ALLOCATABLE :: fixed(:) + ! with static seabed friction, the as-laid seed (7) first + INTEGER, PARAMETER :: SEED_ORDER_LAID(7) = [7, 1, 5, 6, 2, 3, 4] + INTEGER, ALLOCATABLE :: fixed(:), order(:) + LOGICAL :: as_laid REAL(wp), ALLOCATABLE :: q_seed(:), q_try(:), q_mid(:), q_best(:), ten(:) REAL(wp) :: f_node, t_min, t_max, r_soft, r_firm, floor_a, slope_a, h_cat, g_cat LOGICAL :: has_seabed, anchor_grounded, conv, stalled, at_floor, have_seed, done, have_best @@ -1477,13 +1696,25 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh END IF END IF + ! static seabed friction from an as-laid reference: the as-laid seed leads + as_laid = .FALSE. + IF (has_seabed .AND. PRESENT(current)) THEN + IF (ALLOCATED(current%friction_ref) .AND. current%friction_mu > CD_ZERO .AND. current%friction_as_laid) & + as_laid = SIZE(current%friction_ref, 1) == 2 .AND. SIZE(current%friction_ref, 2) == n_nodes + END IF + IF (as_laid) THEN + order = SEED_ORDER_LAID + ELSE + order = SEED_ORDER + END IF + notes = '' q_best = CD_ZERO have_best = .FALSE. - DO iorder = 1, SIZE(SEED_ORDER) - ! seed order: catenary, bathymetry drape, catenary on the penetrated seabed, slack - ! run, other catenary, polyline - iseed = SEED_ORDER(iorder) + DO iorder = 1, SIZE(order) + ! seed order: (as laid,) catenary, bathymetry drape, catenary on the penetrated seabed, + ! slack run, other catenary, polyline + iseed = order(iorder) CALL build_seed(iseed, have_seed) IF (.NOT. have_seed) CYCLE report%seed = seed_name @@ -1792,6 +2023,14 @@ SUBROUTINE build_seed(which, ok) IF (.NOT. (anchor_grounded .AND. PRESENT(bathymetry))) RETURN CALL drape_seed(ok) IF (ok) ok = CD_All_Finite(q_seed) + CASE (7) + ! the as-laid line with its top end moved to the fairlead: a grounded run at the + ! friction reference positions lifting off into a suspended catenary + seed_name = 'as-laid run' + IF (.NOT. (anchor_grounded .AND. as_laid)) RETURN + CALL CD_Static_As_Laid_Seed(anchor, fairlead, l0, ea, weight, current%friction_ref, q_seed, ok, & + seabed_z_floor=seabed_z_floor, bathymetry=bathymetry) + IF (ok) ok = CD_All_Finite(q_seed) CASE DEFAULT seed_name = 'two-leg polyline' CALL polyline_seed(anchor, fairlead, l0, has_seabed, floor_a, q_seed) @@ -2129,6 +2368,7 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, REAL(wp) :: zf, gx, gy, fvec(3), jac(3, 3), curv(3), f2(6), jq2(6, 6), jv2(6, 6), va(3), vb(3), de, cn, ct, wla, wlb CHARACTER(200) :: em INTEGER :: ends(2) + LOGICAL :: drag_ends ErrStat = CD_STATIC_OK ErrMsg = '' @@ -2176,7 +2416,9 @@ SUBROUTINE CD_Static_Line_End_Forces(q, elem_conn, l0, ea, f_ext, tension_only, fint(3*node - 2:3*node) = fint(3*node - 2:3*node) + fvec END DO END IF - IF (PRESENT(current)) THEN + drag_ends = PRESENT(current) + IF (drag_ends) drag_ends = current%drag + IF (drag_ends) THEN DO e = 1, n_elem a = elem_conn(1, e) b = elem_conn(2, e) diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py new file mode 100644 index 00000000..39c4f11a --- /dev/null +++ b/tests/test_static_friction_as_laid.py @@ -0,0 +1,248 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""Static seabed friction toward the as-laid position (OPTIONS staticsFriction asLaid, set in +every deck below; the default is none). + +A grounded run on a seabed sloping down toward its anchor, with friction mu = 1 well above the +slope, must hold in statics where it was laid; with the default frictionless statics (none) the +run slides down the slope and folds back past its anchor (EI = 0), or is rejected as too long +for its span (finite EI). Every deck runs through the standalone +driver: + +* ``slope_ei0`` (EI = 0 chain, 5 degree slope, 700 m line over a 450 m span): converges with + the grounded run on its side of the anchor, and an independent nodal force balance (element + tensions, lumped weight, seabed normal along the local normal) leaves at every grounded node + a horizontal friction force within mu N, mobilised against the slope; its twin with + ``none staticsFriction`` still folds past the anchor (the frictionless static of before); +* ``slope_ei0_rest``: the same deck marched for 2 s from the static state stays at rest (every + output row reproduces the static end forces to 1e-5 of the fairlead tension): the friction + anchors of the march continue the static springs, with no jump at t = 0; +* ``slope_fei`` (finite-EI cable on a 10 degree slope, too long for its span) converges, and + marched for 1 s stays at rest likewise; +* ``flat_*`` (a grounded chain on a flat seabed): laid at the tension its run carries + (``asLaidTension``), the friction is not mobilised and the end tensions equal the + frictionless ones (FairTen to 1e-4, AnchTen to 0.5 %, see the check); laid slack (the + default), friction holds the run back and the anchor tension falls by at most mu w times the + grounded length; +* input checks: ``layAzimuth`` of a line that does not exist and an unknown policy are + rejected. + +usage: test_static_friction_as_laid.py --exe --output +""" + +from __future__ import annotations + +import argparse +import math +import os +import subprocess +import sys +from pathlib import Path + +G, RHO = 9.80665, 1025.0 +CHAIN = (0.216, 286.56, 1.22976e9) # diameter [m], mass [kg/m], EA [N] +REST_TOL = 1.0e-5 +FAILURES: list[str] = [] + + +def check(cond: bool, msg: str) -> None: + print(("ok " if cond else "FAIL ") + msg) + if not cond: + FAILURES.append(msg) + + +def slope_grid(path: Path, depth0: float, slope_deg: float) -> None: + """A seabed z = -(depth0 + tan(slope) x): planar in x, falling toward +x.""" + t = math.tan(math.radians(slope_deg)) + rows = [] + for x in range(-300, 1000, 100): + for y in (-300.0, 300.0): + rows.append("%.1f %.1f %.12g" % (x, y, depth0 + t * x)) + path.write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + + +def deck(title: str, ei: float, length: float, nseg: int, fair: tuple, anch: tuple, seabed: str, + extra: str = "", tmax: float = 0.0, mu: float = 1.0) -> str: + d, m, ea = CHAIN + return ( + "--------------------- CableDyn Input File ---\n" + f"{title}\n" + "--------------------- LINE TYPES ---\n" + "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n" + "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\n" + f"chain {d} {m} {ea} -1 {ei} 1.37 0.64 1 0\n" + "--------------------- POINTS ---\n" + "ID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" + f"1 Coupled {fair[0]} {fair[1]} {fair[2]} 0 0 0 0\n" + f"2 Fixed {anch[0]} {anch[1]} {anch[2]} 0 0 0 0\n" + "--------------------- LINES ---\n" + "ID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 pt\n" + "--------------------- SECTIONS ---\n" + "LineID LineType Length NumSegs\n(-) (-) (m) (-)\n" + f"1 chain {length} {nseg}\n" + "--------------------- OPTIONS ---\n" + f"{G} g\n{RHO} rhoW\n{seabed}\n100000.0 kBot\n1.0e4 cBot\n0.05 dtM\n{tmax} TMax\n" + f"{mu} frictionMu\nasLaid staticsFriction\n{extra}" + "--------------------- OUTPUTS ---\n" + '"FairTen1"\n"AnchTen1"\n"Point1Fx"\n"Point1Fy"\n"Point1Fz"\n"Point2Fx"\n"Point2Fy"\n"Point2Fz"\n' + "--------------------- need this line ---\n" + ) + + +def run(exe: str, cdir: Path, name: str, text: str) -> tuple: + cdir.mkdir(parents=True, exist_ok=True) + (cdir / (name + ".dat")).write_text(text, encoding="utf-8", newline="\n") + env = dict(os.environ) + env.setdefault("OPENBLAS_NUM_THREADS", "1") + env.setdefault("OMP_NUM_THREADS", "1") + p = subprocess.run([exe, name + ".dat", name], cwd=cdir, env=env, capture_output=True, text=True, + timeout=600) + return p.returncode, p.stdout + p.stderr + + +def table(path: Path) -> list: + rows = [r for r in path.read_text(encoding="utf-8").splitlines() if r.strip() and not r.startswith("#")] + names = rows[0].split() + return [dict(zip(names, map(float, r.split()))) for r in rows[1:]] + + +def first_row(path: Path) -> list: + rows = [r for r in path.read_text(encoding="utf-8").splitlines() if r.strip() and not r.startswith("#")] + return [float(v) for v in rows[1].split()[1:]] + + +def grounded_balance(cdir: Path, name: str, length: float, nseg: int, mu: float, depth0: float, + slope_deg: float) -> tuple: + """Largest friction utilisation |f|/(mu N) over grounded nodes and the total friction.""" + d, m, _ = CHAIN + w = (m - RHO * math.pi / 4.0 * d * d) * G + l0 = length / nseg + p = first_row(cdir / (name + ".Line1.p.out")) + pos = [p[3 * i:3 * i + 3] for i in range(len(p) // 3)] + ten = first_row(cdir / (name + ".Line1.t.out")) + gx = -math.tan(math.radians(slope_deg)) + nrm = [-gx / math.hypot(1.0, gx), 0.0, 1.0 / math.hypot(1.0, gx)] + worst, total = 0.0, 0.0 + for i in range(1, len(pos) - 1): + f = [0.0, 0.0, -w * l0] + for e, j in ((i - 1, i - 1), (i, i + 1)): + u = [pos[j][k] - pos[i][k] for k in range(3)] + n = math.sqrt(sum(x * x for x in u)) + for k in range(3): + f[k] += ten[e] * u[k] / n + zf = -(depth0 + math.tan(math.radians(slope_deg)) * pos[i][0]) + normal = -f[2] / nrm[2] + if pos[i][2] > zf + 0.5 or not normal > 1.0e-6 * w * l0: + continue + fr = math.hypot(f[0] + normal * nrm[0], f[1]) + total += fr + worst = max(worst, fr / (mu * normal)) + past = max(p_[0] for p_ in pos) - pos[-1][0] # beyond the anchor (+x) along the span + return worst, total, past + + +def at_rest(cdir: Path, static_name: str, rest_name: str) -> float: + s0 = table(cdir / (static_name + ".out"))[0] + scale = max(abs(s0["FairTen1"]), 1.0) + drift = 0.0 + for row in table(cdir / (rest_name + ".out")): + drift = max(drift, max(abs(row[n] - s0[n]) for n in s0 if n != "Time(s)")) + return drift / scale + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + a = ap.parse_args() + root = Path(a.output).resolve() + root.mkdir(parents=True, exist_ok=True) + d, m, ea = CHAIN + w = (m - RHO * math.pi / 4.0 * d * d) * G + + # --- EI = 0 run on a 5 degree slope (the R3 reproducer) --- + cdir = root / "slope_ei0" + cdir.mkdir(parents=True, exist_ok=True) + depth0, slope = 260.6301014133342, 5.0 + slope_grid(cdir / "bathy.txt", depth0, slope) + sb = "bathy.txt bathymetryFile" + base = dict(ei=0.0, length=700.0, nseg=70, fair=(0, 0, -10), anch=(450, 0, -300), seabed=sb) + rc, log = run(a.exe, cdir, "laid", deck("slope_ei0", **base)) + check(rc == 0, "slope_ei0 converges (rc %d)" % rc) + if rc == 0: + worst, total, past = grounded_balance(cdir, "laid", 700.0, 70, 1.0, depth0, slope) + check(past < 0.5, "slope_ei0: the grounded run stays on its side of the anchor (%.3f m past it)" % past) + check(worst <= 1.0 + 1.0e-3, "slope_ei0: friction within mu N at every grounded node (max %.4f)" % worst) + check(worst > 0.5 * math.tan(math.radians(slope)), + "slope_ei0: friction holds the slope load (max utilisation %.4f)" % worst) + rc, log = run(a.exe, cdir, "none", deck("slope_ei0 none", **base, extra="none staticsFriction\n")) + check(rc == 0, "slope_ei0 with staticsFriction none converges (rc %d)" % rc) + if rc == 0: + _, total, past = grounded_balance(cdir, "none", 700.0, 70, 1.0, depth0, slope) + check(past > 10.0, "slope_ei0 frictionless static still folds past the anchor (%.2f m)" % past) + rc, log = run(a.exe, cdir, "rest", deck("slope_ei0 rest", **base, tmax=2.0)) + check(rc == 0, "slope_ei0 at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "laid", "rest") + check(drift <= REST_TOL, "slope_ei0 stays at rest from the static state (drift %.2e of FairTen)" % drift) + + # --- finite-EI cable on a 10 degree slope, too long for its span --- + cdir = root / "slope_fei" + cdir.mkdir(parents=True, exist_ok=True) + depth0, slope = 220.65285868119076, 10.0 + slope_grid(cdir / "bathy.txt", depth0, slope) + fei = dict(ei=1.0e4, length=650.0, nseg=140, fair=(0, 0, -10), anch=(450, 0, -300), seabed=sb) + rc, log = run(a.exe, cdir, "laid", deck("slope_fei", **fei)) + check(rc == 0, "slope_fei converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + rc, log = run(a.exe, cdir, "rest", deck("slope_fei rest", **fei, tmax=1.0)) + check(rc == 0, "slope_fei at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "laid", "rest") + check(drift <= REST_TOL, "slope_fei stays at rest from the static state (drift %.2e)" % drift) + + # --- flat seabed: friction not mobilised when laid at the run's tension --- + cdir = root / "flat" + flat = dict(ei=0.0, length=850.0, nseg=85, fair=(-58, 0, -14), anch=(-837.6, 0, -200), + seabed="200.0 WtrDpth", mu=0.5) + rc0, _ = run(a.exe, cdir, "none", deck("flat none", **flat, extra="none staticsFriction\n")) + check(rc0 == 0, "flat frictionless static converges") + if rc0 == 0: + r0 = table(cdir / "none.out")[0] + h = abs(r0["Point2Fx"]) # the grounded run carries the anchor's horizontal tension + rc, _ = run(a.exe, cdir, "taut", deck("flat taut", **flat, extra="%.9g asLaidTension\n" % h)) + check(rc == 0, "flat laid at the run tension converges") + if rc == 0: + r1 = table(cdir / "taut.out")[0] + # FairTen to 1e-4. AnchTen to 0.5 %: the anchor rests on the seabed surface and the + # laid run one static penetration below it, so the run is drawn a fraction of a + # millimetre toward the anchor and its friction springs add a small tension there + # (the anchor-level effect Orcina's "OrcaFlex Friction Effects" note describes). + for k, tol in (("FairTen1", 1.0e-4), ("AnchTen1", 5.0e-3)): + rel = abs(r1[k] - r0[k]) / r0[k] + check(rel < tol, "flat laid at the run tension: %s equals the frictionless %.6g N (rel %.1e)" + % (k, r0[k], rel)) + rc, _ = run(a.exe, cdir, "slack", deck("flat slack", **flat)) + check(rc == 0, "flat laid slack converges") + if rc == 0: + r2 = table(cdir / "slack.out")[0] + drop = r0["AnchTen1"] - r2["AnchTen1"] + check(0.0 < drop <= 0.5 * w * 850.0, + "flat laid slack: friction lowers AnchTen by %.4g N (within mu w L)" % drop) + + # --- input checks --- + cdir = root / "inputs" + rc, log = run(a.exe, cdir, "badid", deck("bad id", **flat, extra="30.0 layAzimuth9\n")) + check(rc != 0 and "names no LINE" in log, "layAzimuth9 without a line 9 is rejected") + rc, log = run(a.exe, cdir, "badpolicy", deck("bad policy", **flat, extra="restart staticsFriction\n")) + check(rc != 0 and "asLaid or none" in log, "an unknown staticsFriction policy is rejected") + rc, log = run(a.exe, cdir, "goodid", deck("good id", **flat, extra="180.0 layAzimuth1\n0 asLaidTension1\n")) + check(rc == 0, "layAzimuth1 / asLaidTension1 rows are accepted") + + print("static friction as laid: %d failure(s)" % len(FAILURES)) + return 1 if FAILURES else 0 + + +if __name__ == "__main__": + sys.exit(main()) From f69cd753120e2a1f8d55535966b51537bb3acc42 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Thu, 15 Oct 2026 22:01:26 +0900 Subject: [PATCH 02/10] fix(statics): as-laid friction off the chord plane, lower end, Python options - A finite-EI asLaid line whose lay azimuth leaves the vertical plane of the chord (e.g. 45 layAzimuth) was solved in that plane, because the 3D requirement was set after the planar constraints were built, so a permanent lateral friction force remained (a held run drifted 1.2e-3). The requirement is now decided before the constraints; an azimuth in the plane (180) keeps the planar solve. - The finite-EI reference is laid from the lower end, as on the EI = 0 route, and only the geometric cross-plane offset of an in-plane line is zeroed, keeping the bathymetry sink offset (a cross-slope lateral anchor force of +269 N now -64 N against -59 N on the EI = 0 route). - The fallback anchor walk and the planar-run diagnosis test for a real current, not for the friction carrier of a still-water asLaid line. - asLaid is rejected by name on the multibody output and single-line routes that cannot apply it; an overflowing layAzimuth suffix names no LINE. - The Python deck reader, writer and builder accept and validate staticsFriction, layAzimuth[] and asLaidTension[]. - Tests: off-plane and flipped azimuths, cross-slope, per-line precedence, anisotropic friction, a multi-section line, mobilised friction on the finite-EI slope, input rejection; Python tests. With the default option every example and test deck is byte-identical. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 +- doc/driver_format.md | 2 +- doc/options.rst | 7 +- python/cabledyn/builder.py | 4 +- python/cabledyn/deck.py | 4 +- python/cabledyn/deck_file.py | 54 ++++- python/tests/test_builder.py | 25 ++ python/tests/test_deck_file.py | 86 +++++++ python/tests/test_deck_writer.py | 19 ++ src/CableDyn_DeckDriver.f90 | 183 ++++++++++---- src/CableDyn_Model.f90 | 11 +- tests/test_static_friction_as_laid.py | 327 +++++++++++++++++++++++++- 12 files changed, 663 insertions(+), 68 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae172275..40eebf74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ All notable changes to CableDyn are recorded in this file. The format follows (isotropic or axial/lateral, capped at `mu N`), in still water and in a current, on `EI = 0` and finite-EI lines, standalone, coupled OpenFAST and through the C API; the march continues the static springs, so a held run stays at rest. New OPTIONS `staticsFriction none|asLaid`, - `layAzimuth` and `layAzimuth` (default: each line's anchor → fairlead direction), + `layAzimuth` and `layAzimuth` (default: the horizontal direction of each line's chord, + from its lower end), `asLaidTension` and `asLaidTension` (default 0). The default stays `none`, as in MoorDyn: frictionless statics in still water (friction from the still-water equilibrium in a current), conservative for anchor loads, and every deck without the new rows runs as before. With @@ -31,7 +32,11 @@ All notable changes to CableDyn are recorded in this file. The format follows carries (`asLaidTension`) mobilises none: on a flat seabed FairTen equals the frictionless one to 6e-6 and AnchTen to 0.4 %. A finite-EI line laid past the point under its fairlead has no static solution yet (its touchdown hook is not reached); a lay azimuth across the span - solves it. See the theory page (Friction in statics). + solves it. A lay azimuth across the vertical plane of the chord solves a finite-EI line in 3D + from the start, and a finite-EI line is laid from its lower end like an `EI = 0` one. The + policy is rejected, as `frictionMu` is, on decks with `Connect`/`Free` points, bodies or rods, + and on mixed-topology decks. The Python `DeckFile`, `DeckWriter` and `DeckModel` take the new + rows. See the theory page (Friction in statics). - Run-time profile of the standalone driver. With the environment variable `CABLEDYN_PROFILE=1`, the driver prints at the end of the run how its wall time divides between input parsing, initialisation and statics, and the dynamic march. The march is split diff --git a/doc/driver_format.md b/doc/driver_format.md index 8fa87e2c..14b62889 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -995,7 +995,7 @@ syntax form. The most frequently edited keywords are: | `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape, or toward the as-laid position with `staticsFriction asLaid`), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | | `frictionMuAxial` / `frictionMuLateral` | anisotropic line friction: the coefficients along and across the local line axis (OrcaFlex axial/normal); an omitted one takes `frictionMu`; both positive or both zero; rods and bodies use the lateral one | `frictionMu` | | `staticsFriction` | statics seabed friction policy (OrcaFlex): `none` solves frictionless statics (in a deck current, friction from the still-water equilibrium); `asLaid` holds every grounded node toward its as-laid position (laid from the anchor along `layAzimuth` at `asLaidTension`) with the regularised Coulomb law | `none` | -| `layAzimuth`, `layAzimuth` | lay azimuth (deg, from +x toward +y) of every line, or of line `ID` | anchor → fairlead | +| `layAzimuth`, `layAzimuth` | lay azimuth (deg, from +x toward +y) of every line, or of line `ID` | chord direction, from the lower end | | `asLaidTension`, `asLaidTension` | as-laid effective tension (N, ≥ 0) of every line, or of line `ID` | 0 | | `dtM` | dynamic time step [s] | — | | `TMax` | dynamic end time [s]; an integer multiple of `dtM` | — | diff --git a/doc/options.rst b/doc/options.rst index 8bd32a73..23062ea0 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -144,12 +144,15 @@ Environment and seabed and pulled taut is held back by its friction, so the as-laid statics lowers anchor tensions (by up to ``mu w`` times the grounded length), and the frictionless statics is the conservative choice for anchor loads unless the as-laid layout and tension are - known. Used only with ``frictionMu > 0`` and a seabed. See :ref:`static-friction` + known. Used only with ``frictionMu > 0`` and a seabed; rejected, like ``frictionMu``, + on decks with ``Connect``/``Free`` points, bodies or rods (and on mixed-topology + decks), whose static equilibrium solves the lines without seabed friction. See + :ref:`static-friction` - both - ``asLaid staticsFriction`` * - ``layAzimuth`` / ``lay_azimuth``, and ``layAzimuth`` - real, deg - - absent: each line's anchor → fairlead direction + - absent: each line's chord direction, from its lower end (anchor → fairlead) - finite. Horizontal direction, from global +x toward +y, in which the line was laid from its anchor (its lower end): the as-laid reference of ``staticsFriction asLaid``. ``layAzimuth`` sets every line; ``layAzimuth`` (the line ID appended, e.g. diff --git a/python/cabledyn/builder.py b/python/cabledyn/builder.py index 71666747..d2223602 100644 --- a/python/cabledyn/builder.py +++ b/python/cabledyn/builder.py @@ -39,7 +39,6 @@ _PINNED_END_CONNECTIONS, _RIGID_END_CONNECTIONS, _ROD_ATTACHMENT_ALIASES, - _SCALAR_OPTION_KEYWORDS, _WAVETRAIN_KEYWORDS, DeckFile, DeckRecord, @@ -47,6 +46,7 @@ _copy_companions, _end_connection_end, _is_csys_token, + _is_scalar_option_keyword, _is_turbine_point_type, _native_int, _option_key, @@ -970,7 +970,7 @@ def _make(keyword: str, values: tuple[object, ...], description: str | None) -> or lowered in _WAVETRAIN_KEYWORDS or _option_key(lowered) in _POSITIONAL_KEYS ) - if lowered not in _SCALAR_OPTION_KEYWORDS and not multi: + if not _is_scalar_option_keyword(lowered) and not multi: raise ValueError(f"unknown option keyword {keyword!r}") if not values: raise ValueError(f"option {keyword} needs a value") diff --git a/python/cabledyn/deck.py b/python/cabledyn/deck.py index 81b66ec5..0f9066c2 100644 --- a/python/cabledyn/deck.py +++ b/python/cabledyn/deck.py @@ -20,7 +20,7 @@ from dataclasses import dataclass, field from pathlib import Path -from cabledyn.deck_file import _SCALAR_OPTION_KEYWORDS, DeckFile +from cabledyn.deck_file import DeckFile, _is_scalar_option_keyword _POINT_TYPES = {"fixed", "coupled", "vessel", "free", "connect"} _END_CONNECTION_ENDS = { @@ -391,7 +391,7 @@ def set_option( f"option keyword must be a string, got {type(keyword).__name__}; " "the argument order is set_option(value, keyword, description)" ) - if keyword.lower() not in _SCALAR_OPTION_KEYWORDS: + if not _is_scalar_option_keyword(keyword): raise ValueError( f"unknown option keyword {keyword!r}; the argument order is " "set_option(value, keyword, description)" diff --git a/python/cabledyn/deck_file.py b/python/cabledyn/deck_file.py index 66341c0f..be7f0813 100644 --- a/python/cabledyn/deck_file.py +++ b/python/cabledyn/deck_file.py @@ -240,7 +240,20 @@ "alphaforceblend": "alpha_force_blend", "cable_statics": "cable_statics", "cablestatics": "cable_statics", + "staticsfriction": "statics_friction", + "statics_friction": "statics_friction", + "staticsseabedfrictionpolicy": "statics_friction", + "seabedfrictionpolicy": "statics_friction", + "layazimuth": "lay_azimuth", + "lay_azimuth": "lay_azimuth", + "aslaidtension": "as_laid_tension", + "as_laid_tension": "as_laid_tension", } +# Per-line static friction rows (native apply_option): ``layAzimuth`` and ``asLaidTension`` +# with the LINE id appended; the id is a plain decimal suffix, and leading zeros name the same line. +_LINE_OPTION_PATTERN = re.compile(r"(layazimuth|aslaidtension)([0-9]+)\Z") +_LINE_OPTION_FAMILIES = {"layazimuth": "lay_azimuth", "aslaidtension": "as_laid_tension"} +_STATICS_FRICTION_POLICIES = frozenset({"aslaid", "as_laid", "as-laid", "none"}) _SCALAR_OPTION_KEYWORDS = frozenset(_OPTION_ALIASES) | { "icmode", "bodyic", @@ -800,12 +813,34 @@ def _selector_int(text: object, what: str) -> int: raise ValueError(f"{what} must be an integer, got {text!r}") +def _line_option(keyword: str) -> tuple[str, int] | None: + """Return (family, line id) of a per-line static friction row, else ``None``. + + ``layAzimuth`` and ``asLaidTension`` (case-insensitive) set the lay azimuth and the + as-laid tension of the LINE ``ID`` alone, over the global ``layAzimuth`` / ``asLaidTension`` + row; the family is ``lay_azimuth`` or ``as_laid_tension``. + """ + match = _LINE_OPTION_PATTERN.match(keyword.lower()) + if match is None: + return None + return _LINE_OPTION_FAMILIES[match.group(1)], int(match.group(2)) + + +def _is_scalar_option_keyword(keyword: str) -> bool: + """Whether ``keyword`` (any case) is a two-token scalar OPTIONS keyword (per-line rows too).""" + return keyword.lower() in _SCALAR_OPTION_KEYWORDS or _line_option(keyword) is not None + + def _option_key(keyword: str) -> str: """Return the native identity of an option keyword (aliases collapse to one key).""" lowered = keyword.lower() if lowered in _WAVETRAIN_KEYWORDS: # native CD_Sea_Parse_Train takes both spellings of the one keyword return "wavetrain" + line_option = _line_option(lowered) + if line_option is not None: + # layAzimuth7 and layAzimuth07 set the same line natively: the last row wins + return f"{line_option[0]}:{line_option[1]}" return _OPTION_ALIASES.get(lowered, lowered) @@ -1029,7 +1064,7 @@ def _dynamic_solver_values_are_valid(values: list[str] | tuple[str, ...]) -> boo def _scalar_option_value_error(keyword: str, value: str) -> str | None: """Return why a two-token scalar row violates ``apply_option`` semantics.""" raw = keyword.lower() - key = _option_key(raw) + key = _option_key(raw).partition(":")[0] # a per-line row takes its family's rules defect = _real_token_defect(value) if defect is not None and "subnormal" in defect: return defect @@ -1051,6 +1086,7 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "friction", "friction_axial", "friction_lateral", + "as_laid_tension", "tensile_strain_tolerance", "ramp_time", "max_strain", @@ -1077,6 +1113,8 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: "friction", "friction_axial", "friction_lateral", + "lay_azimuth", + "as_laid_tension", "rhoinf", "tensile_strain_tolerance", "ramp_time", @@ -1170,6 +1208,13 @@ def _scalar_option_value_error(keyword: str, value: str) -> str | None: if abs(numeric - round(numeric)) > integer_tolerance: return "must be an integer" return None + if key == "statics_friction": + # native: the policy is dequoted and compared case-insensitively + return ( + None + if _strip_quotes(value).lower() in _STATICS_FRICTION_POLICIES + else "must be asLaid or none" + ) if key == "cable_statics": return ( None @@ -2076,7 +2121,7 @@ def _option_row(self, index: int) -> OptionRecord | None: "Coulomb friction set by frictionMu, frictionMuLateral and frictionMuAxial; " "remove the row" ) - if keyword.lower() not in _SCALAR_OPTION_KEYWORDS: + if not _is_scalar_option_keyword(keyword): 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}") @@ -2660,6 +2705,11 @@ def end_key(token: str) -> str: for point_type in point_types.values() ) line_ids = unique(self.lines, "line", True) + for option in options: + line_option = _line_option(option.keyword) + if line_option is not None and str(line_option[1]) not in line_ids: + # native: layAzimuth / asLaidTension must name a LINE + raise DeckFormatError(f"{self._label}: OPTION {option.keyword} names no LINE") section_lines: set[str] = set() section_types_by_line: dict[str, list[str]] = {line_id: [] for line_id in line_ids} line_nelems: dict[str, int] = dict.fromkeys(line_ids, 0) diff --git a/python/tests/test_builder.py b/python/tests/test_builder.py index 3afee401..8ee00ec9 100644 --- a/python/tests/test_builder.py +++ b/python/tests/test_builder.py @@ -599,6 +599,31 @@ def test_collections_are_live_lookups() -> None: assert "DeckModel" in repr(model) +def test_option_set_static_friction_rows() -> None: + model = _chain_model() + options = model.options + options.set("staticsFriction", "asLaid") + options.set("layAzimuth", 45.0) + options.set("layAzimuth1", 180.0) + options.set("LAYAZIMUTH01", 90.0) # the same line as layAzimuth1: replaces it + options.set("asLaidTension1", 1.0e5) + assert [row.keyword for row in options if row.keyword.lower().startswith("layazimuth")] == [ + "layAzimuth", + "LAYAZIMUTH01", + ] + assert options.value("layAzimuth1") == "90.0" and options.value("asLaidTension1") == "100000.0" + assert options.value("layAzimuth2") is None + model.validate() + text = model.to_text() + assert "asLaid staticsFriction" in text and "90.0 LAYAZIMUTH01" in text + assert options.remove("layAzimuth1") == 1 and "layAzimuth" in options + with pytest.raises(ValueError, match="unknown option keyword"): + options.set("layAzimuth1x", 1.0) + options.set("layAzimuth3", 10.0) + with pytest.raises(Exception, match="names no LINE"): + model.validate() + + def test_option_set_semantics() -> None: model = _chain_model() options = model.options diff --git a/python/tests/test_deck_file.py b/python/tests/test_deck_file.py index 3141e498..74a5d40c 100644 --- a/python/tests/test_deck_file.py +++ b/python/tests/test_deck_file.py @@ -4093,6 +4093,92 @@ def test_anisotropic_friction_rows_fail_closed_like_native(rows, message): DeckFile.from_text(_wave_source(rows)) +@pytest.mark.parametrize( + "rows", + [ + "asLaid staticsFriction", + "none staticsFriction", + "ASLAID statics_friction", + "As_Laid staticsSeabedFrictionPolicy", + '"as-laid" seabedFrictionPolicy', + "45.0 layAzimuth", + "-30 lay_azimuth", + "180 layAzimuth1", + "2.0e5 asLaidTension", + "0 as_laid_tension", + "1e5 ASLAIDTENSION1", + "10 layAzimuth01\n20 layAzimuth1\n0.5 frictionMu\nasLaid staticsFriction", + ], +) +def test_static_friction_rows_are_native_compatible(rows): + deck = DeckFile.from_text(_wave_source(rows)) + deck.validate() + assert deck.options + + +@pytest.mark.parametrize( + ("rows", "message"), + [ + ("restart staticsFriction", "OPTION staticsFriction must be asLaid or none"), + ("1 seabedFrictionPolicy", "must be asLaid or none"), + ("inf layAzimuth", "must be finite"), + ("abc layAzimuth", "must be numeric"), + ("nan layAzimuth1", "must be finite"), + ("-1 asLaidTension", "must be >= 0"), + ("-1 asLaidTension1", "must be >= 0"), + ("inf as_laid_tension", "must be finite"), + ("30 layAzimuth2", "layAzimuth2 names no LINE"), + ("30 layAzimuth0", "layAzimuth0 names no LINE"), + ("30 asLaidTension7", "asLaidTension7 names no LINE"), + ("30 layAzimuth99999999999999999999", "names no LINE"), + ("1 asLaidTension99999999999999999999", "names no LINE"), + ("30 layAzimuth1x", "unknown OPTION keyword 'layAzimuth1x'"), + ("30 layAzimuth_1", "unknown OPTION keyword"), + ("30 layAzimuthx", "unknown OPTION keyword"), + ("30 asLaidTension-1", "unknown OPTION keyword"), + ], +) +def test_static_friction_rows_fail_closed_like_native(rows, message): + with pytest.raises(DeckFormatError, match=message): + DeckFile.from_text(_wave_source(rows)).validate() + + +def test_static_friction_option_identities_and_editing(): + deck = DeckFile.from_text( + _wave_source( + "90 layAzimuth\n45 LayAzimuth1\n30 layazimuth01\n0 asLaidTension\n" + "5e4 asLaidTension1\nasLaid STATICSFRICTION" + ) + ) + deck.validate() + assert deck.option("layAzimuth").values == ("90",) + assert deck.option("lay_azimuth").values == ("90",) + # layAzimuth1, LayAzimuth1 and layazimuth01 name one line: the last row wins + assert deck.option("layAzimuth1").values == ("30",) + assert deck.option("LAYAZIMUTH001").values == ("30",) + assert deck.option("asLaidTension1").values == ("5e4",) + assert deck.option("as_laid_tension").values == ("0",) + assert deck.option("staticsFriction").values == ("asLaid",) + assert deck.option("seabedFrictionPolicy").values == ("asLaid",) + with pytest.raises(KeyError): + deck.option("layAzimuth2") + deck.set_option("layAzimuth1", 120.0) + deck.set_option("lay_azimuth", -15) + deck.set_option("staticsFriction", "none") + assert deck.option("layAzimuth01").values == ("120",) + assert deck.option("layAzimuth").values == ("-15",) + assert deck.option("staticsFriction").values == ("none",) + with pytest.raises(DeckFormatError, match="asLaid or none"): + deck.set_option("staticsFriction", "restart") + with pytest.raises(DeckFormatError, match=">= 0"): + deck.set_option("asLaidTension1", -2.0) + with pytest.raises(DeckFormatError, match="must be finite"): + deck.set_option("layAzimuth1", float("inf")) + assert deck.option("staticsFriction").values == ("none",) + assert deck.option("asLaidTension1").values == ("5e4",) + assert DeckFile.from_text(deck.text()).option("layAzimuth1").values == ("120",) + + @pytest.mark.parametrize( ("row", "message"), [ diff --git a/python/tests/test_deck_writer.py b/python/tests/test_deck_writer.py index 3bffb6c2..b0e92a31 100644 --- a/python/tests/test_deck_writer.py +++ b/python/tests/test_deck_writer.py @@ -65,6 +65,25 @@ def test_writer_output_validates_and_round_trips(tmp_path): assert path.read_text(encoding="ascii") == deck.text() +def test_writer_accepts_static_friction_rows(tmp_path): + deck = _writer() + deck.set_option("asLaid", "staticsFriction", "Statics seabed friction policy") + deck.set_option(45.0, "layAzimuth") + deck.set_option(180.0, "layAzimuth1") + deck.set_option(2.0e5, "asLaidTension1") + parsed = DeckFile.read(deck.write(tmp_path / "friction.dat")) + assert parsed.option("staticsFriction").values == ("asLaid",) + assert parsed.option("layAzimuth").values == ("45.0",) + assert parsed.option("LAYAZIMUTH1").values == ("180.0",) + assert parsed.option("asLaidTension1").values == ("200000.0",) + with pytest.raises(ValueError, match="unknown option keyword 'layAzimuth1x'"): + deck.set_option(1.0, "layAzimuth1x") + bad = _writer() + bad.set_option(30.0, "layAzimuth7") + with pytest.raises(DeckFormatError, match="names no LINE"): + bad.text() + + def test_set_option_rejects_swapped_value_and_keyword(): deck = _writer() with pytest.raises(TypeError, match="set_option\\(value, keyword"): diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index a9b44de7..2c69377c 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -541,7 +541,7 @@ MODULE CableDyn_DeckDriver REAL(wp) :: friction_mu_axial_row = -1.0_wp, friction_mu_lateral_row = -1.0_wp ! Static seabed friction (staticsFriction, layAzimuth, asLaidTension rows): the policy ! (CD_STATIC_FRICTION_NONE, the default, or _AS_LAID), the lay azimuth [deg] for every - ! line (has_lay_azimuth; otherwise each line's anchor -> fairlead direction) and the + ! line (has_lay_azimuth; otherwise each line's chord direction, from its lower end) and the ! as-laid tension [N], with per-line overrides (layAzimuth, asLaidTension). INTEGER :: static_friction = CD_STATIC_FRICTION_NONE LOGICAL :: has_lay_azimuth = .FALSE. @@ -1747,6 +1747,10 @@ RECURSIVE SUBROUTINE build_one_hermite_cable(ln, sections, types, points, opts, require_3d_static = .TRUE. END IF END IF + ! A lay azimuth across the vertical plane of the chord puts the as-laid friction + ! 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. 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) @@ -3840,50 +3844,110 @@ SUBROUTINE still_water_reference(esr, emr) CALL CD_HFMF_End(sw_cable) END SUBROUTINE still_water_reference + LOGICAL FUNCTION as_laid_off_plane() RESULT(off) + !! Whether the as-laid seabed friction of this line has a lay azimuth across the + !! vertical plane of its chord (an explicit layAzimuth / layAzimuth; the default + !! azimuth is the chord's own heading and lies in that plane). Decided from the deck + !! options alone, so the static solve can be set up in 3D before its held DOFs are chosen. + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: laid_t, dir_l(2) + off = .FALSE. + IF (.NOT. (contact_enabled .AND. opts%has_friction .AND. & + opts%static_friction == CD_STATIC_FRICTION_AS_LAID)) RETURN + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) + IF (.NOT. ALLOCATED(lay_az_opt)) RETURN + dir_l = [frame_cs(1)*COS(lay_az_opt) + frame_cs(2)*SIN(lay_az_opt), & + -frame_cs(2)*COS(lay_az_opt) + frame_cs(1)*SIN(lay_az_opt)] + off = ABS(dir_l(2)) > 64.0_wp*EPSILON(CD_ONE) + END FUNCTION as_laid_off_plane + + SUBROUTINE as_laid_positions(with_sink, from_top, az, laid_t, ref_g, esr, emr) + !! Global (x, y) as-laid position of every node of the deck mesh (CD_Static_As_Laid_Reference): + !! the line laid on the seabed from its lower end (the anchor, node 1; the fairlead, the last + !! node, when from_top) along the azimuth az [rad] at the as-laid tension. with_sink: the + !! nodes sink into the penalty seabed as in the static solve, which moves them along a slope. + LOGICAL, INTENT(IN) :: with_sink, from_top + REAL(wp), INTENT(IN) :: az, laid_t + REAL(wp), INTENT(OUT) :: ref_g(:, :) + INTEGER, INTENT(OUT) :: esr + CHARACTER(*), INTENT(OUT) :: emr + REAL(wp), ALLOCATABLE :: wn(:), kn_r(:), sn(:), l0_r(:), ea_r(:) + REAL(wp) :: o_xy(2) + INTEGER :: k, ne_r + ne_r = SIZE(l0) + IF (with_sink .AND. PRESENT(bathymetry)) THEN + ! static penalty penetration factor w_i/k_i of every node (the nodal contact + ! stiffness of the solve, kBot Diam l0 lumped to the nodes) + ALLOCATE (wn(ne_r + 1), kn_r(ne_r + 1)) + wn = CD_ZERO + kn_r = CD_ZERO + DO k = 1, ne_r + wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) + kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) + END DO + WHERE (kn_r > CD_ZERO) + wn = MAX(wn, CD_ZERO)/kn_r + ELSEWHERE + wn = CD_ZERO + END WHERE + IF (from_top) THEN + sn = wn(ne_r + 1:1:-1) + ELSE + sn = wn + END IF + END IF + IF (from_top) THEN + ! the line is laid from its bottom end, here the last node + l0_r = l0(ne_r:1:-1) + ea_r = ea(ne_r:1:-1) + o_xy = points(pb)%pos(1:2) + ELSE + l0_r = l0 + ea_r = ea + o_xy = points(pa)%pos(1:2) + END IF + CALL CD_Static_As_Laid_Reference(o_xy, az, l0_r, ea_r, laid_t, ref_g, esr, emr, bathymetry=bathymetry, sink=sn) + IF (from_top .AND. esr == CD_STATIC_OK) ref_g = ref_g(:, ne_r + 1:1:-1) + END SUBROUTINE as_laid_positions + SUBROUTINE as_laid_reference(esr, emr) - !! Friction reference of the static solve (CD_Static_As_Laid_Reference): the line laid - !! from its anchor (node 1) along the lay azimuth on the seabed at the as-laid tension, - !! as (x, y) offsets from node 1 in the solve frame along the unstretched arc length of - !! the deck mesh. A lay azimuth off the vertical plane of the chord puts the reference - !! out of that plane, so the static solve then runs in 3D. + !! Friction reference of the static solve (CD_Static_As_Laid_Reference): the line laid on + !! the seabed from its lower end (the anchor, node 1, unless the fairlead is lower, as in + !! the EI = 0 line model) along the lay azimuth at the as-laid tension, as (x, y) offsets + !! from node 1 in the solve frame along the unstretched arc length of the deck mesh. A lay + !! azimuth off the vertical plane of the chord puts the reference out of that plane (see + !! as_laid_off_plane): the static solve then runs in 3D. In the plane the reference is + !! held in it, but for the sink of its nodes along a cross slope. INTEGER, INTENT(OUT) :: esr CHARACTER(*), INTENT(OUT) :: emr - REAL(wp), ALLOCATABLE :: lay_az_opt, ref_g(:, :) - REAL(wp) :: laid_t, az, dg(2), a_g(3), f_g(3), dir_l(2) + REAL(wp), ALLOCATABLE :: lay_az_opt, ref_g(:, :), ref_0(:, :) + REAL(wp) :: laid_t, az, dg(2), dg0(2), a_g(3), f_g(3) INTEGER :: k, ne_r + LOGICAL :: from_top, in_plane esr = CD_DECKDRV_OK emr = '' ne_r = SIZE(l0) CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) a_g = points(pa)%pos f_g = points(pb)%pos + from_top = f_g(3) < a_g(3) + ! the default azimuth is the chord's horizontal direction from the line's lower end + ! (+x from the anchor, and -x from the fairlead, for a vertical chord) az = CD_ZERO IF (NORM2(f_g(1:2) - a_g(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(f_g - a_g))) & az = ATAN2(f_g(2) - a_g(2), f_g(1) - a_g(1)) - IF (ALLOCATED(lay_az_opt)) az = lay_az_opt - ALLOCATE (ref_g(2, ne_r + 1)) - IF (PRESENT(bathymetry)) THEN - BLOCK - ! static penalty penetration factor w_i/k_i of every node (the nodal contact - ! stiffness of the solve, kBot Diam l0 lumped to the nodes) - REAL(wp) :: wn(ne_r + 1), kn_r(ne_r + 1) - wn = CD_ZERO - kn_r = CD_ZERO - DO k = 1, ne_r - wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) - kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) - END DO - WHERE (kn_r > CD_ZERO) - wn = MAX(wn, CD_ZERO)/kn_r - ELSEWHERE - wn = CD_ZERO - END WHERE - CALL CD_Static_As_Laid_Reference(a_g(1:2), az, l0, ea, laid_t, ref_g, esr, emr, bathymetry=bathymetry, & - sink=wn) - END BLOCK - ELSE - CALL CD_Static_As_Laid_Reference(a_g(1:2), az, l0, ea, laid_t, ref_g, esr, emr) - END IF + IF (ALLOCATED(lay_az_opt)) THEN + az = lay_az_opt + ELSE IF (from_top) THEN + az = ATAN2(-SIN(az), -COS(az)) + END IF + in_plane = .NOT. as_laid_off_plane() + ALLOCATE (ref_g(2, ne_r + 1), ref_0(2, ne_r + 1)) + CALL as_laid_positions(.TRUE., from_top, az, laid_t, ref_g, esr, emr) + ! the laid line without the sink of its nodes: its cross-plane offset is geometric + ref_0 = ref_g + IF (esr == CD_STATIC_OK .AND. in_plane .AND. PRESENT(bathymetry)) & + CALL as_laid_positions(.FALSE., from_top, az, laid_t, ref_0, esr, emr) IF (esr /= CD_STATIC_OK) THEN esr = CD_DECKDRV_BADINPUT RETURN @@ -3898,16 +3962,16 @@ SUBROUTINE as_laid_reference(esr, emr) cur_obj%friction%ref_s(k) = cur_obj%friction%ref_s(k - 1) + l0(k - 1) END DO DO k = 1, ne_r + 1 - dg = ref_g(:, k) - ref_g(:, 1) + dg = ref_g(:, k) - a_g(1:2) cur_obj%friction%ref_xy(:, k) = [frame_cs(1)*dg(1) + frame_cs(2)*dg(2), -frame_cs(2)*dg(1) + frame_cs(1)*dg(2)] + IF (in_plane) THEN + ! the laid line lies in the vertical plane of the chord: only the sink offset of the + ! nodes on a cross slope (zero on a flat floor) leaves it + dg0 = ref_0(:, k) - a_g(1:2) + cur_obj%friction%ref_xy(2, k) = (-frame_cs(2)*dg(1) + frame_cs(1)*dg(2)) - & + (-frame_cs(2)*dg0(1) + frame_cs(1)*dg0(2)) + END IF END DO - IF (ALLOCATED(lay_az_opt)) THEN - dir_l = [frame_cs(1)*COS(az) + frame_cs(2)*SIN(az), -frame_cs(2)*COS(az) + frame_cs(1)*SIN(az)] - IF (ABS(dir_l(2)) > 64.0_wp*EPSILON(CD_ONE)) require_3d_static = .TRUE. - ELSE - ! the default azimuth is the chord's own heading: the reference lies in its plane - cur_obj%friction%ref_xy(2, :) = CD_ZERO - END IF END SUBROUTINE as_laid_reference SUBROUTINE fine_mesh_note(note) @@ -4786,12 +4850,19 @@ SUBROUTINE laid_seed_positions(ok) ok = .TRUE. END SUBROUTINE laid_seed_positions + LOGICAL FUNCTION in_current() RESULT(yes) + !! Whether the line is loaded by a real current: the current object carries drag. In + !! still water it may be present only as the carrier of the as-laid seabed friction. + yes = .FALSE. + IF (PRESENT(cur_obj)) yes = cur_obj%drag + END FUNCTION in_current + LOGICAL FUNCTION planar_run_diagnosed(msg) RESULT(yes) !! Whether msg carries the frictionless grounded-run diagnosis of a current (the !! current drives the run on the seabed into compression) for this line held in its !! vertical plane (every node's out-of-plane DOF held). CHARACTER(*), INTENT(IN) :: msg - yes = PRESENT(cur_obj) + yes = in_current() IF (yes) yes = COUNT(MOD(fixed_dofs - 1, 6) == 1) >= nnode IF (yes) yes = INDEX(msg, 'the run on the seabed is in axial compression') > 0 .OR. & INDEX(msg, 'the run on the seabed folds against its end') > 0 @@ -4900,7 +4971,7 @@ SUBROUTINE walk_anchor() DO k = 2, nnode sref(k) = sref(k - 1) + l0(k - 1) END DO - energy = .NOT. PRESENT(cur_obj) + energy = .NOT. in_current() tol_w = MAX(cont_tol, WALK_TOL) tw = CD_ZERO dt = WALK_DT0 @@ -7407,7 +7478,7 @@ SUBROUTINE init_one_model(ln, sections, types, points, opts, model, ErrStat, Err LOGICAL :: want_wave_cfg CHARACTER(200) :: em ! static seabed friction of this line: lay azimuth override [rad] (unallocated: the - ! default, the anchor -> fairlead direction) and as-laid tension [N] + ! default, the chord direction from the line's lower end) and as-laid tension [N] REAL(wp), ALLOCATABLE :: lay_az_opt REAL(wp) :: laid_t @@ -9156,6 +9227,15 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg IF (PRESENT(end_force)) end_force = CD_ZERO force_a = CD_ZERO force_b = CD_ZERO + ! This static-only EI = 0 solve carries no seabed friction (standalone, frictionMu needs + ! dtM and TMax, so the dynamic route owns it): fail closed on the as-laid policy instead of + ! reporting a frictionless equilibrium as the as-laid one. + IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID .AND. & + (PRESENT(bathymetry) .OR. opts%has_wtrdpth)) THEN + CALL fail(ErrStat, ErrMsg, 'OPTION staticsFriction asLaid is not applied by the static-only line solve; '// & + 'run the deck with dtM and TMax (the dynamic route holds the line toward its as-laid '// & + 'position) or use staticsFriction none'); RETURN + END IF ! NodeA is deck End A/fairlead; NodeB is deck End B/anchor. Internally the ! catenary/static model remains anchor -> fairlead. anchor = points(find_point(points, ln%nodeB))%pos @@ -12925,7 +13005,7 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) opts%has_friction = (ErrStat == 0 .AND. opts%friction_mu > CD_ZERO) END IF CASE ('staticsfriction', 'statics_friction', 'staticsseabedfrictionpolicy', 'seabedfrictionpolicy') - ! OrcaFlex's statics seabed friction policy: "as laid" (the default) or "none" + ! OrcaFlex's statics seabed friction policy: "as laid" or "none" (the default) SELECT CASE (to_lower(TRIM(strip_quotes(val)))) CASE ('aslaid', 'as_laid', 'as-laid') opts%static_friction = CD_STATIC_FRICTION_AS_LAID @@ -13068,6 +13148,7 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) BLOCK CHARACTER(LEN(kw)) :: kl INTEGER :: lid, ios_l, np + LOGICAL :: digits REAL(wp) :: xv kl = to_lower(TRIM(kw)) np = 0 @@ -13078,11 +13159,16 @@ SUBROUTINE apply_option(line, opts, ErrStat, ErrMsg) IF (kl(1:13) == 'aslaidtension') np = 13 END IF ios_l = 1 + digits = .FALSE. IF (np > 0) THEN - IF (VERIFY(TRIM(kl(np + 1:)), '0123456789') == 0) READ (kl(np + 1:), *, IOSTAT=ios_l) lid + digits = VERIFY(TRIM(kl(np + 1:)), '0123456789') == 0 + IF (digits) READ (kl(np + 1:), *, IOSTAT=ios_l) lid END IF - IF (ios_l /= 0) THEN + IF (.NOT. digits) THEN CALL fail(ErrStat, ErrMsg, 'unknown OPTION keyword "'//TRIM(kw)//'"') + ELSE IF (ios_l /= 0) THEN + ! an integer suffix too large for a line ID + CALL fail(ErrStat, ErrMsg, 'OPTION '//TRIM(kw)//' names no LINE') ELSE CALL rd(val, xv, ErrStat, ErrMsg) IF (ErrStat == 0) THEN @@ -17286,6 +17372,11 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod first_miss_time = CD_ZERO last_miss_time = CD_ZERO ! ---- scope of the multibody march (fail closed by name) ---- + IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID) THEN + CALL fail(ErrStat, ErrMsg, 'a mixed-topology deck does not support OPTION staticsFriction asLaid (the '// & + 'static equilibrium of its bodies, rods and points solves the lines without seabed friction); '// & + 'use staticsFriction none'); RETURN + END IF IF (opts%has_motion_file) THEN CALL fail(ErrStat, ErrMsg, 'a mixed-topology deck (bodies, rods, dynamic points, EI=0 and finite-EI '// & 'lines together) does not support motionFile coupling'); RETURN diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index a96304e7..bc09bf4c 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -1345,9 +1345,11 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra ! 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(:, :) ! Static seabed friction (with seabed_mu > 0 on a seabed): the policy - ! (CD_STATIC_FRICTION_AS_LAID, the default, or CD_STATIC_FRICTION_NONE), the lay azimuth - ! [rad, from global +x toward +y; default: the horizontal anchor -> fairlead direction, - ! +x for a vertical chord] and the as-laid effective tension [N, default 0] of + ! (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 + ! the line's lower end (anchor -> fairlead, or fairlead -> anchor when the fairlead is + ! lower), +x from the anchor for a vertical chord] and the as-laid effective tension + ! [N, default 0] of ! CD_Static_As_Laid_Reference. As laid, the static solve resists every grounded node's ! horizontal displacement from its as-laid position with the friction springs, and the ! stick-slip anchors of the dynamics continue their forces; with none the static solve @@ -1498,7 +1500,8 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL fail(ErrStat, ErrMsg, 'line model as_laid_tension must be finite and non-negative') RETURN END IF - ! default lay azimuth: the vertical plane through the line ends (anchor -> fairlead) + ! default lay azimuth: the vertical plane through the line ends, from the anchor toward + ! the fairlead (negated below when the line is laid from its fairlead, the lower end) laid_az = CD_ZERO IF (NORM2(fairlead(1:2) - anchor(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(fairlead - anchor))) & laid_az = ATAN2(fairlead(2) - anchor(2), fairlead(1) - anchor(1)) diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index 39c4f11a..4b924b25 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -25,8 +25,19 @@ frictionless ones (FairTen to 1e-4, AnchTen to 0.5 %, see the check); laid slack (the default), friction holds the run back and the anchor tension falls by at most mu w times the grounded length; -* input checks: ``layAzimuth`` of a line that does not exist and an unknown policy are - rejected. +* ``fei_flat_*`` (finite-EI cable on a flat seabed, laid slack): a lay azimuth across the vertical + 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`` (finite-EI cable on a cross slope): the lateral anchor force follows the EI = 0 + line's, i.e. the sink offset of the laid nodes across the slope stays in the friction reference; +* ``pl_*``: per-line rows win over the global ones (``layAzimuth`` over ``layAzimuth``, + ``asLaidTension`` over ``asLaidTension``, in either order), and a row for line 2 leaves + line 1 alone; ``aniso_*``: the axial coefficient rules the friction along a laid run; + ``multi``: a three-section line of different weights keeps every grounded node within mu N; +* 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. usage: test_static_friction_as_laid.py --exe --output """ @@ -63,15 +74,20 @@ def slope_grid(path: Path, depth0: float, slope_deg: float) -> None: def deck(title: str, ei: float, length: float, nseg: int, fair: tuple, anch: tuple, seabed: str, - extra: str = "", tmax: float = 0.0, mu: float = 1.0) -> str: + extra: str = "", tmax: float = 0.0, mu: float = 1.0, types: str | None = None, + sections: str | None = None) -> str: d, m, ea = CHAIN + if types is None: + types = f"chain {d} {m} {ea} -1 {ei} 1.37 0.64 1 0\n" + if sections is None: + sections = f"1 chain {length} {nseg}\n" return ( "--------------------- CableDyn Input File ---\n" f"{title}\n" "--------------------- LINE TYPES ---\n" "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n" "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\n" - f"chain {d} {m} {ea} -1 {ei} 1.37 0.64 1 0\n" + f"{types}" "--------------------- POINTS ---\n" "ID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" f"1 Coupled {fair[0]} {fair[1]} {fair[2]} 0 0 0 0\n" @@ -80,7 +96,7 @@ def deck(title: str, ei: float, length: float, nseg: int, fair: tuple, anch: tup "ID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 pt\n" "--------------------- SECTIONS ---\n" "LineID LineType Length NumSegs\n(-) (-) (m) (-)\n" - f"1 chain {length} {nseg}\n" + f"{sections}" "--------------------- OPTIONS ---\n" f"{G} g\n{RHO} rhoW\n{seabed}\n100000.0 kBot\n1.0e4 cBot\n0.05 dtM\n{tmax} TMax\n" f"{mu} frictionMu\nasLaid staticsFriction\n{extra}" @@ -113,8 +129,12 @@ def first_row(path: Path) -> list: def grounded_balance(cdir: Path, name: str, length: float, nseg: int, mu: float, depth0: float, - slope_deg: float) -> tuple: - """Largest friction utilisation |f|/(mu N) over grounded nodes and the total friction.""" + slope_deg: float, band: float | None = None, end_trim: int = 0) -> tuple: + """Largest friction utilisation |f|/(mu N) over grounded nodes and the total friction. + + band: only the nodes whose three neighbours on either side lie within band [m] of the + seabed are taken (a finite-EI cable bends at its touchdown, which the tension-only balance + does not carry), and not the last end_trim nodes before the anchor.""" d, m, _ = CHAIN w = (m - RHO * math.pi / 4.0 * d * d) * G l0 = length / nseg @@ -135,6 +155,12 @@ def grounded_balance(cdir: Path, name: str, length: float, nseg: int, mu: float, normal = -f[2] / nrm[2] if pos[i][2] > zf + 0.5 or not normal > 1.0e-6 * w * l0: continue + if i >= len(pos) - 1 - end_trim: + continue + if band is not None and not all( + abs(pos[j][2] + depth0 + math.tan(math.radians(slope_deg)) * pos[j][0]) < band + for j in range(max(i - 3, 0), min(i + 4, len(pos)))): + continue fr = math.hypot(f[0] + normal * nrm[0], f[1]) total += fr worst = max(worst, fr / (mu * normal)) @@ -151,6 +177,98 @@ def at_rest(cdir: Path, static_name: str, rest_name: str) -> float: return drift / scale +def deck_two(title: str, extra: str = "", mu: float = 0.5) -> str: + """Two identical EI = 0 chains on a flat seabed, 1000 m apart (lines 1 and 2).""" + d, m, ea = CHAIN + return ( + "--------------------- CableDyn Input File ---\n" + f"{title}\n" + "--------------------- LINE TYPES ---\n" + "TypeName Diam MassDenInAir EA BA EI Cd_n Cd_t Ca_n Ca_t\n" + "(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)\n" + f"chain {d} {m} {ea} -1 0 1.37 0.64 1 0\n" + "--------------------- POINTS ---\n" + "ID Type X Y Z Mass Vol CdA Ca\n(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)\n" + "1 Coupled -58 0 -14 0 0 0 0\n2 Fixed -837.6 0 -200 0 0 0 0\n" + "3 Coupled -58 1000 -14 0 0 0 0\n4 Fixed -837.6 1000 -200 0 0 0 0\n" + "--------------------- LINES ---\n" + "ID NodeA NodeB Outputs\n(-) (-) (-) (-)\n1 1 2 pt\n2 3 4 pt\n" + "--------------------- SECTIONS ---\n" + "LineID LineType Length NumSegs\n(-) (-) (m) (-)\n1 chain 850 85\n2 chain 850 85\n" + "--------------------- OPTIONS ---\n" + f"{G} g\n{RHO} rhoW\n200.0 WtrDpth\n100000.0 kBot\n1.0e4 cBot\n0.05 dtM\n0 TMax\n" + f"{mu} frictionMu\nasLaid staticsFriction\n{extra}" + "--------------------- OUTPUTS ---\n" + '"FairTen1"\n"AnchTen1"\n"FairTen2"\n"AnchTen2"\n' + "--------------------- need this line ---\n" + ) + + +def same(a: dict, b: dict, keys: tuple, tol: float = 1.0e-9) -> bool: + """Whether the channels ``keys`` of two output rows agree to the relative tolerance tol.""" + return all(abs(a[k] - b[k]) <= tol * max(abs(a[k]), 1.0) for k in keys) + + +def chain_weight() -> float: + """Submerged weight per length [N/m] of the test chain.""" + d, m, _ = CHAIN + return (m - RHO * math.pi / 4.0 * d * d) * G + + +def plateau_utilisation(cdir: Path, name: str, mu: float, zfloor: float, kbot: float, sections: tuple, + trim: int = 2) -> tuple: + """Largest |f|/(mu N) over the nodes resting on a flat seabed, from the nodal balance. + + The horizontal force that tensions and weight leave at a grounded node is what friction + carries (EI = 0, or a straight run of a finite-EI cable). The nodes are the ones at the + penetration depth of the penalty seabed, less ``trim`` at each end of the run (the bending + of a finite-EI cable acts at the touchdown and at the anchor). ``sections``: (diameter, + submerged weight per length, element length, number of elements) from End A. Returns + (utilisation, number of nodes, largest |y| of the line, the utilisation and the number of + nodes of each section, a node counted with the section of its End A element). + """ + p = first_row(cdir / (name + ".Line1.p.out")) + pos = [p[3 * i:3 * i + 3] for i in range(len(p) // 3)] + ten = first_row(cdir / (name + ".Line1.t.out")) + elem = [] # per element: diameter, weight per length, length + owner = [] # per element: its section + for k, (dia, wt, l0, ne) in enumerate(sections): + elem += [(dia, wt, l0)] * ne + owner += [k] * ne + grounded = [] + for i in range(1, len(pos) - 1): + # a node is grounded when it sits below the floor by (nearly) the penetration of the + # lighter of its two elements + pen = min(elem[i - 1][1] / (kbot * elem[i - 1][0]), elem[i][1] / (kbot * elem[i][0])) + if pos[i][2] < zfloor - 0.95 * pen: + grounded.append(i) + grounded = grounded[trim:len(grounded) - trim] + worst = 0.0 + by_section = [[0.0, 0] for _ in sections] + for i in grounded: + f = [0.0, 0.0, -0.5 * (elem[i - 1][1] * elem[i - 1][2] + elem[i][1] * elem[i][2])] + for e, j in ((i - 1, i - 1), (i, i + 1)): + u = [pos[j][k] - pos[i][k] for k in range(3)] + n = math.sqrt(sum(x * x for x in u)) + for k in range(3): + f[k] += ten[e] * u[k] / n + util = math.hypot(f[0], f[1]) / (mu * -f[2]) + worst = max(worst, util) + by_section[owner[i - 1]][0] = max(by_section[owner[i - 1]][0], util) + by_section[owner[i - 1]][1] += 1 + return worst, len(grounded), max(abs(q[1]) for q in pos), by_section + + +def cross_grid(path: Path, depth0: float, slope_deg: float) -> None: + """A seabed z = -(depth0 + tan(slope) y): planar in y, falling toward +y (across the line).""" + t = math.tan(math.radians(slope_deg)) + rows = [] + for x in range(-300, 1000, 100): + for y in (-300.0, 300.0): + rows.append("%.1f %.1f %.12g" % (x, y, depth0 + t * y)) + path.write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + + def main() -> int: ap = argparse.ArgumentParser() ap.add_argument("--exe", required=True) @@ -196,6 +314,14 @@ def main() -> int: rc, log = run(a.exe, cdir, "laid", deck("slope_fei", **fei)) check(rc == 0, "slope_fei converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) if rc == 0: + # the straight grounded run (away from the touchdown and the anchor, where the cable + # bends) carries its slope load by friction: mobilised well above zero, within mu N + worst, total, past = grounded_balance(cdir, "laid", 650.0, 140, 1.0, depth0, slope, band=0.35, + end_trim=10) + check(worst <= 1.0 + 1.0e-2, "slope_fei: friction within mu N along the straight run (max %.4f)" % worst) + check(worst > 0.5 * math.tan(math.radians(slope)), + "slope_fei: friction holds the slope load (max utilisation %.4f, tan(slope) %.4f)" + % (worst, math.tan(math.radians(slope)))) rc, log = run(a.exe, cdir, "rest", deck("slope_fei rest", **fei, tmax=1.0)) check(rc == 0, "slope_fei at-rest march runs (rc %d)" % rc) if rc == 0: @@ -204,6 +330,7 @@ def main() -> int: # --- flat seabed: friction not mobilised when laid at the run's tension --- cdir = root / "flat" + h_run = None # the horizontal tension of the frictionless grounded run flat = dict(ei=0.0, length=850.0, nseg=85, fair=(-58, 0, -14), anch=(-837.6, 0, -200), seabed="200.0 WtrDpth", mu=0.5) rc0, _ = run(a.exe, cdir, "none", deck("flat none", **flat, extra="none staticsFriction\n")) @@ -211,6 +338,7 @@ def main() -> int: if rc0 == 0: r0 = table(cdir / "none.out")[0] h = abs(r0["Point2Fx"]) # the grounded run carries the anchor's horizontal tension + h_run = h rc, _ = run(a.exe, cdir, "taut", deck("flat taut", **flat, extra="%.9g asLaidTension\n" % h)) check(rc == 0, "flat laid at the run tension converges") if rc == 0: @@ -231,6 +359,172 @@ def main() -> int: check(0.0 < drop <= 0.5 * w * 850.0, "flat laid slack: friction lowers AnchTen by %.4g N (within mu w L)" % drop) + # --- finite-EI cable on a flat seabed, laid slack: lay azimuth across the chord --- + # A lay azimuth off the vertical plane of the chord puts the reference (and its friction) + # out of that plane, so the static solve is 3D from the start: the state is then an + # equilibrium of the line (friction within mu N, a march from it stays at rest). At 180 + # degrees the reference lies in the plane, on the far side of the anchor: the planar solve + # holds, and the friction saturates along the whole run, below the default's anchor tension. + cdir = root / "fei_flat" + kbot = 1.0e5 + fl = dict(ei=1.0e4, length=400.0, nseg=80, fair=(300, 0, -10), anch=(0, 0, -200), + seabed="200.0 WtrDpth", mu=0.5) + fsec = ((d, w, 400.0 / 80, 80),) + fres = {} + for tag, extra in (("def", ""), ("az45", "45.0 layAzimuth\n"), ("az180", "180.0 layAzimuth\n")): + rc, log = run(a.exe, cdir, tag, deck("fei flat " + tag, **fl, extra=extra)) + check(rc == 0, "fei_flat %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc != 0: + continue + fres[tag] = table(cdir / (tag + ".out"))[0] + util, ngr, maxy, _ = plateau_utilisation(cdir, tag, 0.5, -200.0, kbot, fsec) + check(ngr > 10 and 0.1 < util <= 1.05, + "fei_flat %s: friction within mu N over %d grounded nodes (max %.4f)" % (tag, ngr, util)) + if tag == "az45": + check(maxy > 1.0, "fei_flat az45: the line leaves the chord plane (max |y| %.3f m)" % maxy) + else: + check(maxy < 1.0e-6, "fei_flat %s: the line stays in the chord plane (max |y| %.1e m)" % (tag, maxy)) + rc, _ = run(a.exe, cdir, tag + "_rest", deck("fei flat rest " + tag, **fl, extra=extra, tmax=1.0)) + check(rc == 0, "fei_flat %s at-rest march runs (rc %d)" % (tag, rc)) + if rc == 0: + drift = at_rest(cdir, tag, tag + "_rest") + check(drift <= REST_TOL, "fei_flat %s stays at rest from the static state (drift %.2e)" % (tag, drift)) + if "def" in fres and "az180" in fres: + check(fres["az180"]["AnchTen1"] < 0.8 * fres["def"]["AnchTen1"], + "fei_flat: the 180 degree reference flips (AnchTen %.4g below the default %.4g N)" + % (fres["az180"]["AnchTen1"], fres["def"]["AnchTen1"])) + + # --- finite-EI cable on a cross slope, default lay azimuth --- + # The nodes laid at rest sink into the penalty seabed along its normal, across the slope too; + # the friction reference keeps that offset, so the lateral anchor force is that of the + # EI = 0 line (a reference without it adds a lateral spring force of the order of w tan(slope)). + cdir = root / "fei_cross" + cdir.mkdir(parents=True, exist_ok=True) + cross_grid(cdir / "bathy.txt", 200.0, 5.0) + fy = {} + for tag, ei in (("ei0", 0.0), ("fei", 1.0e4)): + cd = dict(ei=ei, length=400.0, nseg=80, fair=(300, 0, -10), anch=(0, 0, -200), seabed=sb) + rc, log = run(a.exe, cdir, tag, deck("fei cross " + tag, **cd)) + check(rc == 0, "fei_cross %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + fy[tag] = table(cdir / (tag + ".out"))[0]["Point2Fy"] + if len(fy) == 2: + check(fy["ei0"] * fy["fei"] > 0.0 and abs(fy["fei"] - fy["ei0"]) < 0.25 * abs(fy["ei0"]), + "fei_cross: lateral anchor force %.4g N follows the EI = 0 line's %.4g N" % (fy["fei"], fy["ei0"])) + + # --- per-line rows, non-default azimuth and tension, anisotropic friction (EI = 0) --- + cdir = root / "perline" + keys = ("FairTen1", "AnchTen1", "Point1Fx", "Point2Fx", "Point1Fz") + pl = {} + cases = { + "def": "", + "g180": "180.0 layAzimuth\n", + "g90": "90.0 layAzimuth\n", + "p180": "90.0 layAzimuth\n180.0 layAzimuth1\n", + "p180b": "180.0 layAzimuth1\n90.0 layAzimuth\n", + "p90": "180.0 layAzimuth\n90.0 layAzimuth1\n", + } + if h_run is not None: + cases.update({ + "gt": "%.9g asLaidTension\n" % h_run, + "pt": "0.0 asLaidTension\n%.9g asLaidTension1\n" % h_run, + "ptb": "%.9g asLaidTension1\n0.0 asLaidTension\n" % h_run, + "pt0": "%.9g asLaidTension\n0.0 asLaidTension1\n" % h_run, + "lay1": "180.0 layAzimuth1\n", + }) + for tag, extra in cases.items(): + rc, log = run(a.exe, cdir, tag, deck("perline " + tag, **flat, extra=extra)) + check(rc == 0, "perline %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + pl[tag] = table(cdir / (tag + ".out"))[0] + if {"def", "g180", "g90"} <= pl.keys(): + check(not same(pl["g180"], pl["def"], keys, 1.0e-3), + "layAzimuth 180 changes the statics (AnchTen %.5g vs %.5g N)" % (pl["g180"]["AnchTen1"], pl["def"]["AnchTen1"])) + check(not same(pl["g90"], pl["def"], keys, 1.0e-3) and not same(pl["g90"], pl["g180"], keys, 1.0e-3), + "layAzimuth 90 gives its own statics (AnchTen %.5g N)" % pl["g90"]["AnchTen1"]) + if {"g180", "p180", "p180b", "g90"} <= pl.keys(): + check(same(pl["p180"], pl["g180"], keys) and same(pl["p180b"], pl["g180"], keys), + "layAzimuth1 wins over layAzimuth, in either order (as the global 180)") + check(not same(pl["p180"], pl["g90"], keys, 1.0e-3), "layAzimuth1 differs from the global value it overrides") + if {"g180", "p90", "g90"} <= pl.keys(): + check(same(pl["p90"], pl["g90"], keys), "layAzimuth1 wins over layAzimuth (90 over 180)") + if {"def", "gt", "pt", "ptb", "pt0", "lay1"} <= pl.keys(): + check(not same(pl["gt"], pl["def"], keys, 1.0e-3), + "asLaidTension changes the statics (AnchTen %.5g vs %.5g N)" % (pl["gt"]["AnchTen1"], pl["def"]["AnchTen1"])) + check(same(pl["pt"], pl["gt"], keys) and same(pl["ptb"], pl["gt"], keys), + "asLaidTension1 wins over asLaidTension, in either order (as the global value)") + check(same(pl["pt0"], pl["def"], keys), "asLaidTension1 0 wins over a global tension (as the default)") + check(not same(pl["lay1"], pl["def"], keys, 1.0e-3), "layAzimuth1 alone takes effect") + + # two lines: a row for line 2 leaves line 1 alone + two = {} + for tag, extra in (("def", ""), ("g180", "180.0 layAzimuth\n"), ("l2", "180.0 layAzimuth2\n")) + ( + (("gt", "%.9g asLaidTension\n" % h_run), ("t2", "%.9g asLaidTension2\n" % h_run)) if h_run else ()): + rc, log = run(a.exe, cdir, "two_" + tag, deck_two("two lines " + tag, extra=extra)) + check(rc == 0, "two lines %s converge (rc %d)" % (tag, rc)) + if rc == 0: + two[tag] = table(cdir / ("two_" + tag + ".out"))[0] + + def of_line(row: dict, i: int) -> dict: + return {"FairTen1": row["FairTen%d" % i], "AnchTen1": row["AnchTen%d" % i]} + + if {"def", "g180", "l2"} <= two.keys(): + k2 = ("FairTen1", "AnchTen1") + check(same(of_line(two["def"], 1), of_line(two["def"], 2), k2), "two lines: identical lines give identical statics") + check(same(of_line(two["l2"], 1), of_line(two["def"], 1), k2), + "two lines: layAzimuth2 leaves line 1 at the default") + check(same(of_line(two["l2"], 2), of_line(two["g180"], 2), k2) and + not same(of_line(two["l2"], 2), of_line(two["def"], 2), k2, 1.0e-3), + "two lines: layAzimuth2 sets line 2 alone (AnchTen2 %.5g N)" % two["l2"]["AnchTen2"]) + if {"def", "gt", "t2"} <= two.keys(): + k2 = ("FairTen1", "AnchTen1") + check(same(of_line(two["t2"], 1), of_line(two["def"], 1), k2), "two lines: asLaidTension2 leaves line 1 alone") + check(same(of_line(two["t2"], 2), of_line(two["gt"], 2), k2) and + not same(of_line(two["t2"], 2), of_line(two["def"], 2), k2, 1.0e-3), + "two lines: asLaidTension2 sets line 2 alone (AnchTen2 %.5g N)" % two["t2"]["AnchTen2"]) + + # anisotropic friction: along a run laid and pulled along the chord the axial coefficient rules + cdir = root / "aniso" + an = {} + for tag, mu_iso, extra in (("iso05", 0.5, ""), ("iso02", 0.2, ""), + ("ax05_lat02", 0.5, "0.2 frictionMuLateral\n"), + ("ax02_lat05", 0.2, "0.5 frictionMuLateral\n")): + fa = dict(flat, mu=mu_iso) + rc, log = run(a.exe, cdir, tag, deck("aniso " + tag, **fa, extra=extra)) + check(rc == 0, "aniso %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + an[tag] = table(cdir / (tag + ".out"))[0] + if len(an) == 4: + k1 = ("FairTen1", "AnchTen1") + check(not same(an["iso05"], an["iso02"], k1, 1.0e-2), "aniso: the coefficient changes the anchor tension") + check(same(an["ax05_lat02"], an["iso05"], k1, 2.0e-3), + "aniso: axial 0.5 / lateral 0.2 acts as the isotropic 0.5 along the chord (AnchTen %.5g vs %.5g N)" + % (an["ax05_lat02"]["AnchTen1"], an["iso05"]["AnchTen1"])) + check(same(an["ax02_lat05"], an["iso02"], k1, 2.0e-3), + "aniso: axial 0.2 / lateral 0.5 acts as the isotropic 0.2 along the chord (AnchTen %.5g vs %.5g N)" + % (an["ax02_lat05"]["AnchTen1"], an["iso02"]["AnchTen1"])) + + # --- a line of three sections of different weights: friction within mu N everywhere --- + cdir = root / "multi" + light = (0.1, 40.0, 5.0e8) # diameter [m], mass [kg/m], EA [N] + wl = (light[1] - RHO * math.pi / 4.0 * light[0] ** 2) * G + mtypes = (f"chain {d} {m} {ea} -1 0 1.37 0.64 1 0\n" + f"light {light[0]} {light[1]} {light[2]} -1 0 1.2 0.6 1 0\n") + msecs = "1 chain 300 60\n1 light 300 60\n1 chain 250 50\n" + rc, log = run(a.exe, cdir, "multi", deck("multi", ei=0.0, length=850.0, nseg=170, fair=(-58, 0, -14), + anch=(-837.6, 0, -200), seabed="200.0 WtrDpth", mu=0.5, + types=mtypes, sections=msecs)) + check(rc == 0, "multi converges (rc %d)%s" % (rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc == 0: + msec = ((d, w, 5.0, 60), (light[0], wl, 5.0, 60), (d, w, 5.0, 50)) + util, ngr, _, by_sec = plateau_utilisation(cdir, "multi", 0.5, -200.0, kbot, msec) + check(by_sec[1][1] > 5 and by_sec[2][1] > 5, + "multi: the grounded run spans the light (%d nodes) and the heavy (%d) section" % (by_sec[1][1], by_sec[2][1])) + check(util <= 1.01, "multi: friction within mu N at every grounded node (max %.4f)" % util) + check(by_sec[1][0] > 0.9 and by_sec[2][0] > 0.5, + "multi: friction mobilised to mu N in the light section and beyond in the heavy (%.3f, %.3f)" + % (by_sec[1][0], by_sec[2][0])) + # --- input checks --- cdir = root / "inputs" rc, log = run(a.exe, cdir, "badid", deck("bad id", **flat, extra="30.0 layAzimuth9\n")) @@ -239,6 +533,25 @@ def main() -> int: check(rc != 0 and "asLaid or none" in log, "an unknown staticsFriction policy is rejected") rc, log = run(a.exe, cdir, "goodid", deck("good id", **flat, extra="180.0 layAzimuth1\n0 asLaidTension1\n")) check(rc == 0, "layAzimuth1 / asLaidTension1 rows are accepted") + if rc == 0 and "g180" in pl: + # the rows are not only accepted: line 1 is laid at 180 degrees (as the global row does) + check(same(table(cdir / "goodid.out")[0], pl["g180"], keys), + "layAzimuth1 180 / asLaidTension1 0 act as the global 180 degree lay") + if h_run is not None: + rc, log = run(a.exe, cdir, "goodid_t", deck("good id t", **flat, extra="%.9g asLaidTension1\n" % h_run)) + check(rc == 0, "asLaidTension1 row is accepted") + if rc == 0 and "gt" in pl and "def" in pl: + row = table(cdir / "goodid_t.out")[0] + check(same(row, pl["gt"], keys) and not same(row, pl["def"], keys, 1.0e-3), + "asLaidTension1 takes effect (AnchTen %.5g vs %.5g N laid slack)" % (row["AnchTen1"], pl["def"]["AnchTen1"])) + rc, log = run(a.exe, cdir, "hugeid", deck("huge id", **flat, extra="30.0 layAzimuth99999999999\n")) + check(rc != 0 and "names no LINE" in log, "layAzimuth with an integer suffix too large for a line ID is rejected") + rc, log = run(a.exe, cdir, "hugeidt", deck("huge id t", **flat, extra="1.0 asLaidTension99999999999999999999\n")) + check(rc != 0 and "names no LINE" in log, "asLaidTension with an integer suffix too large for a line ID is rejected") + rc, log = run(a.exe, cdir, "badsuffix", deck("bad suffix", **flat, extra="30.0 layAzimuth1x\n")) + check(rc != 0 and "unknown OPTION keyword" in log, "layAzimuth1x is an unknown keyword") + rc, log = run(a.exe, cdir, "badtension", deck("bad tension", **flat, extra="-1.0 asLaidTension1\n")) + check(rc != 0 and "must be finite and >= 0" in log, "a negative asLaidTension1 is rejected") print("static friction as laid: %d failure(s)" % len(FAILURES)) return 1 if FAILURES else 0 From 1f729383bf7208ad2398d3f96e67f887b877df17 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 07:43:05 +0900 Subject: [PATCH 03/10] fix(statics): laid tension in the sink of the as-laid reference On a bathymetry whose slope varies, a positive asLaidTension turns at every node of the laid path and presses the line into a crest or lifts it from a hollow. The sink of the as-laid reference counted only the node's weight, so a line laid at its as-laid tension did not rest at its reference and friction was mobilised spuriously. The reference now adds -T (t_out - t_in).n / k to each interior node's sink, evaluated on the laid path before the sink, on the EI = 0 and the finite-EI routes. With no laid tension the reference is bit-identical. A unit test on a crest checks the correction against an independent evaluation. Signed-off-by: Jae Hoon Seo --- doc/theory.rst | 7 ++++- src/CableDyn_DeckDriver.f90 | 7 +++-- src/CableDyn_Model.f90 | 4 +-- src/CableDyn_Static.f90 | 49 ++++++++++++++++++++++++++---- tests/test_bathymetry.f90 | 60 +++++++++++++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 11 deletions(-) diff --git a/doc/theory.rst b/doc/theory.rst index f58a17a9..03d1d5d3 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -785,7 +785,12 @@ to node :math:`i` is :math:`s_i = \sum_{e CD_ZERO)) CYCLE + sink_j = sink(j) + IF (PRESENT(kn) .AND. laid_tension > CD_ZERO .AND. j <= n_elem) THEN + IF (kn(j) > CD_ZERO) THEN + DO e = 1, 3 + CALL CD_Bathymetry_Floor_Gradient(bathymetry, ref0(1, j + e - 2), ref0(2, j + e - 2), p(3, e), gx, gy, & + es, em) + IF (es /= CD_BATHY_OK) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) + RETURN + END IF + p(1:2, e) = ref0(:, j + e - 2) + IF (e == 2) nrm = [-gx, -gy, CD_ONE]/SQRT(CD_ONE + gx*gx + gy*gy) + END DO + t_in = p(:, 2) - p(:, 1) + t_out = p(:, 3) - p(:, 2) + IF (NORM2(t_in) > CD_ZERO .AND. NORM2(t_out) > CD_ZERO) THEN + ! the tension's force on node j is T (t_out - t_in); its component into the + ! seabed (against the upward normal) adds to the node's penetration + sink_j = MAX(CD_ZERO, sink_j - laid_tension*DOT_PRODUCT(t_out/NORM2(t_out) - t_in/NORM2(t_in), nrm)/ & + kn(j)) + END IF + END IF + END IF + IF (.NOT. (sink_j > CD_ZERO)) CYCLE CALL CD_Bathymetry_Floor_Gradient(bathymetry, ref(1, j), ref(2, j), zf, gx, gy, es, em) IF (es /= CD_BATHY_OK) THEN CALL fail(ErrStat, ErrMsg, 'as-laid reference: bathymetry query failed: '//TRIM(em)) RETURN END IF - ref(:, j) = ref(:, j) + sink(j)*[gx, gy] + ref(:, j) = ref(:, j) + sink_j*[gx, gy] END DO END IF END SUBROUTINE CD_Static_As_Laid_Reference diff --git a/tests/test_bathymetry.f90 b/tests/test_bathymetry.f90 index b3a0b2cf..e8e490dc 100644 --- a/tests/test_bathymetry.f90 +++ b/tests/test_bathymetry.f90 @@ -14,6 +14,7 @@ PROGRAM test_bathymetry CD_Bathymetry_Grid_Floor, CD_Bathymetry_Rotate_Curvature, & CD_BATHY_CREASE_FRACTION USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND + USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE @@ -27,6 +28,7 @@ PROGRAM test_bathymetry CALL case_crease_rounding_c2() CALL case_crease_rounding_planar_exact() CALL case_crease_contact_tangent_fd() + CALL case_as_laid_tension_sink() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -469,4 +471,62 @@ SUBROUTINE expect_vec_fd(got, want, label) END DO END SUBROUTINE expect_vec_fd + SUBROUTINE case_as_laid_tension_sink() + !! The as-laid friction reference on a curved bathymetry (a Gaussian crest along x): + !! with kn and no laid tension it is bit-identical to the reference without kn; with a + !! laid tension T each interior node sinks by the extra T (t_out - t_in).n / kn into the + !! seabed (n the upward normal), which moves its reference by that amount times the + !! local gradient (checked against an independent evaluation on the unsunk path). + TYPE(CD_BathymetryType) :: bathy + INTEGER, PARAMETER :: NE = 20 + REAL(wp), PARAMETER :: T = 2.0e4_wp, KN = 1.0e4_wp, SINK = 0.01_wp + REAL(wp) :: x(41), y(2), depth(41, 2), l0(NE), ea(NE), sk(NE + 1), kv(NE + 1) + REAL(wp) :: r_nokn(2, NE + 1), r_kn(2, NE + 1), r_t(2, NE + 1), r_t0(2, NE + 1), r_t_nokn(2, NE + 1) + REAL(wp) :: p(3, 3), g(2), nrm(3), tin(3), tout(3), extra, expect(2), worst + INTEGER :: i, j, k, es + CHARACTER(160) :: em + + DO i = 1, SIZE(x) + x(i) = 5.0_wp*REAL(i - 1, wp) + depth(i, :) = 100.0_wp - 10.0_wp*EXP(-((x(i) - 100.0_wp)/30.0_wp)**2) + END DO + y = [-20.0_wp, 20.0_wp] + CALL CD_Init_Bathymetry(bathy, x, y, depth, es, em) + CALL expect_es(es, CD_BATHY_OK, 'aslaid:init') + l0 = 9.0_wp + ea = 1.0e9_wp + sk = SINK + kv = KN + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, 0.0_wp, r_nokn, es, em, bathymetry=bathy, & + sink=sk) + CALL expect_es(es, CD_STATIC_OK, 'aslaid:ref') + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, 0.0_wp, r_kn, es, em, bathymetry=bathy, & + sink=sk, kn=kv) + CALL require(ALL(r_kn == r_nokn), 'aslaid:no tension, kn changes nothing') + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, T, r_t, es, em, bathymetry=bathy, & + sink=sk, kn=kv) + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, T, r_t_nokn, es, em, bathymetry=bathy, & + sink=sk) + sk = 0.0_wp + CALL CD_Static_As_Laid_Reference([0.0_wp, 0.0_wp], 0.0_wp, l0, ea, T, r_t0, es, em, bathymetry=bathy) + worst = 0.0_wp + DO j = 2, NE + DO k = 1, 3 + CALL floor_at(bathy, r_t0(1, j + k - 2), r_t0(2, j + k - 2), p(3, k), g) + p(1:2, k) = r_t0(:, j + k - 2) + IF (k == 2) nrm = [-g(1), -g(2), 1.0_wp]/SQRT(1.0_wp + g(1)**2 + g(2)**2) + END DO + tin = (p(:, 2) - p(:, 1))/NORM2(p(:, 2) - p(:, 1)) + tout = (p(:, 3) - p(:, 2))/NORM2(p(:, 3) - p(:, 2)) + extra = MAX(0.0_wp, SINK - T*DOT_PRODUCT(tout - tin, nrm)/KN) + CALL floor_at(bathy, r_t0(1, j), r_t0(2, j), p(3, 2), g) + expect = r_t0(:, j) + extra*g + worst = MAX(worst, MAXVAL(ABS(r_t(:, j) - expect))) + END DO + CALL require(worst <= 1.0e-12_wp, 'aslaid:tension sink matches the turning force') + ! the crest presses the laid line into the seabed: the references differ with tension + CALL require(MAXVAL(ABS(r_t - r_t_nokn)) > 1.0e-6_wp, 'aslaid:tension sink active on a crest') + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_as_laid_tension_sink + END PROGRAM test_bathymetry From aa8846d8622b85f07cd9f01d0fae16a9793ae284 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 09:14:31 +0900 Subject: [PATCH 04/10] fix(options): validate every per-line as-laid row layAzimuth and asLaidTension rows were range-checked only as the final per-line value, so an invalid row (a negative tension, a NaN azimuth) followed by a valid row for the same line passed silently. The OPTIONS row check now applies the family rule (finite azimuth, non-negative tension) to every suffixed row, as for the global rows and as the Python reader does. Tests: shadowed negative tension and NaN azimuth rows are rejected. Signed-off-by: Jae Hoon Seo --- src/CableDyn_DeckDriver.f90 | 11 ++++++++++- tests/test_static_friction_as_laid.py | 9 ++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 3035a6b7..8f19a76e 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -13218,9 +13218,18 @@ SUBROUTINE check_option_row_value(kw, val, ErrStat, ErrMsg) REAL(wp) :: x LOGICAL :: ok CHARACTER(16) :: rule + CHARACTER(LEN(kw)) :: key ErrStat = 0; ErrMsg = '' - SELECT CASE (to_lower(TRIM(kw))) + ! a per-line row (layAzimuth, asLaidTension) takes the rule of its family + key = to_lower(TRIM(kw)) + IF (LEN_TRIM(key) > 10) THEN + IF (key(1:10) == 'layazimuth' .AND. VERIFY(TRIM(key(11:)), '0123456789') == 0) key = 'layazimuth' + END IF + IF (LEN_TRIM(key) > 13) THEN + IF (key(1:13) == 'aslaidtension' .AND. VERIFY(TRIM(key(14:)), '0123456789') == 0) key = 'aslaidtension' + END IF + SELECT CASE (TRIM(key)) 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', & diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index 4b924b25..4b8cb924 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -551,7 +551,14 @@ def of_line(row: dict, i: int) -> dict: rc, log = run(a.exe, cdir, "badsuffix", deck("bad suffix", **flat, extra="30.0 layAzimuth1x\n")) check(rc != 0 and "unknown OPTION keyword" in log, "layAzimuth1x is an unknown keyword") rc, log = run(a.exe, cdir, "badtension", deck("bad tension", **flat, extra="-1.0 asLaidTension1\n")) - check(rc != 0 and "must be finite and >= 0" in log, "a negative asLaidTension1 is rejected") + check(rc != 0 and "asLaidTension1" in log, "a negative asLaidTension1 is rejected") + # every row is validated, also one a later row for the same line overrides + rc, log = run(a.exe, cdir, "shadowt", deck("shadowed tension", **flat, + extra="-1.0 asLaidTension1\n0.0 asLaidTension1\n")) + check(rc != 0 and "asLaidTension1" in log, "a negative asLaidTension1 shadowed by a valid row is rejected") + rc, log = run(a.exe, cdir, "shadowaz", deck("shadowed azimuth", **flat, + extra="nan layAzimuth1\n30.0 layAzimuth1\n")) + check(rc != 0 and "layAzimuth1" in log, "a NaN layAzimuth1 shadowed by a valid row is rejected") print("static friction as laid: %d failure(s)" % len(FAILURES)) return 1 if FAILURES else 0 From 1981277808ec40bfda8ea3c67791f137dcf4666a Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 10:48:45 +0900 Subject: [PATCH 05/10] fix(statics): surface metric in the laid-tension sink The laid tension's normal load P deepens a node's normal penetration by P/k, which moves it horizontally by (P/k) grad(z)/s with s = sqrt(1 + |grad z|^2); the sink, the factor of the gradient (w/k for the weight), therefore gains P/(k s), not P/k. The correction now carries the 1/s factor, taken from the node's own normal, and the unit test and the theory page state it. Signed-off-by: Jae Hoon Seo --- doc/theory.rst | 4 +++- src/CableDyn_Static.f90 | 11 +++++++---- tests/test_bathymetry.f90 | 8 ++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/doc/theory.rst b/doc/theory.rst index 03d1d5d3..d0640ac6 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -790,7 +790,9 @@ laid tension turns at every node and adds :math:`-T_\text{laid}\,(\mathbf{t}_{i}^{+} - \mathbf{t}_{i}^{-})\cdot\mathbf{n}_i` to the normal load (it presses the line into a crest and lifts it from a hollow), with :math:`\mathbf{t}_{i}^{\pm}` the unit tangents of the laid path on either side of the node and -:math:`\mathbf{n}_i` the upward normal. The reference moves with the node, +:math:`\mathbf{n}_i` the upward normal; a normal load :math:`P` deepens the normal penetration by +:math:`P/k_i` and so moves the node horizontally by :math:`P\,(z_{,x}, z_{,y})/(k_i s)`, with +:math:`s = \sqrt{1 + z_{,x}^2 + z_{,y}^2}`. The reference moves with the node, so the line laid at rest carries no friction force (a deflection normal to the seabed is not a friction deflection, as in OrcaFlex's in-plane law). The static solve then holds every node in contact with a friction spring toward its reference, capped smoothly at :math:`\mu N`, diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 5c125e6e..24e8d87f 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -1425,10 +1425,13 @@ SUBROUTINE CD_Static_As_Laid_Reference(origin, azimuth, l0, ea, laid_tension, re t_in = p(:, 2) - p(:, 1) t_out = p(:, 3) - p(:, 2) IF (NORM2(t_in) > CD_ZERO .AND. NORM2(t_out) > CD_ZERO) THEN - ! the tension's force on node j is T (t_out - t_in); its component into the - ! seabed (against the upward normal) adds to the node's penetration - sink_j = MAX(CD_ZERO, sink_j - laid_tension*DOT_PRODUCT(t_out/NORM2(t_out) - t_in/NORM2(t_in), nrm)/ & - kn(j)) + ! the tension's force on node j is T (t_out - t_in); its component P into the + ! seabed (against the upward normal) deepens the normal penetration by P/kn, + ! which moves the node horizontally by (P/kn) (z_x, z_y)/s: in units of the + ! sink (the factor of the gradient, w/kn for the weight) that is P/(kn s), with + ! 1/s = nrm(3) the vertical component of the unit normal + sink_j = MAX(CD_ZERO, sink_j - laid_tension*DOT_PRODUCT(t_out/NORM2(t_out) - t_in/NORM2(t_in), nrm)* & + nrm(3)/kn(j)) END IF END IF END IF diff --git a/tests/test_bathymetry.f90 b/tests/test_bathymetry.f90 index e8e490dc..33120722 100644 --- a/tests/test_bathymetry.f90 +++ b/tests/test_bathymetry.f90 @@ -474,9 +474,9 @@ END SUBROUTINE expect_vec_fd SUBROUTINE case_as_laid_tension_sink() !! The as-laid friction reference on a curved bathymetry (a Gaussian crest along x): !! with kn and no laid tension it is bit-identical to the reference without kn; with a - !! laid tension T each interior node sinks by the extra T (t_out - t_in).n / kn into the - !! seabed (n the upward normal), which moves its reference by that amount times the - !! local gradient (checked against an independent evaluation on the unsunk path). + !! laid tension T each interior node's normal penetration deepens by the load + !! -T (t_out - t_in).n / kn (n the upward normal), which moves its reference horizontally + !! by that over s = sqrt(1 + |grad z|^2) times the local gradient (checked against an independent evaluation on the unsunk path). TYPE(CD_BathymetryType) :: bathy INTEGER, PARAMETER :: NE = 20 REAL(wp), PARAMETER :: T = 2.0e4_wp, KN = 1.0e4_wp, SINK = 0.01_wp @@ -518,8 +518,8 @@ SUBROUTINE case_as_laid_tension_sink() END DO tin = (p(:, 2) - p(:, 1))/NORM2(p(:, 2) - p(:, 1)) tout = (p(:, 3) - p(:, 2))/NORM2(p(:, 3) - p(:, 2)) - extra = MAX(0.0_wp, SINK - T*DOT_PRODUCT(tout - tin, nrm)/KN) CALL floor_at(bathy, r_t0(1, j), r_t0(2, j), p(3, 2), g) + extra = MAX(0.0_wp, SINK - T*DOT_PRODUCT(tout - tin, nrm)/(KN*SQRT(1.0_wp + g(1)**2 + g(2)**2))) expect = r_t0(:, j) + extra*g worst = MAX(worst, MAXVAL(ABS(r_t(:, j) - expect))) END DO From 16314565ad78d19d292be341d3080be29c4fd276 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 12:10:50 +0900 Subject: [PATCH 06/10] fix(statics): bound the as-laid stretch and path integration A finite but huge asLaidTension stretched the laid elements without limit, so the seabed path integration of the as-laid reference could overflow its sub-step count or loop for billions of steps. A laid tension above an element's EA (more than 100 % strain) now fails closed with a named message, and a laid length beyond 1e7 m is refused, which bounds the sub-step count. Test: a 1e30 N asLaidTension is rejected. Signed-off-by: Jae Hoon Seo --- src/CableDyn_Static.f90 | 12 ++++++++++++ tests/test_static_friction_as_laid.py | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 24e8d87f..2e00b537 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -1365,6 +1365,18 @@ SUBROUTINE CD_Static_As_Laid_Reference(origin, azimuth, l0, ea, laid_tension, re CALL fail(ErrStat, ErrMsg, 'as-laid reference: l0 and ea must be positive and laid_tension non-negative') RETURN END IF + ! A laid tension that stretches an element beyond its length is no laid state (and would + ! make the seabed path integration below unbounded): fail closed. + IF (ANY(laid_tension > ea)) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: asLaidTension stretches an element by more than 100 % '// & + '(asLaidTension > EA); give the tension the line was laid with') + RETURN + END IF + IF (PRESENT(bathymetry) .AND. SUM(l0)*2.0_wp > 1.0e7_wp) THEN + CALL fail(ErrStat, ErrMsg, 'as-laid reference: the laid length exceeds the 1e7 m the seabed path '// & + 'integration supports') + RETURN + END IF dir = [COS(azimuth), SIN(azimuth)] ref(:, 1) = origin d = CD_ZERO diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index 4b8cb924..f1eb7069 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -552,6 +552,8 @@ def of_line(row: dict, i: int) -> dict: check(rc != 0 and "unknown OPTION keyword" in log, "layAzimuth1x is an unknown keyword") rc, log = run(a.exe, cdir, "badtension", deck("bad tension", **flat, extra="-1.0 asLaidTension1\n")) check(rc != 0 and "asLaidTension1" in log, "a negative asLaidTension1 is rejected") + rc, log = run(a.exe, cdir, "hugetension", deck("huge tension", **flat, extra="1.0e30 asLaidTension\n")) + check(rc != 0 and "more than 100 %" in log, "an asLaidTension above EA fails closed instead of overflowing") # every row is validated, also one a later row for the same line overrides rc, log = run(a.exe, cdir, "shadowt", deck("shadowed tension", **flat, extra="-1.0 asLaidTension1\n0.0 asLaidTension1\n")) From c19208b15caac3963acc7be830b5793ef9ed106c Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 12:26:35 +0900 Subject: [PATCH 07/10] docs: give the friction-in-statics references their link text The static-friction label marks a paragraph, not a section title, so the bare :ref: references to it had no text and the Sphinx build (run with warnings as errors) failed on four of them. Each reference now carries its link text. Signed-off-by: Jae Hoon Seo --- doc/modeling.rst | 2 +- doc/options.rst | 2 +- doc/theory.rst | 2 +- doc/troubleshooting.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/modeling.rst b/doc/modeling.rst index 3ce96628..61a8c949 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -160,7 +160,7 @@ holds the grounded run toward the position in which the line was laid, as OrcaFl policy does: then decide how the line was laid (``layAzimuth``, by default from the anchor toward the fairlead) and at what tension (``asLaidTension``, by default slack), because the anchor tension depends on it: a run laid slack and pulled taut is held back by friction. See -:ref:`static-friction`. +:ref:`friction in statics `. 7. Configure dynamics and forcing ---------------------------------- diff --git a/doc/options.rst b/doc/options.rst index 23062ea0..93bdd6b3 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -147,7 +147,7 @@ Environment and seabed known. Used only with ``frictionMu > 0`` and a seabed; rejected, like ``frictionMu``, on decks with ``Connect``/``Free`` points, bodies or rods (and on mixed-topology decks), whose static equilibrium solves the lines without seabed friction. See - :ref:`static-friction` + :ref:`friction in statics ` - both - ``asLaid staticsFriction`` * - ``layAzimuth`` / ``lay_azimuth``, and ``layAzimuth`` diff --git a/doc/theory.rst b/doc/theory.rst index d0640ac6..6c012fcc 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -956,7 +956,7 @@ beyond a :math:`10^{-6}` relative round-off band; a slack element reports zero t where the seabed keeps falling past the fairlead the excess slides down the frictionless slope and folds back, with zero tension at the fold; otherwise it lies slack); the other catenary variant; and a two-leg polyline of the line length that never compresses the line. - With static seabed friction the as-laid seed (:ref:`static-friction`) is tried first. + With static seabed friction the as-laid seed (:ref:`friction in statics `) is tried first. Seed nodes deeper below the seabed than their static penetration are lifted onto it. 2. **Compression-capable Newton** at the full load (Armijo line search on :math:`\tfrac{1}{2}\lVert\mathbf{R}\rVert^2`, :ref:`Armijo, 1966 `). A converged diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 553cdfb9..c2f34a07 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -468,7 +468,7 @@ but a few geometries are genuinely hard: (``staticsFriction none``) the static solve is frictionless in still water, so a grounded run on a slope slides down it whatever ``frictionMu`` is, and a line longer than its span folds or is rejected. ``asLaid staticsFriction`` holds every grounded node toward its as-laid position - (see :ref:`static-friction`), so the run rests where it was laid. A line laid slack + (see :ref:`friction in statics `), so the run rests where it was laid. A line laid slack (``asLaidTension 0``) and pulled taut by its fairlead is then held back by friction along its grounded run, and its anchor tension is lower than the frictionless static's by up to ``mu w`` times the grounded length (an 850 m chain in 200 m of water with ``frictionMu 0.35``: From cc0436be0cc7939dd0e7057ebfc276dda94befd8 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 12:53:03 +0900 Subject: [PATCH 08/10] fix(statics): laid-run seed for the finite-EI friction helper; honour drag - The EI = 0 helper solve that seeds a finite-EI asLaid line did not mark its friction load as as-laid, so CD_Static_Line_Equilibrium tried the ordinary catenary/fold seeds instead of the laid-run seed; it now sets friction_as_laid. - The finite-EI static solver ignored the carrier flag drag = .FALSE.: a friction-only current object with a nonzero velocity would still have loaded the line with drag and required drag properties. The element drag and its section properties are now zero for such a carrier, as on the EI = 0 route; the still-water carriers of the as-laid policy, which have zero velocity, are unaffected. Signed-off-by: Jae Hoon Seo --- src/CableDyn_DeckDriver.f90 | 3 +++ src/CableDyn_HermiteCableStatic.f90 | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 8f19a76e..efc266e0 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -4820,6 +4820,9 @@ SUBROUTINE laid_seed_positions(ok) CALL CD_HermiteCable_Friction_Reference(cur_obj%friction, l0, anchor(1:2), ref_l, es_ld, em_ld) IF (es_ld /= CD_HCSTAT_OK) RETURN fr_ld%drag = .FALSE. + ! the static seabed friction of the as-laid policy: the laid-run seed order of + ! CD_Static_Line_Equilibrium (SEED_ORDER_LAID) applies + fr_ld%friction_as_laid = .TRUE. fr_ld%friction_mu = cur_obj%friction%mu fr_ld%friction_mu_axial = cur_obj%friction%mu_axial ALLOCATE (fr_ld%friction_ref(2, nnode)) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 07e5d693..b85c92c9 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -2733,6 +2733,14 @@ SUBROUTINE current_element_props(current, l0, d, cn, ct, ErrStat, ErrMsg) REAL(wp) :: arc, smid ErrStat = CD_HCSTAT_OK ErrMsg = '' + ! a carrier without drag (drag = .FALSE.: the static seabed friction alone) loads no + ! element, whatever its velocity, and needs no drag properties + IF (.NOT. current%drag) THEN + d = CD_ZERO + cn = CD_ZERO + ct = CD_ZERO + RETURN + END IF IF (.NOT. (current%rho > CD_ZERO) .OR. .NOT. CD_Is_Finite(current%rho) .OR. & .NOT. (current%load_factor >= CD_ZERO) .OR. .NOT. CD_Is_Finite(current%load_factor) .OR. & .NOT. CD_All_Finite(current%velocity) .OR. .NOT. CD_Is_Finite(current%waterline_z) .OR. & @@ -2786,6 +2794,8 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, fd = CD_ZERO djq = CD_ZERO ve = CD_ZERO + ! no drag on a friction-only carrier (current_element_props) + IF (.NOT. current%drag) RETURN 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, & From 5de7b1765acfc862422dee3e00942dd6652054d5 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 14:25:20 +0900 Subject: [PATCH 09/10] fix(statics): as-laid reference for attachments, reversed seed, cross slope - A finite-EI asLaid line with ATTACHMENTS on a bathymetry had its friction reference built from the smeared weights, while the attachment polish lumps each module's net weight at one node, so the normal sink showed up as a tangential deflection that mobilised friction. The reference is rebuilt on the final mesh from the lumped nodal loads (bare weight share plus the module's net weight) before the polish: on a 5 deg cross slope the kink at the module nodes falls from 4.65 mm to 0.16 mm and the held run stays at rest. - The as-laid seed of a line whose last node lies below node 1 (lines without a Fixed End B) is now built on the reversed line from that grounded end and reversed back; it had fallen back to the suspended catenary seed. - A finite-EI asLaid line over a bathymetry that slopes across its chord is solved in 3D, as with an off-plane lay azimuth; the planar solve kept the seed's lateral positions and the held run drifted. Tests: att_cross (modules on a cross slope), case_as_laid_seed_from_last (both numberings on a flat floor and a slope give mirrored equilibria), and an at-rest march for the cross-slope cable. Default outputs are byte-identical to dev. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 9 +- doc/options.rst | 4 +- doc/theory.rst | 16 ++- src/CableDyn_DeckDriver.f90 | 142 +++++++++++++++++++++----- src/CableDyn_Static.f90 | 45 +++++++- tests/test_bathymetry.f90 | 99 +++++++++++++++++- tests/test_static_friction_as_laid.py | 98 ++++++++++++++++-- 7 files changed, 366 insertions(+), 47 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 40eebf74..5516fbe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,8 +32,13 @@ All notable changes to CableDyn are recorded in this file. The format follows carries (`asLaidTension`) mobilises none: on a flat seabed FairTen equals the frictionless one to 6e-6 and AnchTen to 0.4 %. A finite-EI line laid past the point under its fairlead has no static solution yet (its touchdown hook is not reached); a lay azimuth across the span - solves it. A lay azimuth across the vertical plane of the chord solves a finite-EI line in 3D - from the start, and a finite-EI line is laid from its lower end like an `EI = 0` one. The + solves it. A lay azimuth across the vertical plane of the chord, or a bathymetry sloping across + it under the laid run, solves a finite-EI line in 3D from the start (so a march from it stays + at rest), and a finite-EI line is laid from its lower end like an `EI = 0` one; a line whose + fairlead lies below its other end is laid, and seeded, from the fairlead. With discrete + `ATTACHMENTS` the reference sinks each node under its discrete load (its share of the line's + weight plus the attachment's net weight), so a module node rests on the laid path like the rest + of the run instead of taking its sink for a friction deflection. The policy is rejected, as `frictionMu` is, on decks with `Connect`/`Free` points, bodies or rods, and on mixed-topology decks. The Python `DeckFile`, `DeckWriter` and `DeckModel` take the new rows. See the theory page (Friction in statics). diff --git a/doc/options.rst b/doc/options.rst index 93bdd6b3..30bce1b5 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -157,8 +157,8 @@ Environment and seabed its anchor (its lower end): the as-laid reference of ``staticsFriction asLaid``. ``layAzimuth`` sets every line; ``layAzimuth`` (the line ID appended, e.g. ``layAzimuth2``) sets line ``ID`` and overrides it. A direction off the vertical plane of - the line ends puts the finite-EI static solve in 3D. An ID that names no line is - rejected + the line ends puts the finite-EI static solve in 3D, as does a bathymetry sloping across + that plane under the laid run. An ID that names no line is rejected - both - ``225.0 layAzimuth2`` * - ``asLaidTension`` / ``as_laid_tension``, and ``asLaidTension`` diff --git a/doc/theory.rst b/doc/theory.rst index 6c012fcc..f6d1b93d 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -785,8 +785,11 @@ to node :math:`i` is :math:`s_i = \sum_{e 64.0_wp*EPSILON(CD_ONE) END FUNCTION as_laid_off_plane - SUBROUTINE as_laid_positions(with_sink, from_top, az, laid_t, ref_g, esr, emr) - !! Global (x, y) as-laid position of every node of the deck mesh (CD_Static_As_Laid_Reference): + SUBROUTINE as_laid_heading(from_top, az, laid_t) + !! Lay of the as-laid reference: from_top when the line is laid from its fairlead (the + !! last node, lower than the anchor), the lay azimuth az [rad, global] and the as-laid + !! tension laid_t [N]. The default azimuth is the chord's horizontal direction from the + !! line's lower end (+x from the anchor, and -x from the fairlead, for a vertical chord). + LOGICAL, INTENT(OUT) :: from_top + REAL(wp), INTENT(OUT) :: az, laid_t + REAL(wp), ALLOCATABLE :: lay_az_opt + REAL(wp) :: a_g(3), f_g(3) + CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) + a_g = points(pa)%pos + f_g = points(pb)%pos + from_top = f_g(3) < a_g(3) + az = CD_ZERO + IF (NORM2(f_g(1:2) - a_g(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(f_g - a_g))) & + az = ATAN2(f_g(2) - a_g(2), f_g(1) - a_g(1)) + IF (ALLOCATED(lay_az_opt)) THEN + az = lay_az_opt + ELSE IF (from_top) THEN + az = ATAN2(-SIN(az), -COS(az)) + END IF + END SUBROUTINE as_laid_heading + + LOGICAL FUNCTION as_laid_cross_slope() RESULT(cross) + !! Whether the seabed under the as-laid path of this line slopes across the vertical + !! plane of its chord (a bathymetry whose gradient has a component across that plane + !! somewhere along the laid length, sampled at most 1 m apart). There the seabed normal + !! pushes every grounded node out of the plane and the friction holds it, so only a 3D + !! static solve is an equilibrium of the line with its end positions alone held, which + !! the dynamics start from at rest; a planar solve leaves the lateral loads unbalanced. + !! A failed bathymetry query answers .FALSE. (the reference build reports it). + INTEGER, PARAMETER :: MAX_SAMPLES = 100000 + REAL(wp) :: az, laid_t, o_xy(2), dir(2), e_cross(2), span, ds, zf, gx, gy + INTEGER :: k, n_s, es_c + LOGICAL :: from_top + CHARACTER(200) :: em_c + cross = .FALSE. + IF (.NOT. (contact_enabled .AND. opts%has_friction .AND. & + opts%static_friction == CD_STATIC_FRICTION_AS_LAID)) RETURN + IF (.NOT. PRESENT(bathymetry)) RETURN + IF (bathymetry_flat) RETURN + CALL as_laid_heading(from_top, az, laid_t) + IF (from_top) THEN + o_xy = points(pb)%pos(1:2) + ELSE + o_xy = points(pa)%pos(1:2) + END IF + dir = [COS(az), SIN(az)] + ! the global horizontal direction across the chord plane (frame_cs: the chord heading) + e_cross = [-frame_cs(2), frame_cs(1)] + ! the laid path is at most its stretched length long (asLaidTension <= EA) + span = SUM(l0)*(CD_ONE + MIN(laid_t/MINVAL(ea), CD_ONE)) + n_s = MIN(MAX_SAMPLES, MAX(1, CEILING(span))) + ds = span/REAL(n_s, wp) + DO k = 0, n_s + CALL CD_Bathymetry_Floor_Gradient(bathymetry, o_xy(1) + REAL(k, wp)*ds*dir(1), & + o_xy(2) + REAL(k, wp)*ds*dir(2), zf, gx, gy, es_c, em_c) + IF (es_c /= CD_BATHY_OK) RETURN + IF (ABS(gx*e_cross(1) + gy*e_cross(2)) > 64.0_wp*EPSILON(CD_ONE)*MAX(CD_ONE, ABS(gx) + ABS(gy))) THEN + cross = .TRUE. + RETURN + END IF + END DO + END FUNCTION as_laid_cross_slope + + SUBROUTINE as_laid_positions(with_sink, from_top, az, laid_t, ref_g, esr, emr, node_load) + !! Global (x, y) as-laid position of every node of the mesh l0 (CD_Static_As_Laid_Reference): !! the line laid on the seabed from its lower end (the anchor, node 1; the fairlead, the last !! node, when from_top) along the azimuth az [rad] at the as-laid tension. with_sink: the - !! nodes sink into the penalty seabed as in the static solve, which moves them along a slope. + !! nodes sink into the penalty seabed as in the static solve, which moves them along a slope, + !! each under its nodal load: the element weights w lumped to the nodes, or node_load [N, + !! downward positive, one entry per node] when given (the discrete loads of an attachment + !! polish). LOGICAL, INTENT(IN) :: with_sink, from_top REAL(wp), INTENT(IN) :: az, laid_t REAL(wp), INTENT(OUT) :: ref_g(:, :) INTEGER, INTENT(OUT) :: esr CHARACTER(*), INTENT(OUT) :: emr + REAL(wp), INTENT(IN), OPTIONAL :: node_load(:) REAL(wp), ALLOCATABLE :: wn(:), kn_r(:), sn(:), kn_o(:), l0_r(:), ea_r(:) REAL(wp) :: o_xy(2) INTEGER :: k, ne_r @@ -3882,9 +3978,15 @@ SUBROUTINE as_laid_positions(with_sink, from_top, az, laid_t, ref_g, esr, emr) wn = CD_ZERO kn_r = CD_ZERO DO k = 1, ne_r - wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) END DO + IF (PRESENT(node_load)) THEN + wn = node_load + ELSE + DO k = 1, ne_r + wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) + END DO + END IF WHERE (kn_r > CD_ZERO) wn = MAX(wn, CD_ZERO)/kn_r ELSEWHERE @@ -3913,40 +4015,31 @@ SUBROUTINE as_laid_positions(with_sink, from_top, az, laid_t, ref_g, esr, emr) IF (from_top .AND. esr == CD_STATIC_OK) ref_g = ref_g(:, ne_r + 1:1:-1) END SUBROUTINE as_laid_positions - SUBROUTINE as_laid_reference(esr, emr) + SUBROUTINE as_laid_reference(esr, emr, node_load) !! Friction reference of the static solve (CD_Static_As_Laid_Reference): the line laid on !! the seabed from its lower end (the anchor, node 1, unless the fairlead is lower, as in !! the EI = 0 line model) along the lay azimuth at the as-laid tension, as (x, y) offsets - !! from node 1 in the solve frame along the unstretched arc length of the deck mesh. A lay - !! azimuth off the vertical plane of the chord puts the reference out of that plane (see + !! from node 1 in the solve frame along the unstretched arc length of the mesh l0 (the deck + !! mesh, or the final mesh when rebuilt for an attachment polish). A lay azimuth off the + !! vertical plane of the chord puts the reference out of that plane (see !! as_laid_off_plane): the static solve then runs in 3D. In the plane the reference is - !! held in it, but for the sink of its nodes along a cross slope. + !! held in it, but for the sink of its nodes along a cross slope. node_load: the nodal + !! loads the nodes sink under (as_laid_positions; default the lumped weights w). INTEGER, INTENT(OUT) :: esr CHARACTER(*), INTENT(OUT) :: emr - REAL(wp), ALLOCATABLE :: lay_az_opt, ref_g(:, :), ref_0(:, :) - REAL(wp) :: laid_t, az, dg(2), dg0(2), a_g(3), f_g(3) + REAL(wp), INTENT(IN), OPTIONAL :: node_load(:) + REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :) + REAL(wp) :: laid_t, az, dg(2), dg0(2), a_g(3) INTEGER :: k, ne_r LOGICAL :: from_top, in_plane esr = CD_DECKDRV_OK emr = '' ne_r = SIZE(l0) - CALL line_static_friction(opts, ln%id, lay_az_opt, laid_t) a_g = points(pa)%pos - f_g = points(pb)%pos - from_top = f_g(3) < a_g(3) - ! the default azimuth is the chord's horizontal direction from the line's lower end - ! (+x from the anchor, and -x from the fairlead, for a vertical chord) - az = CD_ZERO - IF (NORM2(f_g(1:2) - a_g(1:2)) > 1.0e-9_wp*MAX(CD_ONE, NORM2(f_g - a_g))) & - az = ATAN2(f_g(2) - a_g(2), f_g(1) - a_g(1)) - IF (ALLOCATED(lay_az_opt)) THEN - az = lay_az_opt - ELSE IF (from_top) THEN - az = ATAN2(-SIN(az), -COS(az)) - END IF + CALL as_laid_heading(from_top, az, laid_t) in_plane = .NOT. as_laid_off_plane() ALLOCATE (ref_g(2, ne_r + 1), ref_0(2, ne_r + 1)) - CALL as_laid_positions(.TRUE., from_top, az, laid_t, ref_g, esr, emr) + CALL as_laid_positions(.TRUE., from_top, az, laid_t, ref_g, esr, emr, node_load) ! the laid line without the sink of its nodes: its cross-plane offset is geometric ref_0 = ref_g IF (esr == CD_STATIC_OK .AND. in_plane .AND. PRESENT(bathymetry)) & @@ -3955,6 +4048,7 @@ SUBROUTINE as_laid_reference(esr, emr) esr = CD_DECKDRV_BADINPUT RETURN END IF + IF (ALLOCATED(cur_obj%friction)) DEALLOCATE (cur_obj%friction) ALLOCATE (cur_obj%friction) cur_obj%friction%mu = opts%friction_mu cur_obj%friction%mu_axial = opts%friction_mu_axial diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index 2e00b537..f1984bc3 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -1608,7 +1608,10 @@ SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weigh !! their static penetration are lifted onto it. With static seabed friction (current !! carrying friction_ref, CD_Static_As_Laid_Reference) the as-laid seed is tried first: !! the nodes up to a lift-off node rest at their as-laid positions, and the rest hang as - !! the suspended catenary to the fairlead (the line laid, then its top end moved). + !! the suspended catenary to the fairlead (the line laid, then its top end moved). The + !! reference is laid from the lower end of the line: node 1, or node n when it lies below + !! node 1 (a line without a Fixed anchor at node 1), whose seed is the mirror image, laid + !! from node n and hanging to node 1. !! For each seed: !! A. Newton (plain, then Levenberg-Marquardt) with the compression-capable law, first at !! the full load, then by load continuation. Accepted when it converges and (for a @@ -2077,11 +2080,18 @@ SUBROUTINE build_seed(which, ok) IF (ok) ok = CD_All_Finite(q_seed) CASE (7) ! the as-laid line with its top end moved to the fairlead: a grounded run at the - ! friction reference positions lifting off into a suspended catenary + ! friction reference positions lifting off into a suspended catenary. The reference + ! is laid from the lower end of the line (CD_Static_As_Laid_Reference): node 1, or + ! node n when it lies below node 1, whose seed is built on the reversed line seed_name = 'as-laid run' - IF (.NOT. (anchor_grounded .AND. as_laid)) RETURN - CALL CD_Static_As_Laid_Seed(anchor, fairlead, l0, ea, weight, current%friction_ref, q_seed, ok, & - seabed_z_floor=seabed_z_floor, bathymetry=bathymetry) + IF (.NOT. as_laid) RETURN + IF (fairlead(3) < anchor(3)) THEN + CALL laid_seed_from_last(ok) + ELSE + IF (.NOT. anchor_grounded) RETURN + CALL CD_Static_As_Laid_Seed(anchor, fairlead, l0, ea, weight, current%friction_ref, q_seed, ok, & + seabed_z_floor=seabed_z_floor, bathymetry=bathymetry) + END IF IF (ok) ok = CD_All_Finite(q_seed) CASE DEFAULT seed_name = 'two-leg polyline' @@ -2090,6 +2100,31 @@ SUBROUTINE build_seed(which, ok) END SELECT END SUBROUTINE build_seed + SUBROUTINE laid_seed_from_last(ok) + !! As-laid seed of a line laid from its last node (node n below node 1, the reference + !! laid from node n): CD_Static_As_Laid_Seed on the reversed line (node n first, with + !! the element and reference arrays reversed), its node order then reversed back into + !! q_seed. ok = .FALSE. when node n does not rest on the seabed or the seed has no + !! lift-off node. + LOGICAL, INTENT(OUT) :: ok + INTEGER :: es_r, i_r + REAL(wp) :: floor_n + REAL(wp), ALLOCATABLE :: q_rev(:) + CHARACTER(200) :: em_r + ok = .FALSE. + floor_n = seabed_floor_at(fairlead(1), fairlead(2), es_r, em_r) + IF (es_r /= 0) RETURN + IF (fairlead(3) > floor_n + CD_Static_Anchor_Seabed_Tolerance(floor_n)) RETURN + ALLOCATE (q_rev(n_dof)) + CALL CD_Static_As_Laid_Seed(fairlead, anchor, l0(n_elem:1:-1), ea(n_elem:1:-1), weight(n_elem:1:-1), & + current%friction_ref(:, n_nodes:1:-1), q_rev, ok, & + seabed_z_floor=seabed_z_floor, bathymetry=bathymetry) + IF (.NOT. ok) RETURN + DO i_r = 1, n_nodes + q_seed(3*i_r - 2:3*i_r) = q_rev(3*(n_nodes - i_r) + 1:3*(n_nodes - i_r) + 3) + END DO + END SUBROUTINE laid_seed_from_last + SUBROUTINE drape_seed(ok) !! Seed for a grounded line on a non-planar or sloped seabed: nodes 1..k lie on the !! seabed along the horizontal anchor -> fairlead direction (each at the arc length of diff --git a/tests/test_bathymetry.f90 b/tests/test_bathymetry.f90 index 33120722..f539d032 100644 --- a/tests/test_bathymetry.f90 +++ b/tests/test_bathymetry.f90 @@ -14,7 +14,8 @@ PROGRAM test_bathymetry CD_Bathymetry_Grid_Floor, CD_Bathymetry_Rotate_Curvature, & CD_BATHY_CREASE_FRACTION USE CableDyn_SeabedContact, ONLY: CD_SEABED_CONTACT_BLEND - USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK + USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK, CD_Static_Line_Equilibrium, & + CableSolverConfig, CableCurrentLoad, CD_StaticLineReport USE, INTRINSIC :: IEEE_ARITHMETIC, ONLY: IEEE_VALUE, IEEE_QUIET_NAN IMPLICIT NONE @@ -29,6 +30,7 @@ PROGRAM test_bathymetry CALL case_crease_rounding_planar_exact() CALL case_crease_contact_tangent_fd() CALL case_as_laid_tension_sink() + CALL case_as_laid_seed_from_last() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -529,4 +531,99 @@ SUBROUTINE case_as_laid_tension_sink() CALL CD_End_Bathymetry(bathy) END SUBROUTINE case_as_laid_tension_sink + SUBROUTINE case_as_laid_seed_from_last() + !! The as-laid seed of the EI = 0 static equilibrium for a line whose last node is its lower + !! end (a line without a Fixed anchor at node 1, e.g. a FAST.Farm shared line): its friction + !! reference is laid from node n (as CD_Init_Line_Model lays it), and the seed must be laid + !! from node n too, the mirror image of the seed of the same line numbered from its lower + !! end. A grounded line (300 m, laid slack, mu = 0.5) is solved both ways, on a level floor + !! and on a bathymetry rising toward the upper end: both take the as-laid seed and reach the + !! same equilibrium, node for node mirrored. + INTEGER, PARAMETER :: NE = 60, NN = NE + 1 + REAL(wp), PARAMETER :: L0E = 5.0_wp, EA = 1.0e9_wp, WPL = 1.0e3_wp, KNE = 5.0e4_wp, Z0 = -100.0_wp + REAL(wp), PARAMETER :: SLOPE = 0.05_wp, MU = 0.5_wp + TYPE(CD_BathymetryType) :: bathy + TYPE(CableSolverConfig) :: cfg + TYPE(CableCurrentLoad) :: fr_a, fr_b + TYPE(CD_StaticLineReport) :: rep_a, rep_b + INTEGER :: conn(2, NE), i, j, es, icase + REAL(wp) :: l0(NE), ea_e(NE), w(NE), f_ext(3*NN), kn(NN), sink(NN), lo(3), up(3) + REAL(wp) :: ref(2, NN), q_a(3*NN), q_b(3*NN), gx(21), gy(2), depth(21, 2), worst + LOGICAL :: conv_a, conv_b + CHARACTER(160) :: em + CHARACTER(32) :: tag + + DO i = 1, NE + conn(:, i) = [i, i + 1] + END DO + l0 = L0E + ea_e = EA + w = WPL + f_ext = 0.0_wp + kn = KNE + DO i = 1, NE + f_ext(3*i) = f_ext(3*i) - 0.5_wp*WPL*L0E + f_ext(3*i + 3) = f_ext(3*i + 3) - 0.5_wp*WPL*L0E + END DO + kn(1) = 0.5_wp*KNE + kn(NN) = 0.5_wp*KNE + sink = MAX(-f_ext(3:3*NN:3), 0.0_wp)/kn + DO i = 1, SIZE(gx) + gx(i) = -50.0_wp + 20.0_wp*REAL(i - 1, wp) + depth(i, :) = -(Z0 + SLOPE*gx(i)) + END DO + gy = [-50.0_wp, 50.0_wp] + CALL CD_Init_Bathymetry(bathy, gx, gy, depth, es, em) + CALL expect_es(es, CD_BATHY_OK, 'laid-last:init') + lo = [0.0_wp, 0.0_wp, Z0] + up = [250.0_wp, 0.0_wp, -10.0_wp] + DO icase = 1, 2 + tag = MERGE('laid-last:flat ', 'laid-last:slope', icase == 1) + ! the reference laid from the lower end along +x (the default azimuth of either numbering) + IF (icase == 1) THEN + CALL CD_Static_As_Laid_Reference(lo(1:2), 0.0_wp, l0, ea_e, 0.0_wp, ref, es, em) + ELSE + CALL CD_Static_As_Laid_Reference(lo(1:2), 0.0_wp, l0, ea_e, 0.0_wp, ref, es, em, bathymetry=bathy, & + sink=sink, kn=kn) + END IF + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' reference') + fr_a%drag = .FALSE. + fr_a%friction_mu = MU + fr_a%friction_as_laid = .TRUE. + fr_a%friction_ref = ref + fr_b = fr_a + fr_b%friction_ref = ref(:, NN:1:-1) + IF (icase == 1) THEN + CALL CD_Static_Line_Equilibrium(lo, up, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_a, conv_a, rep_a, es, em, & + seabed_z_floor=Z0, seabed_kn=kn, current=fr_a) + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' from node 1') + CALL CD_Static_Line_Equilibrium(up, lo, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_b, conv_b, rep_b, es, em, & + seabed_z_floor=Z0, seabed_kn=kn, current=fr_b) + ELSE + CALL CD_Static_Line_Equilibrium(lo, up, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_a, conv_a, rep_a, es, em, & + seabed_kn=kn, bathymetry=bathy, current=fr_a) + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' from node 1') + CALL CD_Static_Line_Equilibrium(up, lo, conn, l0, ea_e, w, f_ext, cfg, .TRUE., q_b, conv_b, rep_b, es, em, & + seabed_kn=kn, bathymetry=bathy, current=fr_b) + END IF + CALL expect_es(es, CD_STATIC_OK, TRIM(tag)//' from node n') + CALL require(conv_a .AND. conv_b, TRIM(tag)//' both numberings converge') + CALL require(TRIM(rep_a%seed) == 'as-laid run', TRIM(tag)//' node 1 lower: as-laid seed ('// & + TRIM(rep_a%seed)//')') + CALL require(TRIM(rep_b%seed) == 'as-laid run', TRIM(tag)//' node n lower: as-laid seed ('// & + TRIM(rep_b%seed)//')') + worst = 0.0_wp + DO i = 1, NN + j = NN + 1 - i + worst = MAX(worst, MAXVAL(ABS(q_b(3*i - 2:3*i) - q_a(3*j - 2:3*j)))) + END DO + IF (.NOT. (worst <= 1.0e-6_wp)) WRITE (*, '(A,ES10.3,A)') ' '//TRIM(tag)//': mirror mismatch ', worst, ' m' + CALL require(worst <= 1.0e-6_wp, TRIM(tag)//' the two numberings give the mirrored equilibrium') + ! the run rests on the seabed where it was laid (its friction holds it there) + CALL require(ABS(q_a(3*11) - (Z0 + MERGE(0.0_wp, SLOPE*q_a(3*11 - 2), icase == 1))) < 0.2_wp, & + TRIM(tag)//' node 11 rests on the seabed') + END DO + CALL CD_End_Bathymetry(bathy) + END SUBROUTINE case_as_laid_seed_from_last + END PROGRAM test_bathymetry diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index f1eb7069..80b676f5 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -29,8 +29,13 @@ 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`` (finite-EI cable on a cross slope): the lateral anchor force follows the EI = 0 - line's, i.e. the sink offset of the laid nodes across the slope stays in the friction reference; +* ``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 + 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 + sinks each node under its discrete load, so the module nodes rest on the laid path (no lateral + kink, as in the smeared twin) and a march from the static state stays at rest; * ``pl_*``: per-line rows win over the global ones (``layAzimuth`` over ``layAzimuth``, ``asLaidTension`` over ``asLaidTension``, in either order), and a row for line 2 leaves line 1 alone; ``aniso_*``: the axial coefficient rules the friction along a laid run; @@ -75,12 +80,16 @@ def slope_grid(path: Path, depth0: float, slope_deg: float) -> None: def deck(title: str, ei: float, length: float, nseg: int, fair: tuple, anch: tuple, seabed: str, extra: str = "", tmax: float = 0.0, mu: float = 1.0, types: str | None = None, - sections: str | None = None) -> str: + sections: str | None = None, attachments: str | None = None) -> str: d, m, ea = CHAIN if types is None: types = f"chain {d} {m} {ea} -1 {ei} 1.37 0.64 1 0\n" if sections is None: sections = f"1 chain {length} {nseg}\n" + if attachments is not None: + sections += ("--------------------- ATTACHMENTS ---\n" + "LineID ArcLength Mass Volume CdA Ca CdAx\n(-) (m) (kg) (m^3) (m^2) (-) (m^2)\n" + f"{attachments}") return ( "--------------------- CableDyn Input File ---\n" f"{title}\n" @@ -396,8 +405,14 @@ def main() -> int: # --- finite-EI cable on a cross slope, default lay azimuth --- # The nodes laid at rest sink into the penalty seabed along its normal, across the slope too; - # the friction reference keeps that offset, so the lateral anchor force is that of the - # EI = 0 line (a reference without it adds a lateral spring force of the order of w tan(slope)). + # 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 + # 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" cdir.mkdir(parents=True, exist_ok=True) cross_grid(cdir / "bathy.txt", 200.0, 5.0) @@ -407,10 +422,75 @@ def main() -> int: rc, log = run(a.exe, cdir, tag, deck("fei cross " + tag, **cd)) check(rc == 0, "fei_cross %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) if rc == 0: - fy[tag] = table(cdir / (tag + ".out"))[0]["Point2Fy"] - if len(fy) == 2: - check(fy["ei0"] * fy["fei"] > 0.0 and abs(fy["fei"] - fy["ei0"]) < 0.25 * abs(fy["ei0"]), - "fei_cross: lateral anchor force %.4g N follows the EI = 0 line's %.4g N" % (fy["fei"], fy["ei0"])) + 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 + 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 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) + if rc == 0: + drift = at_rest(cdir, "fei", "fei_rest") + check(drift <= REST_TOL, "fei_cross fei stays at rest from the static state (drift %.2e)" % drift) + + # --- finite-EI line with discrete buoyancy modules on a cross slope --- + # Three modules (net buoyancy 8.09 kN, two thirds of a node's weight) on the grounded run of a + # soft rope (EA 2e7 N: its laid slack run beyond the touchdown is held by friction at a small + # tension, so it rests as laid). The static solve smears each module over its node's two + # elements, then polishes to the discrete loads; the friction reference sinks every node under + # those discrete loads, so a module node rests on the laid path as its neighbours do. A + # reference built from the smeared weights would deflect each module node across the slope by + # about half its net weight times tan(slope) over the nodal seabed stiffness (3.3 mm) and hold + # that with a spurious friction force (the seabed stiffness times that kink). Checked: the + # lateral kink of the line at the module nodes stays within a tenth of that and no larger than + # in its smeared twin (each module spread over its node's two elements as a section), and a + # march from the static state stays at rest. + cdir = root / "att_cross" + cdir.mkdir(parents=True, exist_ok=True) + cross_grid(cdir / "bathy.txt", 200.0, 5.0) + ea_soft, l_att, n_att, mods = 2.0e7, 600.0, 120, (450.0, 500.0, 550.0) + m_mod, v_mod = 200.0, 1.0 + d_m = 0.5 * (m_mod - RHO * v_mod) / 5.0 # smeared mass per length over each of the two elements + soft = f"chain {d} {m} {ea_soft} -1 1.0e4 1.37 0.64 1 0\n" + ac = dict(ei=1.0e4, length=l_att, nseg=n_att, fair=(500, 0, -10), anch=(0, 0, -200), seabed=sb) + att_rows = "".join("1 %.1f %.1f %.1f 0.0 0.0 0.0\n" % (s, m_mod, v_mod) for s in mods) + secs, s0 = "", 0.0 + for s in mods: + secs += "1 chain %.1f %d\n1 mod %.1f 2\n" % (s - 5.0 - s0, round((s - 5.0 - s0) / 5.0), 10.0) + s0 = s + 5.0 + secs += "1 chain %.1f %d\n" % (l_att - s0, round((l_att - s0) / 5.0)) + twin_types = soft + f"mod {d} {m + d_m} {ea_soft} -1 1.0e4 1.37 0.64 1 0\n" + ys = {} + for tag, kw in (("discrete", dict(types=soft, attachments=att_rows)), + ("smeared", dict(types=twin_types, sections=secs))): + rc, log = run(a.exe, cdir, tag, deck("att cross " + tag, **ac, **kw)) + check(rc == 0, "att_cross %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc != 0: + continue + p = first_row(cdir / (tag + ".Line1.p.out")) + ys[tag] = [p[3 * i + 1] for i in range(len(p) // 3)] + if tag == "discrete": + rc, _ = run(a.exe, cdir, tag + "_rest", deck("att cross rest", **ac, **kw, tmax=1.0)) + check(rc == 0, "att_cross at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, tag, tag + "_rest") + check(drift <= REST_TOL, "att_cross stays at rest from the static state (drift %.2e)" % drift) + if len(ys) == 2: + spurious = 0.5 * abs(m_mod - RHO * v_mod) * G * math.tan(math.radians(5.0)) / (1.0e5 * d * 5.0) + + def kink(y: list) -> float: + """Largest lateral offset of a module node from the chord of its two neighbours [m].""" + return max(abs(y[k] - 0.5 * (y[k - 1] + y[k + 1])) for k in (round(s / 5.0) for s in mods)) + + kd, ks = kink(ys["discrete"]), kink(ys["smeared"]) + check(kd < 0.1 * spurious, + "att_cross: no lateral kink at the module nodes (%.2e m, the smeared reference's %.2e m)" % (kd, spurious)) + check(kd <= ks, + "att_cross: the module nodes rest on the laid path as closely as in the smeared twin (%.2e <= %.2e m)" + % (kd, ks)) # --- per-line rows, non-default azimuth and tension, anisotropic friction (EI = 0) --- cdir = root / "perline" From 9750192e40cb9407ca15890b6e1cde785961a590 Mon Sep 17 00:00:00 2001 From: Jae Hoon Seo Date: Fri, 16 Oct 2026 15:40:57 +0900 Subject: [PATCH 10/10] fix(statics): as-laid reference laid on every mesh; route and wording fixes - The as-laid friction reference was laid once on the deck mesh and interpolated onto refined meshes, so on a seabed curved along the line with a section change on the grounded run the refined solve differed from the same line declared on the fine mesh (0.95 mm, an 8 N anchor tension change and a reversed lateral anchor force). The friction type now keeps the lay itself (origin, azimuth, tension, lower end, frame) and every static solve, and the dynamic hand-off, lays the reference on its own mesh with that mesh's lengths, EA, lumped weights and seabed stiffnesses (CD_HermiteCable_As_Laid_Offsets); the refined line now equals its fine-mesh twin to 1e-12 m. - The finite-EI compatibility route (a line whose End B is not Fixed) ignored staticsFriction asLaid; it now refuses it by name. - A still-water asLaid line keeps the tensile-polish fallback of a line without current, and its fixed-point and load-step failures name the friction instead of a current. - A laid path longer than the cross-slope sample cap takes the 3D solve conservatively; the sample count is computed without integer overflow. - Docs: the spring of a line laid on a slope carries the slope and turning load only (the normal sink adds no friction deflection); the none policy's anchors are described for still water and a current; the lay is from the lower end (the anchor, or the fairlead when that is lower); the asLaid rejection scope and its message are corrected. Tests: a refined two-section line against its fine-mesh twin, the compatibility-route rejection. Default outputs remain byte-identical. Signed-off-by: Jae Hoon Seo --- CHANGELOG.md | 18 ++- doc/driver_format.md | 2 +- doc/modeling.rst | 4 +- doc/options.rst | 31 ++-- doc/theory.rst | 23 ++- src/CableDyn_DeckDriver.f90 | 203 +++++++++++------------ src/CableDyn_HermiteCableStatic.f90 | 222 +++++++++++++++++++++++--- src/CableDyn_Model.f90 | 11 +- src/CableDyn_Static.f90 | 10 +- tests/test_static_friction_as_laid.py | 68 +++++++- 10 files changed, 424 insertions(+), 168 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5516fbe8..7fd83771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,8 +12,8 @@ All notable changes to CableDyn are recorded in this file. The format follows - Seabed friction in the static solve, toward the as-laid position (OrcaFlex's *as laid* statics seabed friction policy, opt-in): `asLaid staticsFriction`. Every grounded node is - held by a friction spring toward the position at which the line was laid from its anchor - along the lay azimuth on the seabed, with the regularised Coulomb law of the dynamics + held by a friction spring toward the position at which the line was laid from its lower end + (the anchor, or the fairlead when that is lower) along the lay azimuth on the seabed, with the regularised Coulomb law of the dynamics (isotropic or axial/lateral, capped at `mu N`), in still water and in a current, on `EI = 0` and finite-EI lines, standalone, coupled OpenFAST and through the C API; the march continues the static springs, so a held run stays at rest. New OPTIONS `staticsFriction none|asLaid`, @@ -38,9 +38,17 @@ All notable changes to CableDyn are recorded in this file. The format follows fairlead lies below its other end is laid, and seeded, from the fairlead. With discrete `ATTACHMENTS` the reference sinks each node under its discrete load (its share of the line's weight plus the attachment's net weight), so a module node rests on the laid path like the rest - of the run instead of taking its sink for a friction deflection. The - policy is rejected, as `frictionMu` is, on decks with `Connect`/`Free` points, bodies or rods, - and on mixed-topology decks. The Python `DeckFile`, `DeckWriter` and `DeckModel` take the new + of the run instead of taking its sink for a friction deflection. On a mesh the finite-EI + statics refines (adaptive refinement, the bending-length and stability refinements) or + coarsens, the reference is laid on that mesh itself, under its own lumped weights and nodal + seabed stiffnesses, and the march takes it on the final mesh: a run refined 16x on a seabed + curved along it and sloping across it, with a section change on the grounded run, rests where + its twin declared on the refined mesh does (to solver precision), where a reference + interpolated from the deck nodes moved it by up to 1 mm and reversed its lateral anchor force. The policy is rejected + where the statics carry no seabed friction: on decks with bodies, rods or dynamic + (`Connect`/`Free`) points (`frictionMu` itself is rejected on the latter and accepted on the + default monolithic body and rod march), and on a finite-EI deck whose line has a moving End B + (a line shared between two turbines, which takes the compatibility route). The Python `DeckFile`, `DeckWriter` and `DeckModel` take the new rows. See the theory page (Friction in statics). - Run-time profile of the standalone driver. With the environment variable `CABLEDYN_PROFILE=1`, the driver prints at the end of the run how its wall time divides diff --git a/doc/driver_format.md b/doc/driver_format.md index 14b62889..5b39e369 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -994,7 +994,7 @@ syntax form. The most frequently edited keywords are: | `bodyIC` | `static`: free `Rigid6` bodies and free rods, with `Free`/`Connect` points, start at their static equilibrium; `deck`: they start at their deck pose (for example a free-decay test) | `static` | | `frictionMu` / `mu` | isotropic seabed friction coefficient: stick-slip springs on line nodes (held by the static solve too in a deck current, from the still-water laid shape, or toward the as-laid position with `staticsFriction asLaid`), regularised kinetic friction on rods and bodies; requires `WtrDpth` or `bathymetryFile`, and `dtM`/`TMax` in the standalone driver. Rejected on some routes (decks with `Connect`/`Free` points, `Point3` buoys or `FAILURE` rows, and body or rod decks off the default monolithic march); see the [OPTIONS reference](options.rst) | 0 | | `frictionMuAxial` / `frictionMuLateral` | anisotropic line friction: the coefficients along and across the local line axis (OrcaFlex axial/normal); an omitted one takes `frictionMu`; both positive or both zero; rods and bodies use the lateral one | `frictionMu` | -| `staticsFriction` | statics seabed friction policy (OrcaFlex): `none` solves frictionless statics (in a deck current, friction from the still-water equilibrium); `asLaid` holds every grounded node toward its as-laid position (laid from the anchor along `layAzimuth` at `asLaidTension`) with the regularised Coulomb law | `none` | +| `staticsFriction` | statics seabed friction policy (OrcaFlex): `none` solves frictionless statics (in a deck current, friction from the still-water equilibrium); `asLaid` holds every grounded node toward its as-laid position (laid from the line's lower end, the anchor or the fairlead when that is lower, along `layAzimuth` at `asLaidTension`) with the regularised Coulomb law; rejected where the statics solve the lines without seabed friction (decks with bodies, rods or `Connect`/`Free` points, and a finite-EI line whose End B is not `Fixed`, as a line shared between two turbines) | `none` | | `layAzimuth`, `layAzimuth` | lay azimuth (deg, from +x toward +y) of every line, or of line `ID` | chord direction, from the lower end | | `asLaidTension`, `asLaidTension` | as-laid effective tension (N, ≥ 0) of every line, or of line `ID` | 0 | | `dtM` | dynamic time step [s] | — | diff --git a/doc/modeling.rst b/doc/modeling.rst index 61a8c949..b68537c8 100644 --- a/doc/modeling.rst +++ b/doc/modeling.rst @@ -157,8 +157,8 @@ tension gradient, penetrated seabed, broken symmetry, or unresolved curvature pe With seabed friction (``frictionMu``) the static solve is frictionless in still water by default, as in MoorDyn, which is conservative for anchor loads. ``asLaid staticsFriction`` holds the grounded run toward the position in which the line was laid, as OrcaFlex's *as laid* -policy does: then decide how the line was laid (``layAzimuth``, by default from the anchor -toward the fairlead) and at what tension (``asLaidTension``, by default slack), because the +policy does: then decide how the line was laid (``layAzimuth``, by default along the chord +from its lower end, normally the anchor) and at what tension (``asLaidTension``, by default slack), because the anchor tension depends on it: a run laid slack and pulled taut is held back by friction. See :ref:`friction in statics `. diff --git a/doc/options.rst b/doc/options.rst index 30bce1b5..ac834613 100644 --- a/doc/options.rst +++ b/doc/options.rst @@ -133,28 +133,35 @@ Environment and seabed - ``none`` - ``none`` or ``asLaid`` (also ``as_laid``, ``as-laid``), case-insensitive; OrcaFlex's statics seabed friction policy. ``none``: the static solve is frictionless in still water - (in a deck current, friction springs from the still-water equilibrium hold the line), and - the friction anchors of the march start at the static node positions. ``asLaid``: the + and the friction anchors of the march start at the static node positions; in a deck + current friction springs from the still-water equilibrium hold the line, and the anchors + continue their static forces. ``asLaid``: the static solve resists the horizontal displacement of every grounded node from its as-laid - position (the line laid from its anchor along ``layAzimuth`` on the seabed at - ``asLaidTension``, its top end then moved to the fairlead) with the regularised Coulomb + position (the line laid from its lower end, the anchor or the fairlead when that is lower, + along ``layAzimuth`` on the seabed at ``asLaidTension``, its top end then moved to its + position; on a mesh the finite-EI statics refines, laid on the refined mesh) with the + regularised Coulomb law of the dynamics, capped at ``mu N``, in still water and in a current, so a run on a slope with ``tan(slope) < mu`` holds and surplus length rests where it was laid; the march continues the springs. ``none`` is the default, as in MoorDyn: a run laid slack and pulled taut is held back by its friction, so the as-laid statics lowers anchor tensions (by up to ``mu w`` times the grounded length), and the frictionless statics is the conservative choice for anchor loads unless the as-laid layout and tension are - known. Used only with ``frictionMu > 0`` and a seabed; rejected, like ``frictionMu``, - on decks with ``Connect``/``Free`` points, bodies or rods (and on mixed-topology - decks), whose static equilibrium solves the lines without seabed friction. See + 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 :ref:`friction in statics ` - both - ``asLaid staticsFriction`` * - ``layAzimuth`` / ``lay_azimuth``, and ``layAzimuth`` - real, deg - - absent: each line's chord direction, from its lower end (anchor → fairlead) - - finite. Horizontal direction, from global +x toward +y, in which the line was laid from - its anchor (its lower end): the as-laid reference of ``staticsFriction asLaid``. + - absent: each line's chord direction, from its lower end (anchor → fairlead, or + fairlead → anchor when the fairlead is lower) + - finite. Horizontal direction, from global +x toward +y, in which the line was laid away + from its lower end (the anchor, or the fairlead when that is lower): the as-laid + reference of ``staticsFriction asLaid``. ``layAzimuth`` sets every line; ``layAzimuth`` (the line ID appended, e.g. ``layAzimuth2``) sets line ``ID`` and overrides it. A direction off the vertical plane of the line ends puts the finite-EI static solve in 3D, as does a bathymetry sloping across @@ -165,8 +172,8 @@ Environment and seabed - real, N - ``0`` - finite, ≥ 0. Effective tension with which the line was laid: the as-laid node spacing is - the unstretched one times ``1 + asLaidTension/EA``, so a run whose static tension equals - it carries no friction force. ``asLaidTension`` sets line ``ID`` alone, as for + the unstretched one times ``1 + asLaidTension/EA``, so a run on a level seabed whose + static tension equals it carries no friction force. ``asLaidTension`` sets line ``ID`` alone, as for ``layAzimuth`` - both - ``2.0e5 asLaidTension1`` diff --git a/doc/theory.rst b/doc/theory.rst index f6d1b93d..46fbf879 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -777,11 +777,11 @@ the static solve is frictionless in still water, and in a deck current the frict below hold the line from its still-water equilibrium (the same line solved without the current first). It is conservative for anchor loads, since an as-laid run pulled taut is held back by its friction (below). With ``asLaid`` the reference of -node :math:`i` is the as-laid position: the line is laid from its anchor (its lower end) along -the azimuth :math:`\alpha` (``layAzimuth``; by default the horizontal anchor → fairlead -direction, the vertical plane through the line ends) on the seabed at the tension -:math:`T_\text{laid}` (``asLaidTension``, default 0), so that the seabed path from the anchor -to node :math:`i` is :math:`s_i = \sum_{e CD_ZERO .AND. span <= HUGE(span))) RETURN + ! beyond MAX_SAMPLES m the samples would lie more than 1 m apart and could miss a local + ! cross slope: the 3D solve, an equilibrium in either case, is chosen conservatively + IF (span > REAL(MAX_SAMPLES, wp)) THEN + cross = .TRUE. + RETURN + END IF + n_s = MAX(1, CEILING(span)) ds = span/REAL(n_s, wp) DO k = 0, n_s CALL CD_Bathymetry_Floor_Gradient(bathymetry, o_xy(1) + REAL(k, wp)*ds*dir(1), & @@ -3953,122 +3973,78 @@ LOGICAL FUNCTION as_laid_cross_slope() RESULT(cross) END DO END FUNCTION as_laid_cross_slope - SUBROUTINE as_laid_positions(with_sink, from_top, az, laid_t, ref_g, esr, emr, node_load) - !! Global (x, y) as-laid position of every node of the mesh l0 (CD_Static_As_Laid_Reference): - !! the line laid on the seabed from its lower end (the anchor, node 1; the fairlead, the last - !! node, when from_top) along the azimuth az [rad] at the as-laid tension. with_sink: the - !! nodes sink into the penalty seabed as in the static solve, which moves them along a slope, - !! each under its nodal load: the element weights w lumped to the nodes, or node_load [N, - !! downward positive, one entry per node] when given (the discrete loads of an attachment - !! polish). - LOGICAL, INTENT(IN) :: with_sink, from_top - REAL(wp), INTENT(IN) :: az, laid_t - REAL(wp), INTENT(OUT) :: ref_g(:, :) - INTEGER, INTENT(OUT) :: esr - CHARACTER(*), INTENT(OUT) :: emr - REAL(wp), INTENT(IN), OPTIONAL :: node_load(:) - REAL(wp), ALLOCATABLE :: wn(:), kn_r(:), sn(:), kn_o(:), l0_r(:), ea_r(:) - REAL(wp) :: o_xy(2) - INTEGER :: k, ne_r - ne_r = SIZE(l0) - IF (with_sink .AND. PRESENT(bathymetry)) THEN - ! static penalty penetration factor w_i/k_i of every node (the nodal contact - ! stiffness of the solve, kBot Diam l0 lumped to the nodes) - ALLOCATE (wn(ne_r + 1), kn_r(ne_r + 1)) - wn = CD_ZERO - kn_r = CD_ZERO - DO k = 1, ne_r - kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) - END DO - IF (PRESENT(node_load)) THEN - wn = node_load - ELSE - DO k = 1, ne_r - wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) - END DO - END IF - WHERE (kn_r > CD_ZERO) - wn = MAX(wn, CD_ZERO)/kn_r - ELSEWHERE - wn = CD_ZERO - END WHERE - IF (from_top) THEN - sn = wn(ne_r + 1:1:-1) - kn_o = kn_r(ne_r + 1:1:-1) - ELSE - sn = wn - kn_o = kn_r - END IF - END IF - IF (from_top) THEN - ! the line is laid from its bottom end, here the last node - l0_r = l0(ne_r:1:-1) - ea_r = ea(ne_r:1:-1) - o_xy = points(pb)%pos(1:2) - ELSE - l0_r = l0 - ea_r = ea - o_xy = points(pa)%pos(1:2) - END IF - CALL CD_Static_As_Laid_Reference(o_xy, az, l0_r, ea_r, laid_t, ref_g, esr, emr, bathymetry=bathymetry, sink=sn, & - kn=kn_o) - IF (from_top .AND. esr == CD_STATIC_OK) ref_g = ref_g(:, ne_r + 1:1:-1) - END SUBROUTINE as_laid_positions - SUBROUTINE as_laid_reference(esr, emr, node_load) - !! Friction reference of the static solve (CD_Static_As_Laid_Reference): the line laid on - !! the seabed from its lower end (the anchor, node 1, unless the fairlead is lower, as in + !! Friction reference of the static solve (CD_HermiteCable_As_Laid_Offsets): the line laid + !! on the seabed from its lower end (the anchor, node 1, unless the fairlead is lower, as in !! the EI = 0 line model) along the lay azimuth at the as-laid tension, as (x, y) offsets - !! from node 1 in the solve frame along the unstretched arc length of the mesh l0 (the deck - !! mesh, or the final mesh when rebuilt for an attachment polish). A lay azimuth off the - !! vertical plane of the chord puts the reference out of that plane (see + !! from node 1 in the solve frame along the unstretched arc length of the mesh l0. A lay + !! azimuth off the vertical plane of the chord puts the reference out of that plane (see !! as_laid_off_plane): the static solve then runs in 3D. In the plane the reference is - !! held in it, but for the sink of its nodes along a cross slope. node_load: the nodal - !! loads the nodes sink under (as_laid_positions; default the lumped weights w). + !! held in it, but for the sink of its nodes along a cross slope, each under its nodal + !! load over its nodal seabed stiffness (kBot Diam l0 lumped to the nodes). The lay is + !! kept with the profile of the deck mesh, and every static solve lays the reference on + !! its own mesh (a refined or coarsened one too) under its own lumped weights, as the + !! dynamic hand-off does on the final mesh. node_load [N, downward positive, one entry per + !! node]: the discrete loads of an attachment polish on the final mesh l0, which hold on + !! that mesh alone; the reference is then this profile (default: the lumped weights w). INTEGER, INTENT(OUT) :: esr CHARACTER(*), INTENT(OUT) :: emr REAL(wp), INTENT(IN), OPTIONAL :: node_load(:) - REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :) - REAL(wp) :: laid_t, az, dg(2), dg0(2), a_g(3) - INTEGER :: k, ne_r - LOGICAL :: from_top, in_plane + REAL(wp), ALLOCATABLE :: wn(:), kn_r(:), offsets(:, :) + REAL(wp) :: laid_t, az + INTEGER :: k, ne_r, es_r + LOGICAL :: from_top esr = CD_DECKDRV_OK emr = '' ne_r = SIZE(l0) - a_g = points(pa)%pos CALL as_laid_heading(from_top, az, laid_t) - in_plane = .NOT. as_laid_off_plane() - ALLOCATE (ref_g(2, ne_r + 1), ref_0(2, ne_r + 1)) - CALL as_laid_positions(.TRUE., from_top, az, laid_t, ref_g, esr, emr, node_load) - ! the laid line without the sink of its nodes: its cross-plane offset is geometric - ref_0 = ref_g - IF (esr == CD_STATIC_OK .AND. in_plane .AND. PRESENT(bathymetry)) & - CALL as_laid_positions(.FALSE., from_top, az, laid_t, ref_0, esr, emr) - IF (esr /= CD_STATIC_OK) THEN - esr = CD_DECKDRV_BADINPUT - RETURN - END IF IF (ALLOCATED(cur_obj%friction)) DEALLOCATE (cur_obj%friction) ALLOCATE (cur_obj%friction) cur_obj%friction%mu = opts%friction_mu cur_obj%friction%mu_axial = opts%friction_mu_axial cur_obj%friction%as_laid = .TRUE. - ALLOCATE (cur_obj%friction%ref_s(ne_r + 1), cur_obj%friction%ref_xy(2, ne_r + 1)) + cur_obj%friction%laid_from_top = from_top + cur_obj%friction%laid_in_plane = .NOT. as_laid_off_plane() + cur_obj%friction%laid_bathymetry = PRESENT(bathymetry) + IF (from_top) THEN + cur_obj%friction%laid_origin = points(pb)%pos(1:2) + ELSE + cur_obj%friction%laid_origin = points(pa)%pos(1:2) + END IF + cur_obj%friction%laid_node1 = points(pa)%pos(1:2) + cur_obj%friction%laid_azimuth = az + cur_obj%friction%laid_tension = laid_t + cur_obj%friction%laid_frame_cs = frame_cs + ! the nodal loads and seabed stiffnesses the nodes of mesh l0 sink under + ALLOCATE (wn(ne_r + 1), kn_r(ne_r + 1), offsets(2, ne_r + 1)) + wn = CD_ZERO + kn_r = CD_ZERO + DO k = 1, ne_r + kn_r(k:k + 1) = kn_r(k:k + 1) + 0.5_wp*opts%kbot*diam(k)*l0(k) + END DO + IF (PRESENT(node_load)) THEN + wn = node_load + ELSE + DO k = 1, ne_r + wn(k:k + 1) = wn(k:k + 1) + 0.5_wp*w(k)*l0(k) + END DO + END IF + IF (PRESENT(bathymetry)) THEN + CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr, bathymetry) + ELSE + CALL CD_HermiteCable_As_Laid_Offsets(cur_obj%friction, l0, ea, wn, kn_r, offsets, es_r, emr) + END IF + IF (es_r /= CD_HCSTAT_OK) THEN + esr = CD_DECKDRV_BADINPUT + RETURN + END IF + ALLOCATE (cur_obj%friction%ref_s(ne_r + 1)) cur_obj%friction%ref_s(1) = CD_ZERO DO k = 2, ne_r + 1 cur_obj%friction%ref_s(k) = cur_obj%friction%ref_s(k - 1) + l0(k - 1) END DO - DO k = 1, ne_r + 1 - dg = ref_g(:, k) - a_g(1:2) - cur_obj%friction%ref_xy(:, k) = [frame_cs(1)*dg(1) + frame_cs(2)*dg(2), -frame_cs(2)*dg(1) + frame_cs(1)*dg(2)] - IF (in_plane) THEN - ! the laid line lies in the vertical plane of the chord: only the sink offset of the - ! nodes on a cross slope (zero on a flat floor) leaves it - dg0 = ref_0(:, k) - a_g(1:2) - cur_obj%friction%ref_xy(2, k) = (-frame_cs(2)*dg(1) + frame_cs(1)*dg(2)) - & - (-frame_cs(2)*dg0(1) + frame_cs(1)*dg0(2)) - END IF - END DO + CALL MOVE_ALLOC(offsets, cur_obj%friction%ref_xy) + cur_obj%friction%laid_on_mesh = .NOT. PRESENT(node_load) END SUBROUTINE as_laid_reference SUBROUTINE fine_mesh_note(note) @@ -4910,8 +4886,10 @@ SUBROUTINE laid_seed_positions(ok) kn_ld(e_ + 1) = kn_ld(e_ + 1) + 0.5_wp*opts%kbot*diam(e_)*l0(e_) END DO IF (.NOT. ALL(kn_ld > CD_ZERO)) RETURN - ! the as-laid reference on this mesh, from the solve frame to global coordinates - CALL CD_HermiteCable_Friction_Reference(cur_obj%friction, l0, anchor(1:2), ref_l, es_ld, em_ld) + ! the as-laid reference on this mesh (laid on it as the static solve lays it), from the + ! solve frame to global coordinates + CALL CD_HermiteCable_Friction_Reference(cur_obj%friction, l0, anchor(1:2), ref_l, es_ld, em_ld, EA=ea, w=w, & + node_kn=kn_ld, bathymetry=bathymetry) IF (es_ld /= CD_HCSTAT_OK) RETURN fr_ld%drag = .FALSE. ! the static seabed friction of the as-laid policy: the laid-run seed order of @@ -17482,7 +17460,8 @@ SUBROUTINE write_multibody_dynamic_out(deck_path, out_root, channels, types, bod last_miss_time = CD_ZERO ! ---- scope of the multibody march (fail closed by name) ---- IF (opts%has_friction .AND. opts%static_friction == CD_STATIC_FRICTION_AS_LAID) THEN - CALL fail(ErrStat, ErrMsg, 'a mixed-topology deck does not support OPTION staticsFriction asLaid (the '// & + CALL fail(ErrStat, ErrMsg, 'a deck with bodies, rods or dynamic points does not support OPTION '// & + 'staticsFriction asLaid (the '// & 'static equilibrium of its bodies, rods and points solves the lines without seabed friction); '// & 'use staticsFriction none'); RETURN END IF diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index b85c92c9..446ba6df 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -48,6 +48,7 @@ MODULE CableDyn_HermiteCableStatic CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK, & 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_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & CD_HermiteTorsion_Accept, CD_HermiteTorsion_Compliance, & @@ -70,7 +71,7 @@ MODULE CableDyn_HermiteCableStatic PUBLIC :: CD_HermiteCable_Prolong_Arc PUBLIC :: CD_HermiteCable_Static_Solve_AutoMesh PUBLIC :: CD_HermiteCable_Current_Load - PUBLIC :: CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Friction_Reference + PUBLIC :: CD_HermiteCable_Friction_Anchors, CD_HermiteCable_Friction_Reference, CD_HermiteCable_As_Laid_Offsets PUBLIC :: CD_HermiteCable_Mean_Axial_Extremes 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 @@ -169,7 +170,8 @@ MODULE CableDyn_HermiteCableStatic ! position, capped at mu times the normal contact force. The reference is a profile ! along the unstretched arc length (ref_s ascending; ref_xy(1:2, :) the solve-frame ! offsets from node 1, the held first end), interpolated at each node, so it survives - ! mesh refinement and a translated solve origin: the as-laid position of the line. + ! mesh refinement and a translated solve origin: the as-laid position of the line, which + ! is instead rebuilt on the mesh itself when its lay is given (laid_on_mesh, below). ! frozen_capacity (optional, one entry per node of the solved mesh) holds the capacities ! fixed: the springs are then conservative (the energy-minimising step applies), as the ! frozen drag of a fixed-point pass. @@ -184,6 +186,20 @@ MODULE CableDyn_HermiteCableStatic ! the reference is the as-laid position (staticsFriction asLaid; otherwise the still-water ! equilibrium of a current deck) LOGICAL :: as_laid = .FALSE. + ! The lay of an as-laid reference that is rebuilt on every mesh it is applied to + ! (laid_on_mesh, CD_HermiteCable_As_Laid_Offsets): the nodes of a refined or coarsened + ! mesh are laid and sink as the deck nodes are, under their own lumped weights and nodal + ! seabed stiffnesses, which no interpolation of the deck-mesh profile gives at a section + ! change or on a varying slope. The line is laid from laid_origin (global x, y of its + ! lower end, node 1 or, laid_from_top, the last node) along laid_azimuth [rad, global] at + ! laid_tension [N], over the bathymetry when laid_bathymetry; the offsets are taken from + ! laid_node1 (global x, y of node 1) in the solve frame laid_frame_cs = (cos, sin). With + ! laid_in_plane only the sink of the nodes leaves the vertical plane of the chord. + LOGICAL :: laid_on_mesh = .FALSE. + LOGICAL :: laid_from_top = .FALSE., laid_in_plane = .FALSE., laid_bathymetry = .FALSE. + REAL(wp) :: laid_origin(2) = 0.0_wp, laid_node1(2) = 0.0_wp + REAL(wp) :: laid_azimuth = 0.0_wp, laid_tension = 0.0_wp + REAL(wp) :: laid_frame_cs(2) = [1.0_wp, 0.0_wp] END TYPE CD_HermiteStaticFrictionType TYPE, PUBLIC :: CD_HermiteStaticCurrentType @@ -2152,7 +2168,9 @@ SUBROUTINE setup_friction(fr, ecs, ecm) ELSE fr_k = kn*trib END IF - CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), fr_ref, ecs, ecm) + ! an as-laid reference is laid on this mesh, with its nodal loads and stiffnesses + CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), fr_ref, ecs, ecm, EA=EA, w=w, node_kn=fr_k, & + bathymetry=bathymetry) IF (ecs /= CD_HCSTAT_OK) RETURN IF (ALLOCATED(fr%frozen_capacity)) THEN IF (SIZE(fr%frozen_capacity) /= nn) THEN @@ -2606,20 +2624,140 @@ END SUBROUTINE fail END SUBROUTINE CD_HermiteCable_Static_Solve - SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrMsg) + SUBROUTINE CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, offsets, ErrStat, ErrMsg, bathymetry) + !! As-laid friction reference of the nodes of mesh l0 (the lay of fr, laid_* above; + !! CD_Static_As_Laid_Reference): node i at the stretched arc length of the elements + !! l0 (1 + laid_tension/EA) along the seabed from the lower end, and on a bathymetry + !! moved with its sink into the penalty seabed under its nodal load node_load(i) [N, + !! downward positive] over its nodal seabed stiffness node_kn(i) [N/m] (with the + !! turning force of the laid tension). offsets(1:2, i) is the reference of node i less + !! the global position laid_node1 of node 1, in the solve frame laid_frame_cs; with + !! laid_in_plane on a bathymetry only the sink offset across the chord leaves its plane. + TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr + REAL(wp), INTENT(IN) :: l0(:), EA(:), node_load(:), node_kn(:) + REAL(wp), INTENT(OUT) :: offsets(:, :) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), ALLOCATABLE :: ref_g(:, :), ref_0(:, :), wn(:), sn(:), kn_o(:), l0_r(:), ea_r(:) + REAL(wp) :: dg(2), dg0(2), cs(2) + INTEGER :: k, ne, es + CHARACTER(200) :: em + ErrStat = CD_HCSTAT_OK + ErrMsg = '' + ne = SIZE(l0) + IF (ne < 1 .OR. SIZE(EA) /= ne .OR. SIZE(node_load) /= ne + 1 .OR. SIZE(node_kn) /= ne + 1 .OR. & + SIZE(offsets, 1) /= 2 .OR. SIZE(offsets, 2) /= ne + 1) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'as-laid friction reference: inconsistent array sizes'; RETURN + END IF + IF (.NOT. CD_All_Finite(node_load) .OR. .NOT. CD_All_Finite(node_kn)) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'as-laid friction reference: nodal loads and stiffnesses must be finite' + RETURN + END IF + offsets = CD_ZERO + ALLOCATE (ref_g(2, ne + 1)) + IF (PRESENT(bathymetry)) THEN + ! the static penalty penetration factor w_i/k_i of every node + ALLOCATE (wn(ne + 1)) + WHERE (node_kn > CD_ZERO) + wn = MAX(node_load, CD_ZERO)/node_kn + ELSEWHERE + wn = CD_ZERO + END WHERE + IF (fr%laid_from_top) THEN + sn = wn(ne + 1:1:-1) + kn_o = node_kn(ne + 1:1:-1) + ELSE + sn = wn + kn_o = node_kn + END IF + END IF + IF (fr%laid_from_top) THEN + ! the line is laid from its bottom end, here the last node + l0_r = l0(ne:1:-1) + ea_r = EA(ne:1:-1) + ELSE + l0_r = l0 + ea_r = EA + END IF + ! sn and kn_o are unallocated (absent) without a bathymetry + CALL CD_Static_As_Laid_Reference(fr%laid_origin, fr%laid_azimuth, l0_r, ea_r, fr%laid_tension, ref_g, es, em, & + bathymetry=bathymetry, sink=sn, kn=kn_o) + IF (es /= CD_STATIC_OK) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = TRIM(em); RETURN + END IF + IF (fr%laid_from_top) ref_g = ref_g(:, ne + 1:1:-1) + ! the laid line without the sink of its nodes: its cross-plane offset is geometric + ref_0 = ref_g + IF (fr%laid_in_plane .AND. PRESENT(bathymetry)) THEN + CALL CD_Static_As_Laid_Reference(fr%laid_origin, fr%laid_azimuth, l0_r, ea_r, fr%laid_tension, ref_0, es, em, & + bathymetry=bathymetry) + IF (es /= CD_STATIC_OK) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = TRIM(em); RETURN + END IF + IF (fr%laid_from_top) ref_0 = ref_0(:, ne + 1:1:-1) + END IF + cs = fr%laid_frame_cs + DO k = 1, ne + 1 + dg = ref_g(:, k) - fr%laid_node1 + offsets(:, k) = [cs(1)*dg(1) + cs(2)*dg(2), -cs(2)*dg(1) + cs(1)*dg(2)] + IF (fr%laid_in_plane) THEN + ! the laid line lies in the vertical plane of the chord: only the sink offset of the + ! nodes on a cross slope (zero on a flat floor) leaves it + dg0 = ref_0(:, k) - fr%laid_node1 + offsets(2, k) = (-cs(2)*dg(1) + cs(1)*dg(2)) - (-cs(2)*dg0(1) + cs(1)*dg0(2)) + END IF + END DO + END SUBROUTINE CD_HermiteCable_As_Laid_Offsets + + SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrMsg, EA, w, node_kn, bathymetry) !! Reference position (x, y) of every node of mesh l0: origin (the position of node 1, !! the held first end, in the caller's frame) plus the friction reference offset !! profile interpolated linearly in unstretched arc length (constant past its ends). + !! An as-laid reference whose lay is given (fr%laid_on_mesh) is instead rebuilt on mesh + !! l0 itself (CD_HermiteCable_As_Laid_Offsets) when the mesh's axial stiffnesses EA, + !! submerged weights per length w (lumped to the nodes) and nodal seabed stiffnesses + !! node_kn are given, and the bathymetry it was laid on (fr%laid_bathymetry). TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr REAL(wp), INTENT(IN) :: l0(:), origin(2) REAL(wp), INTENT(OUT) :: ref(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: EA(:), w(:), node_kn(:) + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + REAL(wp), ALLOCATABLE :: node_load(:) INTEGER :: node, k, np REAL(wp) :: s, t + LOGICAL :: on_mesh ErrStat = CD_HCSTAT_OK ErrMsg = '' ref = CD_ZERO + on_mesh = fr%as_laid .AND. fr%laid_on_mesh .AND. PRESENT(EA) .AND. PRESENT(w) .AND. PRESENT(node_kn) + IF (on_mesh .AND. fr%laid_bathymetry) on_mesh = PRESENT(bathymetry) + IF (on_mesh) THEN + IF (SIZE(w) /= SIZE(l0) .OR. SIZE(ref, 1) /= 2 .OR. SIZE(ref, 2) /= SIZE(l0) + 1 .OR. & + .NOT. CD_Is_Finite(fr%mu) .OR. .NOT. CD_All_Finite(w)) THEN + ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'friction: as-laid reference inputs inconsistent or non-finite'; RETURN + END IF + ! the element weights lumped to the nodes + ALLOCATE (node_load(SIZE(l0) + 1)) + node_load = CD_ZERO + DO k = 1, SIZE(l0) + node_load(k:k + 1) = node_load(k:k + 1) + 0.5_wp*w(k)*l0(k) + END DO + IF (fr%laid_bathymetry) THEN + CALL CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, ref, ErrStat, ErrMsg, bathymetry) + ELSE + CALL CD_HermiteCable_As_Laid_Offsets(fr, l0, EA, node_load, node_kn, ref, ErrStat, ErrMsg) + END IF + IF (ErrStat /= CD_HCSTAT_OK) THEN + ErrMsg = 'friction: '//TRIM(ErrMsg); RETURN + END IF + DO node = 1, SIZE(l0) + 1 + ref(:, node) = origin + ref(:, node) + END DO + RETURN + END IF IF (.NOT. (ALLOCATED(fr%ref_s) .AND. ALLOCATED(fr%ref_xy))) THEN ErrStat = CD_HCSTAT_BADINPUT; ErrMsg = 'friction: reference profile required'; RETURN END IF @@ -2647,19 +2785,22 @@ SUBROUTINE CD_HermiteCable_Friction_Reference(fr, l0, origin, ref, ErrStat, ErrM END SUBROUTINE CD_HermiteCable_Friction_Reference SUBROUTINE CD_HermiteCable_Friction_Anchors(l0, q, fr, contact_kn, seabed_z, anchors, force, & - ErrStat, ErrMsg, bathymetry, contact_frame_cs) + ErrStat, ErrMsg, bathymetry, contact_frame_cs, EA, w) !! Elastic-plastic friction anchors that continue a static equilibrium solved with !! seabed friction fr into the dynamics: the static spring force f_s of every node !! (CD_Seabed_Friction_Spring at its normal force in state q) and the anchor !! x - f_s/k at which a linear spring of the same stiffness k (contact_kn) gives f_s. !! force(1:2, node) returns f_s (the force the seabed exerts is -f_s). + !! EA, w (optional, per element): the axial stiffnesses and submerged weights per length + !! of the static solve, with which an as-laid reference is laid on mesh l0 as it was + !! there (CD_HermiteCable_Friction_Reference). REAL(wp), INTENT(IN) :: l0(:), q(:), contact_kn(:), seabed_z TYPE(CD_HermiteStaticFrictionType), INTENT(IN) :: fr REAL(wp), INTENT(OUT) :: anchors(:, :), force(:, :) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry - REAL(wp), INTENT(IN), OPTIONAL :: contact_frame_cs(2) + REAL(wp), INTENT(IN), OPTIONAL :: contact_frame_cs(2), EA(:), w(:) REAL(wp), ALLOCATABLE :: ref(:, :) REAL(wp) :: z_floor, gxg, gyg, xg, yg, normal, normal_gap, dfd(2, 2), dfc(2), cs(2) INTEGER :: node, ix, nn, es @@ -2686,7 +2827,8 @@ SUBROUTINE CD_HermiteCable_Friction_Anchors(l0, q, fr, contact_kn, seabed_z, anc END IF END IF ALLOCATE (ref(2, nn)) - CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), ref, ErrStat, ErrMsg) + CALL CD_HermiteCable_Friction_Reference(fr, l0, q(1:2), ref, ErrStat, ErrMsg, EA=EA, w=w, node_kn=contact_kn, & + bathymetry=bathymetry) IF (ErrStat /= CD_HCSTAT_OK) THEN ErrMsg = 'CD_HermiteCable_Friction_Anchors: '//TRIM(ErrMsg); RETURN END IF @@ -3088,7 +3230,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ picard_ok = ErrStat == CD_HCSTAT_OK IF (picard_ok) THEN CALL full_fixed_point(picard_ok) - IF (.NOT. picard_ok) first_msg = 'current drag fixed point not reached: '// & + IF (.NOT. picard_ok) first_msg = TRIM(fixed_point_name())//' not reached: '// & TRIM(compression_note(q))//TRIM(em) ELSE first_msg = ErrMsg @@ -3139,15 +3281,21 @@ SUBROUTINE CD_HermiteCable_Static_Solve_Continuation(l0, EA, EI, w, seed, fixed_ ! Formatted into a short buffer: the assembled message may exceed ErrMsg and is ! truncated by the assignment (an internal WRITE past the record length aborts). WRITE (frac_txt, '(F6.3)') cur_frac - ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: current load stepping stopped at drag '// & - 'fraction '//TRIM(ADJUSTL(frac_txt))//': '//TRIM(compression_note(q))//TRIM(em)// & - ' (with the current along the homotopy: '//TRIM(first_msg)//')' + IF (current_has_drag(current)) THEN + ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: current load stepping stopped at drag '// & + 'fraction '//TRIM(ADJUSTL(frac_txt))//': '//TRIM(compression_note(q))//TRIM(em)// & + ' (with the current along the homotopy: '//TRIM(first_msg)//')' + ELSE + ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: seabed friction load stepping stopped at '// & + 'load fraction '//TRIM(ADJUSTL(frac_txt))//': '//TRIM(em)// & + ' (with the friction along the homotopy: '//TRIM(first_msg)//')' + END IF q_out = q; RETURN END IF CALL full_fixed_point(picard_ok) IF (.NOT. picard_ok) THEN ErrStat = CD_HCSTAT_NOCONVERGE - ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: current drag fixed point not reached: '// & + ErrMsg = 'CD_HermiteCable_Static_Solve_Continuation: '//TRIM(fixed_point_name())//' not reached: '// & TRIM(compression_note(q))//TRIM(em) q_out = q; RETURN END IF @@ -3352,6 +3500,25 @@ FUNCTION compression_note(qx) RESULT(note) note = current_compression_note(l0, EA, qx, seabed_z, flat, use_fric) END FUNCTION compression_note + FUNCTION fixed_point_name() RESULT(name) + !! The frozen-load fixed point of this solve in its messages: the current drag, or the + !! seabed friction a zero-velocity carrier holds in still water. + CHARACTER(40) :: name + name = 'seabed friction fixed point' + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) name = 'current drag fixed point' + END IF + END FUNCTION fixed_point_name + + FUNCTION fraction_name() RESULT(name) + !! The continuation parameter of the load steps in messages (see fixed_point_name). + CHARACTER(16) :: name + name = 'load fraction' + IF (PRESENT(current)) THEN + IF (current_has_drag(current)) name = 'drag fraction' + END IF + END FUNCTION fraction_name + SUBROUTINE drag_arclength(ok) !! Pseudo-arclength continuation of F(q, lambda) = R(q; lambda * drag) = 0 in the drag !! fraction lambda, from the last converged state (q, cur_frac) to lambda = 1, passing @@ -3426,7 +3593,8 @@ SUBROUTINE drag_arclength(ok) IF (.NOT. conv) THEN ds = 0.5_wp*ds IF (ds < DS_MIN .OR. iters_out >= iteration_budget) THEN - WRITE (em, '(A,F6.3,A)') 'stalled at drag fraction ', lam, ' (arclength step below its minimum)' + WRITE (em, '(A,F6.3,A)') 'stalled at '//TRIM(fraction_name())//' ', lam, & + ' (arclength step below its minimum)' RETURN END IF CYCLE @@ -3468,11 +3636,11 @@ SUBROUTINE drag_arclength(ok) tl = tl_new IF (n_corr <= 4) ds = MIN(DS_MAX, 1.5_wp*ds) IF (iters_out >= iteration_budget) THEN - WRITE (em, '(A,F6.3)') 'iteration budget exhausted at drag fraction ', lam + WRITE (em, '(A,F6.3)') 'iteration budget exhausted at '//TRIM(fraction_name())//' ', lam RETURN END IF END DO - WRITE (em, '(A,F6.3)') 'step limit reached at drag fraction ', lam + WRITE (em, '(A,F6.3)') 'step limit reached at '//TRIM(fraction_name())//' ', lam END SUBROUTINE drag_arclength SUBROUTINE arc_assemble(qx, lamx, resx, esx) @@ -3633,14 +3801,27 @@ SUBROUTINE friction_capacity(qx, cap) REAL(wp), INTENT(IN) :: qx(:) REAL(wp), INTENT(OUT) :: cap(:) REAL(wp) :: z_floor, gxg, gyg, xg, yg, normal, normal_gap, trib_k, cs(2), mu_c, q_c, gq_c(2) - REAL(wp), ALLOCATABLE :: fr_ref_c(:, :) + REAL(wp), ALLOCATABLE :: fr_ref_c(:, :), kn_c(:) INTEGER :: k, es_c CHARACTER(200) :: em_c cs = [CD_ONE, CD_ZERO] IF (PRESENT(contact_frame_cs)) cs = contact_frame_cs IF (current%friction%mu_axial > CD_ZERO .AND. ABS(current%friction%mu_axial - current%friction%mu) > CD_ZERO) THEN ALLOCATE (fr_ref_c(2, nn)) - CALL CD_HermiteCable_Friction_Reference(current%friction, l0, qx(1:2), fr_ref_c, es_c, em_c) + ! an as-laid reference laid on this mesh, as the solve lays it (with its nodal + ! seabed stiffnesses: contact_kn, or kn times the tributary length) + ALLOCATE (kn_c(nn)) + IF (PRESENT(contact_kn)) THEN + kn_c = contact_kn + ELSE + kn_c = CD_ZERO + DO k = 1, ne + kn_c(k:k + 1) = kn_c(k:k + 1) + 0.5_wp*l0(k) + END DO + kn_c = kn*kn_c + END IF + CALL CD_HermiteCable_Friction_Reference(current%friction, l0, qx(1:2), fr_ref_c, es_c, em_c, EA=EA, w=w, & + node_kn=kn_c, bathymetry=bathymetry) IF (es_c /= CD_HCSTAT_OK) DEALLOCATE (fr_ref_c) END IF DO k = 1, nn @@ -6017,7 +6198,7 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs LOGICAL, ALLOCATABLE :: axial_marks(:) CHARACTER(LEN(ErrMsg)) :: emloc LOGICAL :: contact_active, polish_initial, must_resolve, must_be_tensile, refine_other - LOGICAL :: needs_refinement, local_axial + LOGICAL :: needs_refinement, local_axial, in_drag REAL(wp) :: contact_cs(2) ! Local axial refinement guards: an element budget and a no-progress stop, so a ! genuinely compressive equilibrium cannot grow the mesh geometrically. @@ -6238,7 +6419,10 @@ SUBROUTINE CD_HermiteCable_Static_Solve_AutoMesh(l0, EA, EI, w, seed, fixed_dofs CALL solve_level(l0r, EAr, EIr, wr, qr, fixedr, contact_diam_r, dry_r, & qnew, curvnew, res_out, it, es, emloc, .TRUE.) iters_out = iters_out + it - IF (es /= CD_HCSTAT_OK .AND. local_axial .AND. .NOT. PRESENT(current)) THEN + ! (a still-water carrier of the as-laid friction is no current here) + in_drag = .FALSE. + IF (PRESENT(current)) in_drag = current_has_drag(current) + IF (es /= CD_HCSTAT_OK .AND. local_axial .AND. .NOT. in_drag) THEN ! The tensile refinement of a compressive state could not be carried further: the ! last converged (parent-mesh) state keeps its compression, which is what the ! tensile contract rejects below (or returns, when advisory). diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index f0fb3d54..7bd66c1f 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -1353,7 +1353,9 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra ! CD_Static_As_Laid_Reference. As laid, the static solve resists every grounded node's ! horizontal displacement from its as-laid position with the friction springs, and the ! stick-slip anchors of the dynamics continue their forces; with none the static solve - ! is frictionless and the anchors start at the static node positions. + ! is frictionless in still water and the anchors start at the static node positions, + ! while in a current the friction springs hold the line from its still-water equilibrium + ! and the anchors continue their forces likewise. INTEGER, INTENT(IN), OPTIONAL :: static_friction REAL(wp), INTENT(IN), OPTIONAL :: lay_azimuth, as_laid_tension @@ -1574,9 +1576,10 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra cur%drag = .FALSE. END IF ! Static seabed friction (the OrcaFlex "as laid" policy): every grounded node is held - ! by a friction spring toward its as-laid position -- the line laid from the anchor - ! along the lay azimuth on the seabed at the as-laid tension -- capped at mu N; the - ! spring forces then seed the stick-slip anchors of the march below. + ! by a friction spring toward its as-laid position -- the line laid from its lower end + ! (the anchor, or the fairlead when that is lower) along the lay azimuth on the seabed at + ! the as-laid tension -- capped at mu N; the spring forces then seed the stick-slip + ! anchors of the march below. IF (friction_static) THEN cur%friction_mu = seabed_mu cur%friction_as_laid = .TRUE. diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index f1984bc3..50b1140e 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -1330,14 +1330,16 @@ SUBROUTINE CD_Static_As_Laid_Reference(origin, azimuth, l0, ea, laid_tension, re !! sink (optional, per node, on a bathymetry): the static penalty penetration factor !! w_i/k_i of each node (its submerged weight over its seabed stiffness). A laid node !! sinks into the penalty seabed along the surface normal, which on a slope moves it - !! horizontally by w_i (z_x, z_y)/k_i; its reference moves with it, so the line laid at - !! rest on a slope carries no friction force (a deflection normal to the seabed is not a - !! friction deflection, as in OrcaFlex's in-plane friction). + !! horizontally by w_i (z_x, z_y)/k_i; its reference moves with it, so the normal sink + !! adds no spurious friction deflection (a deflection normal to the seabed is not a + !! friction deflection, as in OrcaFlex's in-plane friction): the spring of a node laid at + !! rest on a slope carries only the slope load that friction holds there. !! kn (optional, per node, with sink): the nodal seabed stiffness. With a positive !! laid_tension on a bathymetry whose slope varies, the tension turns at every node of !! the laid path and presses it into the seabed (over a crest) or lifts it (in a hollow); !! the normal component of that turning force over kn is added to the node's sink, so - !! the line laid at its as-laid tension rests at its reference without friction. + !! the line laid at its as-laid tension rests on its laid path, its springs carrying + !! only the slope and turning loads along the seabed. REAL(wp), INTENT(IN) :: origin(2), azimuth, l0(:), ea(:), laid_tension REAL(wp), INTENT(OUT) :: ref(:, :) INTEGER, INTENT(OUT) :: ErrStat diff --git a/tests/test_static_friction_as_laid.py b/tests/test_static_friction_as_laid.py index 80b676f5..aacf39be 100644 --- a/tests/test_static_friction_as_laid.py +++ b/tests/test_static_friction_as_laid.py @@ -40,9 +40,14 @@ ``asLaidTension`` over ``asLaidTension``, in either order), and a row for line 2 leaves line 1 alone; ``aniso_*``: the axial coefficient rules the friction along a laid run; ``multi``: a three-section line of different weights keeps every grounded node within mu N; +* ``refined`` (a finite-EI line of two sections laid at a tension on a seabed curved along it and + sloping across it, on a deck mesh the adaptive refinement takes 16x finer): the reference is laid + on the refined mesh, so the run rests where its twin declared on that mesh does (positions to + 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. + 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. usage: test_static_friction_as_laid.py --exe --output """ @@ -605,6 +610,51 @@ def of_line(row: dict, i: int) -> dict: "multi: friction mobilised to mu N in the light section and beyond in the heavy (%.3f, %.3f)" % (by_sec[1][0], by_sec[2][0])) + # --- a refined mesh is laid as its own deck would be --- + # A finite-EI line of two sections (the light one grounded at the anchor end) laid at a + # tension on a seabed curved along the line and sloping across it, on a 20 m deck mesh that + # the adaptive refinement takes to 1.25 m (16x). The friction reference of the refined solve + # is laid on the refined mesh itself (path, sink under each node's lumped weight over its + # seabed stiffness, turning force of the laid tension), so the run reaches the equilibrium + # of its twin declared on that 1.25 m mesh to solver precision. A reference interpolated + # from the 20 m deck nodes misplaces the sink of the refined nodes next to the section + # change (about 1 mm across the slope) and the turning force along the curved floor, which + # moves the run (the lateral anchor force changes sign, AnchTen moves by about 8 N). The + # refined run marched for 1 s stays at rest. + cdir = root / "refined" + cdir.mkdir(parents=True, exist_ok=True) + rows = ["%.1f %.1f %.12g" % (x, y, 200.0 + 1.0e-4 * x * x + 0.05 * y) + for x in range(-300, 1000, 10) for y in (-300.0, 300.0)] + (cdir / "bathy.txt").write_text("\n".join(rows) + "\n", encoding="utf-8", newline="\n") + rtypes = (f"chain {d} {m} {ea} -1 1.0e4 1.37 0.64 1 0\n" + f"light {light[0]} {light[1]} {light[2]} -1 1.0e4 1.2 0.6 1 0\n") + rpos = {} + for tag, nseg, extra in (("coarse", 20, "True adaptive_mesh\n"), ("fine", 320, "")): + rd = dict(ei=1.0e4, length=400.0, nseg=nseg, fair=(300, 0, -10), anch=(0, 0, -200), seabed=sb, mu=0.5, + types=rtypes, sections="1 chain 300 %d\n1 light 100 %d\n" % (nseg * 3 // 4, nseg // 4)) + ex = extra + "50000 asLaidTension\n" + rc, log = run(a.exe, cdir, tag, deck("refined " + tag, **rd, extra=ex)) + check(rc == 0, "refined %s converges (rc %d)%s" % (tag, rc, "" if rc == 0 else ": " + log.strip()[-300:])) + if rc != 0: + continue + p = first_row(cdir / (tag + ".Line1.p.out")) + rpos[tag] = ([p[3 * i:3 * i + 3] for i in range(len(p) // 3)], table(cdir / (tag + ".out"))[0]) + if tag == "coarse": + check(len(rpos[tag][0]) == 321, "refined: the 20-element deck mesh is refined to 320 elements (%d nodes)" + % len(rpos[tag][0])) + rc, _ = run(a.exe, cdir, "coarse_rest", deck("refined rest", **rd, extra=ex, tmax=1.0)) + check(rc == 0, "refined at-rest march runs (rc %d)" % rc) + if rc == 0: + drift = at_rest(cdir, "coarse", "coarse_rest") + check(drift <= REST_TOL, "refined stays at rest from the static state (drift %.2e)" % drift) + if len(rpos) == 2 and len(rpos["coarse"][0]) == len(rpos["fine"][0]): + dpos = max(abs(u[k] - v[k]) for u, v in zip(rpos["coarse"][0], rpos["fine"][0]) for k in range(3)) + check(dpos < 1.0e-6, "refined: the refined run rests where its twin on the refined mesh does (%.1e m)" % dpos) + rc_, rf_ = rpos["coarse"][1], rpos["fine"][1] + check(same(rc_, rf_, ("FairTen1", "AnchTen1", "Point2Fx"), 1.0e-7) and abs(rc_["Point2Fy"] - rf_["Point2Fy"]) < 0.1, + "refined: end forces as on the refined mesh (AnchTen %.6g / %.6g N, anchor Fy %.4g / %.4g N)" + % (rc_["AnchTen1"], rf_["AnchTen1"], rc_["Point2Fy"], rf_["Point2Fy"])) + # --- input checks --- cdir = root / "inputs" rc, log = run(a.exe, cdir, "badid", deck("bad id", **flat, extra="30.0 layAzimuth9\n")) @@ -642,6 +692,22 @@ 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 + 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) + txt = txt.replace("1 Coupled", "1 Turbine1").replace("2 Fixed", "2 Turbine2") + txt = txt.replace("--------------------- LINES ---", + "--------------------- TURBINES ---\nJ X0 Y0 Z0\n(-) (m) (m) (m)\n1 0 0 0\n2 300 0 0\n" + "--------------------- LINES ---") + txt = txt.replace('"Point1Fx"\n"Point1Fy"\n"Point1Fz"\n"Point2Fx"\n"Point2Fy"\n"Point2Fz"\n', "") + rc, log = run(a.exe, cdir, tag, txt) + if tag == "shared": + check(rc != 0 and "moving End B" in log, "asLaid on a line with a moving End B (shared line) is rejected") + else: + check(rc == 0, "the shared line runs with staticsFriction none (rc %d)" % rc) + print("static friction as laid: %d failure(s)" % len(FAILURES)) return 1 if FAILURES else 0