diff --git a/CHANGELOG.md b/CHANGELOG.md index 60775dd9..83ac53d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -123,8 +123,12 @@ All notable changes to CableDyn are recorded in this file. The format follows velocities, with `A`, `B`, `C` and `D` by central differences of the accelerations solved at the perturbed state. On the UMaine chains the stiffness `D - C A^-1 B` matches MoorDyn-F's to 0.1 % and the lowest nine line-mode frequencies to 0.3 %; with a lazy-wave power cable every coupled - point matches the deck's own static solutions to 3e-4, also with a hang-off spring. A cable - end connection with a numeric stiffness now linearises. The viscoelastic slow-branch stretch + point matches the deck's own static solutions to 3e-4, also with a hang-off spring. The + reduction is the static stiffness at an operating point whose coupled points do not + accelerate: the coupled load includes the line's inertia, so at the accelerating `t = 0` + platform the lazy wave's force per unit rotation reads 1.2 % off, and 2.7e-4 with the platform + DOFs disabled (`doc/openfast.rst`). A cable end connection with a numeric stiffness now + linearises. The viscoelastic slow-branch stretch and the Syrope slow strain are first-order states, so the reduction gives these ropes' relaxed static stiffness (each matches its deck's static solutions to 7e-5; held, they would read the chain 0.6 % and the polyester 2.9 times too stiff). Free/Connect points, a `Rigid` cable end @@ -357,6 +361,68 @@ All notable changes to CableDyn are recorded in this file. The format follows a pinned arm rod numbered 1, its tether on an explicit `Rod1B` POINT listed first, now writes the outputs of the same deck with the arm as rod 3 bit for bit; before, the arm turned 172 deg in pitch, the body 1.06 deg, and a leg tension moved 3.0 kN in 1 s. +- The static start of a neutral finite-EI line whose length equals its span (straight at zero + strain, so with neither weight nor tension) failed with neutral `ATTACHMENTS` or with + attachments that only carry a drag area: the attachment polish stalled at the round-off of the + axial forces, 7.6e-8 N, against a tolerance of 1e-8 times the solver's 1 N force floor, at + every load step. For a line whose chord is at least its length the force scale of the + convergence test now includes that round-off floor over the tolerance + (`16 eps max(EA/L0) |x| / tol`, as on the `EI = 0` path), so these lines start straight and + unloaded, also between two moving ends, restrained in torsion at one or both ends, and with a + chord 1e-8 longer than the line (its 0.1 N tension to 2.2e-7 N); slack lines and lines that + carry weight or tension above the floor are unchanged. +- The Newton tangent of the finite-EI static solve in a depth-profile current or a current grid + carries the current's gradient: the drag samples the current at the node positions, so it moves + with them. The drag part of the tangent now matches central differences of the residual to + 8e-10 (before off by 5e-2 to 0.2 in sheared profiles). Newton takes up to a third fewer + iterations on a light cable in a strong shear (16 instead of 23); the equilibria are unchanged + within the solver tolerance. +- The static start of an `EI = 0` line held above the still-water level kept the buoyancy of its + dry part, while the march (with `WtrDpth` or a bathymetry) gives that part its dry weight. The + start was not the march's equilibrium: a chain hung from 5 m above the surface onto the + seabed moved by 1e-3 of its fairlead load in the first step, and the coupled start differed + from the standalone one by 2.4e-4. The static solve now carries the dry weight (a fixed point + on the wetted lengths): the start holds to 1e-10, the two routes agree to 1.4e-8, and a + vertical chain's end loads sum to its weight to 1.5e-8 (before 1.4 % low). The force balance + of `Connect` and `Free` points and free bodies and rods takes the same dry weight: a 50 t + `Connect` point hung by two chains from 10 m above the surface holds its position to the + output's 8 digits over 2 s (before it sank 1.1e-2 m). There a finite-EI line, carried without + its bending stiffness, takes its dry weight with or without a seabed, as its cubic-Hermite + cable does: a stiff body with a light cable pinned 5 m above the surface on a deck without a + seabed holds its heave to 7e-6 m over 3 s (before it moved 2.8e-3 m), and an `EI = 0` chain + between that body 5 m above the surface and a `Connect` clump holds both to the output's 8 + digits (before 5.5e-3 m). Lines below the surface are unchanged. +- `ATTACHMENTS` above the still-water level kept their buoyancy in the static start of a + finite-EI line, while the march loads them with their weight alone. A 500 kg, 0.2 m^3 module + 3 m above the surface on a cable hung from 5 m above it moved the fairlead load by up to + 6.1 % in the first second, and as much on the same cable restrained in torsion. The + attachment polish and the torsion stage after it now give each attachment the load of its side + of the surface (a fixed point that repeats the solve until none changes side); both starts + hold to the output's 8 digits. An attachment that its weight in air takes below the surface + and its weight in water above it (a net-buoyant module that would float) has no static + position and fails closed, naming the attachment that crossed the surface. +- A bending-pinned finite-EI line with `ATTACHMENTS` from a Rigid6 body or a rod end left its + attachments out of the body static balance, which carries such a line as a cable without + bending stiffness: on a moored body with a 2 t clump 50 m along a pinned cable the body started + at the pose of the line without the clump and drifted by up to 2.9e-2 m and 0.20 deg in 5 s. + Such a line now takes the static passes of a connected end, which balance the body on the + cubic-Hermite cable's end loads; the body holds its pose to the output's 8 digits. Their + passes are Anderson-mixed, as those of a line between two objects, and the core cable of the + passes carries the line's `ATTACHMENTS` smeared, so the passes correct only the lumped, + side-of-the-surface and bending differences: on a free spar rod with a 1500 kg clump on a cable + pinned at its upper end the plain passes on a core cable without the clump diverged (the deck + stopped), and Anderson-mixed ones converged in 26 passes or stopped by round-off (a 1-ulp + change of an anchor coordinate; the Linux build stopped). They now converge in 6, the same + for those 1-ulp changes, and the rod holds its pose to 8 digits. The mixing drops history + columns that add less than 1e-6 of a new direction (1e-10 before), which had let round-off + columns drive the mixed loads to 1e6 N. Across a sweep of the rod deck (clump 0 to 4 t, cable + 50 to 70 m, rod mass, clump position, start offsets, 1-ulp changes) 42 of 45 decks converge + (34 before), the three left with no stable equilibrium found on either core cable. +- A bending-pinned finite-EI line on a Rigid6 body or a rod end without `ATTACHMENTS` was left to + the body static solve's cable without bending stiffness, whose end force lacks the bending's + share: a free spar rod with a 55 m pinned cable (EI 2e4 N m^2) started 5.7e-2 m off its + equilibrium, drifted 7e-2 m in 3 s and moved a leg tension by 2.3 %. Such a line now takes the + static passes too (4 here); the rod holds its pose to the output's 8 digits. - In OpenFAST, Free Rigid6 bodies and Free, Pinned and CoupledPinned rods started their first step from zero acceleration: the module restores its state mirror after the output call at `t = 0`, which marked the objects' accelerations as committed before the start accelerations diff --git a/CMakeLists.txt b/CMakeLists.txt index d414303a..87526527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -663,6 +663,13 @@ target_link_libraries(test_hermite_cable_static PRIVATE cabledyn_core) add_test(NAME hermite_cable_static COMMAND test_hermite_cable_static) set_tests_properties(hermite_cable_static PROPERTIES LABELS "fortran;unit;static") +# Finite-EI static tangent of a depth-profile current: the profile's vertical gradient in the drag +# tangent, against central differences of the residual +add_executable(test_hermite_static_current_gradient tests/test_hermite_static_current_gradient.f90) +target_link_libraries(test_hermite_static_current_gradient PRIVATE cabledyn_core) +add_test(NAME hermite_static_current_gradient COMMAND test_hermite_static_current_gradient) +set_tests_properties(hermite_static_current_gradient PROPERTIES LABELS "fortran;unit;static;hermite") + # Finite-EI mesh-resolution diagnosis: h*kappa peak / curvature-jump / contact-island metrics # and the power-of-two refinement recommendation -- the preflight trigger for the adaptive mesh # policy. Synthetic controlled profiles + fail-closed validation. @@ -1201,6 +1208,10 @@ target_link_libraries(test_flagship_compression_note PRIVATE cabledyn_core) add_test(NAME flagship_compression_note COMMAND test_flagship_compression_note ${CMAKE_SOURCE_DIR}/examples/iea15mw_umaine_mixed_cabledyn.dat) set_tests_properties(flagship_compression_note PROPERTIES LABELS "fortran;integration;static;contact") +add_executable(test_static_dry_weight tests/test_static_dry_weight.f90) +target_link_libraries(test_static_dry_weight PRIVATE cabledyn_core) +add_test(NAME static_dry_weight COMMAND test_static_dry_weight WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) +set_tests_properties(static_dry_weight PROPERTIES LABELS "fortran;integration;static;openfast") add_executable(test_viv_kernels tests/test_viv_kernels.f90) target_link_libraries(test_viv_kernels PRIVATE cabledyn_core) diff --git a/VALIDATION.md b/VALIDATION.md index c6c0594e..f0ce65de 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -392,6 +392,23 @@ scripts, results, and source provenance are in lazy-wave power cable (positions and tangents of its free nodes, and their rates). Every coupled point's linearised stiffness equals central differences of the deck's own static solutions to ≤3.3e-4, the cable's 36.0 / 2.62 / 38.5 N/m included, and also with a 5e4 N·m/rad hang-off spring. + With that spring, the t = 0 linearisation's force per unit rotation reads 1.2 % below the static + solutions out of plane (Fy per x-rotation 2.583 against 2.614 N/rad). In plane it is 0.08 % and + 0.32 % off (Fx and Fz per y-rotation). The cause is the operating point, not the `.lin` + matrices. A probe that differentiates the core's acceleration recompute as `lin_eval` does + reproduces `A`, `B`, `C` and `D` to 1e-8. The platform starts out of balance, so at t = 0 the + fairlead accelerates at (−0.019, 0, −0.016) m/s². The cable's coupled load is its support + reaction, which includes the inertia `−M(q) a` of the line, and turning the end tangent changes + that reaction while the fairlead accelerates. With this acceleration prescribed, the probe + reproduces the rotation columns to 2e-5 (2.5826 N/rad). With the platform DOFs disabled in + ElastoDyn, the coupled point does not accelerate. The OpenFAST reduction is then symmetric, + and it matches the static solutions, Richardson-extrapolated over 0.125° and 0.25° rotations, + in plane to 1.1e-5 (Fx per y-rotation 33.8954 / 33.8952 N/rad) and out of plane to 2.7e-4 + (2.6149 / 2.6142 N/rad). The out-of-plane residue is the O(h²) truncation of the 1 µm state + step on the soft sideways mode of the frictionless laid tail. In the probe it falls to 2.6e-5 + at a 0.3 µm step and grows to 2.9e-2 at 10 µm, and the sway translation column shows the same + residue. The moments per unit translation carry no inertia, so they match the static solutions + at either operating point. Two step sizes had to be small. A millimetre position step lifted the cable's grounded nodes out of their 0.3 mm seabed penetration on one side of the difference, and a 5 cm coupled-point step slackened the chain's last element. Each halved a stiffness (the cable's sway stiffness read 242 diff --git a/doc/driver_format.md b/doc/driver_format.md index 7cd9dc7d..ed01706b 100644 --- a/doc/driver_format.md +++ b/doc/driver_format.md @@ -421,9 +421,12 @@ connection moment at every connected end, and at both ends of a cable between tw Static initial condition: the static solve moves the free bodies, the free rods, the pinned rods (two rotations about the pin, the pin force on the parent body) and the `Free`/`Connect` points -together. A finite-EI line enters it with its axial stiffness and weight, without its bending -stiffness (a note names the line); its own shape is then solved with the bending stiffness at -the equilibrium end positions. +together. A finite-EI line enters it with its axial stiffness and weight (its part above the +surface with its dry weight), without its bending stiffness (a note names the line); its own +shape is then solved with the bending stiffness at the equilibrium end positions. A line +connected (clamped, elastic or restrained in torsion) at a body or rod end, a line between two +objects, and a bending-pinned line on a Rigid6 body or a rod end are balanced on their +cubic-Hermite end loads in static passes. **OpenFAST `CompMooring = 5` (aggregate route):** finite-EI cables run on the cubic-Hermite path: lazy-wave statics and generalised-α dynamics driven by the coupled fairlead, including platform @@ -1027,12 +1030,13 @@ Behaviour: A deck current (a `current` row, uniform or profile, or a MoorDyn-C `Currents` field at `t = 0`, sampled at the attachment node) loads the attachments in the static initial condition with the same drag law at rest, so a run in a current starts in equilibrium. - An attachment above the free surface carries its weight only. Attachments have no seabed - contact of their own; the node's contact acts on the line. + An attachment above the free surface carries its weight only, in the static initial condition + too. Attachments have no seabed contact of their own; the node's contact acts on the line. - The static equilibrium is solved first with each attachment's net weight spread over the two elements at its node, then carried to the discrete loads by continuation. The current drag - depends on the node's position and line direction, so the final solve is repeated until the - node positions change by less than 1e-9 m. On a line restrained in torsion the torsion stage + depends on the node's position and line direction, and the weight on the side of the surface + an attachment is on, so the final solve is repeated until the node positions change by less + than 1e-9 m and no attachment changes side. On a line restrained in torsion the torsion stage (the imposed twist) follows on the discrete equilibrium, with the attachments' net weights and drag as nodal loads (the drag again to a fixed point), so a run starts in the twisted equilibrium. An attachment adds no polar inertia to the line's twist. diff --git a/doc/openfast.rst b/doc/openfast.rst index a2b56410..c8259a5d 100644 --- a/doc/openfast.rst +++ b/doc/openfast.rst @@ -484,8 +484,20 @@ turn of an end frame or connection direction is nonlinear); a run without linear operating point, such as the still-water start, they lie on the linearised surface, while at a moving one the accelerations and the end-frame rates of the last step enter them. -The zero-frequency reduction ``D − C A⁻¹ B`` is the static mooring stiffness. It agrees with -MoorDyn-F and with CableDyn's own static solutions (:doc:`validation`). Quadratic drag has no +The zero-frequency reduction ``D − C A⁻¹ B`` is the static mooring stiffness at an operating point +whose coupled points do not accelerate. It agrees with MoorDyn-F and with CableDyn's own static +solutions (:doc:`validation`). A cable's coupled load is its support reaction, which includes the +inertia ``−M(q) a`` of the line, and the mass moves with the configuration: the added mass turns +with each element, and the end tangent's mass couples to the fairlead. At a coupled-point +acceleration ``a`` the force rows therefore also carry the configuration derivative of that +inertial reaction. The rotation columns, which turn the end tangent, show it most. An OpenFAST run +generally starts out of balance, so its platform accelerates at ``t = 0``. On the lazy-wave cable of +the mixed example, held by a 5e4 N·m/rad hang-off spring, a fairlead acceleration of 0.025 m/s² +moves the force per unit rotation by 1.2 % out of plane and by 0.08–0.32 % in plane. The translation +columns and the moments per unit translation stay within 3e-4 of the static solutions. At zero +acceleration the rotation columns match them too, to 2.7e-4 out of plane and 1.1e-5 in plane. +Compare a reduction with static solutions only at an operating point whose coupled points do not +accelerate, for example with the platform degrees of freedom disabled. Quadratic drag has no slope at rest, so the 0.1 m/s step gives its equivalent linear damping at that velocity amplitude. CableDyn integrates the drag over the element, and a one-node step then gives about half of MoorDyn-F's lumped value. diff --git a/doc/theory.rst b/doc/theory.rst index 2bc324c6..9be55fbb 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -545,6 +545,34 @@ order, End B, and :math:`\Phi` at End A), so a turn of the frame enters the end reference twist through the same solid angles. A turn of an end frame by more than :math:`\pi/2` about the line within one step is refused, and the step is cut. +The held end section turns with its frame. Its spin about the tangent, relative to the +time-parallel reference, is the frame's angular velocity projected by the derivative of the end +element's reference twist with respect to the frame's rotation. Its polar inertia (half the end +element's) carries the kinetic energy of that spin and loads the frame through the reaction +moment. A bending-pinned or elastic end lets the end tangent :math:`\mathbf{t}` move off the +director :math:`\mathbf{d}`, and the section's director, the frame's normal carried by the +smallest rotation :math:`G(\mathbf{d} \to \mathbf{t})`, then spins about :math:`\mathbf{t}` as +well: + +.. math:: + + c = \frac{(\mathbf{t} \times \mathbf{d})\cdot\dot{\mathbf{t}}}{1 + \mathbf{d}\cdot\mathbf{t}}, + \qquad \lvert c\rvert \le \tan\tfrac{\theta}{2}\,\lvert\dot{\mathbf{t}}\rvert , + +with :math:`\theta` the end bend angle. The model leaves this carry spin out of the kinetic +energy, out of the line's equations of motion and out of the reaction moment alike, so the +three stay consistent: with the end frames held, the energy without the carry spin keeps the +same band at a polar inertia of 0.02 and of 1 kg m. Including the spin would give the end tangent +a configuration-dependent rank-one polar mass :math:`I\,\nabla c\,\nabla c^{\mathsf T}` with its +gyroscopic velocity terms. Its kinetic energy :math:`\tfrac12 I c^2` is of order +:math:`(d^2/2l^2)\tan^2(\theta/2)` of the end element's translational kinetic energy (section +diameter :math:`d`, element length :math:`l`). The test suite measures it on a 10 m line pinned +in bending and rigid in torsion at both ends, twisted by 4 rad and swinging with a 13° end bend +angle: 6e-8 of the peak kinetic energy at :math:`I_{rn} = 0.02` kg m and 4e-6 at an extreme +1 kg m, against the step's own energy band of 6e-3 at :math:`\rho_\infty = 1`. The modal analysis +and the OpenFAST linearisation take the same lumped polar mass on the angles, with a held end's +angle not a coordinate, so they leave the carry spin out too. + .. _theory-free-end: **A free end.** A line restrained in torsion at one end only has its other end free to twist: @@ -1520,6 +1548,22 @@ beyond a :math:`10^{-6}` relative round-off band; a slack element reports zero t A line with no admissible equilibrium fails closed, naming the line, the seeds and stages tried, and the reason. +With a seabed (``WtrDpth`` or a bathymetry) the march gives the part of a line above the +still-water level its dry weight, through the recovery load of *Buoyancy and wetting* above, and +the static start does the same. The recovery depends on the wetted lengths, so the line is +solved again with the recovery of the last solution as a constant load until its nodes move by +less than :math:`10^{-9}` m. This fixed point contracts at the ratio of the recovery's stiffness +:math:`\rho g A/\sin\theta` (:math:`\theta` the inclination at the surface) to the line's own, +a few :math:`10^{-3}` for a hanging chain. A chain hung from 5 m above the surface then starts in +the equilibrium its march holds, and the coupled and standalone starts agree; with its buoyancy +kept above the surface it moved by :math:`10^{-3}` of its fairlead load in the first step. A line +wholly below the surface has no recovery and is solved once. Without a seabed the march, and so +the static start, keeps the buoyancy everywhere (the driver warns about a line end above the +surface then). The force balance of ``Connect`` and ``Free`` points and of free bodies and rods +below takes its lines with the same dry weight, so these objects start balanced against the march +too; a finite-EI line, which enters it without its bending stiffness, takes its dry weight there +with or without a seabed, as its cubic-Hermite cable does. + A steady current (uniform, or a depth profile sampled at each node's own elevation as in the march) enters the static equilibrium as Morison drag on the line at rest, so the out-of-plane offset is part of the initial condition. ``Connect`` and ``Free`` points are then placed at @@ -1722,7 +1766,13 @@ the current itself; the element fluid velocity is the mean of the current at its as in the dynamics). The drag follows the line and is not a potential force: it is carried along the stiffness continuation frozen at the last accepted configuration, then converged at full stiffness by a fixed-point iteration on the frozen drag and a final Newton solve with -the configuration-dependent drag and its Jacobian. If the frozen-drag continuation fails, the +the configuration-dependent drag and its Jacobian. A depth profile is sampled at the node +elevations and a current grid at the node positions, so the drag moves with the nodes through the +current too; the Jacobian carries it as the drag's derivative with respect to the fluid velocity, +:math:`-(\partial\mathbf{f}/\partial\dot{\mathbf{r}}_a + \partial\mathbf{f}/\partial +\dot{\mathbf{r}}_b)`, times the element velocity's gradient +:math:`\tfrac12\,\mathbf{R}^{\mathsf T}(\partial\mathbf{U}/\partial\mathbf{x})\,\mathbf{R}` at each +node (:math:`\mathbf{R}` the turn of the solve frame). If the frozen-drag continuation fails, the still-water equilibrium is found first and the drag is brought in by load steps. A load step that stalls hands over to a pseudo-arclength continuation in the drag fraction :math:`\lambda`: each corrector solves the bordered system @@ -1805,7 +1855,15 @@ The fallback and the dynamic Hermite path use fallback hierarchies are tried before a direct cold solve; every attempt uses the same physical inputs and tolerance; - a **dimensionless per-DOF residual norm**, with tangent-DOF residuals divided by the nodal - tributary length. + tributary length. The force scale is the largest of 1 N, the line's weight, the applied nodal + loads, and, for a line held at both ends whose chord is at least its length, the tension the + chord implies and the round-off floor of the axial forces over the tolerance, + :math:`16\,\epsilon\,\max(EA/L_0)\max(\lvert x\rvert, L_0)/\text{tol}` with + :math:`\lvert x\rvert` the largest coordinate (the floor of the ``EI = 0`` path). A neutral line + of the length of its span, straight at zero strain, carries neither weight nor tension, and + without the floor its residual could not meet the tolerance: its attachment polish stalled at + 7.6e-8 N against :math:`10^{-8}` N. A slack weightless line keeps its scale, so its round-off + stall on the straight compressed strut fails over to the weight continuation above. The static tolerance is :math:`\min(10^{-6},\ \text{tol}_\text{dyn})`, where :math:`\text{tol}_\text{dyn}` is the dynamic Newton tolerance, so the dynamics start from an @@ -2719,7 +2777,19 @@ whose frame rolls with it. The static solve carries the cable first without bending; passes then add the difference between the cubic-Hermite cable's end force and that surrogate, and the Hermite connection moment, at the previous pass's pose, until these loads change by less than :math:`10^{-7}` of the force scale. At the -fixed point the object balances the Hermite cable exactly. +fixed point the object balances the Hermite cable exactly. A bending-pinned end carries no +moment, but the surrogate gives its end force without the share of the bending, which on a soft +object is not small (a free spar rod with a pinned 55 m cable of :math:`EI = 2\times10^4` N m\ :sup:`2` +started 5.7 cm off its equilibrium), and with the line's ``ATTACHMENTS`` only smeared: on a +Rigid6 body or a rod end such a line takes the passes too, Anderson-mixed. The surrogate carries +the attachments' net weight smeared over the elements beside their nodes, as the smeared start of +the Hermite statics, so the passes correct only the lumped, side-of-the-surface, drag and bending +differences; a surrogate without them left the passes a heavy clump's whole load, whose change +with the object's pose its end stiffness did not see, and the passes converged or stopped by +round-off. Should the passes fail on that surrogate, they are repeated once on the surrogate +without the attachments. The mixing drops history columns that add less than :math:`10^{-6}` of +a new direction, which keeps its least-squares fit well conditioned when the residuals span fewer +directions than the history. **End connections (Hermite lines).** A line end may carry an isotropic rotational spring with potential :math:`U = \tfrac{1}{2}k\,\theta^2`, where :math:`\theta` is the angle between the end @@ -2799,10 +2869,17 @@ with the fluid velocity :math:`\mathbf{u}` and acceleration :math:`\dot{\mathbf{ the relative velocity :math:`\mathbf{w} = \mathbf{u} - \dot{\mathbf{r}}_j` split normal and along the nodal tangent :math:`\mathbf{m}_j/\lvert\mathbf{m}_j\rvert` (the line's Morison law with :math:`C_dA = C_{d,n} d` and :math:`C_dA_x = \pi C_{d,t} d`). The drag enters the velocity tangent -and, through :math:`\mathbf{m}_j`, the position tangent exactly. The statics start from the +and, through :math:`\mathbf{m}_j`, the position tangent exactly. Above the free surface an +attachment carries its weight :math:`-m g\,\mathbf{e}_z` alone. The statics start from the equilibrium with the net weight smeared over the node's two elements and continue to the lumped -load in warm-started Newton solves; in a deck current the drag at rest is added and the final -solve is repeated with the drag of its own solution until the nodes stop moving. The load moves +load in warm-started Newton solves; in a deck current the drag at rest is added, each solve takes +every attachment's load on the side of the still-water level its node is on, and the final +solve is repeated with the loads of its own solution until the nodes stop moving and no +attachment changes side (an attachment that its weight in air takes below the surface and its +weight in water above it has no static position, and the solve fails closed, naming the +attachment that crossed the surface). Before, an attachment above the surface +kept its buoyancy in the statics: a 500 kg, 0.2 m\ :sup:`3` module 3 m above it moved the +fairlead load by up to 6.1 % in the first second of the march. The load moves in eighths; a step whose damped Newton solve does not converge is repeated from the last converged state with pseudo-transient continuation and then with a residual-merit line search, and is halved (down to 1/1024) when neither converges. A halved step doubles again (up to 1/8) diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index 36aee8f9..8c590c8b 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -624,6 +624,13 @@ but a few geometries are genuinely hard: reported in the note ``... was reached after a failed Newton solve ... and passed the acceptance checks of the smeared state``. Check that the deck with the modules replaced by the equivalent smeared buoyancy section solves; if it does, the discrete layout itself is the difficulty. + ``... attachment of the line (Mass ..., Volume ...) crossed the still-water level ...`` + means the solves carried that attachment across the surface, where the dynamics drops its + buoyancy: its weight in air takes it below the surface and its weight in water above it, so a + point attachment has no static position there (the dynamics would bob it there). It is a + net-buoyant module that would float, or a module whose node lies nearer the surface than the + deflection its buoyancy gives the line. The message of the failed solve follows it. Move it + along the line or change its ``Mass`` or ``Volume``. - **A cold start at full load.** The static solve continues the load in stages; if you have hand-tuned a case into a bad basin, remove the tuning and let the default continuation run from the catenary/arch seed. diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index 24401cab..2141712b 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -37,7 +37,7 @@ MODULE CableDyn_DeckDriver CD_Assemble_Cable_Tangent_Force_Banded_Free USE CableDyn_Static, ONLY: CableSolverConfig, CableCurrentLoad, CD_StaticLineReport, CD_Static_Line_Equilibrium, & CD_Static_Line_End_Forces, CD_Static_Anchor_Seabed_Tolerance, CD_Static_Cable_Solve, & - CD_STATIC_OK, CD_STATIC_BADINPUT, & + CD_Static_Line_Dry_Load, CD_STATIC_OK, CD_STATIC_BADINPUT, & CD_STATIC_FRICTION_AS_LAID, CD_STATIC_FRICTION_NONE USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Init_Bathymetry, CD_End_Bathymetry, & CD_Bathymetry_Is_Initialized, CD_Bathymetry_Floor, & @@ -3440,32 +3440,37 @@ END SUBROUTINE torsion_note SUBROUTINE torsion_after_attachments(est, emt) !! The torsion stage of a line with ATTACHMENTS, on its discrete equilibrium (after the - !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes and, - !! in a deck current, their drag at the twisted state as nodal loads. The drag depends on - !! the node's position and line tangent, so the stage is repeated, each time a fresh torsion - !! solve from the last state, with the drag of the last solution until the solution stops - !! moving (fixed point, as in attachment_static_polish). + !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes (-m g + !! e_z above the still-water level, attachment_static_weight) and, in a deck current, their + !! drag at the twisted state as nodal loads. The drag depends on the node's position and + !! line tangent, and the weight on the side of the surface, so the stage is repeated, each + !! time a fresh torsion solve from the last state, with the loads of the last solution until + !! the solution stops moving and no attachment changes side (fixed point, as in + !! attachment_static_polish). INTEGER, INTENT(OUT) :: est CHARACTER(*), INTENT(OUT) :: emt INTEGER, PARAMETER :: MAX_FIXED_POINT = 60 REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), q_prev(:), q_polished(:) + LOGICAL, ALLOCATABLE :: att_dry(:), att_dry_now(:) LOGICAL :: has_drag - INTEGER :: k, fp + INTEGER :: fp, k_cross + ! the first attachment a pass moved across the still-water level, which names a failure of + ! the stage after it (as in attachment_static_polish) + CHARACTER(512) :: cause + CHARACTER(64) :: mv est = CD_DECKDRV_OK + k_cross = 0 + cause = '' emt = '' ! every pass starts from the polished, untwisted discrete state (a pass from the last twisted ! state would first relax it, and a writhe a buckling descent left could put Theta_0 a turn ! away, on another branch) q_polished = q_static - ALLOCATE (f_att(SIZE(q_static)), f_drag(SIZE(q_static))) - f_att = CD_ZERO - DO k = 1, SIZE(att_node) - f_att(6*(att_node(k) - 1) + 3) = f_att(6*(att_node(k) - 1) + 3) - & - (ln%att(2, k) - opts%rhoW*ln%att(3, k))*opts%g - END DO + ALLOCATE (f_att(SIZE(q_static)), f_drag(SIZE(q_static)), att_dry(SIZE(att_node)), att_dry_now(SIZE(att_node))) has_drag = opts%has_current .AND. ANY(ln%att(4, :) > CD_ZERO .OR. ln%att(6, :) > CD_ZERO) DO fp = 1, MAX_FIXED_POINT + CALL attachment_static_weight(q_static, att_node, ln%att, opts, f_att, att_dry) f_drag = CD_ZERO IF (has_drag) THEN CALL attachment_static_drag(q_static, att_node, ln%att, opts, frame_cs, f_drag, est, emt) @@ -3477,13 +3482,35 @@ SUBROUTINE torsion_after_attachments(est, emt) q_prev = q_static q_static = q_polished CALL torsion_stage(est, emt, f_att + f_drag) - IF (est /= CD_DECKDRV_OK) RETURN + IF (est /= CD_DECKDRV_OK) THEN + IF (k_cross > 0) emt = TRIM(cause)//'; '//TRIM(emt) + RETURN + END IF + ! an attachment the twist moved across the still-water level: once more, with its weight on + ! its new side + CALL attachment_static_weight(q_static, att_node, ln%att, opts, f_att, att_dry_now) + IF (.NOT. ALL(att_dry_now .EQV. att_dry)) THEN + IF (k_cross == 0) THEN + k_cross = FINDLOC(att_dry_now .NEQV. att_dry, .TRUE., DIM=1) + WRITE (mv, '(ES9.3,A,ES9.3)') ln%att(2, k_cross), ' kg, Volume ', ln%att(3, k_cross) + cause = 'finite-EI torsion static solve with discrete ATTACHMENTS: attachment '// & + TRIM(int_to_str(k_cross))//' of the line (Mass '//TRIM(ADJUSTL(mv))//' m^3) crossed the '// & + 'still-water level, where the dynamics drops its buoyancy; a point attachment that its weight '// & + 'in air takes below the surface and its weight in water above it has no static position (move '// & + 'it along the line or change its Mass or Volume)' + END IF + CYCLE + END IF IF (.NOT. has_drag) RETURN IF (MAXVAL(ABS(q_static - q_prev)) <= FIXED_POINT_TOL) RETURN END DO est = CD_DECKDRV_SOLVEFAIL - emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment current drag did not '// & - 'settle to a fixed point' + IF (ALL(att_dry_now .EQV. att_dry)) THEN + emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment current drag did not '// & + 'settle to a fixed point' + ELSE + emt = cause + END IF END SUBROUTINE torsion_after_attachments SUBROUTINE twisted_attachment_checks(est, emt) @@ -5121,11 +5148,14 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att opts, tol, ErrStat, ErrMsg, bathymetry, cur_obj, fell_back) !! Homotopy from the smeared-attachment equilibrium q to the discrete one: in warm-started !! Newton solves the element weights move from w_smear to w_bare while the lumped nodal - !! forces -(m - rho V) g e_z and, in a deck current, the attachment current drag grow from + !! forces -(m - rho V) g e_z (-m g e_z for an attachment above the still-water level, + !! attachment_static_weight) and, in a deck current, the attachment current drag grow from !! zero to full, with the contact, dry-buoyancy, end-connection and line current terms of !! the builder's static problem. The drag depends on the node's position (profile current, - !! current grid) and line tangent, so the full-load solve is repeated with the drag of the - !! last solution until the solution stops moving (fixed point). + !! current grid) and line tangent, and the weight on the side of the surface the node is on, + !! so each solve takes them at its incoming state and the full-load solve is repeated with + !! those of the last solution until the solution stops moving and no attachment changes + !! side (fixed point). !! !! The load fraction advances in steps of 1/NSTEP. A step whose damped Newton solve does !! not converge is repeated from the last converged state with pseudo-transient @@ -5169,8 +5199,14 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), dry(:), knnode(:), wl(:), q_out(:), curv(:) REAL(wp) :: lam, lam_done, dlam, res, change - INTEGER :: i, k, ne, fp, n_failed, n_ok, grow_after + INTEGER :: i, ne, fp, n_failed, n_ok, grow_after LOGICAL :: has_drag, converged, newton_failed, grown + ! which attachments are above the still-water level: in the state the last solve took its + ! loads at, and in the state it returned + LOGICAL, ALLOCATABLE :: att_dry(:), att_dry_now(:) + ! the first attachment a solve moved across the still-water level (0: none), which names a + ! failure of the polish after it + INTEGER :: k_cross ! The damped Newton failure of the first failed solve, and of the last one. CHARACTER(1024) :: first_msg, last_msg CHARACTER(48) :: step_buf, lam_buf @@ -5183,10 +5219,9 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att n_failed = 0 ne = SIZE(l0) ALLOCATE (f_att(6*(ne + 1)), f_drag(6*(ne + 1)), dry(ne), q_out(SIZE(q)), curv(ne + 1)) - f_att = CD_ZERO - DO k = 1, SIZE(node) - f_att(6*(node(k) - 1) + 3) = f_att(6*(node(k) - 1) + 3) - (att(2, k) - opts%rhoW*att(3, k))*opts%g - END DO + ALLOCATE (att_dry(SIZE(node)), att_dry_now(SIZE(node))) + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry) + k_cross = 0 has_drag = opts%has_current .AND. ANY(att(4, :) > CD_ZERO .OR. att(6, :) > CD_ZERO) dry = opts%rhoW*opts%g*QUARTER_PI*diam**2 IF (contact_enabled) THEN @@ -5228,30 +5263,67 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att WRITE (lam_buf, '(F8.6)') lam_done IF (dlam < MIN_STEP) THEN WRITE (step_buf, '(ES9.2)') MIN_STEP - CALL fail_solve(ErrStat, ErrMsg, TRIM(first_msg)//'; the homotopy stopped at load fraction '// & - TRIM(ADJUSTL(lam_buf))//', where load steps down to '//TRIM(ADJUSTL(step_buf))// & - ' did not converge either') + CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(first_msg)//'; the homotopy stopped at '// & + 'load fraction '//TRIM(ADJUSTL(lam_buf))//', where load steps down to '// & + TRIM(ADJUSTL(step_buf))//' did not converge either') ELSE WRITE (step_buf, '(I0)') MAX_FAILED_STEPS - CALL fail_solve(ErrStat, ErrMsg, TRIM(first_msg)//'; the homotopy stopped at load fraction '// & - TRIM(ADJUSTL(lam_buf))//' after '//TRIM(step_buf)//' load steps had failed') + CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(first_msg)//'; the homotopy stopped at '// & + 'load fraction '//TRIM(ADJUSTL(lam_buf))//' after '//TRIM(step_buf)// & + ' load steps had failed') END IF RETURN END IF END IF END DO - IF (.NOT. has_drag) RETURN + ! An attachment whose node the last solve moved across the still-water level was loaded with + ! the weight of the other side: the full-load solve is repeated (below) until none does. A + ! line below the surface (or wholly above it) without attachment drag is done. + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry_now) + IF (.NOT. has_drag .AND. ALL(att_dry_now .EQV. att_dry)) RETURN DO fp = 1, MAX_FIXED_POINT CALL solve_with(CD_ONE, converged, change) IF (ErrStat /= CD_DECKDRV_OK) RETURN IF (.NOT. converged) THEN - CALL fail_solve(ErrStat, ErrMsg, TRIM(last_msg)//' (attachment current drag fixed point)'); RETURN + CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(last_msg)// & + ' (attachment current drag and surface fixed point)') + RETURN END IF - IF (change <= FIXED_POINT_TOL) RETURN + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry_now) + ! the weight is constant on either side of the surface: with no attachment changing side the + ! solve took the weights of its own solution, and without drag it is the equilibrium + IF (ALL(att_dry_now .EQV. att_dry) .AND. (.NOT. has_drag .OR. change <= FIXED_POINT_TOL)) RETURN END DO - CALL fail_solve(ErrStat, ErrMsg, 'finite-EI static solve with discrete ATTACHMENTS: the attachment '// & - 'current drag did not settle to a fixed point') + IF (ALL(att_dry_now .EQV. att_dry)) THEN + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI static solve with discrete ATTACHMENTS: the attachment '// & + 'current drag did not settle to a fixed point') + ELSE + IF (k_cross == 0) k_cross = FINDLOC(att_dry_now .NEQV. att_dry, .TRUE., DIM=1) + CALL fail_solve(ErrStat, ErrMsg, surface_note('')) + END IF CONTAINS + FUNCTION surface_note(sep) RESULT(msg) + !! The cause of a failed polish in which a solve moved an attachment across the still-water + !! level (k_cross; empty without one), followed by sep: a point attachment that its weight + !! in air takes below the surface and its weight in water above it (a net-buoyant module + !! that would float, or any module whose node lies nearer the surface than the deflection + !! its buoyancy rho V g gives the line) has no static position. Without this the failure + !! read as a homotopy that stopped (a 200 kg, 2 m^3 module on a slack cable, which the + !! solves carried above and below the surface in turn). + CHARACTER(*), INTENT(IN) :: sep + CHARACTER(:), ALLOCATABLE :: msg + CHARACTER(64) :: mv + msg = '' + IF (k_cross < 1) RETURN + WRITE (mv, '(ES9.3,A,ES9.3)') att(2, k_cross), ' kg, Volume ', att(3, k_cross) + msg = 'finite-EI static solve with discrete ATTACHMENTS: attachment '//TRIM(int_to_str(k_cross))// & + ' of the line (Mass '//TRIM(ADJUSTL(mv))//' m^3) crossed the still-water level, where the '// & + 'dynamics drops its buoyancy; a point attachment that its weight in air takes below the surface '// & + 'and its weight in water above it has no static position (move it along the line or change its '// & + 'Mass or Volume)' + msg = msg//sep + END FUNCTION surface_note + SUBROUTINE solve_with(scale, ok, dq_max) !! One warm-started solve at load fraction scale, with the attachment current drag !! evaluated on the incoming state: the damped Newton iteration and, when it does not @@ -5269,6 +5341,12 @@ SUBROUTINE solve_with(scale, ok, dq_max) CHARACTER(48) :: num_buf ok = .FALSE. max_it = [MERGE(NEWTON_RETRY_ITER, 200, newton_failed), 200, 200] + ! the attachments' weights on the side of the surface of the incoming state (the first one the + ! last solve moved across the surface is recorded for the failure message) + CALL attachment_static_weight(q, node, att, opts, f_att, att_dry_now) + IF (k_cross == 0 .AND. .NOT. ALL(att_dry_now .EQV. att_dry)) & + k_cross = FINDLOC(att_dry_now .NEQV. att_dry, .TRUE., DIM=1) + att_dry = att_dry_now f_drag = CD_ZERO IF (has_drag) THEN CALL attachment_static_drag(q, node, att, opts, frame_cs, f_drag, es, em) @@ -5360,6 +5438,34 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM END DO END SUBROUTINE attachment_static_drag + SUBROUTINE attachment_static_weight(q, node, att, opts, f, dry) + !! The attachments' weight at rest as nodal loads (f, the generalized load vector of the + !! cable solve, set here): -(m - rho V) g e_z at the node of an attachment at or below the + !! still-water level and -m g e_z above it, as the dynamics loads it (attachment_residual of + !! the cubic-Hermite model: above the free surface its weight only, no buoyancy, and no drag, + !! which attachment_static_drag skips there too). Without it the static start kept the + !! buoyancy of an attachment above the surface: a 500 kg, 0.2 m^3 module 3 m above it on a + !! cable hung from 5 m above the surface moved the fairlead load by up to 6.1 % in the first + !! second. + !! dry(k): attachment k is above the surface in q. + REAL(wp), INTENT(IN) :: q(:), att(:, :) + INTEGER, INTENT(IN) :: node(:) + TYPE(DeckOptions), INTENT(IN) :: opts + REAL(wp), INTENT(OUT) :: f(:) + LOGICAL, INTENT(OUT) :: dry(:) + INTEGER :: k, base + f = CD_ZERO + DO k = 1, SIZE(node) + base = 6*(node(k) - 1) + dry(k) = q(base + 3) > CD_ZERO + IF (dry(k)) THEN + f(base + 3) = f(base + 3) - att(2, k)*opts%g + ELSE + f(base + 3) = f(base + 3) - (att(2, k) - opts%rhoW*att(3, k))*opts%g + END IF + END DO + END SUBROUTINE attachment_static_weight + PURE INTEGER FUNCTION bending_refine_scale(l0, ei, w) RESULT(scale) !! The power-of-two refinement factor (at most CD_HC_REFINE_CAP, and at most !! REFINED_MAX_ELEMENTS elements after it) that brings every element of a finite-EI mesh to @@ -11259,8 +11365,10 @@ END SUBROUTINE solve_point_equilibrium SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) !! Standard-output WARNINGS (never failures) for admissible but non-physical or - !! questionable inputs: a line end above the still-water level (the line is modelled - !! fully submerged), a line type that sinks into the penalty seabed by more than its + !! questionable inputs: an EI = 0 line end above the still-water level on a deck without a + !! seabed (the line is then modelled fully submerged; with WtrDpth or a bathymetry, and on + !! a finite-EI line, the part above the surface carries its dry weight), a line type that + !! sinks into the penalty seabed by more than its !! diameter (kBot too soft for its submerged weight), a slack anchored line that hangs !! below its anchor on a deck with no seabed (reported after the static solve by !! warn_line_below_anchor), and a line with fewer than three segments (a straight @@ -11272,14 +11380,23 @@ SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) TYPE(DeckOptions), INTENT(IN) :: opts INTEGER :: i, j, k, nseg REAL(wp) :: w, pen + LOGICAL :: dry_weight CHARACTER(32) :: b1, b2 DO i = 1, SIZE(lines) + ! the line's model carries the dry weight above the surface: a finite-EI line always, an + ! EI = 0 line with a seabed (its buoyancy recovery) + dry_weight = opts%has_wtrdpth .OR. opts%has_bathymetry_file + DO j = 1, SIZE(sections) + IF (sections(j)%line_id /= lines(i)%id) CYCLE + IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE + IF (types(sections(j)%ltype)%ei > CD_ZERO) dry_weight = .TRUE. + END DO DO k = 1, 2 IF (k == 1) j = find_point(points, lines(i)%nodeA) IF (k == 2) j = find_point(points, lines(i)%nodeB) IF (j < 1) CYCLE - IF (points(j)%pos(3) > CD_ZERO) THEN + IF (points(j)%pos(3) > CD_ZERO .AND. .NOT. dry_weight) THEN WRITE (b1, '(ES10.3)') points(j)%pos(3) WRITE (output_unit, '(A)') ' WARNING: LINE '//TRIM(int_to_str(lines(i)%id))//' end POINT '// & TRIM(int_to_str(points(j)%id))//' is above the still-water level (z = '//TRIM(ADJUSTL(b1))// & @@ -11885,6 +12002,9 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg INTEGER, ALLOCATABLE :: conn(:, :) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mpl(:), diam(:), w(:), load(:, :), f_ext(:) REAL(wp), ALLOCATABLE :: kn(:) + ! the dry part's weight (with a seabed, as the dynamic model's buoyancy recovery): the + ! waterline per node and the recovery load of the solution + REAL(wp), ALLOCATABLE :: dry_wl(:), f_dry(:) REAL(wp) :: anchor(3), fairlead(3), force_a(3), force_b(3) INTEGER :: ne, n_dof, i, j, ns, es CHARACTER(1024) :: em @@ -11998,28 +12118,43 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg cur%elem_cdn = cur%elem_cdn(ne:1:-1) cur%elem_cdt = cur%elem_cdt(ne:1:-1) END IF + ALLOCATE (f_dry(n_dof)) + f_dry = CD_ZERO IF (PRESENT(bathymetry) .OR. opts%has_wtrdpth) THEN CALL CD_Nodal_Seabed_Stiffness(opts%kbot, diam, l0, kn, es, em) IF (es /= CD_LINE_OK) THEN CALL fail(ErrStat, ErrMsg, 'seabed stiffness: '//TRIM(em)); RETURN END IF + ! the line's model has a seabed and so the buoyancy recovery of its dry part + ! (init_deck_models_from_parsed): the part above the still-water level takes its dry + ! weight here too, so that the static-only start is the dynamic route's + ALLOCATE (dry_wl(ne + 1)) + dry_wl = CD_ZERO END IF IF (PRESENT(bathymetry)) THEN IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_kn=kn, bathymetry=bathymetry, current=cur) + report, es, em, seabed_kn=kn, bathymetry=bathymetry, current=cur, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_kn=kn, bathymetry=bathymetry) + report, es, em, seabed_kn=kn, bathymetry=bathymetry, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) END IF ELSE IF (opts%has_wtrdpth) THEN IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, current=cur) + report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, current=cur, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn) + report, es, em, seabed_z_floor=-opts%wtrdpth, seabed_kn=kn, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) END IF ELSE IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & @@ -12045,6 +12180,8 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg CALL fail_solve(ErrStat, ErrMsg, 'tension recovery: '//TRIM(em)); RETURN END IF IF (PRESENT(end_ten) .OR. PRESENT(end_force)) THEN + ! the equilibrium's external load: the submerged weight and the dry part's recovery + f_ext = f_ext + f_dry IF (PRESENT(bathymetry) .AND. opts%has_current) THEN CALL CD_Static_Line_End_Forces(q, conn, l0, ea, f_ext, .TRUE., force_a, force_b, es, em, & seabed_kn=kn, bathymetry=bathymetry, current=cur) @@ -25950,7 +26087,8 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l !! = -K_c, mapped to the object unknowns through the attachment arms, plus the moment of !! the end force under a rotation of the arm. The objects' own loads (no lines, cheap) are !! differentiated by central differences. The line's steady-current drag stiffness is not in - !! K_c; the residual is exact, so it only slows convergence in a current. A line exactly at + !! K_c, nor the stiffness of its dry part's weight above the still-water level (with a seabed, + !! cached_line_solve); the residual is exact, so they only slow convergence. A line exactly at !! its slack/taut kink has no one-sided stiffness: when the analytic Newton system is !! singular or its step fails, the iteration falls back to a central-difference Jacobian of !! the full residual (warm-started line solves per column). Newton steps in a trust region @@ -26011,6 +26149,10 @@ SUBROUTINE solve_body_equilibrium_core(types, bodies, rod_types, rods, points, l INTEGER, ALLOCATABLE :: conn(:, :) REAL(wp), ALLOCATABLE :: l0(:), ea(:), w(:), f_ext(:), kn(:), q(:), s(:) REAL(wp), ALLOCATABLE :: dia(:), cdn(:), cdt(:) + ! with a seabed, the dry part's weight above the still-water level (as the dynamic model's + ! buoyancy recovery): the element diameters and the waterline per node (unallocated: the + ! line keeps its buoyancy everywhere) + REAL(wp), ALLOCATABLE :: dry_d(:), dry_wl(:) REAL(wp) :: anchor(3) = CD_ZERO, fairlead(3) = CD_ZERO REAL(wp) :: ef(3, 2) = CD_ZERO, kc(6, 6) = CD_ZERO END TYPE @@ -27154,6 +27296,18 @@ SUBROUTINE prepare_line(jl, es_out, em_out) IF (es_l /= 0) THEN CALL fail(es_out, em_out, 'submerged weight: '//TRIM(em_l)); RETURN END IF + ! A finite-EI line's ATTACHMENTS, smeared over the elements beside their nodes with their + ! net weight (m - rho V) g, as in the smeared start of its cubic-Hermite statics: the cable + ! of the body passes (solve_body_equilibrium) carries them, so their correction is only the + ! bending's share and the difference of the lumped, side-of-the-surface and drag loads. + IF (ALLOCATED(lines(jl)%att)) THEN + BLOCK + INTEGER, ALLOCATABLE :: anode(:) + REAL(wp) :: aoff + CALL attachment_nodes(lc(jl)%l0, lines(jl)%att(1, :), anode, aoff) + CALL smear_attachments(lc(jl)%w, lc(jl)%l0, anode, lines(jl)%att, opts%rhoW, opts%g) + END BLOCK + END IF DO ii = 1, ne load(:, ii) = [CD_ZERO, CD_ZERO, -lc(jl)%w(ii)] END DO @@ -27188,6 +27342,17 @@ SUBROUTINE prepare_line(jl, es_out, em_out) CALL fail(es_out, em_out, 'seabed stiffness: '//TRIM(em_l)); RETURN END IF END IF + ! The part above the still-water level takes its dry weight here, as in solve_one_line, + ! where the line's own model gives it that weight, so that the objects start balanced + ! against the loads the march applies: an EI = 0 line with a seabed (its model's buoyancy + ! recovery, init_deck_models_from_parsed) and a finite-EI line always (its cubic-Hermite + ! cable's dry buoyancy, with or without a seabed). Without a seabed this surrogate of a + ! finite-EI line kept its buoyancy above the surface, while its cable did not. + IF (PRESENT(bathymetry) .OR. opts%has_wtrdpth .OR. line_is_finite_ei(lines(jl), types, sections)) THEN + lc(jl)%dry_d = diam + ALLOCATE (lc(jl)%dry_wl(ne + 1)) + lc(jl)%dry_wl = CD_ZERO + END IF lc(jl)%ready = .TRUE. END SUBROUTINE prepare_line @@ -27204,14 +27369,14 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) CHARACTER(*), INTENT(OUT) :: em_out LOGICAL, INTENT(IN), OPTIONAL :: want_k LOGICAL, INTENT(OUT), OPTIONAL :: k_ok - TYPE(CableSolverConfig) :: cfg, cfg_w + TYPE(CableSolverConfig) :: cfg TYPE(CD_StaticLineReport) :: report TYPE(CableCurrentLoad), ALLOCATABLE :: curp - REAL(wp), ALLOCATABLE :: zf, q0(:), q(:), tq(:) + REAL(wp), ALLOCATABLE :: zf, q0(:), q(:), f_dry(:), f_prev(:), q_prev(:) REAL(wp) :: c_old(3), c_new(3), rot_w(3, 3), sc_w REAL(wp) :: anchor(3), fairlead(3), fa(3), fb(3) - INTEGER :: nn, ii, es_l, nit - LOGICAL :: conv, stalled, at_floor + INTEGER :: nn, ii, es_l, kd + LOGICAL :: conv CHARACTER(1024) :: em_l es_out = CD_DECKDRV_OK @@ -27266,37 +27431,53 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) END DO q0(1:3) = anchor q0(3*nn - 2:3*nn) = fairlead - ! (a) plain Newton with the compression-capable law, accepted when no element is - ! compressed beyond the 1e-6 round-off band (every element taut: it is then the - ! tension-only equilibrium), as the cold initializer's first stage accepts it - CALL CD_Static_Cable_Solve(q0, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., lc(jl)%f_ext, & - [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg, q, conv, stalled, at_floor, nit, & - es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & - bathymetry=bathymetry) - IF (es_l /= CD_STATIC_OK) conv = .FALSE. - IF (conv) conv = ALL(IEEE_IS_FINITE(q)) - IF (conv) THEN - ALLOCATE (tq(nn - 1)) - CALL CD_Compute_Cable_Tension(RESHAPE(q, [3, nn]), lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., tq, & - es_l, em_l) - conv = es_l == 0 - IF (conv) conv = MINVAL(tq) >= -1.0e-6_wp*MAX(MAXVAL(ABS(tq)), TINY(CD_ONE)) - END IF - IF (.NOT. conv) THEN - ! (b) the exact tension-only law (a slack run), Levenberg-Marquardt, short budget - cfg_w%max_iter = 10 - CALL CD_Static_Cable_Solve(q0, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .TRUE., lc(jl)%f_ext, & - [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg_w, q, conv, stalled, at_floor, nit, & - es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & - bathymetry=bathymetry, regularized=.TRUE.) + ALLOCATE (f_dry(3*nn)) + f_dry = CD_ZERO + CALL warm_line_solve(jl, q0, lc(jl)%f_ext, zf, curp, q, conv) + ! With the dry part's weight (a line above the still-water level), the warm solve is + ! repeated with the recovery of the last solution as a constant load until the nodes move + ! by less than 1e-9 m or the recovery changes by less than 1e-10 of the largest nodal + ! load, as CD_Static_Line_Equilibrium iterates it; f_dry is then the recovery the + ! returned shape was solved with. A line wholly below the surface is solved once. + IF (conv .AND. ALLOCATED(lc(jl)%dry_d)) THEN + CALL CD_Static_Line_Dry_Load(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%dry_wl, opts%rhoW, opts%g, lc(jl)%dry_d, & + f_dry, es_l, em_l) IF (es_l /= CD_STATIC_OK) conv = .FALSE. - IF (conv) conv = ALL(IEEE_IS_FINITE(q)) + IF (conv .AND. ANY(f_dry /= CD_ZERO)) THEN + conv = .FALSE. + DO kd = 1, 50 + q_prev = q + f_prev = f_dry + CALL warm_line_solve(jl, q_prev, lc(jl)%f_ext + f_prev, zf, curp, q, conv) + IF (.NOT. conv) EXIT + CALL CD_Static_Line_Dry_Load(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%dry_wl, opts%rhoW, opts%g, & + lc(jl)%dry_d, f_dry, es_l, em_l) + IF (es_l /= CD_STATIC_OK) THEN + conv = .FALSE. + EXIT + END IF + conv = MAXVAL(ABS(q - q_prev)) <= 1.0e-9_wp .OR. & + MAXVAL(ABS(f_dry - f_prev)) <= 1.0e-10_wp*MAXVAL(ABS(lc(jl)%f_ext)) + IF (conv) EXIT + END DO + f_dry = f_prev + END IF END IF END IF IF (.NOT. conv) THEN - CALL CD_Static_Line_Equilibrium(anchor, fairlead, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%w, & - lc(jl)%f_ext, cfg, .TRUE., q, conv, report, es_l, em_l, seabed_z_floor=zf, & - seabed_kn=lc(jl)%kn, bathymetry=bathymetry, current=curp) + IF (.NOT. ALLOCATED(f_dry)) ALLOCATE (f_dry(3*nn)) + f_dry = CD_ZERO + IF (ALLOCATED(lc(jl)%dry_d)) THEN + CALL CD_Static_Line_Equilibrium(anchor, fairlead, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%w, & + lc(jl)%f_ext, cfg, .TRUE., q, conv, report, es_l, em_l, seabed_z_floor=zf, & + seabed_kn=lc(jl)%kn, bathymetry=bathymetry, current=curp, & + dry_waterline_z=lc(jl)%dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=lc(jl)%dry_d, dry_load=f_dry) + ELSE + CALL CD_Static_Line_Equilibrium(anchor, fairlead, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%w, & + lc(jl)%f_ext, cfg, .TRUE., q, conv, report, es_l, em_l, seabed_z_floor=zf, & + seabed_kn=lc(jl)%kn, bathymetry=bathymetry, current=curp) + END IF IF (es_l /= CD_STATIC_OK) THEN CALL fail(es_out, em_out, 'static equilibrium: line '//TRIM(int_to_str(lines(jl)%id))// & ' static solve rejected the input: '//TRIM(em_l)); RETURN @@ -27308,8 +27489,9 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) RETURN END IF END IF - CALL CD_Static_Line_End_Forces(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%f_ext, .TRUE., fa, fb, es_l, & - em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, bathymetry=bathymetry, & + ! the equilibrium's external load: the submerged weight and the dry part's recovery + CALL CD_Static_Line_End_Forces(q, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, lc(jl)%f_ext + f_dry, .TRUE., fa, fb, & + es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, bathymetry=bathymetry, & current=curp) IF (es_l /= 0 .OR. .NOT. (ALL(IEEE_IS_FINITE(fa)) .AND. ALL(IEEE_IS_FINITE(fb)))) THEN CALL fail_solve(es_out, em_out, 'static equilibrium: line '//TRIM(int_to_str(lines(jl)%id))// & @@ -27329,6 +27511,49 @@ SUBROUTINE cached_line_solve(jl, pts, es_out, em_out, want_k, k_ok) END IF END SUBROUTINE cached_line_solve + SUBROUTINE warm_line_solve(jl, qs, fl, zf, curp, q, conv) + !! One warm solve of line jl from the seed qs (both ends held) under the constant load fl + !! (cached_line_solve): q the shape, conv whether it was accepted. + INTEGER, INTENT(IN) :: jl + REAL(wp), INTENT(IN) :: qs(:), fl(:) + REAL(wp), ALLOCATABLE, INTENT(IN) :: zf + TYPE(CableCurrentLoad), ALLOCATABLE, INTENT(IN) :: curp + REAL(wp), INTENT(OUT) :: q(:) + LOGICAL, INTENT(OUT) :: conv + TYPE(CableSolverConfig) :: cfg, cfg_w + REAL(wp), ALLOCATABLE :: tq(:) + INTEGER :: nn, es_l, nit + LOGICAL :: stalled, at_floor + CHARACTER(1024) :: em_l + nn = lc(jl)%nn + ! (a) plain Newton with the compression-capable law, accepted when no element is + ! compressed beyond the 1e-6 round-off band (every element taut: it is then the + ! tension-only equilibrium), as the cold initializer's first stage accepts it + CALL CD_Static_Cable_Solve(qs, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., fl, & + [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg, q, conv, stalled, at_floor, nit, & + es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & + bathymetry=bathymetry) + IF (es_l /= CD_STATIC_OK) conv = .FALSE. + IF (conv) conv = ALL(IEEE_IS_FINITE(q)) + IF (conv) THEN + ALLOCATE (tq(nn - 1)) + CALL CD_Compute_Cable_Tension(RESHAPE(q, [3, nn]), lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .FALSE., tq, & + es_l, em_l) + conv = es_l == 0 + IF (conv) conv = MINVAL(tq) >= -1.0e-6_wp*MAX(MAXVAL(ABS(tq)), TINY(CD_ONE)) + END IF + IF (.NOT. conv) THEN + ! (b) the exact tension-only law (a slack run), Levenberg-Marquardt, short budget + cfg_w%max_iter = 10 + CALL CD_Static_Cable_Solve(qs, lc(jl)%conn, lc(jl)%l0, lc(jl)%ea, .TRUE., fl, & + [1, 2, 3, 3*nn - 2, 3*nn - 1, 3*nn], cfg_w, q, conv, stalled, at_floor, nit, & + es_l, em_l, seabed_z_floor=zf, seabed_kn=lc(jl)%kn, current=curp, & + bathymetry=bathymetry, regularized=.TRUE.) + IF (es_l /= CD_STATIC_OK) conv = .FALSE. + IF (conv) conv = ALL(IEEE_IS_FINITE(q)) + END IF + END SUBROUTINE warm_line_solve + SUBROUTINE condensed_end_stiffness(jl, zf, ok) !! lc(jl)%kc: the static tangent of line jl at its stored shape condensed onto its end !! nodes, K_c = K_ee - K_ei K_ii^-1 K_ie (end 1 = node 1 = End B, end 2 = the last node = @@ -27487,7 +27712,20 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, !! the finite-EI lines whose End A is clamped (Rigid) or elastically connected to a body or a !! rod. The core solve carries a finite-EI line as a cable without bending stiffness; for a !! connected End A the bending changes the end force and adds the connection moment, which - !! the object must carry. Each pass solves the core with extra loads on the End A points: the + !! the object must carry. A bending-pinned End A carries no moment, but the core's cable gives + !! its end force without the bending's share, which on a soft object is not small (a free spar + !! rod on four taut legs with a 55 m cable, EI 2e4 N m^2, pinned at its upper end: the rod + !! started 5.7e-2 m off its equilibrium, its top drifted 7e-2 m in 3 s and a leg tension moved + !! by 2.3 %), and its ATTACHMENTS only smeared, without their lumped, side-of-the-surface and + !! drag loads (a 2 t clump 50 m along a pinned cable from a moored body, which the core's + !! cable once left out: the body started at the pose of the line without it and drifted by up + !! to 2.9e-2 m and 0.20 deg in 5 s). Such a line on a Rigid6 body or a rod end takes the passes + !! too. The core's cable carries a line's ATTACHMENTS smeared, so the passes correct only the + !! differences: without them the correction was the clump's whole load, which the core's end + !! stiffness did not see, and on a free spar rod with a 1500 kg clump the passes converged in + !! 26 or stopped, by round-off; with them in 6. Should the passes fail on that cable, they are + !! repeated once on the core cable without the ATTACHMENTS. Each pass solves the core with + !! extra loads on the End A points: the !! difference between the cubic-Hermite cable's static end force (bending, the connection !! direction turned with the object) and the core's own end force of that line, and the !! Hermite connection moment, both evaluated at the previous pass's equilibrium. The passes @@ -27507,7 +27745,8 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, !! (Anderson mixing of the last ANDERSON_DEPTH passes on the extra loads, ext_fm, a secant !! method that a pass map oscillating about its fixed point does not defeat: a stiff cable !! between two moored bodies turns them through an out-of-plane mode that the plain passes - !! overshoot); a deck without one keeps the plain passes. + !! overshoot), and so does a deck with a bending-pinned line listed for its ATTACHMENTS; a + !! deck without either keeps the plain passes. TYPE(DeckLineType), INTENT(IN) :: types(:) TYPE(DeckBody), INTENT(INOUT) :: bodies(:) TYPE(DeckRodType), INTENT(IN) :: rod_types(:) @@ -27522,7 +27761,7 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, LOGICAL, INTENT(IN), OPTIONAL :: points_only REAL(wp), INTENT(OUT), OPTIONAL :: jac_check_err INTEGER, PARAMETER :: MAX_PASS = 60, ANDERSON_DEPTH = 6 - REAL(wp), PARAMETER :: PASS_TOL = 1.0e-7_wp, PASS_TOL_TORSION = 1.0e-10_wp + REAL(wp), PARAMETER :: PASS_TOL = 1.0e-7_wp, PASS_TOL_TORSION = 1.0e-10_wp, ANDERSON_DROP = 1.0e-6_wp TYPE(DeckBody), ALLOCATABLE :: bodies0(:) TYPE(DeckRod), ALLOCATABLE :: rods0(:) TYPE(DeckPoint), ALLOCATABLE :: points0(:) @@ -27535,6 +27774,13 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, REAL(wp), ALLOCATABLE :: new_km(:, :, :), new_rot(:, :, :), fsb(:, :) INTEGER :: j, pa, e, pass, ncl, eworst, pb, ne, nb LOGICAL :: only_points, held + ! the passes are Anderson-mixed (lines between two objects, pinned lines with ATTACHMENTS) + LOGICAL :: mix + ! the lines the core solve carries (lines_core: with or without their ATTACHMENTS), the + ! attempt of the passes, and the failure of the first + TYPE(DeckLine), ALLOCATABLE :: lines_core(:) + INTEGER :: attempt, n_attempt, first_stat + CHARACTER(1024) :: first_msg REAL(wp) :: scale, change, pass_tol_eff CHARACTER(24) :: b1 @@ -27556,9 +27802,14 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, CYCLE END IF END IF - IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) CYCLE + ! a bending-pinned End A free in torsion takes the passes on a Rigid6 body or a rod end (a + ! finite-EI end on a Point3 buoy is refused by name after this solve; the passes, which turn + ! a body frame, would refuse it as a clamped end instead) pa = find_point(points, lines(j)%nodeA) IF (pa < 1) CYCLE + IF (lines(j)%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(j))) THEN + IF (point_on_point3_body(points(pa), bodies)) CYCLE + END IF IF (starts_with(TRIM(points(pa)%ptype), 'body')) THEN cl = [cl, j] ELSE IF (is_rod_point_type(points(pa)%ptype)) THEN @@ -27609,82 +27860,131 @@ SUBROUTINE solve_body_equilibrium(types, bodies, rod_types, rods, points, lines, n_and = 0 max_pass_eff = MAX_PASS IF (body_static_pass_limit > 0) max_pass_eff = body_static_pass_limit - IF (nb > 0) ALLOCATE (and_x(6*ne, ANDERSON_DEPTH + 1), and_f(6*ne, ANDERSON_DEPTH + 1)) - ext_fm = CD_ZERO - ext_km = CD_ZERO - ext_rot = CD_ZERO - DO e = 1, ne - ext_rot(1, 1, e) = CD_ONE - ext_rot(2, 2, e) = CD_ONE - ext_rot(3, 3, e) = CD_ONE - END DO - DO pass = 1, max_pass_eff - bodies = bodies0 - rods = rods0 - points = points0 - ! the torque stiffness only with torsion: without it the core's arithmetic is exactly that - ! of a deck before torsion existed (no zero-stiffness correction, signed zeros kept) - IF (pass_tol_eff < PASS_TOL) THEN - CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, & - ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, end_force_a=fs, & - quiet=pass > 1, skipped=held, ext_km=ext_km, ext_rot=ext_rot, & - end_force_b=fsb) - ELSE - CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines, sections, opts, ErrStat, & - ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, end_force_a=fs, & - quiet=pass > 1, skipped=held, end_force_b=fsb) + ! The passes of a bending-pinned line are Anderson-mixed, as those of the lines between two + ! objects: on the core cable without its ATTACHMENTS (the second attempt below) the + ! correction is the attachments' whole load, which turns with the object as the heavier or + ! lighter cable does and not as the core's, and the plain passes overshoot without bound on + ! a soft object (a free spar rod with a 1500 kg clump 25 m along a pinned cable from its upper + ! end: the end-load change grew to 2.9 of the force scale in 60 passes). + mix = nb > 0 + DO e = 1, ncl + IF (lines(cl(e))%endconn_mode(1) == CD_ENDCONN_PINNED .AND. .NOT. line_torsion_at_a(lines(cl(e)))) & + mix = .TRUE. + END DO + IF (mix) ALLOCATE (and_x(6*ne, ANDERSON_DEPTH + 1), and_f(6*ne, ANDERSON_DEPTH + 1)) + ! The core carries a finite-EI line's ATTACHMENTS smeared (prepare_line). Should the passes + ! fail on that cable (its equilibrium of the object unstable or not found, or the passes not + ! converging), they are repeated once on the core cable without them, whose correction is the + ! attachments' whole load: that solve keeps the object balanced by its lines without the + ! attachments' load, where a heavy clump on a slack cable from a free spar rod tilted the + ! rod's balance on the smeared cable past its stability test. + lines_core = lines + n_attempt = 1 + IF (ANY([(ALLOCATED(lines(eline(e))%att), e=1, ne)])) n_attempt = 2 + first_stat = CD_DECKDRV_OK + first_msg = '' + DO attempt = 1, n_attempt + IF (attempt == 2) THEN + first_stat = ErrStat + first_msg = ErrMsg + ErrStat = CD_DECKDRV_OK + ErrMsg = '' + DO j = 1, SIZE(lines_core) + IF (ALLOCATED(lines_core(j)%att)) DEALLOCATE (lines_core(j)%att) + END DO + n_and = 0 END IF - IF (ErrStat /= CD_DECKDRV_OK) RETURN - ! the objects stay at their deck poses (the core has already said why): nothing to balance - IF (held) RETURN - scale = CD_ONE - DO e = 1, ncl - IF (eb(e) > 0) THEN - CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e), new_fm(:, eb(e)), & - new_km(:, :, eb(e)), new_rot(:, :, eb(e))) + ext_fm = CD_ZERO + ext_km = CD_ZERO + ext_rot = CD_ZERO + DO e = 1, ne + ext_rot(1, 1, e) = CD_ONE + ext_rot(2, 2, e) = CD_ONE + ext_rot(3, 3, e) = CD_ONE + END DO + DO pass = 1, max_pass_eff + bodies = bodies0 + rods = rods0 + points = points0 + ! the torque stiffness only with torsion: without it the core's arithmetic is exactly that + ! of a deck before torsion existed (no zero-stiffness correction, signed zeros kept) + IF (pass_tol_eff < PASS_TOL) THEN + CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines_core, sections, opts, & + ErrStat, ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, & + end_force_a=fs, quiet=pass > 1, skipped=held, ext_km=ext_km, & + ext_rot=ext_rot, end_force_b=fsb) ELSE - CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e)) + CALL solve_body_equilibrium_core(types, bodies, rod_types, rods, points, lines_core, sections, opts, & + ErrStat, ErrMsg, bathymetry, ext_pt=ext_pt, ext_fm=ext_fm, & + end_force_a=fs, quiet=pass > 1, skipped=held, end_force_b=fsb) + END IF + IF (ErrStat /= CD_DECKDRV_OK) EXIT + ! the objects stay at their deck poses (the core has already said why): nothing to balance + IF (held) RETURN + scale = CD_ONE + DO e = 1, ncl + IF (eb(e) > 0) THEN + CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e), new_fm(:, eb(e)), & + new_km(:, :, eb(e)), new_rot(:, :, eb(e))) + ELSE + CALL hermite_end_loads(cl(e), new_fm(:, e), new_km(:, :, e), new_rot(:, :, e)) + END IF + IF (ErrStat /= CD_DECKDRV_OK) EXIT + new_fm(1:3, e) = new_fm(1:3, e) - fs(:, cl(e)) + scale = MAX(scale, NORM2(fs(:, cl(e))), NORM2(new_fm(1:3, e) + fs(:, cl(e)))) + IF (eb(e) > 0) THEN + new_fm(1:3, eb(e)) = new_fm(1:3, eb(e)) - fsb(:, cl(e)) + scale = MAX(scale, NORM2(fsb(:, cl(e))), NORM2(new_fm(1:3, eb(e)) + fsb(:, cl(e)))) + END IF + END DO + IF (ErrStat /= CD_DECKDRV_OK) EXIT + change = MAXVAL(ABS(new_fm - ext_fm)) + eworst = MAXLOC(MAXVAL(ABS(new_fm - ext_fm), DIM=1), DIM=1) + ext_km = new_km + ext_rot = new_rot + IF (change <= pass_tol_eff*scale) THEN + ext_fm = new_fm + EXIT + END IF + IF (mix) THEN + CALL anderson_next(ext_fm, new_fm) + ELSE + ext_fm = new_fm + END IF + END DO + IF (ErrStat == CD_DECKDRV_OK) THEN + IF (change <= pass_tol_eff*scale) EXIT + WRITE (b1, '(ES10.3)') change/scale + IF (nb == 0) THEN + CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the END CONNECTION or ATTACHMENTS '// & + 'of finite-EI LINE '//TRIM(int_to_str(lines(eline(eworst))%id))// & + ' did not converge after '//TRIM(int_to_str(max_pass_eff))//' passes (relative end-load '// & + 'change '//TRIM(ADJUSTL(b1))//'); OPTION bodyIC deck starts from the deck pose instead') + ELSE + ! the worst entry may be the End B of a line between two objects, connected or pinned + CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the bending end loads of finite-EI '// & + 'LINE '//TRIM(int_to_str(lines(eline(eworst))%id))//' (its End '// & + MERGE('B', 'A', eworst > ncl)//', on a body or rod) did not converge after '// & + TRIM(int_to_str(max_pass_eff))//' passes (relative end-load change '//TRIM(ADJUSTL(b1))// & + '); OPTION bodyIC deck starts from the deck pose instead') END IF - IF (ErrStat /= CD_DECKDRV_OK) RETURN - new_fm(1:3, e) = new_fm(1:3, e) - fs(:, cl(e)) - scale = MAX(scale, NORM2(fs(:, cl(e))), NORM2(new_fm(1:3, e) + fs(:, cl(e)))) - IF (eb(e) > 0) THEN - new_fm(1:3, eb(e)) = new_fm(1:3, eb(e)) - fsb(:, cl(e)) - scale = MAX(scale, NORM2(fsb(:, cl(e))), NORM2(new_fm(1:3, eb(e)) + fsb(:, cl(e)))) - END IF - END DO - change = MAXVAL(ABS(new_fm - ext_fm)) - eworst = MAXLOC(MAXVAL(ABS(new_fm - ext_fm), DIM=1), DIM=1) - ext_km = new_km - ext_rot = new_rot - IF (change <= pass_tol_eff*scale) THEN - ext_fm = new_fm - EXIT END IF - IF (nb > 0) THEN - CALL anderson_next(ext_fm, new_fm) - ELSE - ext_fm = new_fm + IF (attempt == n_attempt) THEN + ! both failed: the failure on the cable that carries the attachments + IF (attempt == 2) THEN + ErrStat = first_stat + ErrMsg = first_msg + END IF + RETURN END IF END DO - IF (change > pass_tol_eff*scale) THEN - WRITE (b1, '(ES10.3)') change/scale - IF (nb == 0) THEN - CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the clamped or elastic END '// & - 'CONNECTION of finite-EI LINE '//TRIM(int_to_str(lines(eline(eworst))%id))// & - ' did not converge after '//TRIM(int_to_str(max_pass_eff))//' passes (relative end-load '// & - 'change '//TRIM(ADJUSTL(b1))//'); OPTION bodyIC deck starts from the deck pose instead') - ELSE - ! the worst entry may be the End B of a line between two objects, connected or pinned - CALL fail_solve(ErrStat, ErrMsg, 'static body/rod equilibrium with the bending end loads of finite-EI '// & - 'LINE '//TRIM(int_to_str(lines(eline(eworst))%id))//' (its End '// & - MERGE('B', 'A', eworst > ncl)//', on a body or rod) did not converge after '// & - TRIM(int_to_str(max_pass_eff))//' passes (relative end-load change '//TRIM(ADJUSTL(b1))// & - '); OPTION bodyIC deck starts from the deck pose instead') - END IF - RETURN - END IF - IF (nb == 0) THEN + IF (nb == 0 .AND. ANY([(lines(cl(e))%endconn_mode(1) == CD_ENDCONN_PINNED .AND. & + .NOT. line_torsion_at_a(lines(cl(e))), e=1, ncl)])) THEN + ! a bending-pinned line among them (its bending share of the end force, its ATTACHMENTS) + WRITE (output_unit, '(A)') ' Initial conditions: the end loads (bending, connection moments, torsion, '// & + 'ATTACHMENTS) of '//TRIM(int_to_str(ncl))//' finite-EI line end(s) on bodies and rods balanced in '// & + TRIM(int_to_str(pass))//' static pass(es).' + ELSE IF (nb == 0) THEN WRITE (output_unit, '(A)') ' Initial conditions: the end moments and bending end forces of '// & TRIM(int_to_str(ncl))//' clamped or elastic finite-EI line end(s) balanced in '// & TRIM(int_to_str(pass))//' static pass(es).' @@ -27701,8 +28001,14 @@ SUBROUTINE anderson_next(x, g) !! loads x it was given): Anderson mixing, x+ = g - dG gamma with gamma the least-squares !! fit of the residual f = g - x by the differences of the last residuals, dF gamma ~ f !! (at most ANDERSON_DEPTH of them, the oldest dropped first). The fit is solved by - !! modified Gram-Schmidt on dF; a column that adds no new direction is dropped. A residual - !! that grows tenfold over the last one restarts the mixing from the plain pass. + !! modified Gram-Schmidt on dF; a column that adds no new direction, its part normal to the + !! kept ones below ANDERSON_DROP of its length, is dropped. A residual that grows tenfold + !! over the last one restarts the mixing from the plain pass. The drop bound keeps the fit + !! well conditioned: residuals that span fewer directions than the history (a pinned end's + !! moment rows are zero, its force acts in the line's plane) leave the later columns a + !! normal part of round-off size, and with a bound of 1e-10 their coefficients reached + !! 1e12, so the mixed loads jumped by 1e6 N and the passes converged or stopped by 1 ulp of + !! an anchor coordinate (a free spar rod with a 1500 kg clump on a pinned cable). REAL(wp), INTENT(INOUT) :: x(:, :) REAL(wp), INTENT(IN) :: g(:, :) REAL(wp) :: xv(SIZE(x)), gv(SIZE(x)), fv(SIZE(x)), q(SIZE(x), ANDERSON_DEPTH), rr(ANDERSON_DEPTH, ANDERSON_DEPTH) @@ -27739,7 +28045,7 @@ SUBROUTINE anderson_next(x, g) rr(k, kept + 1) = DOT_PRODUCT(q(:, k), dfi) dfi = dfi - rr(k, kept + 1)*q(:, k) END DO - IF (NORM2(dfi) <= 1.0e-10_wp*nrm) CYCLE + IF (NORM2(dfi) <= ANDERSON_DROP*nrm) CYCLE kept = kept + 1 rr(kept, kept) = NORM2(dfi) q(:, kept) = dfi/rr(kept, kept) diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index f4eac2af..40b1dd63 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -49,7 +49,8 @@ MODULE CableDyn_HermiteCableStatic CD_Bathymetry_Rotate_Curvature USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK USE CableDyn_Static, ONLY: CD_Static_As_Laid_Reference, CD_STATIC_OK - USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_Velocity, CD_HYDRO_OK + USE CableDyn_Hydro, ONLY: CD_Current_Profile_Velocity, CD_CurrentGridType, CD_Current_Grid_Velocity, & + CD_Current_Profile_Gradient, CD_Current_Grid_Gradient, CD_HYDRO_OK USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType, CD_HermiteTorsion_Line, CD_HermiteTorsion_Unwrap, & CD_HermiteTorsion_Coupling_Twist, & CD_HermiteTorsion_Accept, CD_HermiteTorsion_Compliance, & @@ -917,6 +918,27 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ IF (.NOT. (ANY(freemask(1:3)) .OR. ANY(freemask(6*(nn - 1) + 1:6*(nn - 1) + 3))) .AND. ALL(EA > CD_ZERO)) THEN chord = NORM2(q(6*(nn - 1) + 1:6*(nn - 1) + 3) - q(1:3)) IF (chord > SUM(l0)) fscale = MAX(fscale, (chord/SUM(l0) - CD_ONE)*SUM(l0)/SUM(l0/EA)) + ! The round-off floor of the residual itself, for a line whose chord is at least its + ! length. The axial force is formed from coordinate differences, so a nodal force carries + ! a round-off of about eps max(EA/l0) |x| (|x| the largest coordinate; the EI = 0 path's + ! floor is 16 eps max(EA/L0) max(|q|, L0)), and the residual can fall no lower. The scale + ! keeps tol x fscale at 16 times that floor. A neutral line whose length equals its span, + ! straight at zero strain, carries neither weight nor tension and otherwise met the 1 N + ! floor of the scale: under neutral attachments its polish stalled at ||R|| = 7.6e-8 N + ! against tol x 1 N = 1e-8 N (EA 1e7, 2.5 m elements, |x| = 100 m) and failed at every load + ! step. A slack line keeps its scale: a weightless one can stall at that floor on its straight + ! compressed strut, a saddle, and is solved by the weight continuation that accepts the + ! floor on its bowed equilibrium (light_line_route of the deck driver). + IF (chord >= (CD_ONE - 1.0e-9_wp)*SUM(l0) .AND. tol > CD_ZERO) THEN + BLOCK + REAL(wp) :: xmax + xmax = MAXVAL(l0) + DO i = 1, nn + xmax = MAX(xmax, MAXVAL(ABS(q(6*(i - 1) + 1:6*(i - 1) + 3)))) + END DO + fscale = MAX(fscale, 16.0_wp*EPSILON(CD_ONE)*MAXVAL(EA/l0)*xmax/tol) + END BLOCK + END IF END IF ! Buoyancy load continuation. A net-buoyant section (w < 0, e.g. a lazy-wave buoyancy @@ -2954,14 +2976,16 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, !! Steady-current drag on one element at rest: the load fd(12) (f_ext) and, when !! want_jac, its position Jacobian, both scaled by current%load_factor. The element !! fluid velocity is the mean of the current at its two nodes, rotated into the solve - !! frame. + !! frame. A depth profile is sampled at the nodes' elevations and a current grid at their + !! positions, so the current moves with them: the Jacobian carries that dependence too + !! (below). TYPE(CD_HermiteStaticCurrentType), INTENT(IN) :: current REAL(wp), INTENT(IN) :: qe(12), l0e, d, cn, ct LOGICAL, INTENT(IN) :: want_jac REAL(wp), INTENT(OUT) :: fd(12), djq(12, 12) INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp) :: ve(12), djv(12, 12), ua(3), ub(3), ug(3), ul(3) + REAL(wp) :: ve(12), djv(12, 12), ua(3), ub(3), ug(3), ul(3), ga(3, 3), gb(3, 3), dfdu(12, 3), rot(3, 3) INTEGER :: es CHARACTER(200) :: em ErrStat = CD_HCSTAT_OK @@ -3002,6 +3026,32 @@ SUBROUTINE current_element_load(current, qe, l0e, d, cn, ct, want_jac, fd, djq, IF (es /= CD_HCDYN_OK) THEN ErrStat = CD_HCSTAT_NOCONVERGE; ErrMsg = TRIM(em); RETURN END IF + IF (want_jac .AND. (ALLOCATED(current%grid) .OR. ALLOCATED(current%profile_z))) THEN + ! The current at the nodes moves with them. The element fluid velocity is + ! u = R^T (U(x_a) + U(x_b))/2, with R the turn of frame_cs (global = R solve frame, z + ! alone) and x = R (x_l + origin) the global node position (a profile reads only z), so + ! du/dx_l,a = R^T G_a R / 2 with G = dU/dx the field's gradient at the node. The drag sees + ! u - v(s), and a uniform velocity c of the element is the nodal velocity [c, 0, c, 0] + ! (its tangent rates zero: the Hermite shape functions of the two positions sum to one), + ! so d fd/du = -(djv(:, 1:3) + djv(:, 7:9)) and d fd/dx_l,a = d fd/du du/dx_l,a. Without + ! it a sheared current entered the Newton tangent as if it were uniform. + IF (ALLOCATED(current%grid)) THEN + CALL CD_Current_Grid_Gradient(current%grid, global_position(qe(1:3)), 0.0_wp, ga, es, em) + IF (es == CD_HYDRO_OK) CALL CD_Current_Grid_Gradient(current%grid, global_position(qe(7:9)), 0.0_wp, gb, & + es, em) + IF (es /= CD_HYDRO_OK) THEN + ErrStat = CD_HCSTAT_NOCONVERGE; ErrMsg = TRIM(em); RETURN + END IF + ELSE + CALL CD_Current_Profile_Gradient(qe(3), current%profile_z, current%profile_velocity, ga) + CALL CD_Current_Profile_Gradient(qe(9), current%profile_z, current%profile_velocity, gb) + END IF + rot = RESHAPE([current%frame_cs(1), current%frame_cs(2), CD_ZERO, -current%frame_cs(2), current%frame_cs(1), & + CD_ZERO, CD_ZERO, CD_ZERO, CD_ONE], [3, 3]) + dfdu = -(djv(:, 1:3) + djv(:, 7:9)) + djq(:, 1:3) = djq(:, 1:3) + 0.5_wp*MATMUL(dfdu, MATMUL(TRANSPOSE(rot), MATMUL(ga, rot))) + djq(:, 7:9) = djq(:, 7:9) + 0.5_wp*MATMUL(dfdu, MATMUL(TRANSPOSE(rot), MATMUL(gb, rot))) + END IF fd = current%load_factor*fd IF (want_jac) djq = current%load_factor*djq diff --git a/src/CableDyn_Model.f90 b/src/CableDyn_Model.f90 index 02038957..d81f086c 100644 --- a/src/CableDyn_Model.f90 +++ b/src/CableDyn_Model.f90 @@ -1563,6 +1563,9 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra INTEGER, ALLOCATABLE :: elem_conn(:, :), fixed_dofs(:) REAL(wp), ALLOCATABLE :: l0(:), ea(:), mass_per_length(:), diameter(:) REAL(wp), ALLOCATABLE :: weight(:), elem_load(:, :), f_ext(:), q_static(:), v0(:) + ! the waterline and diameters of the dry part's weight in the static start (unallocated: + ! the static start keeps the buoyancy everywhere, as a model without buoyancy recovery) + REAL(wp), ALLOCATABLE :: dry_wl(:), dry_d(:) INTEGER :: n_elem, n_dof, e, es, istat, fr_policy LOGICAL :: dyn_to, friction_static REAL(wp) :: laid_az, laid_t @@ -1713,6 +1716,23 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL fail(ErrStat, ErrMsg, 'line model lay_azimuth must be finite') RETURN END IF + ! The dynamic model's buoyancy recovery gives the part of the line above the waterline its + ! dry weight; the static start does the same (CD_Static_Line_Equilibrium), so that a line + ! held above the surface starts in the equilibrium its march holds. + IF (PRESENT(buoyancy_waterline_z) .AND. PRESENT(buoyancy_rho) .AND. PRESENT(buoyancy_gravity)) THEN + IF (SIZE(buoyancy_waterline_z) == n_dof/3) THEN + IF (PRESENT(buoyancy_diameter_elem)) THEN + IF (SIZE(buoyancy_diameter_elem) == n_elem .AND. .NOT. PRESENT(buoyancy_diameter)) THEN + dry_wl = buoyancy_waterline_z + dry_d = buoyancy_diameter_elem + END IF + ELSE IF (PRESENT(buoyancy_diameter)) THEN + dry_wl = buoyancy_waterline_z + ALLOCATE (dry_d(n_elem)) + dry_d = buoyancy_diameter + END IF + END IF + END IF friction_static = .FALSE. IF (use_seabed .AND. use_seabed_friction) friction_static = seabed_mu > CD_ZERO .AND. & fr_policy == CD_STATIC_FRICTION_AS_LAID @@ -1770,7 +1790,9 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra IF (seabed_mu > CD_ZERO) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & - seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors) + seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, dry_gravity=buoyancy_gravity, & + dry_diameter=dry_d) IF (es /= CD_STATIC_OK .OR. .NOT. converged) THEN ErrStat = CD_MODEL_SOLVEFAIL ErrMsg = 'CableDyn_Model: still-water reference of the seabed friction failed: '//TRIM(em)// & @@ -1827,11 +1849,15 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & seabed_kn=seabed_kn, bathymetry=bathymetry, current=cur, & - load_factors=load_factors) + load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, dry_gravity=buoyancy_gravity, & + dry_diameter=dry_d) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, dyn_to, & q_static, converged, report, es, em, seabed_z_floor=seabed_z_floor, & - seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors) + seabed_kn=seabed_kn, bathymetry=bathymetry, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, dry_gravity=buoyancy_gravity, & + dry_diameter=dry_d) END IF IF (es /= CD_STATIC_OK) THEN ErrStat = CD_MODEL_SOLVEFAIL @@ -1859,12 +1885,16 @@ SUBROUTINE CD_Init_Line_Model(model, anchor, fairlead, line_types, sections, gra CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, & dyn_to, q_sw, conv_sw, report_sw, es, em, & seabed_z_floor=seabed_z_floor, seabed_kn=seabed_kn, & - bathymetry=bathymetry, current=cur_sw, load_factors=load_factors) + bathymetry=bathymetry, current=cur_sw, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, & + dry_gravity=buoyancy_gravity, dry_diameter=dry_d) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, static_cfg, & dyn_to, q_sw, conv_sw, report_sw, es, em, & seabed_z_floor=seabed_z_floor, seabed_kn=seabed_kn, & - bathymetry=bathymetry, load_factors=load_factors) + bathymetry=bathymetry, load_factors=load_factors, & + dry_waterline_z=dry_wl, dry_rho=buoyancy_rho, & + dry_gravity=buoyancy_gravity, dry_diameter=dry_d) END IF IF (es == CD_STATIC_OK .AND. conv_sw) THEN IF (ALLOCATED(cur%friction_ref)) THEN diff --git a/src/CableDyn_Static.f90 b/src/CableDyn_Static.f90 index a64d2849..6fd697ba 100644 --- a/src/CableDyn_Static.f90 +++ b/src/CableDyn_Static.f90 @@ -34,7 +34,7 @@ MODULE CableDyn_Static CD_Bathymetry_Floor_Gradient, CD_BATHY_OK USE CableDyn_Hydro, ONLY: CD_Cable_Morison_Drag_Force, CD_Morison_Drag_Element_Load, CD_Current_Profile_Velocity, & CD_CurrentGridType, CD_Current_Grid_Velocity, CD_Current_Grid_Gradient, & - CD_Current_Profile_Gradient, CD_HYDRO_OK + CD_Current_Profile_Gradient, CD_Buoyancy_Recovery_Element_Force, CD_HYDRO_OK USE CableDyn_Linalg, ONLY: CD_Solve_Banded USE CableDyn_Mesh, ONLY: CD_Partition_Free_Dofs USE CableDyn_Catenary, ONLY: CD_Catenary_Seed, CD_CAT_OK @@ -48,6 +48,7 @@ MODULE CableDyn_Static PUBLIC :: CD_Static_Cable_Solve_Continuation PUBLIC :: CD_Static_Line_Equilibrium PUBLIC :: CD_Static_Line_End_Forces + PUBLIC :: CD_Static_Line_Dry_Load PUBLIC :: CD_Static_Anchor_Seabed_Tolerance PUBLIC :: CD_Static_Friction_Anchors PUBLIC :: CD_Static_As_Laid_Reference @@ -1623,9 +1624,169 @@ END FUNCTION CD_Static_Anchor_Seabed_Tolerance SUBROUTINE CD_Static_Line_Equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, cfg, tension_only, & q, converged, report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, & - bathymetry, current, load_factors) + bathymetry, current, load_factors, dry_waterline_z, dry_rho, dry_gravity, & + dry_diameter, dry_load) !! Robust static equilibrium of one EI=0 line held at both ends: the single initializer - !! shared by the static-only deck route and the dynamic-model initial condition. + !! shared by the static-only deck route and the dynamic-model initial condition (see + !! line_equilibrium for the seeds and solver stages). + !! + !! f_ext is the submerged weight, full buoyancy everywhere. With the dry-part arguments + !! (dry_waterline_z per node, dry_rho, dry_gravity, dry_diameter per element) the part of + !! the line above its waterline carries its dry weight, as in the dynamic model's buoyancy + !! recovery (CD_Buoyancy_Recovery_Element_Force): each element straddling or above the + !! waterline gives back the buoyancy -(1 - f) rho g (pi/4) d^2 l0 / 2 at each of its nodes, + !! f its submerged fraction. A line held above the surface (a fairlead on deck) then starts + !! in the equilibrium the march holds; without them its dry part kept its buoyancy, and a + !! chain hung 5 m above the surface jumped by 1e-3 of its fairlead load in the first step. + !! The recovery load depends on the wetted lengths, so the solve is repeated with the + !! recovery of the last solution as a constant load until the nodes move by less than + !! DRY_TOL or the recovery changes by less than DRY_REL of the largest nodal load, below + !! what the solver's own residual tolerance resolves (a fixed point: it contracts at the + !! ratio of the recovery's stiffness rho g A / sin(inclination) to the line's own, a few + !! 1e-3 for a hanging chain). A fully submerged + !! line has no recovery and is solved once, unchanged. A fixed point that does not settle in + !! DRY_MAX solves (a line floating at the surface, whose dry weight is its whole restoring) + !! returns converged = .FALSE. with the reason. dry_load (optional) returns the recovery + !! load at the solution, zero without the dry-part arguments: f_ext + dry_load is the + !! external load of the equilibrium (its end forces, CD_Static_Line_End_Forces). + REAL(wp), INTENT(IN) :: anchor(3), fairlead(3) + INTEGER, INTENT(IN) :: elem_conn(:, :) + REAL(wp), INTENT(IN) :: l0(:), ea(:), weight(:), f_ext(:) + TYPE(CableSolverConfig), INTENT(IN) :: cfg + LOGICAL, INTENT(IN) :: tension_only + REAL(wp), INTENT(OUT) :: q(:) + LOGICAL, INTENT(OUT) :: converged + TYPE(CD_StaticLineReport), INTENT(OUT) :: report + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp), INTENT(IN), OPTIONAL :: seabed_z_floor + REAL(wp), INTENT(IN), OPTIONAL :: seabed_kn(:) + TYPE(CD_BathymetryType), INTENT(IN), OPTIONAL :: bathymetry + TYPE(CableCurrentLoad), INTENT(IN), OPTIONAL :: current + REAL(wp), INTENT(IN), OPTIONAL :: load_factors(:) + REAL(wp), INTENT(IN), OPTIONAL :: dry_waterline_z(:), dry_rho, dry_gravity, dry_diameter(:) + REAL(wp), INTENT(OUT), OPTIONAL :: dry_load(:) + ! fixed-point tolerances on the node positions [m] and on the recovery load (relative to + ! the largest nodal load), and the solve budget + REAL(wp), PARAMETER :: DRY_TOL = 1.0e-9_wp, DRY_REL = 1.0e-10_wp + INTEGER, PARAMETER :: DRY_MAX = 50 + REAL(wp), ALLOCATABLE :: f_dry(:), q_prev(:), f_prev(:) + REAL(wp) :: change, f_scale + INTEGER :: k, n_it + CHARACTER(64) :: num + + IF (PRESENT(dry_load)) dry_load = CD_ZERO + CALL line_equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, cfg, tension_only, q, converged, & + report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, bathymetry, current, load_factors) + IF (.NOT. (PRESENT(dry_waterline_z) .AND. PRESENT(dry_rho) .AND. PRESENT(dry_gravity) .AND. & + PRESENT(dry_diameter))) RETURN + IF (ErrStat /= CD_STATIC_OK .OR. .NOT. converged) RETURN + IF (SIZE(dry_waterline_z) /= SIZE(q)/3 .OR. SIZE(dry_diameter) /= SIZE(l0) .OR. & + (PRESENT(dry_load) .AND. SIZE(f_ext) /= SIZE(q))) THEN + CALL fail(ErrStat, ErrMsg, 'line equilibrium: dry_waterline_z (n_nodes) / dry_diameter (n_elem) shapes') + converged = .FALSE. + RETURN + END IF + IF (PRESENT(dry_load)) THEN + IF (SIZE(dry_load) /= SIZE(q)) THEN + CALL fail(ErrStat, ErrMsg, 'line equilibrium: dry_load must have shape (3 n_nodes)') + converged = .FALSE. + RETURN + END IF + END IF + ALLOCATE (f_dry(SIZE(q)), q_prev(SIZE(q)), f_prev(SIZE(q))) + CALL dry_recovery(q, f_dry) + IF (ErrStat /= CD_STATIC_OK) RETURN + ! fully submerged: no recovery, the solution stands as solved + IF (ALL(f_dry == CD_ZERO)) RETURN + f_scale = MAXVAL(ABS(f_ext)) + n_it = report%n_iter + DO k = 1, DRY_MAX + q_prev = q + f_prev = f_dry + CALL line_equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext + f_dry, cfg, tension_only, q, & + converged, report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, bathymetry, current, & + load_factors) + n_it = n_it + report%n_iter + report%n_iter = n_it + IF (ErrStat /= CD_STATIC_OK) RETURN + IF (.NOT. converged) THEN + report%message = 'with the dry weight above the waterline: '//TRIM(report%message) + RETURN + END IF + change = MAXVAL(ABS(q - q_prev)) + CALL dry_recovery(q, f_dry) + IF (ErrStat /= CD_STATIC_OK) RETURN + IF (change <= DRY_TOL .OR. MAXVAL(ABS(f_dry - f_prev)) <= DRY_REL*f_scale) THEN + ! the recovery the returned state was solved with (its end forces balance it exactly) + IF (PRESENT(dry_load)) dry_load = f_prev + RETURN + END IF + END DO + converged = .FALSE. + WRITE (num, '(ES9.2)') change + report%message = 'the dry weight above the waterline did not settle to a fixed point (the nodes still move '// & + TRIM(ADJUSTL(num))//' m per solve): a line floating at the surface is outside the EI = 0 '// & + 'static start' + + CONTAINS + + SUBROUTINE dry_recovery(qs, f) + !! The buoyancy recovery of the dry part of every element in state qs. + REAL(wp), INTENT(IN) :: qs(:) + REAL(wp), INTENT(OUT) :: f(:) + INTEGER :: es + CHARACTER(1024) :: em + CALL CD_Static_Line_Dry_Load(qs, elem_conn, l0, dry_waterline_z, dry_rho, dry_gravity, dry_diameter, f, es, em) + IF (es /= CD_STATIC_OK) THEN + CALL fail(ErrStat, ErrMsg, 'line equilibrium: '//TRIM(em)) + converged = .FALSE. + END IF + END SUBROUTINE dry_recovery + END SUBROUTINE CD_Static_Line_Equilibrium + + SUBROUTINE CD_Static_Line_Dry_Load(q, elem_conn, l0, waterline_z, rho, gravity, diameter, f, ErrStat, ErrMsg) + !! The dry part's weight of an EI = 0 line in state q (3 n_nodes), as the dynamic model's + !! buoyancy recovery gives it (CD_Buoyancy_Recovery_Element_Force): each element straddling + !! or above the waterline (waterline_z per node) gives back the buoyancy + !! -(1 - f) rho g (pi/4) d^2 l0 / 2 at each of its nodes, f its submerged fraction + !! (diameter per element). f is exactly zero for a line wholly below its waterline. + REAL(wp), INTENT(IN) :: q(:) + INTEGER, INTENT(IN) :: elem_conn(:, :) + REAL(wp), INTENT(IN) :: l0(:), waterline_z(:), rho, gravity, diameter(:) + REAL(wp), INTENT(OUT) :: f(:) + INTEGER, INTENT(OUT) :: ErrStat + CHARACTER(*), INTENT(OUT) :: ErrMsg + REAL(wp) :: fe(6) + INTEGER :: e, a, b, es + CHARACTER(1024) :: em + ErrStat = CD_STATIC_OK + ErrMsg = '' + f = CD_ZERO + IF (SIZE(waterline_z) /= SIZE(q)/3 .OR. SIZE(diameter) /= SIZE(l0) .OR. SIZE(f) /= SIZE(q) .OR. & + SIZE(elem_conn, 2) /= SIZE(l0)) THEN + CALL fail(ErrStat, ErrMsg, 'dry-part buoyancy: waterline_z (n_nodes) / diameter (n_elem) / f shapes') + RETURN + END IF + DO e = 1, SIZE(l0) + a = elem_conn(1, e) + b = elem_conn(2, e) + CALL CD_Buoyancy_Recovery_Element_Force(q(3*a - 2:3*a), q(3*b - 2:3*b), l0(e), waterline_z(a), & + waterline_z(b), rho, diameter(e), gravity, fe, es, em) + IF (es /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'dry-part buoyancy: '//TRIM(em)) + RETURN + END IF + f(3*a - 2:3*a) = f(3*a - 2:3*a) + fe(1:3) + f(3*b - 2:3*b) = f(3*b - 2:3*b) + fe(4:6) + END DO + END SUBROUTINE CD_Static_Line_Dry_Load + + SUBROUTINE line_equilibrium(anchor, fairlead, elem_conn, l0, ea, weight, f_ext, cfg, tension_only, & + q, converged, report, ErrStat, ErrMsg, seabed_z_floor, seabed_kn, & + bathymetry, current, load_factors) + !! Robust static equilibrium of one EI=0 line held at both ends under the constant load + !! f_ext (CD_Static_Line_Equilibrium adds the dry part above the waterline). !! !! Node 1 is the anchor and node n the fairlead (both held); weight is the signed !! submerged weight per unit length of each element (downward positive) used by the seeds, @@ -2355,7 +2516,7 @@ SUBROUTINE seabed_slope_along(x, y, hd, g) IF (es_g == CD_BATHY_OK) g = gx*hd(1) + gy*hd(2) END SUBROUTINE seabed_slope_along - END SUBROUTINE CD_Static_Line_Equilibrium + END SUBROUTINE line_equilibrium SUBROUTINE polyline_seed(anchor, fairlead, l0, has_seabed, z_floor, q) !! Positions-only seed that never compresses a line longer than its chord: the nodes are diff --git a/tests/test_hermite_static_current_gradient.f90 b/tests/test_hermite_static_current_gradient.f90 new file mode 100644 index 00000000..ca0cba1e --- /dev/null +++ b/tests/test_hermite_static_current_gradient.f90 @@ -0,0 +1,233 @@ +! File: tests/test_hermite_static_current_gradient.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_hermite_static_current_gradient + !! The finite-EI static tangent of a depth-profile current: the drag samples the profile at + !! the node elevations, so it moves with the nodes, and the Newton tangent carries that + !! dependence (the current's vertical gradient times the drag's velocity derivative). On a + !! 260 m cable (60 elements, EA 4.69e8 N, EI 1.99e4 N m^2, 157.8 N/m) hung between + !! (0, 0, -20) and (200, 0, -150) m, in three sheared currents at their static equilibrium: + !! 1. the drag part of the solver's tangent (the tangent with the current less the tangent + !! without it, both from CD_HermiteCable_Static_Solve at the same state) against central + !! differences of the drag part of its residual, over the vertical position columns where + !! the profile enters: within 1e-5 (measured 4e-10 to 8e-10; without the gradient term it + !! was off by 5.4e-2, 6.7e-2 and 0.20 in the three currents); + !! 2. the Newton iterations from the still-water equilibrium to the current's at tol 1e-8, + !! printed (7/5/6 before, 7/5/5 with the gradient), the equilibria within the solver + !! tolerance of the previous ones. + !! A fourth current is a grid (MoorDyn-C Currents 2 and 5) varying along x, y and z, sampled in a + !! solve frame turned by 30 deg about z and shifted from the global origin, where the gradient + !! enters every position column as R^T (dU/dx) R / 2: gate 1 over all the free position + !! columns (measured 1.7e-9; without the gradient term 3.9e-2). + !! A fifth case restrains the cable in torsion at both ends (GJ 1e5 N m^2 with the torque-tension + !! coupling K/GJ = 0.02, ends pinned in bending, a quarter turn) in the cross-flow shear of case 1. + !! The twisted solve assembles the drag and its tangent in the same residual as the untwisted one + !! (its condensed-torsion Newton system and stability test add the torque's terms to it), so the + !! gate is the twisted solve's convergence, stable, with a torque, and gate 1 at its twisted, out + !! of plane equilibrium (the solver returns no tangent with torsion: the drag part is evaluated + !! there without it), over the vertical columns. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HermiteStaticCurrentType, CD_HCSTAT_OK + USE CableDyn_HermiteTorsion, ONLY: CD_HermiteTorsionType + USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED + USE CableDyn_Hydro, ONLY: CD_CurrentGridType + IMPLICIT NONE + INTEGER, PARAMETER :: NE = 60, NN = NE + 1, NDOF = 6*NN, KL = 11, KU = 11, LDAB = 2*KL + KU + 1 + REAL(wp), PARAMETER :: LEN = 260.0_wp, PI = 3.14159265358979323846_wp + REAL(wp) :: l0(NE), EA(NE), EI(NE), w(NE), seed(NDOF), q_sw(NDOF), q(NDOF), curv(NN), res, s + REAL(wp) :: a(3), b(3) + INTEGER :: it, es, i, k, icase, nfail + INTEGER, ALLOCATABLE :: fixed(:) + CHARACTER(1024) :: em + TYPE(CD_HermiteStaticCurrentType) :: cur + ! case 5: the torsion of the twisted solve and its end directions + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: tdir(3, 2) + + nfail = 0 + l0 = LEN/NE + EA = 4.69e8_wp + EI = 1.99e4_wp + w = 157.8_wp + a = [0.0_wp, 0.0_wp, -20.0_wp] + b = [200.0_wp, 0.0_wp, -150.0_wp] + DO i = 1, NN + s = REAL(i - 1, wp)/NE + seed(6*(i - 1) + 1:6*(i - 1) + 3) = a + s*(b - a) + [0.0_wp, 0.0_wp, -240.0_wp*s*(1.0_wp - s)] + END DO + DO i = 1, NN + k = MIN(NE, i) + seed(6*(i - 1) + 4:6*(i - 1) + 6) = (seed(6*k + 1:6*k + 3) - seed(6*(k - 1) + 1:6*(k - 1) + 3))/l0(1) + END DO + fixed = [1, 2, 3, 6*NE + 1, 6*NE + 2, 6*NE + 3] + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed, -1.0e4_wp, 0.0_wp, 10, 400, 1.0e-10_wp, 0.7_wp, & + q_sw, curv, res, it, es, em) + CALL check(es == CD_HCSTAT_OK, 'still-water equilibrium: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) ERROR STOP 1 + + DO icase = 1, 4 + CALL set_current(icase) + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, q_sw, fixed, -1.0e4_wp, 0.0_wp, 1, 400, 1.0e-8_wp, 1.0_wp, & + q, curv, res, it, es, em, current=cur) + CALL check(es == CD_HCSTAT_OK, 'equilibrium in the current: '//TRIM(em)) + IF (es /= CD_HCSTAT_OK) CYCLE + WRITE (*, '(A,I0,A,I0,A,ES10.2,A,3F12.6)') ' case ', icase, ': Newton iterations from still water ', it, & + ', residual ', res, ', mid-span node ', q(6*(NE/2) + 1:6*(NE/2) + 3) + CALL check_drag_tangent(icase, q) + END DO + + ! 5. restrained in torsion (GJ|K), a quarter turn, in the cross-flow shear of case 1 + IF (ALLOCATED(cur%grid)) DEALLOCATE (cur%grid) + cur%frame_cs = [1.0_wp, 0.0_wp] + cur%origin = [0.0_wp, 0.0_wp] + CALL set_current(1) + tdir(:, 1) = q_sw(4:6)/NORM2(q_sw(4:6)) + tdir(:, 2) = q_sw(NDOF - 2:NDOF)/NORM2(q_sw(NDOF - 2:NDOF)) + tors%active = .TRUE. + ALLOCATE (tors%gj(NE), tors%couple(NE)) + tors%gj = 1.0e5_wp + tors%couple = 0.02_wp + tors%phi = 0.5_wp*PI + tors%ends(:, 1) = tdir(:, 1) + tors%ends(:, 2) = [0.0_wp, 1.0_wp, 0.0_wp] + tors%ends(:, 3) = tdir(:, 2) + tors%ends(:, 4) = [0.0_wp, 1.0_wp, 0.0_wp] + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, q_sw, fixed, -1.0e4_wp, 0.0_wp, 1, 400, 1.0e-8_wp, 1.0_wp, & + q, curv, res, it, es, em, current=cur, endconn_stiffness=[0.0_wp, 0.0_wp], & + endconn_direction=tdir, endconn_mode=[CD_ENDCONN_PINNED, CD_ENDCONN_PINNED], & + torsion=tors) + CALL check(es == CD_HCSTAT_OK, 'twisted equilibrium in the current: '//TRIM(em)) + IF (es == CD_HCSTAT_OK) THEN + WRITE (*, '(A,I0,A,ES10.2,A,ES12.5,A,L1)') ' case 5 (torsion): Newton iterations ', it, ', residual ', res, & + ', torque ', tors%torque, ' N m, stable ', tors%stable + CALL check(ABS(tors%torque) > 1.0e2_wp, 'the twisted line carries a torque') + CALL check(tors%stable, 'the twisted equilibrium in the current is stable') + CALL check_drag_tangent(5, q) + END IF + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAILED: ', nfail, ' check(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: finite-EI static tangent of a depth-profile current' + +CONTAINS + + SUBROUTINE check(ok, what) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: what + IF (ok) RETURN + WRITE (*, '(2A)') ' FAIL: ', what + nfail = nfail + 1 + END SUBROUTINE check + + SUBROUTINE set_current(icase) + !! 1: cross-flow shear, 0 at -150 m to 1.2 m/s at the surface; 2: in-plane shear reversing + !! with depth; 3: oblique, strongly sheared near the surface and held above -10 m; 4: a grid + !! varying along x, y and z in a solve frame turned by 30 deg and shifted by (40, -25) m. + INTEGER, INTENT(IN) :: icase + INTEGER :: ix, iy, iz + cur%rho = 1025.0_wp + cur%waterline_z = 0.0_wp + cur%arc_end = [LEN] + cur%diam = [0.16_wp] + cur%cdn = [1.2_wp] + cur%cdt = [0.1_wp] + SELECT CASE (icase) + CASE (1) + cur%profile_z = [-150.0_wp, 0.0_wp] + cur%profile_velocity = RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.0_wp, 1.2_wp, 0.0_wp], [3, 2]) + CASE (2) + cur%profile_z = [-150.0_wp, -60.0_wp, 0.0_wp] + cur%profile_velocity = RESHAPE([-0.6_wp, 0.0_wp, 0.0_wp, 0.2_wp, 0.0_wp, 0.0_wp, 1.0_wp, 0.0_wp, 0.0_wp], & + [3, 3]) + CASE (3) + cur%profile_z = [-150.0_wp, -40.0_wp, -10.0_wp] + cur%profile_velocity = RESHAPE([0.0_wp, 0.0_wp, 0.0_wp, 0.3_wp, 0.3_wp, 0.0_wp, 1.0_wp, 1.5_wp, 0.0_wp], & + [3, 3]) + CASE (4) + IF (ALLOCATED(cur%profile_z)) DEALLOCATE (cur%profile_z, cur%profile_velocity) + ALLOCATE (cur%grid) + cur%grid%x = [-100.0_wp, 50.0_wp, 150.0_wp, 300.0_wp] + cur%grid%y = [-200.0_wp, 0.0_wp, 200.0_wp] + cur%grid%z = [-200.0_wp, -100.0_wp, -50.0_wp, 0.0_wp] + cur%grid%nt = 1 + ALLOCATE (cur%grid%velocity(3, 4, 3, 4, 1)) + DO iz = 1, 4 + DO iy = 1, 3 + DO ix = 1, 4 + cur%grid%velocity(:, ix, iy, iz, 1) = [0.3_wp + 0.002_wp*cur%grid%x(ix) + 0.004_wp*cur%grid%z(iz), & + 0.5_wp + 0.004_wp*cur%grid%z(iz) - 0.001_wp*cur%grid%y(iy), & + 0.0002_wp*cur%grid%x(ix)] + END DO + END DO + END DO + cur%frame_cs = [COS(PI/6.0_wp), SIN(PI/6.0_wp)] + cur%origin = [40.0_wp, -25.0_wp] + END SELECT + END SUBROUTINE set_current + + SUBROUTINE evaluate(qx, with_current, r, ab) + !! The solver's residual and banded tangent at qx (no Newton update: tol = HUGE). + REAL(wp), INTENT(IN) :: qx(NDOF) + LOGICAL, INTENT(IN) :: with_current + REAL(wp), INTENT(OUT) :: r(NDOF), ab(LDAB, NDOF) + REAL(wp) :: qd(NDOF), cd(NN), rr + INTEGER :: itx, esx + CHARACTER(512) :: emx + IF (with_current) THEN + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, -1.0e4_wp, 0.0_wp, 1, 1, HUGE(1.0_wp), 1.0_wp, & + qd, cd, rr, itx, esx, emx, current=cur, residual_out=r, tangent_out=ab) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, EA, EI, w, qx, fixed, -1.0e4_wp, 0.0_wp, 1, 1, HUGE(1.0_wp), 1.0_wp, & + qd, cd, rr, itx, esx, emx, residual_out=r, tangent_out=ab) + END IF + CALL check(esx == CD_HCSTAT_OK, 'residual and tangent evaluation: '//TRIM(emx)) + END SUBROUTINE evaluate + + SUBROUTINE check_drag_tangent(icase, qs) + !! 1: the drag part of the tangent against central differences of the drag part of the + !! residual, over the free vertical position columns. + INTEGER, INTENT(IN) :: icase + REAL(wp), INTENT(IN) :: qs(NDOF) + REAL(wp), PARAMETER :: H = 1.0e-5_wp + REAL(wp) :: rc(NDOF), rs(NDOF), abc(LDAB, NDOF), abs_(LDAB, NDOF), dum(LDAB, NDOF), qp(NDOF) + REAL(wp) :: rp(NDOF), rm(NDOF), col_fd(NDOF), col_an(NDOF), num, den + INTEGER :: j, node, ii, jj + CALL evaluate(qs, .TRUE., rc, abc) + CALL evaluate(qs, .FALSE., rs, abs_) + num = 0.0_wp + den = 0.0_wp + DO jj = 1, MERGE(3*(NE - 1), NE - 1, icase == 4) + IF (icase == 4) THEN + node = 2 + (jj - 1)/3 + j = 6*(node - 1) + 1 + MOD(jj - 1, 3) + ELSE + node = jj + 1 + j = 6*(node - 1) + 3 + END IF + qp = qs + qp(j) = qs(j) + H + CALL evaluate(qp, .TRUE., rc, dum) + CALL evaluate(qp, .FALSE., rs, dum) + rp = rc - rs + qp(j) = qs(j) - H + CALL evaluate(qp, .TRUE., rc, dum) + CALL evaluate(qp, .FALSE., rs, dum) + rm = rc - rs + col_fd = (rp - rm)/(2.0_wp*H) + col_an = 0.0_wp + DO ii = MAX(1, j - KU), MIN(NDOF, j + KL) + col_an(ii) = abc(KL + KU + 1 + ii - j, j) - abs_(KL + KU + 1 + ii - j, j) + END DO + DO ii = 1, NDOF + IF (ANY(fixed == ii)) CYCLE + num = num + (col_an(ii) - col_fd(ii))**2 + den = den + col_fd(ii)**2 + END DO + END DO + WRITE (*, '(A,I0,A,A,ES10.3)') ' case ', icase, ': drag tangent vs central differences, ', & + MERGE('position columns:', 'vertical columns:', icase == 4), SQRT(num/den) + CALL check(SQRT(num/den) <= 1.0e-5_wp, 'the drag tangent carries the current''s vertical gradient') + END SUBROUTINE check_drag_tangent +END PROGRAM test_hermite_static_current_gradient diff --git a/tests/test_line_attachments.f90 b/tests/test_line_attachments.f90 index 9795d5ea..c69dcfe7 100644 --- a/tests/test_line_attachments.f90 +++ b/tests/test_line_attachments.f90 @@ -20,8 +20,53 @@ PROGRAM test_line_attachments !! 7. Acceptance of a fallback attachment state (CD_Attachment_Discrete_Verdict): a slope !! jump beside an attachment node passes the kink limit; the same bend away from it, a !! compressed state under tensile_safety and an unstable state fail closed by name. + !! 8. A neutral line whose length equals its span (straight at zero strain, no weight, no + !! tension) with neutral modules (m = rho V) or with a drag area alone, pinned or clamped: + !! the static start converges and stays straight and unloaded (fairlead tension below + !! 1e-3 N). Its residual sits at the round-off floor of the axial forces, about + !! eps max(EA/l0) |x| = 9e-8 N here, above tol x 1 N, where the polish stalled at every + !! load step; the convergence scale now keeps tol x scale at 16 times that floor. Heavy + !! modules on the same line (which carry it into tension) still solve. Restrained in + !! torsion (GJ 5e4 N m^2, a quarter turn at End B), the neutral-module line carries the + !! torque GJ Phi / L to 1e-6. The same with End B on a Coupled point (two moving ends): + !! neutral modules and a drag area alone stay unloaded, the line restrained in torsion at + !! both ends carries GJ Phi / L to 1e-6, and a span 1e-8 longer than the line (two moving + !! ends whose chord exceeds the length, a 0.1 N tension that the tension bound of the + !! convergence scale alone put below the floor) carries EA (chord / L - 1) to 2e-6 N + !! (measured 2.2e-7 N). Restrained in torsion at End A only (End B free in torsion), the + !! line starts untwisted. Each of these failed in the polish before the floor. + !! 9. A bending-pinned cable from a moored body (a keel point, 45 deg towards a Fixed anchor) + !! carrying a 2 t clump 50 m along it, with and without its END CONNECTIONS row: the body + !! static solve balances the body on the cubic-Hermite cable's end loads (the passes of the + !! connected ends), so the body holds its static pose over 5 s of the march to 1e-5 m and + !! 1e-4 deg (measured 0, the output's 8 digits). The cable without bending stiffness that + !! the body solve otherwise takes for a pinned line does not carry the clump: the body + !! started at the pose of the line without it and drifted by up to 2.9e-2 m and 0.20 deg. + !! 10. The pinned cable with the clump of case 9 from a Point3 buoy, where a finite-EI end is not + !! supported: the deck is refused by that name. Before, the body passes of case 9 took the + !! line and refused it as a clamped or elastic END CONNECTION on a body that is not Rigid6, + !! which the deck does not have. + !! 11. A free buoyant spar rod (10 m, 1 m diameter) on four taut legs with a finite-EI cable + !! pinned at its upper end carrying a 1500 kg clump 25 m along it; bodyIC static: the body + !! static passes converge (6, on the core cable that carries the clump smeared) and the rod + !! holds its static pose over 0.3 s of the march (dtM 0.002 s) to 1e-6 m (measured 0) and + !! the leg tensions to 1e-5 (measured 3e-7). Before, the plain passes diverged (end-load + !! change 2.9 of the force scale after 60 passes) and the deck stopped. + !! 12. The spar rod of case 11 with the cable and no clump: the bending share of the pinned + !! cable's end force is in the rod's static balance too, so the rod holds its pose over + !! 0.3 s to 1e-6 m (measured 0) and its leg tensions to 1e-5 (measured 0). Before, the + !! body passes left a pinned line without ATTACHMENTS to the core's cable without bending + !! stiffness: the rod started 5.7e-2 m off its equilibrium and its top moved 1.8e-4 m in 0.1 s + !! (dtM 0.01 s; 7e-2 m and a 2.3 % leg tension change in 3 s with the implicit object + !! coupling). + !! 13. The static start of case 11 does not hinge on round-off: with the anchor of a leg moved + !! by 1 ulp either way (x = 25 m -+ 3.6e-15 m) the passes converge to the same rod pose to + !! 1e-9 m (measured 0) in at most 10 passes (measured 6). Before, the Anderson fit kept + !! columns of round-off size and the passes converged in 26, or ran out after 60 (the + !! relative end-load change 1.5) or turned the rod over, by that 1 ulp. USE CableDyn_Precision, ONLY: wp - USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Attachment_Discrete_Verdict + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK, CD_Attachment_Discrete_Verdict, & + CD_Body_Static_Pass_Limit USE CableDyn_EndConnection, ONLY: CD_ENDCONN_PINNED USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & CD_AGG_UpdateStates_Moving, CD_AGG_Step_Moving, CD_AGG_CalcOutput, & @@ -47,6 +92,13 @@ PROGRAM test_line_attachments CALL case_grammar() CALL case_coupled() CALL case_fallback_verdict() + CALL case_zero_strain() + CALL case_zero_strain_moving() + CALL case_pinned_body_clump() + CALL case_pinned_point3_clump() + CALL case_pinned_rod_clump(.TRUE.) + CALL case_pinned_rod_clump(.FALSE.) + CALL case_pinned_rod_roundoff() IF (nfail > 0) THEN WRITE (*, '(A,I0,A)') 'FAIL: ', nfail, ' assertion(s) failed' @@ -58,6 +110,541 @@ PROGRAM test_line_attachments INCLUDE 'nan_max_abs.inc' + SUBROUTINE case_zero_strain() + !! 8: a 100 m neutral line (Diam 0.2 m, mass rho pi d^2/4, EA 1e7, EI 1e6) between a Coupled + !! point and a Fixed one 100 m apart, 40 elements, TMax 0, with three modules at 25 m pitch. + CHARACTER(160) :: trow + ! the module rows: neutral (m = rho V), a drag area alone, heavy + CHARACTER(*), PARAMETER :: ROW1 = '1 25.0:25.0:75.0 102.5 0.1 0.0 0.0 0.0' + CHARACTER(*), PARAMETER :: ROW2 = '1 25.0:25.0:75.0 0.0 0.0 0.1 0.0 0.0' + CHARACTER(*), PARAMETER :: ROW3 = '1 25.0:25.0:75.0 200.0 0.1 0.0 0.0 0.0' + CHARACTER(64) :: rows(3) + CHARACTER(16) :: label(3) + REAL(wp), ALLOCATABLE :: d(:, :) + INTEGER :: k, iend, u, nrow + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(32) :: root + rows = [CHARACTER(64) :: ROW1, ROW2, ROW3] + label = [CHARACTER(16) :: 'neutral modules', 'drag area alone', 'heavy modules'] + WRITE (trow, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 0.0 0.0 0.0 0.0' + DO iend = 1, 2 + DO k = 1, 3 + WRITE (root, '(A,I0,A,I0)') 'att_span_', k, '_', iend + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'neutral line of the length of its span with attachments' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(trow) + WRITE (u, '(A)') '--------------------- POINTS -------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0' + WRITE (u, '(A)') '--------------------- LINES --------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS -----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') TRIM(rows(k)) + IF (iend == 2) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '1 A Rigid 1 0 0' + WRITE (u, '(A)') '1 B Rigid 1 0 0' + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') '--------------------- END ----------------------------------------------------' + CLOSE (u) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '8 '//TRIM(label(k))//MERGE(' (clamped)', ' (pinned) ', iend == 2)// & + ': the static start of a line as long as its span converges: '//TRIM(msg)) + IF (.NOT. ok) CYCLE + CALL read_out(TRIM(root)//'.out', d, nrow, 2) + CALL require(nrow >= 1, '8 '//TRIM(label(k))//': static row written') + IF (nrow < 1) CYCLE + WRITE (*, '(A,A,A,ES12.4,A)') ' 8 ', TRIM(label(k)), MERGE(' (clamped)', ' (pinned) ', iend == 2), & + d(2, 1), ' N fairlead tension' + IF (k < 3) CALL require(ABS(d(2, 1)) < 1.0e-3_wp, '8 '//TRIM(label(k))//': the line stays unloaded') + IF (k == 3) CALL require(d(2, 1) > 1.0e3_wp, '8 heavy modules: the line is carried into tension') + END DO + END DO + ! restrained in torsion, pinned in bending, a quarter turn at End B + WRITE (trow, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + root = 'att_span_torsion' + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'neutral line of the length of its span with neutral attachments, restrained in torsion' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') TRIM(trow) + WRITE (u, '(A)') '--------------------- POINTS -------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0' + WRITE (u, '(A)') '--------------------- LINES --------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS -----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') TRIM(rows(1)) + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Pinned 1 0 0 Rigid 0 0 1 0' + WRITE (u, '(A)') '1 B Pinned 1 0 0 Rigid 0 0 1 90' + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') 'Torq1N1' + WRITE (u, '(A)') '--------------------- END ----------------------------------------------------' + CLOSE (u) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '8 torsion: the static start of a line as long as its span converges: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out(TRIM(root)//'.out', d, nrow, 3) + CALL require(nrow >= 1, '8 torsion: static row written') + IF (nrow < 1) RETURN + WRITE (*, '(A,ES16.8,A,ES16.8,A)') ' 8 torsion: torque ', d(3, 1), ' N m, GJ Phi / L ', & + 5.0e4_wp*0.5_wp*PI/100.0_wp, ' N m' + CALL require(ABS(d(3, 1) - 5.0e4_wp*0.5_wp*PI/100.0_wp) <= 1.0e-6_wp*5.0e4_wp*0.5_wp*PI/100.0_wp, & + '8 torsion: the straight line carries GJ Phi / L') + END SUBROUTINE case_zero_strain + + SUBROUTINE case_zero_strain_moving() + !! 8 (continued): the line of case 8 with End B on a Coupled point (two moving ends), and + !! restrained in torsion at End A only. + CHARACTER(*), PARAMETER :: NEUTRAL = '1 25.0:25.0:75.0 102.5 0.1 0.0 0.0 0.0' + CHARACTER(*), PARAMETER :: DRAG = '1 25.0:25.0:75.0 0.0 0.0 0.1 0.0 0.0' + CHARACTER(*), PARAMETER :: TORS_HDR = 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + CHARACTER(*), PARAMETER :: TORS_UNITS = '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: chord, ten + INTEGER :: nrow + LOGICAL :: ok + ! two moving ends: neutral modules, a drag area alone + CALL span_deck('att_span_b1', 'Coupled', '100.0', NEUTRAL, .FALSE., [CHARACTER(64) ::], ['FairTen1']) + CALL span_run('att_span_b1', 'two moving ends, neutral modules', 2, d, nrow, ok) + IF (ok) CALL require(ABS(d(2, 1)) < 1.0e-3_wp, '8 two moving ends, neutral modules: the line stays unloaded') + CALL span_deck('att_span_b2', 'Coupled', '100.0', DRAG, .FALSE., [CHARACTER(64) ::], ['FairTen1']) + CALL span_run('att_span_b2', 'two moving ends, drag area alone', 2, d, nrow, ok) + IF (ok) CALL require(ABS(d(2, 1)) < 1.0e-3_wp, '8 two moving ends, drag area alone: the line stays unloaded') + ! two moving ends whose chord exceeds the length by 1e-8: tension EA (chord/L - 1) = 0.1 N + CALL span_deck('att_span_b3', 'Coupled', '100.000001', NEUTRAL, .FALSE., [CHARACTER(64) ::], ['FairTen1']) + CALL span_run('att_span_b3', 'two moving ends, chord above the length', 2, d, nrow, ok) + IF (ok) THEN + chord = 100.000001_wp + ten = 1.0e7_wp*(chord/100.0_wp - 1.0_wp) + WRITE (*, '(A,ES16.8,A,ES16.8,A)') ' 8 two moving ends, chord above the length: tension ', d(2, 1), & + ' N, EA (chord/L - 1) ', ten, ' N' + CALL require(ABS(d(2, 1) - ten) <= 2.0e-6_wp, '8 two moving ends, chord above the length: EA (chord/L - 1)') + END IF + ! two moving ends restrained in torsion at both ends, a quarter turn at End B + CALL span_deck('att_span_b4', 'Coupled', '100.0', NEUTRAL, .TRUE., & + [CHARACTER(80) :: TORS_HDR, TORS_UNITS, '1 A Pinned 1 0 0 Rigid 0 0 1 0', & + '1 B Pinned 1 0 0 Rigid 0 0 1 90'], ['FairTen1', 'Torq1N1 ']) + CALL span_run('att_span_b4', 'two moving ends, torsion', 3, d, nrow, ok) + IF (ok) THEN + WRITE (*, '(A,ES16.8,A,ES16.8,A)') ' 8 two moving ends, torsion: torque ', d(3, 1), ' N m, GJ Phi / L ', & + 5.0e4_wp*0.5_wp*PI/100.0_wp, ' N m' + CALL require(ABS(d(3, 1) - 5.0e4_wp*0.5_wp*PI/100.0_wp) <= 1.0e-6_wp*5.0e4_wp*0.5_wp*PI/100.0_wp, & + '8 two moving ends, torsion: the straight line carries GJ Phi / L') + END IF + ! restrained in torsion at End A only + CALL span_deck('att_span_b5', 'Fixed', '100.0', NEUTRAL, .TRUE., & + [CHARACTER(80) :: TORS_HDR, TORS_UNITS, '1 A Pinned 1 0 0 Rigid 0 0 1 0', & + '1 B Pinned 1 0 0 Free 0 0 1 0'], ['FairTen1', 'Twist1 ']) + CALL span_run('att_span_b5', 'torsion at End A only', 3, d, nrow, ok) + IF (ok) THEN + WRITE (*, '(A,ES12.4,A,ES12.4,A)') ' 8 torsion at End A only: tension ', d(2, 1), ' N, twist ', d(3, 1), ' deg' + CALL require(ABS(d(2, 1)) < 1.0e-3_wp .AND. ABS(d(3, 1)) < 1.0e-6_wp, & + '8 torsion at End A only: the line starts straight, unloaded and untwisted') + END IF + END SUBROUTINE case_zero_strain_moving + + SUBROUTINE span_deck(root, end_b_type, end_b_x, att_row, torsion, endconn_rows, outputs) + !! The neutral 100 m line of case 8 (40 elements, TMax 0) from a Coupled End A at + !! (0, 0, -50) m to End B of type end_b_type at (end_b_x, 0, -50) m, with one ATTACHMENTS row; + !! torsion: the line type with GJ 5e4 N m^2 (and its END CONNECTIONS rows). + CHARACTER(*), INTENT(IN) :: root, end_b_type, end_b_x, att_row + LOGICAL, INTENT(IN) :: torsion + CHARACTER(*), INTENT(IN) :: endconn_rows(:), outputs(:) + CHARACTER(160) :: trow + INTEGER :: u, i + OPEN (NEWUNIT=u, FILE=root//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'neutral line of the length of its span with attachments' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + IF (torsion) THEN + WRITE (trow, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, & + ' 1.0e7 0.0 1.0e6 1.0e8 5.0e4 1.0 1.0e-12 0.0 0.0 0.0 0.0' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + ELSE + WRITE (trow, '(A,ES24.16,A)') 'cab 0.2 ', 1025.0_wp*0.25_wp*PI*0.04_wp, ' 1.0e7 0.0 1.0e6 0.0 0.0 0.0 0.0' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + END IF + WRITE (u, '(A)') TRIM(trow) + WRITE (u, '(A)') '--------------------- POINTS -------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -50.0' + WRITE (u, '(A)') '2 '//end_b_type//' '//end_b_x//' 0.0 -50.0' + WRITE (u, '(A)') '--------------------- LINES --------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS -----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 cab 100.0 40' + WRITE (u, '(A)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') att_row + IF (SIZE(endconn_rows) > 0) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + DO i = 1, SIZE(endconn_rows) + WRITE (u, '(A)') TRIM(endconn_rows(i)) + END DO + END IF + WRITE (u, '(A)') '--------------------- OPTIONS ------------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.1 dtM' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS ------------------------------------------------' + DO i = 1, SIZE(outputs) + WRITE (u, '(A)') TRIM(outputs(i)) + END DO + WRITE (u, '(A)') '--------------------- END ----------------------------------------------------' + CLOSE (u) + END SUBROUTINE span_deck + + SUBROUTINE span_run(root, label, ncol, d, nrow, ok) + !! Run a span_deck deck and read its static row (ncol columns, time first). + CHARACTER(*), INTENT(IN) :: root, label + INTEGER, INTENT(IN) :: ncol + REAL(wp), ALLOCATABLE, INTENT(OUT) :: d(:, :) + INTEGER, INTENT(OUT) :: nrow + LOGICAL, INTENT(OUT) :: ok + CHARACTER(1024) :: msg + nrow = 0 + CALL run(root//'.dat', root, ok, msg) + CALL require(ok, '8 '//label//': the static start of a line as long as its span converges: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out(root//'.out', d, nrow, ncol) + ok = nrow >= 1 + CALL require(ok, '8 '//label//': static row written') + IF (ok) WRITE (*, '(A,A,A,ES12.4,A)') ' 8 ', label, ': ', d(2, 1), ' N fairlead tension' + END SUBROUTINE span_run + + SUBROUTINE case_pinned_body_clump() + !! 9: a buoyant body (hydrostatic C44 = C55 = 2e6 N m/rad) on three EI = 0 legs, with a + !! finite-EI cable from its keel point at 45 deg towards a Fixed anchor, pinned in bending at + !! the body, carrying a 2 t clump 50 m along it; bodyIC static, 5 s of the march (dtM 0.05 s). + INTEGER :: u, k, nrow + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: dpos, dpitch + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(32) :: root + DO k = 1, 2 + root = MERGE('att_body_pin_row', 'att_body_pin ', k == 1) + OPEN (NEWUNIT=u, FILE=TRIM(root)//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned cable with a clump on a moored body' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.12 15.0 5.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.2 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0' + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm) (Nm) (m2) (-) (kgm2) (kgm2) (kgm2)' + WRITE (u, '(A)') '1 Rigid6 0 0 -20 0 0 0 2.0e4 40.0 0.0 2.0e6 2.0e6 8.0 0.5 3.5e4 3.5e4 3.5e4' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Body1 1.5 0.0 -2.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 -0.75 1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '3 Body1 -0.75 -1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -20.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -20.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body1 0.0 0.0 -3.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 86.85 20' + WRITE (u, '(A)') '2 poly 86.85 20' + WRITE (u, '(A)') '3 poly 86.85 20' + WRITE (u, '(A)') '4 cab 100.0 50' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '4 50.0 2000.0 0.0 0.0 0.0' + IF (k == 1) THEN + WRITE (u, '(A)') '--- END CONNECTIONS ---' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-)' + WRITE (u, '(A)') '4 A Pinned -0.7071067811865476 0.0 -0.7071067811865476' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '5.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px' + WRITE (u, '(A)') 'Body1Pz' + WRITE (u, '(A)') 'Body1Ry' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '9 '//TRIM(root)//': runs: '//TRIM(msg)) + IF (.NOT. ok) CYCLE + CALL read_out(TRIM(root)//'.out', d, nrow, 4) + CALL require(nrow >= 101, '9 '//TRIM(root)//': 5 s written') + IF (nrow < 101) CYCLE + dpos = MAXVAL(ABS(d(2:3, 1:nrow) - SPREAD(d(2:3, 1), 2, nrow))) + dpitch = MAXVAL(ABS(d(4, 1:nrow) - d(4, 1))) + WRITE (*, '(A,A,A,ES10.3,A,ES10.3,A)') ' 9 ', TRIM(root), ': body drift over 5 s ', dpos, ' m, pitch ', & + dpitch, ' deg' + CALL require(dpos <= 1.0e-5_wp .AND. dpitch <= 1.0e-4_wp, & + '9 '//TRIM(root)//': the clump on a pinned cable is in the body''s static balance') + END DO + END SUBROUTINE case_pinned_body_clump + + SUBROUTINE case_pinned_point3_clump() + !! 10: a Point3 buoy (2 t, 10 m^3) on an EI = 0 leg, with the finite-EI cable of case 9 pinned + !! at it carrying the 2 t clump; bodyIC static. + INTEGER :: u + LOGICAL :: ok + CHARACTER(1024) :: msg + OPEN (NEWUNIT=u, FILE='att_point3_pin.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned cable with a clump on a Point3 buoy' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.12 15.0 5.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.2 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0' + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm) (Nm) (m2) (-) (kgm2) (kgm2) (kgm2)' + WRITE (u, '(A)') '1 Point3 0 0 -20 0 0 0 2.0e3 10.0 0.0 0.0 0.0 8.0 0.5 0 0 0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Body1 0.0 0.0 0.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 60.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -60.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '4 1 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 105.0 20' + WRITE (u, '(A)') '4 cab 110.0 50' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '4 50.0 2000.0 0.0 0.0 0.0' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '1.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point1Pz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL run('att_point3_pin.dat', 'att_point3_pin', ok, msg) + WRITE (*, '(2A)') ' 10 pinned cable on a Point3 buoy: ', TRIM(msg) + CALL require(.NOT. ok .AND. INDEX(msg, 'Point3 buoy is not supported') > 0, & + '10 pinned cable with a clump on a Point3 buoy: refused by that name') + END SUBROUTINE case_pinned_point3_clump + + SUBROUTINE case_pinned_rod_clump(clump) + !! 11 (clump) and 12: 0.3 s of the march of pinned_rod_deck (dtM 0.002 s, which the explicit + !! coupling of the cable to the rod on this route needs to stay stable). + LOGICAL, INTENT(IN) :: clump + INTEGER :: nrow + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: dpos, dten + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(16) :: root, gate + root = MERGE('att_rod_pin ', 'att_rod_pin_no', clump) + gate = MERGE('11 with a clump', '12 alone ', clump) + CALL pinned_rod_deck(TRIM(root), clump, '25.0', '0.002', '0.3') + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, TRIM(gate)//', a pinned cable on a free rod: runs: '//TRIM(msg)) + IF (.NOT. ok) RETURN + CALL read_out(TRIM(root)//'.out', d, nrow, 6) + CALL require(nrow >= 151, TRIM(gate)//', a pinned cable on a free rod: the run written') + IF (nrow < 151) RETURN + dpos = MAXVAL(ABS(d(2:3, 1:nrow) - SPREAD(d(2:3, 1), 2, nrow))) + dten = MAXVAL(ABS(d(4:6, 1:nrow) - SPREAD(d(4:6, 1), 2, nrow))/SPREAD(ABS(d(4:6, 1)), 2, nrow)) + WRITE (*, '(A,A,A,ES10.3,A,ES10.3)') ' ', TRIM(gate), ', a pinned cable on a free rod: rod top drift ', dpos, & + ' m, rel. leg tension ', dten + CALL require(dpos <= 1.0e-6_wp .AND. dten <= 1.0e-5_wp, & + TRIM(gate)//', a pinned cable on a free rod: the rod starts in the march''s equilibrium') + END SUBROUTINE case_pinned_rod_clump + + SUBROUTINE case_pinned_rod_roundoff() + !! 13: the static start of case 11 with leg anchor x = 25 m and 1 ulp either side of it. + CHARACTER(*), PARAMETER :: X3(3) = ['25.0 ', '24.999999999999996', '25.000000000000004'] + REAL(wp), ALLOCATABLE :: d(:, :) + REAL(wp) :: p0(2), dmax + INTEGER :: k, nrow + LOGICAL :: ok + CHARACTER(1024) :: msg + CHARACTER(24) :: root + dmax = 0.0_wp + p0 = 0.0_wp + nrow = 0 + ok = .FALSE. + ! at most 10 passes + CALL CD_Body_Static_Pass_Limit(10) + DO k = 1, 3 + WRITE (root, '(A,I0)') 'att_rod_ulp', k + CALL pinned_rod_deck(TRIM(root), .TRUE., TRIM(X3(k)), '0.01', '0.0') + CALL run(TRIM(root)//'.dat', TRIM(root), ok, msg) + CALL require(ok, '13 '//TRIM(root)//' (anchor x '//TRIM(X3(k))//'): the static start converges: '//TRIM(msg)) + IF (.NOT. ok) EXIT + CALL read_out(TRIM(root)//'.out', d, nrow, 6) + CALL require(nrow >= 1, '13 '//TRIM(root)//': static row written') + IF (nrow < 1) EXIT + IF (k == 1) p0 = d(2:3, 1) + dmax = MAX(dmax, MAXVAL(ABS(d(2:3, 1) - p0))) + END DO + CALL CD_Body_Static_Pass_Limit(0) + IF (.NOT. ok .OR. nrow < 1) RETURN + WRITE (*, '(A,ES10.3,A)') ' 13 anchor moved by 1 ulp: rod pose change ', dmax, ' m' + CALL require(dmax <= 1.0e-9_wp, '13 anchor moved by 1 ulp: the same static start') + END SUBROUTINE case_pinned_rod_roundoff + + SUBROUTINE pinned_rod_deck(root, clump, x3, dtm, tmax) + !! The spar rod from z = -30 m to -20 m in 50 m of water, two legs from each end (the first + !! to an anchor at x = x3), the cable from its upper end towards a Fixed point at + !! (-40, 0, -50) m, a 1500 kg clump 25 m along it with clump. + CHARACTER(*), INTENT(IN) :: root, x3, dtm, tmax + LOGICAL, INTENT(IN) :: clump + INTEGER :: u + OPEN (NEWUNIT=u, FILE=root//'.dat', STATUS='REPLACE', ACTION='WRITE') + WRITE (u, '(A)') 'pinned cable with a clump on a free spar rod' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.10 10.0 2.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.20 60.0 5.0e8 -1.0 2.0e4 1.2 0.0 1.0 0.0' + WRITE (u, '(A)') '--- ROD TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass Cd Ca CdEnd CaEnd CdAx CaAx' + WRITE (u, '(A)') '(-) (m) (kg/m) (-) (-) (-) (-) (-) (-)' + WRITE (u, '(A)') 'spar 1.0 300.0 0.8 1.0 0.0 0.0 0.2 0.0' + WRITE (u, '(A)') '--- RODS ---' + WRITE (u, '(A)') 'ID RodType Type XA YA ZA XB YB ZB NumSegs Outputs' + WRITE (u, '(A)') '(-) (-) (-) (m) (m) (m) (m) (m) (m) (-) (-)' + WRITE (u, '(A)') '1 spar Free 0.0 0.0 -30.0 0.0 0.0 -20.0 1 -' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Rod1A 0.0 0.0 -30.0 0 0 0 0' + WRITE (u, '(A)') '2 Rod1B 0.0 0.0 -20.0 0 0 0 0' + WRITE (u, '(A)') '3 Fixed '//x3//' 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed -25.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed 0.0 30.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed 0.0 -30.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '7 Fixed -40.0 0.0 -50.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 3 -' + WRITE (u, '(A)') '2 1 4 -' + WRITE (u, '(A)') '3 2 5 -' + WRITE (u, '(A)') '4 2 6 -' + WRITE (u, '(A)') '5 2 7 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 31.95 16' + WRITE (u, '(A)') '2 poly 31.95 16' + WRITE (u, '(A)') '3 poly 42.40 20' + WRITE (u, '(A)') '4 poly 42.40 20' + WRITE (u, '(A)') '5 cab 55.0 40' + IF (clump) THEN + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '5 25.0 1500.0 0.0 0.0 0.0' + END IF + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') dtm//' dtM' + WRITE (u, '(A)') tmax//' TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point2px' + WRITE (u, '(A)') 'Point2pz' + WRITE (u, '(A)') 'FairTen1' + WRITE (u, '(A)') 'FairTen2' + WRITE (u, '(A)') 'FairTen3' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + END SUBROUTINE pinned_rod_deck + SUBROUTINE case_fallback_verdict() !! A straight 10 m line on 1 m elements whose tangent at node 6 is turned by 0.6 rad: the !! two elements beside node 6 carry h*kappa of about 2.3, beyond the kink limit 0.7, as the diff --git a/tests/test_nodal_twist_dynamic.f90 b/tests/test_nodal_twist_dynamic.f90 index f4caa2fd..0a6bcf08 100644 --- a/tests/test_nodal_twist_dynamic.f90 +++ b/tests/test_nodal_twist_dynamic.f90 @@ -21,6 +21,12 @@ PROGRAM test_nodal_twist_dynamic !! (with the polar part) + elastic (with the twist) stays within the band of the line !! without torsion; a parent rolling the clamped line's end frame at a steady rate puts !! the continuum's polar kinetic energy into it, the held end section's spin included; + !! a line pinned in bending and rigid in torsion at both ends, twisted and swinging (13 deg + !! end bend angle): the spin c = (t x d).dt/dt / (1 + d.t) of the end section that the + !! carry G(d -> t) adds as the end tangent t moves, which the model leaves out of the + !! kinetic energy, the line's equations and the reaction alike (theory, Nodal twist), + !! carries at most 4e-6 of the peak kinetic energy with an extreme Irn = 1 kg m (6e-8 at + !! 0.02 kg m), below the step's own energy band; !! R restart: a rolling, torsionally damped run restored from a snapshot, and one rebuilt !! from the checkpoint mirror, continue bit-identically. USE CableDyn_Precision, ONLY: wp @@ -53,6 +59,7 @@ PROGRAM test_nodal_twist_dynamic CALL check_frame_damping() CALL check_energy() CALL check_frame_energy() + CALL check_pinned_energy() CALL check_restart() IF (nfail > 0) THEN @@ -580,6 +587,87 @@ SUBROUTINE check_frame_energy() CALL CD_HFMF_End(cab) END SUBROUTINE check_frame_energy + ! ------------------------------------------------------------------------------------------ + SUBROUTINE check_pinned_energy() + REAL(wp) :: band_lo, band_hi + CALL check_pinned_carry(0.02_wp, 1.0e-6_wp, band_lo) + CALL check_pinned_carry(1.0_wp, 1.0e-5_wp, band_hi) + CALL require(ABS(band_hi - band_lo) <= 0.05_wp*band_lo, & + 'E pinned: the energy band does not depend on the held sections'' polar inertia') + END SUBROUTINE check_pinned_energy + + SUBROUTINE check_pinned_carry(irn, bound, band) + !! E: the straight line pinned in bending and rigid in torsion at both ends (no gravity, no + !! fluid, rho_inf = 1), twisted by 4 rad and released with the first pinned bending mode's + !! velocity, 6 m/s at mid-span, for ten periods. Each step evaluates, from the end tangents + !! m and their rates, the spin c = (t x d).dt/dt / (1 + d.t) of the carry G(d -> t) at both + !! ends (d the end director +x) and the kinetic energy 1/2 I c^2 of the held end sections + !! (I = Irn l0/2) that the model omits; its largest value against the peak kinetic energy + !! must stay below bound. band: (max - min) of kinetic + elastic over E0. + REAL(wp), INTENT(IN) :: irn, bound + REAL(wp), INTENT(OUT) :: band + TYPE(CD_HermiteCableDynType) :: m + TYPE(CD_HermiteTorsionType) :: tors + REAL(wp) :: q(NDOF), l0(NE), s, ke, se, e0, emax, emin, ke_max, tc, tc_max, th_max, dt, mm(3), mv(3), t(3) + REAL(wp) :: td(3), c + INTEGER :: k, es, iend, b + CHARACTER(300) :: em + l0 = LL/REAL(NE, wp) + CALL line_seed(0.0_wp, 0.0_wp, q) + CALL CD_HermiteCable_Dyn_Init(m, l0, [(EA, k=1, NE)], [(EI, k=1, NE)], [(RHOA, k=1, NE)], [(0.0_wp, k=1, NE)], q, & + [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], 0.0_wp, 0.0_wp, 1.0_wp, es, em) + CALL require(es == CD_HCDYN_OK, 'E pinned: init: '//TRIM(em)) + CALL torsion_of(q, 4.0_wp, tors, irn, 0.0_wp) + CALL CD_HermiteCable_Dyn_Set_Torsion(m, tors, es, em) + CALL require(es == CD_HCDYN_OK, 'E pinned: torsion: '//TRIM(em)) + band = HUGE(1.0_wp) + IF (es /= CD_HCDYN_OK) RETURN + DO k = 1, NN + s = LL*REAL(k - 1, wp)/REAL(NE, wp) + m%v(6*k - 4) = 6.0_wp*SIN(PI*s/LL) + m%v(6*k - 1) = 6.0_wp*(PI/LL)*COS(PI*s/LL) + END DO + dt = 2.0_wp*PI/(PI*PI*SQRT(EI/(RHOA*LL**4)))/400.0_wp + CALL CD_HermiteCable_Dyn_Energy(m, ke, se, es, em) + e0 = ke + se + emax = e0 + emin = e0 + ke_max = ke + tc_max = 0.0_wp + th_max = 0.0_wp + DO k = 1, 4000 + CALL CD_HermiteCable_Dyn_Step(m, dt, 40, 1.0e-11_wp, es, em) + IF (es /= CD_HCDYN_OK) THEN + CALL require(.FALSE., 'E pinned: step: '//TRIM(em)) + EXIT + END IF + CALL CD_HermiteCable_Dyn_Energy(m, ke, se, es, em) + emax = nan_max_abs([emax, ke + se]) + emin = MIN(emin, ke + se) + ke_max = MAX(ke_max, ke) + tc = 0.0_wp + DO iend = 1, 2 + b = MERGE(3, 6*(NN - 1) + 3, iend == 1) + mm = m%q(b + 1:b + 3) + mv = m%v(b + 1:b + 3) + t = mm/NORM2(mm) + td = (mv - DOT_PRODUCT(t, mv)*t)/NORM2(mm) + ! (t x d) . td with d = +x: (0, t3, -t2) . td + c = (t(3)*td(2) - t(2)*td(3))/(1.0_wp + t(1)) + tc = tc + 0.25_wp*irn*l0(1)*c*c + th_max = MAX(th_max, ACOS(MIN(1.0_wp, t(1)))) + END DO + tc_max = MAX(tc_max, tc) + END DO + WRITE (*, '(A,ES9.2,A,F5.1,A,ES10.3,A,ES10.3)') 'E pinned, Irn ', irn, ' kg m: end bend angle up to ', & + th_max*180.0_wp/PI, ' deg; omitted carry-spin energy / peak kinetic energy ', tc_max/ke_max, & + ', energy band / E0 ', (emax - emin)/e0 + CALL require(tc_max <= bound*ke_max, 'E pinned: the end sections'' carry spin holds a negligible energy') + CALL require(th_max > 0.2_wp, 'E pinned: the end tangents swing off their directors') + band = (emax - emin)/e0 + CALL CD_HermiteCable_Dyn_End(m) + END SUBROUTINE check_pinned_carry + ! ------------------------------------------------------------------------------------------ SUBROUTINE check_restart() !! R: 150 steps, snapshot, 100 more; restore and redo the 100: identical. A fresh module diff --git a/tests/test_static_dry_weight.f90 b/tests/test_static_dry_weight.f90 new file mode 100644 index 00000000..178e9c99 --- /dev/null +++ b/tests/test_static_dry_weight.f90 @@ -0,0 +1,656 @@ +! File: tests/test_static_dry_weight.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_static_dry_weight + !! The static start of an EI = 0 line held above the still-water level gives the part above + !! the surface its dry weight, as the dynamic model's buoyancy recovery does, on the + !! standalone and the coupled route alike (CD_Static_Line_Equilibrium with the dry-part + !! arguments). Gates: + !! 1. A vertical chain hung from 10 m above the surface to a point 90 m below it (99.9 m, + !! taut): the vertical loads of its two ends sum to its weight, w_sub times the wet + !! length plus the dry weight per metre times the dry length (the dry length 10 m over + !! the stretch of the top element), to 1e-6 (measured 1.5e-8). With the buoyancy kept + !! above the surface the sum read 1.4e-2 low. + !! 2. A chain hung 5 m above the surface onto a 200 m seabed (850 m, grounded tail): the + !! coupled aggregate's static start gives the standalone driver's fairlead load to the + !! driver's 8 output digits, 2e-7 (measured 1.4e-8; before 2.4e-4: the coupled load was + !! the dynamic reaction of a start that was not the equilibrium of the dynamics, whose + !! buoyancy recovery gives the dry part its dry weight). + !! 3. The same chain held still on the coupled route for 1 s (40 steps of 0.025 s): the + !! fairlead load stays at its static value to 1e-7 (measured 1e-10; before it moved by + !! 9.7e-4 in the first step and by 1.4e-3 at 1 s, ringing about the heavier + !! equilibrium). + !! 4. A finite-EI cable hung 5 m above the surface (its statics already carry the dry + !! weight): coupled and standalone starts agree to 2e-7 (measured 7e-8; a guard). + !! 5. A 50 t Connect point hung by two chains from Fixed points 10 m above the surface on a + !! 300 m seabed: the point's force balance (the static object solve, its warm line solves + !! included) carries the dry weight too, so the point holds its static position over 2 s + !! of the march to 1e-4 m, the output's 8 digits (measured 0), and the fairlead tension to + !! 1e-6 (measured 0). With the dry weight only in the line starts the point sank 1.1e-2 m + !! and the tension moved by 9.6e-4. + !! 6. A finite-EI cable hung from 5 m above the surface carrying a module (500 kg, 0.2 m^3) + !! 2 m along it, above the surface, which the dynamics loads with its weight alone (no + !! buoyancy, no drag), held still for 1 s (dtM 0.01 s): the fairlead load stays at its + !! static value to 1e-7 (measured 0, the output's 8 digits); before, the static start gave + !! the module its buoyancy and the load moved by up to 6.1e-2 (Fz -44269 to -46272 N at + !! 1 s). The same cable restrained in torsion at both ends (GJ 1e4 N m^2, a quarter turn, + !! the torsion stage after the attachment polish): the same, measured 0, before 6.1e-2. A + !! module 30 m along the line, under water, keeps its net weight: the guard of both + !! (measured 0). + !! 7. A stiff body (C44 = C55 = 2e8 N m/rad) on three EI = 0 legs, with a light finite-EI cable + !! (EI 100 N m^2, whose bending changes its end force little) pinned at a body point 5 m + !! above the surface, on a deck without a seabed: the body static solve gives the cable's + !! part above the surface its dry weight, as its cubic-Hermite cable has it, so the body + !! holds its heave over 3 s to 1e-4 m (measured 7e-6 m); before the solve kept the buoyancy + !! of that part (the cable's EI = 0 surrogate took the dry weight only with a seabed) and the + !! body's heave moved by 2.8e-3 m. + !! 8. An EI = 0 chain between two moving objects across the surface: from a body point 5 m above + !! it (the stiff body of gate 7) to a 3 t Connect clump that a second chain holds to an + !! anchor, WtrDpth 100 m. The object solve moves the body and the point together, the chain + !! solved with its dry part between them: both hold their static positions over 3 s of the + !! march to 1e-4 m (measured 0); with the buoyancy kept above the surface (dev before the + !! dry-weight fix) they moved by 5.5e-3 m. + !! 9. A net-buoyant module (200 kg, 2 m^3) 50 m along a slack finite-EI cable from 20 m below + !! the surface: in water it lifts its node 4.5 m above the surface, where the dynamics gives + !! it its weight alone, which sinks it: a point attachment has no static position there. + !! The static start fails closed and its message names the attachment that crossed the + !! still-water level. Before, the solves carried the module above and below the surface in + !! turn until a load step failed, and the message read as a homotopy that stopped (dev + !! started the module 4.5 m above the surface with its buoyancy and ran). + !! A deck whose lines are all submerged is solved once, bit-identically (the example A/B). + USE CableDyn_Precision, ONLY: wp + USE CableDyn_OpenFAST_Aggregate, ONLY: CD_AGG_ModuleType, CD_AGG_Init_From_Deck, CD_AGG_GetMovingPointMesh, & + CD_AGG_NMovingPoints, CD_AGG_CalcOutput, CD_AGG_Step_Moving, CD_AGG_End, & + CD_AGG_OK + USE CableDyn_DeckDriver, ONLY: CD_Run_Deck_Driver, CD_DECKDRV_OK + IMPLICIT NONE + + REAL(wp), PARAMETER :: G = 9.80665_wp, RHOW = 1025.0_wp, PI = 3.14159265358979323846_wp + REAL(wp), PARAMETER :: D_CHAIN = 0.333_wp, M_CHAIN = 685.0_wp, EA_CHAIN = 3.27e9_wp + INTEGER :: nfail + REAL(wp) :: f_drv(3), f_agg(3), f2(3), w_dry, w_sub, l_dry, eps_top, w_true, err, dmax + + nfail = 0 + w_dry = M_CHAIN*G + w_sub = w_dry - RHOW*G*0.25_wp*PI*D_CHAIN**2 + + ! 1. vertical chain across the surface + CALL write_deck('dry_vertical.dat', 'main 0.333 685.00 3.27e9 -1.0 0.0 2.0 0.4 0.82 0.27', & + '0.0 0.0 10.0', '0.0 0.0 -90.0', '1 main 99.9 100', 200.0_wp) + CALL driver_forces('dry_vertical', f_drv, f2) + ! the dry length: 10 m of the top element's stretch (the tension varies by 0.1 % over it) + eps_top = -f_drv(3)/EA_CHAIN + l_dry = 10.0_wp/(1.0_wp + eps_top) + w_true = w_sub*(99.9_wp - l_dry) + w_dry*l_dry + err = ABS(f_drv(3) + f2(3) + w_true)/w_true + WRITE (*, '(A,ES12.4,A,ES12.4,A,ES10.2)') ' vertical chain: sum of the end loads ', -(f_drv(3) + f2(3)), & + ' N, weight ', w_true, ' N, rel. error ', err + WRITE (*, '(A,ES10.2)') ' (buoyancy kept above the surface would read it low by ', & + (w_dry - w_sub)*l_dry/w_true + CALL check(err <= 1.0e-6_wp, 'vertical chain: the end loads carry the dry weight above the surface') + + ! 2. and 3. chain from 5 m above the surface onto the seabed + CALL write_deck('dry_chain.dat', 'main 0.333 685.00 3.27e9 -1.0 0.0 2.0 0.4 0.82 0.27', & + '-58.0 0.0 5.0', '-837.6 0.0 -200.0', '1 main 850.0 50', 200.0_wp) + CALL driver_forces('dry_chain', f_drv, f2) + CALL coupled_force('dry_chain.dat', 40, f_agg, dmax) + err = MAXVAL(ABS(f_agg - f_drv))/NORM2(f_drv) + WRITE (*, '(A,3ES16.8)') ' chain, standalone fairlead load ', f_drv + WRITE (*, '(A,3ES16.8,A,ES10.2)') ' chain, coupled fairlead load ', f_agg, ' rel. ', err + CALL check(err <= 2.0e-7_wp, 'chain above the surface: coupled and standalone static starts agree') + WRITE (*, '(A,ES10.2)') ' chain held still 1 s on the coupled route: largest rel. load change ', dmax + CALL check(dmax <= 1.0e-7_wp, 'chain above the surface: the static start is the equilibrium of the march') + + ! 4. finite-EI cable from 5 m above the surface + CALL write_deck('dry_cable.dat', 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0', & + '30.0 0.0 5.0', '500.0 0.0 -200.0', '1 bare 600.0 240', 200.0_wp) + CALL driver_forces('dry_cable', f_drv, f2) + CALL coupled_force('dry_cable.dat', 0, f_agg, dmax) + err = MAXVAL(ABS(f_agg - f_drv))/NORM2(f_drv) + WRITE (*, '(A,ES10.2)') ' finite-EI cable above the surface: coupled vs standalone rel. ', err + CALL check(err <= 2.0e-7_wp, 'finite-EI cable above the surface: coupled and standalone static starts agree') + + ! 5. a Connect point between two chains held above the surface + CALL connect_point_drift(err, dmax) + WRITE (*, '(A,ES10.2,A,ES10.2)') ' Connect point held 2 s: largest vertical drift ', dmax, & + ' m, largest rel. fairlead tension change ', err + CALL check(dmax <= 1.0e-4_wp, 'Connect point above the surface: its static position is the equilibrium of the march') + CALL check(err <= 1.0e-6_wp, 'Connect point above the surface: the fairlead tension holds its static value') + + ! 6. an attachment above the surface, untwisted and restrained in torsion; under water, the guard + CALL attachment_hold('dry_att', '1 2.0 500.0 0.2 0.0 0.0', .FALSE., err) + WRITE (*, '(A,ES10.2)') ' module above the surface, held 1 s: largest rel. fairlead load change ', err + CALL check(err <= 1.0e-7_wp, 'module above the surface: the static start is the equilibrium of the march') + CALL attachment_hold('dry_att_tors', '1 2.0 500.0 0.2 0.0 0.0', .TRUE., err) + WRITE (*, '(A,ES10.2)') ' module above the surface, torsion, held 1 s: largest rel. fairlead load change ', err + CALL check(err <= 1.0e-7_wp, 'module above the surface, torsion: the static start is the equilibrium of the march') + CALL attachment_hold('wet_att', '1 30.0 500.0 0.2 0.0 0.0', .FALSE., err) + WRITE (*, '(A,ES10.2)') ' module under water, held 1 s: largest rel. fairlead load change ', err + CALL check(err <= 1.0e-7_wp, 'module under water: the static start is the equilibrium of the march') + + ! 7. a pinned finite-EI cable above the surface on a body, no seabed + CALL body_cable_heave(dmax) + WRITE (*, '(A,ES10.2,A)') ' body with a pinned cable above the surface, no seabed: largest heave change ', dmax, ' m' + CALL check(dmax <= 1.0e-4_wp, 'pinned cable above the surface on a body: the body static balance carries its '// & + 'dry weight') + + ! 8. an EI = 0 chain between a body above the surface and a Connect point + CALL two_objects_drift(dmax) + WRITE (*, '(A,ES10.2,A)') ' chain between a body above the surface and a Connect point: largest drift ', dmax, ' m' + CALL check(dmax <= 1.0e-4_wp, 'chain between two moving objects across the surface: both start in the march''s '// & + 'equilibrium') + + ! 9. a module that would float: no static position, failed by name + CALL floating_module() + + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAILED: ', nfail, ' check(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: static dry weight above the surface' + +CONTAINS + + SUBROUTINE check(ok, what) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: what + IF (ok) THEN + WRITE (*, '(2A)') ' ok: ', what + ELSE + WRITE (*, '(2A)') ' FAIL: ', what + nfail = nfail + 1 + END IF + END SUBROUTINE check + + SUBROUTINE write_deck(path, type_row, pa, pb, section_row, depth) + !! One line from a Coupled point pa (End A) to a Fixed point pb; the standalone static start + !! at TMax = 0, the time step for the coupled route. + CHARACTER(*), INTENT(IN) :: path, type_row, pa, pb, section_row + REAL(wp), INTENT(IN) :: depth + INTEGER :: u + OPEN (NEWUNIT=u, FILE=path, STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'test_static_dry_weight: a line held above the still-water level' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') type_row + WRITE (u, '(A)') '--------------------- POINTS ------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled '//pa + WRITE (u, '(A)') '2 Fixed '//pb + WRITE (u, '(A)') '--------------------- LINES -------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS ----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') section_row + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.025 dtM' + WRITE (u, '(F8.2,A)') depth, ' WtrDpth' + WRITE (u, '(A)') '0.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') '"Point1Fx"' + WRITE (u, '(A)') '"Point1Fy"' + WRITE (u, '(A)') '"Point1Fz"' + WRITE (u, '(A)') '"Point2Fx"' + WRITE (u, '(A)') '"Point2Fy"' + WRITE (u, '(A)') '"Point2Fz"' + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + END SUBROUTINE write_deck + + SUBROUTINE driver_forces(root, fa, fb) + !! The standalone static start (TMax = 0): the loads on points 1 and 2 (the t = 0 row). + CHARACTER(*), INTENT(IN) :: root + REAL(wp), INTENT(OUT) :: fa(3), fb(3) + LOGICAL :: conv + INTEGER :: es, u, ios + CHARACTER(1024) :: em + CHARACTER(4096) :: line + REAL(wp) :: t + fa = 0.0_wp + fb = 0.0_wp + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, root//': standalone static start: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='old', ACTION='read') + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) t, fa, fb + EXIT + END DO + CLOSE (u) + END SUBROUTINE driver_forces + + SUBROUTINE connect_point_drift(ten_rel, dz_max) + !! Gate 5: two 240 m chains from Fixed points at (-+200, 0, 10) m to a Connect point (50 t, + !! 2 m^3) at (0, 0, -100) m, WtrDpth 300 m, held 2 s (dtM 0.01 s). ten_rel: the largest change + !! of FairTen1 over its t = 0 value, relative; dz_max: the largest change of the point's z [m]. + REAL(wp), INTENT(OUT) :: ten_rel, dz_max + INTEGER :: u, ios, es + LOGICAL :: conv + REAL(wp) :: row(4), t0, z0 + CHARACTER(1024) :: em + CHARACTER(4096) :: line + LOGICAL :: first + ten_rel = HUGE(1.0_wp) + dz_max = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE='dry_connect.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'test_static_dry_weight: a Connect point between two chains held above the surface' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0' + WRITE (u, '(A)') '--------------------- POINTS ------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-)' + WRITE (u, '(A)') '1 Fixed -200.0 0.0 10.0 0 0 0 0' + WRITE (u, '(A)') '2 Connect 0.0 0.0 -100.0 50000.0 2.0 0 0' + WRITE (u, '(A)') '3 Fixed 200.0 0.0 10.0 0 0 0 0' + WRITE (u, '(A)') '--------------------- LINES -------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '2 3 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS ----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 chain 240.0 30' + WRITE (u, '(A)') '2 chain 240.0 30' + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '2.0 TMax' + WRITE (u, '(A)') '300.0 WtrDpth' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') '"FairTen1"' + WRITE (u, '(A)') '"Point2px"' + WRITE (u, '(A)') '"Point2pz"' + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_connect.dat', 'dry_connect', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'dry_connect: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_connect.out', STATUS='old', ACTION='read') + first = .TRUE. + t0 = 0.0_wp + z0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + t0 = row(2) + z0 = row(4) + ten_rel = 0.0_wp + dz_max = 0.0_wp + first = .FALSE. + END IF + ten_rel = MAX(ten_rel, ABS(row(2) - t0)/t0) + dz_max = MAX(dz_max, ABS(row(4) - z0)) + END DO + CLOSE (u) + END SUBROUTINE connect_point_drift + + SUBROUTINE attachment_hold(root, att_row, torsion, dmax_rel) + !! Gate 6: a 600 m finite-EI cable (240 elements) from a Coupled point at (30, 0, 5) m to a + !! Fixed one at (500, 0, -200) m on a 200 m seabed with one ATTACHMENTS row, held 1 s (dtM + !! 0.01 s); torsion: restrained at both ends, a quarter turn at End B. dmax_rel: the largest + !! change of the fairlead load over its t = 0 value, relative. + CHARACTER(*), INTENT(IN) :: root, att_row + LOGICAL, INTENT(IN) :: torsion + REAL(wp), INTENT(OUT) :: dmax_rel + INTEGER :: u, ios, es + LOGICAL :: conv, first + REAL(wp) :: row(3), f0(2) + CHARACTER(1024) :: em + CHARACTER(4096) :: line + dmax_rel = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE=root//'.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') '--------------------- CableDyn Input File ------------------------------------' + WRITE (u, '(A)') 'test_static_dry_weight: a module above the still-water level' + WRITE (u, '(A)') '--------------------- LINE TYPES ---------------------------------------------' + IF (torsion) THEN + WRITE (u, '(A)') 'Name Diam Mass EA BA EI GAs GJ Irt Irn Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (N) (Nm2) (kgm) (kgm) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.0e8 1.0e4 1.0 0.1 1.2 0.1 1.0 0.0' + ELSE + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0' + END IF + WRITE (u, '(A)') '--------------------- POINTS ------------------------------------------------' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 30.0 0.0 5.0' + WRITE (u, '(A)') '2 Fixed 500.0 0.0 -200.0' + WRITE (u, '(A)') '--------------------- LINES -------------------------------------------------' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--------------------- SECTIONS ----------------------------------------------' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 bare 600.0 240' + WRITE (u, '(A)') '--------------------- ATTACHMENTS -------------------------------------------' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') att_row + IF (torsion) THEN + WRITE (u, '(A)') '--------------------- END CONNECTIONS ----------------------------------------' + WRITE (u, '(A)') 'LineID End Stiffness EzX EzY EzZ TorsStiffness NxX NxY NxZ Pretwist' + WRITE (u, '(A)') '(-) (-) (N-m/rad) (-) (-) (-) (N-m/rad) (-) (-) (-) (deg)' + WRITE (u, '(A)') '1 A Pinned 0.7071067811865476 0 -0.7071067811865476 Rigid 0 1 0 0' + WRITE (u, '(A)') '1 B Pinned 1 0 0 Rigid 0 1 0 90' + END IF + WRITE (u, '(A)') '--------------------- OPTIONS -----------------------------------------------' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '200.0 WtrDpth' + WRITE (u, '(A)') '1.0 TMax' + WRITE (u, '(A)') '--------------------- OUTPUTS -----------------------------------------------' + WRITE (u, '(A)') '"Point1Fx"' + WRITE (u, '(A)') '"Point1Fz"' + WRITE (u, '(A)') 'END' + WRITE (u, '(A)') '--------------------- need this line ----------------------------------------' + CLOSE (u) + CALL CD_Run_Deck_Driver(root//'.dat', root, conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, root//': run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE=root//'.out', STATUS='old', ACTION='read') + first = .TRUE. + f0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + f0 = row(2:3) + dmax_rel = 0.0_wp + first = .FALSE. + END IF + dmax_rel = MAX(dmax_rel, NORM2(row(2:3) - f0)/NORM2(f0)) + END DO + CLOSE (u) + END SUBROUTINE attachment_hold + + SUBROUTINE body_cable_heave(dz_max) + !! Gate 7: a body at z = -3 m on three 103 m polyester legs to anchors at -100 m, with a + !! 120 m finite-EI cable (EI 100 N m^2, 60 elements) pinned at the body point (0, 0, 8) m (5 m + !! above the surface) towards a Fixed point at (-40, 0, -100) m, no seabed, bodyIC static, + !! 3 s of the march (dtM 0.05 s). dz_max: the largest change of the body's heave [m]. + REAL(wp), INTENT(OUT) :: dz_max + INTEGER :: u, ios, es + LOGICAL :: conv, first + REAL(wp) :: row(4), z0 + CHARACTER(1024) :: em + CHARACTER(4096) :: line + dz_max = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE='dry_body_cable.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') 'test_static_dry_weight: a pinned finite-EI cable above the surface on a body, no seabed' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.12 15.0 5.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'cab 0.2 60.0 5.0e8 -1.0 1.0e2 1.2 0.0 1.0 0.0' + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm) (Nm) (m2) (-) (kgm2) (kgm2) (kgm2)' + WRITE (u, '(A)') '1 Rigid6 0 0 -3 0 0 0 2.0e4 40.0 0.0 2.0e8 2.0e8 8.0 0.5 3.5e4 3.5e4 3.5e4' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Body1 1.5 0.0 -2.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 -0.75 1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '3 Body1 -0.75 -1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -20.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -20.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body1 0.0 0.0 8.0 0 0 0 0' + WRITE (u, '(A)') '8 Fixed -40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 8 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 103.0 20' + WRITE (u, '(A)') '2 poly 103.0 20' + WRITE (u, '(A)') '3 poly 103.0 20' + WRITE (u, '(A)') '4 cab 120.0 60' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '0.05 dtM' + WRITE (u, '(A)') '3.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px' + WRITE (u, '(A)') 'Body1Pz' + WRITE (u, '(A)') 'Body1Ry' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_body_cable.dat', 'dry_body_cable', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'dry_body_cable: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_body_cable.out', STATUS='old', ACTION='read') + first = .TRUE. + z0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + z0 = row(3) + dz_max = 0.0_wp + first = .FALSE. + END IF + dz_max = MAX(dz_max, ABS(row(3) - z0)) + END DO + CLOSE (u) + END SUBROUTINE body_cable_heave + + SUBROUTINE floating_module() + !! Gate 9: a 160 m finite-EI cable (80 elements) from a Coupled point at (0, 0, -20) m to a + !! Fixed one at (100, 0, -50) m on a 50 m seabed, a 200 kg, 2 m^3 module 50 m along it. + INTEGER :: u, es + LOGICAL :: conv + CHARACTER(1024) :: em + OPEN (NEWUNIT=u, FILE='dry_float.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') 'test_static_dry_weight: a net-buoyant module that would float' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'bare 0.16 36.70 4.69e8 0.0 1.99e4 1.2 0.1 1.0 0.0' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z' + WRITE (u, '(A)') '(-) (-) (m) (m) (m)' + WRITE (u, '(A)') '1 Coupled 0.0 0.0 -20.0' + WRITE (u, '(A)') '2 Fixed 100.0 0.0 -50.0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 2 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 bare 160.0 80' + WRITE (u, '(A)') '--- ATTACHMENTS ---' + WRITE (u, '(A)') 'LineID ArcLength Mass Volume CdA Ca CdAx' + WRITE (u, '(A)') '(-) (m) (kg) (m^3) (m^2) (-) (m^2)' + WRITE (u, '(A)') '1 50.0 200.0 2.0 0.0 0.0 0.0' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '3.0e6 kBot' + WRITE (u, '(A)') '3.0e5 cBot' + WRITE (u, '(A)') '0.01 dtM' + WRITE (u, '(A)') '50.0 WtrDpth' + WRITE (u, '(A)') '0.1 TMax' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Point1Fz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_float.dat', 'dry_float', conv, es, em) + WRITE (*, '(2A)') ' module that would float: ', TRIM(em) + CALL check(es /= CD_DECKDRV_OK, 'module that would float: the static start fails closed') + CALL check(INDEX(em, 'attachment 1 of the line') > 0 .AND. INDEX(em, 'crossed the still-water level') > 0, & + 'module that would float: the failure names the attachment that crossed the surface') + END SUBROUTINE floating_module + + SUBROUTINE two_objects_drift(dmax) + !! Gate 8: the body of gate 7, a 65 m chain (EI = 0, 30 segments) from its point (0, 0, 8) m to + !! a Connect point (3 t) at (-30, 0, -50) m, and an 85 m chain from there to a Fixed point at + !! (-90, 0, -100) m, WtrDpth 100 m, bodyIC static, 3 s of the march (dtM 0.02 s). dmax: the + !! largest change of the body's x and z and the point's z [m]. + REAL(wp), INTENT(OUT) :: dmax + INTEGER :: u, ios, es + LOGICAL :: conv, first + REAL(wp) :: row(4), r0(3) + CHARACTER(1024) :: em + CHARACTER(4096) :: line + dmax = HUGE(1.0_wp) + OPEN (NEWUNIT=u, FILE='dry_two_objects.dat', STATUS='replace', ACTION='write') + WRITE (u, '(A)') 'test_static_dry_weight: an EI = 0 chain between a body above the surface and a Connect point' + WRITE (u, '(A)') '--- LINE TYPES ---' + WRITE (u, '(A)') 'Name Diam Mass EA BA EI Cdn Cdt Can Cat' + WRITE (u, '(A)') '(-) (m) (kg/m) (N) (-) (Nm2) (-) (-) (-) (-)' + WRITE (u, '(A)') 'poly 0.12 15.0 5.0e7 -1.0 0.0 1.2 0.2 1.0 0.0' + WRITE (u, '(A)') 'chain 0.1 60.0 8.0e8 -1.0 0.0 1.2 0.4 1.0 0.5' + WRITE (u, '(A)') '--- BODIES ---' + WRITE (u, '(A)') 'ID Type X Y Z Roll Pitch Yaw Mass Vol C33 C44 C55 CdA Ca Ixx Iyy Izz' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (deg) (deg) (deg) (kg) (m3) (N/m) (Nm) (Nm) (m2) (-) (kgm2) (kgm2) (kgm2)' + WRITE (u, '(A)') '1 Rigid6 0 0 -3 0 0 0 2.0e4 40.0 0.0 2.0e8 2.0e8 8.0 0.5 3.5e4 3.5e4 3.5e4' + WRITE (u, '(A)') '--- POINTS ---' + WRITE (u, '(A)') 'ID Type X Y Z Mass Vol CdA Ca' + WRITE (u, '(A)') '(-) (-) (m) (m) (m) (kg) (m3) (m2) (-)' + WRITE (u, '(A)') '1 Body1 1.5 0.0 -2.0 0 0 0 0' + WRITE (u, '(A)') '2 Body1 -0.75 1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '3 Body1 -0.75 -1.299 -2.0 0 0 0 0' + WRITE (u, '(A)') '4 Fixed 40.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '5 Fixed -20.0 34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '6 Fixed -20.0 -34.641 -100.0 0 0 0 0' + WRITE (u, '(A)') '7 Body1 0.0 0.0 8.0 0 0 0 0' + WRITE (u, '(A)') '8 Connect -30.0 0.0 -50.0 3000.0 0.0 0 0' + WRITE (u, '(A)') '9 Fixed -90.0 0.0 -100.0 0 0 0 0' + WRITE (u, '(A)') '--- LINES ---' + WRITE (u, '(A)') 'ID NodeA NodeB Outputs' + WRITE (u, '(A)') '(-) (-) (-) (-)' + WRITE (u, '(A)') '1 1 4 -' + WRITE (u, '(A)') '2 2 5 -' + WRITE (u, '(A)') '3 3 6 -' + WRITE (u, '(A)') '4 7 8 -' + WRITE (u, '(A)') '5 8 9 -' + WRITE (u, '(A)') '--- SECTIONS ---' + WRITE (u, '(A)') 'LineID LineType Length NumSegs' + WRITE (u, '(A)') '(-) (-) (m) (-)' + WRITE (u, '(A)') '1 poly 103.0 20' + WRITE (u, '(A)') '2 poly 103.0 20' + WRITE (u, '(A)') '3 poly 103.0 20' + WRITE (u, '(A)') '4 chain 65.0 30' + WRITE (u, '(A)') '5 chain 85.0 30' + WRITE (u, '(A)') '--- OPTIONS ---' + WRITE (u, '(A)') '100.0 WtrDpth' + WRITE (u, '(A)') '9.80665 g' + WRITE (u, '(A)') '1025.0 rhoW' + WRITE (u, '(A)') '1.0e5 kBot' + WRITE (u, '(A)') '1.0e4 cBot' + WRITE (u, '(A)') '0.02 dtM' + WRITE (u, '(A)') '3.0 TMax' + WRITE (u, '(A)') 'static bodyIC' + WRITE (u, '(A)') 'monolithic bodyScheme' + WRITE (u, '(A)') '--- OUTPUTS ---' + WRITE (u, '(A)') 'Body1Px' + WRITE (u, '(A)') 'Body1Pz' + WRITE (u, '(A)') 'Point8pz' + WRITE (u, '(A)') '--- END ---' + CLOSE (u) + CALL CD_Run_Deck_Driver('dry_two_objects.dat', 'dry_two_objects', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'dry_two_objects: run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_two_objects.out', STATUS='old', ACTION='read') + first = .TRUE. + r0 = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (line(1:1) == '#' .OR. INDEX(line, 'Time') > 0 .OR. LEN_TRIM(line) == 0) CYCLE + READ (line, *) row + IF (first) THEN + r0 = row(2:4) + dmax = 0.0_wp + first = .FALSE. + END IF + dmax = MAX(dmax, MAXVAL(ABS(row(2:4) - r0))) + END DO + CLOSE (u) + END SUBROUTINE two_objects_drift + + SUBROUTINE coupled_force(path, nstep, f0, dmax_rel) + !! The coupled aggregate's static start (OpenFAST host environment): the fairlead load, and + !! the largest relative change of it over nstep still steps of 0.025 s. + CHARACTER(*), INTENT(IN) :: path + INTEGER, INTENT(IN) :: nstep + REAL(wp), INTENT(OUT) :: f0(3), dmax_rel + TYPE(CD_AGG_ModuleType) :: agg + REAL(wp), ALLOCATABLE :: pos(:, :), vel(:, :), acc(:, :), ld(:, :), p0(:, :) + INTEGER :: es, ncp, n, it + LOGICAL :: conv, stalled + CHARACTER(1024) :: em + f0 = 0.0_wp + dmax_rel = HUGE(1.0_wp) + CALL CD_AGG_Init_From_Deck(agg, path, 0.025_wp, es, em, env_gravity=G, env_rho_water=RHOW, & + env_wtrdpth=200.0_wp) + CALL check(es == CD_AGG_OK, path//': coupled static start: '//TRIM(em)) + IF (es /= CD_AGG_OK) RETURN + ncp = CD_AGG_NMovingPoints(agg, es, em) + ALLOCATE (pos(3, ncp), vel(3, ncp), acc(3, ncp), ld(3, ncp), p0(3, ncp)) + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, ld, es, em) + f0 = ld(:, 1) + p0 = pos + vel = 0.0_wp + acc = 0.0_wp + dmax_rel = 0.0_wp + DO n = 1, nstep + CALL CD_AGG_Step_Moving(agg, 0.025_wp, p0, vel, acc, conv, stalled, it, es, em) + IF (es /= CD_AGG_OK) THEN + CALL check(.FALSE., path//': coupled still step: '//TRIM(em)) + EXIT + END IF + CALL CD_AGG_CalcOutput(agg, es, em) + CALL CD_AGG_GetMovingPointMesh(agg, pos, vel, acc, ld, es, em) + vel = 0.0_wp + acc = 0.0_wp + dmax_rel = MAX(dmax_rel, NORM2(ld(:, 1) - f0)/NORM2(f0)) + END DO + CALL CD_AGG_End(agg, es, em) + END SUBROUTINE coupled_force +END PROGRAM test_static_dry_weight