diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cedc0c..530f4aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -118,6 +118,16 @@ All notable changes to CableDyn are recorded in this file. The format follows Froude-Krylov load and VIV lift of a Gauss point now carry the immersed fraction of its section, linear across one diameter about the surface, with its derivative in the Jacobians. Fully submerged points are unchanged to the bit; the full test suite passes unchanged. +- A buoyancy module (an `ATTACHMENTS` row) on a finite-EI line that floats had no static + position: its buoyancy switched off at its node's height, so its weight in air took it below + the surface and its weight in water above it, and the static start stopped with an error. Its + buoyancy, Froude-Krylov force and drag now carry the immersed fraction of the sphere of its + volume (of its drag area without one), as a Rigid6 body's buoyancy does, continuous with its + slope through the surface; the statics solve for it in each Newton iterate with its stiffness. + A 200 kg, 2 m^3 module on a slack cable now floats 0.35 m below the surface and holds that + height in the march, and rides 1.5 m waves. A module deeper than its sphere's radius is + unchanged to the bit. In deck waves a node above the instantaneous surface takes the wave + kinematics at the surface (they were zero there), as a cable's internal waves already did. ## [0.4.2] - 2026-11-09 diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ed467e..c0fe0de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1333,6 +1333,10 @@ add_executable(test_static_surface_crossing tests/test_static_surface_crossing.f target_link_libraries(test_static_surface_crossing PRIVATE cabledyn_core) add_test(NAME static_surface_crossing COMMAND test_static_surface_crossing WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) set_tests_properties(static_surface_crossing PROPERTIES LABELS "fortran;integration;static" TIMEOUT 600) +add_executable(test_attachment_surface tests/test_attachment_surface.f90) +target_link_libraries(test_attachment_surface PRIVATE cabledyn_core) +add_test(NAME attachment_surface COMMAND test_attachment_surface) +set_tests_properties(attachment_surface PROPERTIES LABELS "fortran;unit;static") # VIV amplitude estimate (Thorsen et al. 2016, Eq. 8 and 9) and the amplitude tables. add_executable(test_viv_amplitude_kernel tests/test_viv_amplitude_kernel.f90) diff --git a/doc/theory.rst b/doc/theory.rst index 8aea3e3..2702128 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -3480,19 +3480,34 @@ 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. Above the free surface an -attachment carries its weight :math:`-m g\,\mathbf{e}_z` alone. The statics start from the +and, through :math:`\mathbf{m}_j`, the position tangent exactly. At the free surface the buoyancy, +Froude–Krylov force and drag carry the immersed fraction of the sphere of the attachment's volume, +:math:`r = (3V/4\pi)^{1/3}` (of its drag area, :math:`C_dA = \pi r^2`, without a volume), as a +Rigid6 body's buoyancy does: with the immersed height :math:`h = \min(2r, \max(0, \eta - z_j + r))`, + +.. math:: + + \phi = \frac{h^2 (3r - h)}{4 r^3}, + +so the weight is :math:`-(m - \phi\rho V)\,g\,\mathbf{e}_z`, continuous with its slope as the node +crosses the surface: :math:`\phi = 1` exactly from :math:`r` below the surface (the loads above, +unchanged) and :math:`\phi = 0` from :math:`r` above it (the weight :math:`-m g\,\mathbf{e}_z` +alone). A module that floats then rests at the height where :math:`\phi\rho V g` balances its +share of the load, where a wet/dry switch at the node gave it no position. The added mass +:math:`C_a \rho V` stays in the constant mass matrix, and the modal analysis leaves out the +hydrostatic stiffness of the surface, a module's as a line's own. The statics start from the equilibrium with the net weight smeared over the node's two elements, in a deck current across the vertical plane of the chord with the drag areas smeared over them too (per-metre drag coefficients :math:`C_dA/(d\,L)` and :math:`C_dA_x/(\pi d\,L)` added to an element of length :math:`L` for each share), and continue to the lumped loads in warm-started Newton solves, the smeared weight and drag moving to the node together; in a deck current the drag at rest is lumped at the node, 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 +it at its incoming state, and the final solve is repeated with the drag of its own solution +until the nodes stop moving. The buoyancy an attachment loses at the still-water level, +:math:`\rho V g (1 - \phi)` downward, is part of every Newton iterate with its stiffness +:math:`-\rho V g\, \partial\phi/\partial z` and potential, so a floating module needs no +outer iteration. Before, a wet/dry switch at the node gave a module at the surface no static +position and the solve stopped with an error; and before that, 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 solve that stalls on a residual floor above the tight static tolerance is diff --git a/doc/troubleshooting.rst b/doc/troubleshooting.rst index fd141c6..f89f972 100644 --- a/doc/troubleshooting.rst +++ b/doc/troubleshooting.rst @@ -653,13 +653,8 @@ 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 module at the surface is not a cause: its buoyancy fades over the sphere of its volume, so a + module that floats has a static position. - **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 a0dbf67..7814c4e 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -97,6 +97,7 @@ MODULE CableDyn_DeckDriver CD_HCSTAT_NOCONVERGE, CD_HC_COMPRESSION_OSCILLATION, & CD_HC_COMPRESSION_STRICT USE CableDyn_HermiteCableDynamic, ONLY: CD_HCDYN_OK, CD_HCDYN_TENSILE_OFF, CD_HCDYN_TENSILE_WARN, & + CD_HermiteCable_Point_Immersion, CD_HermiteCable_Point_Radius, & CD_HCDYN_TENSILE_ERROR, CD_HermiteCable_Dyn_Load_Power, & CD_HermiteCable_Dyn_VIV_Amplitude, & CD_HermiteCable_Axial_Damping_Resultant, & @@ -3979,13 +3980,13 @@ 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 (-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). Every pass starts from the polished state, in equilibrium + !! attachment polish): the attachments' net weights -(m - rho V) g e_z at their nodes, less + !! the buoyancy an attachment within its radius of the surface loses there + !! (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 that buoyancy + !! on its height, 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 (fixed point). + !! Every pass starts from the polished state, in equilibrium !! under the loads at that state: the change to the loads of the last solution is ramped !! with the imposed twist, in full at the target. Taken in full from the untwisted start, the !! drag of a twisted shape pushed a lazy wave whose untwisted state is unstable out of its @@ -3994,26 +3995,19 @@ SUBROUTINE torsion_after_attachments(est, emt) 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(:), f_untwisted(:) - LOGICAL, ALLOCATABLE :: att_dry(:), att_dry_now(:) + REAL(wp), ALLOCATABLE :: f_att(:), f_att_now(:), f_drag(:), q_prev(:), q_polished(:), f_untwisted(:) LOGICAL :: has_drag - 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 + INTEGER :: fp 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)), att_dry(SIZE(att_node)), att_dry_now(SIZE(att_node))) + ALLOCATE (f_att(SIZE(q_static)), f_att_now(SIZE(q_static)), f_drag(SIZE(q_static))) 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) + CALL attachment_static_weight(q_static, att_node, ln%att, opts, f_att, surface=.TRUE.) 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) @@ -4030,35 +4024,16 @@ SUBROUTINE torsion_after_attachments(est, emt) ELSE CALL torsion_stage(est, emt, f_untwisted, f_att + f_drag - f_untwisted) END IF - IF (est /= CD_DECKDRV_OK) THEN - IF (k_cross > 0) emt = TRIM(cause)//'; '//TRIM(emt) - RETURN - 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 (est /= CD_DECKDRV_OK) RETURN + ! the weights at the twisted state: an attachment the twist moved within its radius of the + ! surface carries another share of its buoyancy (once more, with the loads of this state) + CALL attachment_static_weight(q_static, att_node, ln%att, opts, f_att_now, surface=.TRUE.) + IF (.NOT. has_drag .AND. ALL(f_att_now == f_att)) RETURN IF (MAXVAL(ABS(q_static - q_prev)) <= FIXED_POINT_TOL) RETURN END DO est = CD_DECKDRV_SOLVEFAIL - 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 + emt = 'finite-EI torsion static solve with discrete ATTACHMENTS: the attachment loads (current drag, '// & + 'buoyancy at the surface) did not settle to a fixed point' END SUBROUTINE torsion_after_attachments SUBROUTINE twisted_attachment_checks(est, emt) @@ -5786,18 +5761,19 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att cdt_bare, tol_floor, floor_res, release) !! 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 (-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 + !! forces -(m - rho V) g e_z (attachment_static_weight), the buoyancy an attachment loses at + !! the still-water level (in each Newton iterate: the static solve's att_buoyancy, the + !! immersed fraction of the sphere of its volume) 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. With cdn_bare and cdt_bare (the line's own drag !! coefficients of cur_obj, whose cdn and cdt carry the attachments' drag smeared, !! smear_attachment_drag) the element drag coefficients move from those of cur_obj to them !! with the weights, so the smeared drag passes to the nodes as the smeared weight does. !! The drag depends on the node's position (profile current, - !! 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). + !! current grid) and line tangent, so each solve takes it at its incoming state and the + !! full-load solve is repeated with that of the last solution until the solution stops + !! moving (fixed point). !! !! The load fraction advances in steps of 1/NSTEP. A step whose damped Newton solve does !! not converge is repeated from the last converged state with pseudo-transient @@ -5853,15 +5829,11 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att INTEGER, PARAMETER :: NEWTON_RETRY_ITER = 40, MAX_FAILED_STEPS = 64 REAL(wp), PARAMETER :: FIXED_POINT_TOL = 1.0e-9_wp ! m REAL(wp), ALLOCATABLE :: f_att(:), f_drag(:), dry(:), knnode(:), wl(:), q_out(:), curv(:) + ! each attachment's buoyancy rho g V and the radius of its sphere at the surface + REAL(wp), ALLOCATABLE :: att_b(:), att_r(:) REAL(wp) :: lam, lam_done, dlam, res, change INTEGER :: i, ne, fp, n_failed, n_ok, grow_after LOGICAL :: has_drag, converged, newton_failed, grown, release_ - ! 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 @@ -5895,9 +5867,12 @@ 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)) - 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 + CALL attachment_static_weight(q, node, att, opts, f_att) + ALLOCATE (att_b(SIZE(node)), att_r(SIZE(node))) + DO i = 1, SIZE(node) + att_b(i) = opts%rhoW*opts%g*att(3, i) + att_r(i) = CD_HermiteCable_Point_Radius(att(3, i), att(4, i)) + END DO 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 @@ -5947,12 +5922,12 @@ 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, surface_note('; ')//TRIM(first_msg)//'; the homotopy stopped at '// & + 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') ELSE WRITE (step_buf, '(I0)') MAX_FAILED_STEPS - CALL fail_solve(ErrStat, ErrMsg, surface_note('; ')//TRIM(first_msg)//'; the homotopy stopped at '// & + 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') END IF @@ -5960,54 +5935,21 @@ SUBROUTINE attachment_static_polish(l0, ea, ei, w_bare, w_smear, diam, node, att END IF END IF END DO - ! 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. release_ .AND. .NOT. has_drag .AND. ALL(att_dry_now .EQV. att_dry)) RETURN + ! The weights are constant and the buoyancy at the surface is part of each solve: without + ! attachment drag the homotopy's last solve is the equilibrium. + IF (.NOT. release_ .AND. .NOT. has_drag) 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, surface_note('; ')//TRIM(last_msg)// & - ' (attachment current drag and surface fixed point)') + CALL fail_solve(ErrStat, ErrMsg, TRIM(last_msg)//' (attachment current drag fixed point)') RETURN END IF - 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 + IF (.NOT. has_drag .OR. change <= FIXED_POINT_TOL) RETURN END DO - 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 + CALL fail_solve(ErrStat, ErrMsg, 'finite-EI static solve with discrete ATTACHMENTS: the attachment '// & + 'current drag did not settle to a fixed point') 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 @@ -6025,12 +5967,6 @@ 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) @@ -6091,7 +6027,8 @@ SUBROUTINE static_solve(mode_s, tol_s, scale, max_it, it, es, em) endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & water_weight=opts%rhoW*opts%g, current=cur_l, & backtracking=mode_s == MERIT, merit_line_search=mode_s == MERIT, & - pseudo_transient=mode_s == PSEUDO_TRANSIENT) + pseudo_transient=mode_s == PSEUDO_TRANSIENT, att_node=node, & + att_buoyancy=scale*att_b, att_radius=att_r) ELSE CALL CD_HermiteCable_Static_Solve(l0, ea, ei, wl, q, fixed_dofs, contact_z, CD_ZERO, 1, max_it(mode_s), & tol_s, 0.7_wp, q_out, curv, res, it, es, em, & @@ -6102,7 +6039,8 @@ SUBROUTINE static_solve(mode_s, tol_s, scale, max_it, it, es, em) endconn_mode=endconn_mode, waterline_z=CD_ZERO, dry_buoyancy=dry, & water_weight=opts%rhoW*opts%g, current=cur_l, & backtracking=mode_s == MERIT, merit_line_search=mode_s == MERIT, & - pseudo_transient=mode_s == PSEUDO_TRANSIENT) + pseudo_transient=mode_s == PSEUDO_TRANSIENT, att_node=node, & + att_buoyancy=scale*att_b, att_radius=att_r) END IF END SUBROUTINE static_solve END SUBROUTINE attachment_static_polish @@ -6118,13 +6056,16 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, base, es - REAL(wp) :: ug(3), ul(3), fd(3) + REAL(wp) :: ug(3), ul(3), fd(3), wf, dwf CHARACTER(1024) :: em ErrStat = CD_DECKDRV_OK; ErrMsg = '' DO k = 1, SIZE(node) IF (.NOT. (att(4, k) > CD_ZERO .OR. att(6, k) > CD_ZERO)) CYCLE base = 6*(node(k) - 1) - IF (q(base + 3) > CD_ZERO) CYCLE + ! the immersed fraction of the attachment's sphere at the still-water level, as the + ! dynamics scales its drag (attachment_residual of the cubic-Hermite model) + CALL CD_HermiteCable_Point_Immersion(-q(base + 3), CD_HermiteCable_Point_Radius(att(3, k), att(4, k)), wf, dwf) + IF (.NOT. (wf > CD_ZERO)) CYCLE ! the node's global position (the solve frame is the global one turned by frame_cs) ug = deck_current_velocity(opts, [frame_cs(1)*q(base + 1) - frame_cs(2)*q(base + 2), & frame_cs(2)*q(base + 1) + frame_cs(1)*q(base + 2), q(base + 3)], & @@ -6138,32 +6079,42 @@ SUBROUTINE attachment_static_drag(q, node, att, opts, frame_cs, f, ErrStat, ErrM IF (es /= CD_HCDYN_OK) THEN CALL fail(ErrStat, ErrMsg, TRIM(em)); RETURN END IF - f(base + 1:base + 3) = f(base + 1:base + 3) + fd + f(base + 1:base + 3) = f(base + 1:base + 3) + wf*fd END DO END SUBROUTINE attachment_static_drag - SUBROUTINE attachment_static_weight(q, node, att, opts, f, dry) + SUBROUTINE attachment_static_weight(q, node, att, opts, f, surface) !! 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. + !! cable solve, set here): the net weight -(m - rho V) g e_z at the node of each attachment. + !! With surface (default false) also the buoyancy an attachment loses at the still-water + !! level at its height in q, -rho g V (1 - wf) e_z, wf the immersed fraction of the sphere of + !! its volume (CD_HermiteCable_Point_Immersion), as the dynamics loads it (attachment_residual + !! of the cubic-Hermite model); exactly -m g e_z from its radius above the surface, nothing + !! more from its radius below it. Without surface the static solve adds that share in each + !! Newton iterate (att_buoyancy of CD_HermiteCable_Static_Solve). 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. REAL(wp), INTENT(IN) :: q(:), att(:, :) INTEGER, INTENT(IN) :: node(:) TYPE(DeckOptions), INTENT(IN) :: opts REAL(wp), INTENT(OUT) :: f(:) - LOGICAL, INTENT(OUT) :: dry(:) + LOGICAL, INTENT(IN), OPTIONAL :: surface INTEGER :: k, base + REAL(wp) :: wf, dwf + LOGICAL :: surface_ + surface_ = .FALSE. + IF (PRESENT(surface)) surface_ = surface f = CD_ZERO DO k = 1, SIZE(node) base = 6*(node(k) - 1) - dry(k) = q(base + 3) > CD_ZERO - IF (dry(k)) THEN + wf = CD_ONE + IF (surface_) CALL CD_HermiteCable_Point_Immersion(-q(base + 3), CD_HermiteCable_Point_Radius(att(3, k), & + att(4, k)), wf, dwf) + IF (.NOT. (wf > CD_ZERO)) THEN f(base + 3) = f(base + 3) - att(2, k)*opts%g + ELSE IF (wf < CD_ONE) THEN + f(base + 3) = f(base + 3) - (att(2, k) - wf*opts%rhoW*att(3, k))*opts%g ELSE f(base + 3) = f(base + 3) - (att(2, k) - opts%rhoW*att(3, k))*opts%g END IF @@ -34005,7 +33956,7 @@ SUBROUTINE hermite_cable_fluid(cable, n, xyz, fv, fa, wl) INTEGER, INTENT(IN) :: n REAL(wp), INTENT(OUT) :: xyz(3, n), fv(3, n), fa(3, n), wl(n) INTEGER :: j, es - REAL(wp) :: eta, wv(3), wa(3) + REAL(wp) :: eta, eta_s, wv(3), wa(3), zs CHARACTER(1024) :: em CHARACTER(200) :: em_k ! a per-node current or wave kinematics message (at most 160 characters) CALL CD_HFMF_GetNodePositions(cable, xyz, es, em) @@ -34025,6 +33976,17 @@ SUBROUTINE hermite_cable_fluid(cable, n, xyz, fv, fa, wl) IF (es /= CD_HYDRO_OK) THEN CALL hermite_fluid_fail('wave kinematics', em_k); RETURN END IF + IF (xyz(3, j) > eta) THEN + ! a node above the instantaneous surface takes the field at the surface: the parts of + ! the section (an attachment's sphere, a Gauss point's band) still wet there move with + ! it (the internal waves of a cable do the same, CD_HermiteCable_Drag_Element); the + ! kinematics above the surface are zero + zs = eta + CALL deck_wave_kinematics(opts, xyz(1, j), xyz(2, j), zs, time, eta_s, wv, wa, es, em_k) + IF (es /= CD_HYDRO_OK) THEN + CALL hermite_fluid_fail('wave kinematics', em_k); RETURN + END IF + END IF fv(:, j) = fv(:, j) + wv; fa(:, j) = wa; wl(j) = eta END IF END DO diff --git a/src/CableDyn_HermiteCableDynamic.f90 b/src/CableDyn_HermiteCableDynamic.f90 index 1d6bf87..8058345 100644 --- a/src/CableDyn_HermiteCableDynamic.f90 +++ b/src/CableDyn_HermiteCableDynamic.f90 @@ -120,6 +120,8 @@ MODULE CableDyn_HermiteCableDynamic PUBLIC :: CD_HermiteCable_Dyn_Set_AddedMass PUBLIC :: CD_HermiteCable_Dyn_Set_Waves PUBLIC :: CD_HermiteCable_Dyn_Set_Held_Fluid + PUBLIC :: CD_HermiteCable_Point_Immersion + PUBLIC :: CD_HermiteCable_Point_Radius PUBLIC :: CD_HermiteCable_Dyn_Set_Contact PUBLIC :: CD_HermiteCable_Dyn_Set_Attachments PUBLIC :: CD_HermiteCable_Attachment_Drag @@ -498,14 +500,17 @@ MODULE CableDyn_HermiteCableDynamic ! [N] it loses above the free surface, the fluid-inertia coefficient att_fk(k) = ! rho V (1 + Ca) [kg], and the drag areas normal (att_cda) and axial (att_cdax) to the ! line tangent at the node [m^2] with the fluid density att_rho. Its mass - ! plus added mass m + Ca rho V is part of the constant mass Mgb. + ! plus added mass m + Ca rho V is part of the constant mass Mgb. Across the free surface + ! its buoyancy, Froude-Krylov force and drag carry the immersed fraction of the sphere of + ! its volume (radius att_r; of its drag area CdA without a volume), as a Rigid6 body's do + ! (CD_HermiteCable_Point_Immersion). LOGICAL :: has_attach = .FALSE. ! Set by a checkpoint-restart reload (CD_HFMF_UnpackMirror): the committed acceleration is ! a generalised-alpha history value, so the first held fluid field after the reload must ! preserve it instead of re-deriving an initial-condition acceleration. LOGICAL :: a_restored = .FALSE. INTEGER, ALLOCATABLE :: att_node(:) - REAL(wp), ALLOCATABLE :: att_w(:), att_b(:), att_fk(:), att_cda(:), att_cdax(:) + REAL(wp), ALLOCATABLE :: att_w(:), att_b(:), att_fk(:), att_cda(:), att_cdax(:), att_r(:) ! a point's isotropic drag (a Free point ending the line) in place of the normal/axial split LOGICAL, ALLOCATABLE :: att_iso(:) ! the point a free end carries: in the equations of motion, not in the end force @@ -2305,7 +2310,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Attachments(model, node, mass, volume, cda, c mgb_old = model%Mgb ALLOCATE (model%att_node(n), model%att_w(n), model%att_b(n), model%att_fk(n), model%att_cda(n), & model%att_cdax(n), model%att_mass(n), model%att_madd(n), model%att_iso(n), & - model%att_point(n)) + model%att_point(n), model%att_r(n)) model%att_iso = .FALSE. IF (PRESENT(isotropic)) model%att_iso = isotropic model%att_point = .FALSE. @@ -2319,6 +2324,9 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Attachments(model, node, mass, volume, cda, c model%att_rho = rho_w model%att_mass = mass model%att_madd = ca*rho_w*volume + DO k = 1, n + model%att_r(k) = CD_HermiteCable_Point_Radius(volume(k), cda(k)) + END DO DO k = 1, n DO d = 1, 3 dof = 6*(node(k) - 1) + d @@ -2329,7 +2337,7 @@ SUBROUTINE CD_HermiteCable_Dyn_Set_Attachments(model, node, mass, volume, cda, c CALL solve_consistent_acceleration(model, es, em) IF (es /= CD_HCDYN_OK) THEN DEALLOCATE (model%att_node, model%att_w, model%att_b, model%att_fk, model%att_cda, model%att_cdax, & - model%att_mass, model%att_madd, model%att_iso, model%att_point) + model%att_mass, model%att_madd, model%att_iso, model%att_point, model%att_r) model%has_attach = .FALSE. model%Mgb = mgb_old model%a = a_old @@ -2403,14 +2411,21 @@ SUBROUTINE assemble_attachments(model, q_cfg, v_cfg, want_residual, want_tangent CHARACTER(*), INTENT(OUT) :: ErrMsg INTEGER :: k, base, a, b LOGICAL :: has_jac - REAL(wp) :: rk(3), jrel(3, 3), jtan(3, 3) + REAL(wp) :: rk(3), jrel(3, 3), jtan(3, 3), jz(3) ErrStat = CD_HCDYN_OK; ErrMsg = '' DO k = 1, SIZE(model%att_node) IF (model%att_node(k) < n_lo .OR. model%att_node(k) > n_hi) CYCLE base = 6*(model%att_node(k) - 1) - CALL attachment_residual(model, k, q_cfg, v_cfg, want_tangent, rk, has_jac, jrel, jtan, ErrStat, ErrMsg) + CALL attachment_residual(model, k, q_cfg, v_cfg, want_tangent, rk, has_jac, jrel, jtan, ErrStat, ErrMsg, & + jz=jz) IF (ErrStat /= CD_HCDYN_OK) RETURN IF (want_residual) R(base + 1:base + 3) = R(base + 1:base + 3) + rk + ! the dependence on the node height through the immersed fraction (zero off the surface) + IF (want_tangent) THEN + DO a = 1, 3 + Kb(KL_D + KU_D + 1 + a - 3, base + 3) = Kb(KL_D + KU_D + 1 + a - 3, base + 3) + jz(a) + END DO + END IF IF (want_tangent .AND. has_jac) THEN ! w = u - v, so dR/dv = +df/dw; the tangent DOFs m enter through df/dm DO b = 1, 3 @@ -2425,11 +2440,16 @@ SUBROUTINE assemble_attachments(model, q_cfg, v_cfg, want_residual, want_tangent END SUBROUTINE assemble_attachments SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jrel, jtan, ErrStat, ErrMsg, & - f_drag) + f_drag, jz) !! Contribution rk of attachment k to R = f_int - f_ext at the translations of its node: - !! weight, buoyancy, Froude-Krylov force and drag (inertia excluded). With want_jac, the - !! drag Jacobians d f/d w and d f/d tangent are returned when has_jac is set. f_drag - !! (optional) returns the drag force on the node alone (zero above the free surface). + !! weight, buoyancy, Froude-Krylov force and drag (inertia excluded). Buoyancy, Froude-Krylov + !! force and drag carry the immersed fraction wf of the attachment's sphere (radius att_r) + !! at the local surface, so the load is continuous (C1) as the node crosses it: a buoy + !! floating at the surface has an equilibrium, where a wet/dry switch at the node height + !! had none. A node deeper than att_r below the surface has wf exactly 1 (unchanged loads). + !! With want_jac, the drag Jacobians d f/d w and d f/d tangent are returned when has_jac is + !! set. f_drag (optional) returns the drag force on the node alone (zero above the free + !! surface); jz (optional) returns d rk/d z through wf (zero off the surface band). TYPE(CD_HermiteCableDynType), INTENT(IN) :: model INTEGER, INTENT(IN) :: k REAL(wp), INTENT(IN) :: q_cfg(:), v_cfg(:) @@ -2438,12 +2458,13 @@ SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jr LOGICAL, INTENT(OUT) :: has_jac INTEGER, INTENT(OUT) :: ErrStat CHARACTER(*), INTENT(OUT) :: ErrMsg - REAL(wp), INTENT(OUT), OPTIONAL :: f_drag(3) + REAL(wp), INTENT(OUT), OPTIONAL :: f_drag(3), jz(3) INTEGER :: j, base - REAL(wp) :: u(3), ud(3), wrel(3), wl, f(3) + REAL(wp) :: u(3), ud(3), wrel(3), wl, f(3), wf, dwf ErrStat = CD_HCDYN_OK; ErrMsg = '' rk = CD_ZERO; jrel = CD_ZERO; jtan = CD_ZERO; has_jac = .FALSE. IF (PRESENT(f_drag)) f_drag = CD_ZERO + IF (PRESENT(jz)) jz = CD_ZERO j = model%att_node(k) base = 6*(j - 1) u = CD_ZERO; ud = CD_ZERO; wl = CD_ZERO @@ -2456,13 +2477,23 @@ SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jr IF (model%has_held_field) THEN u = u + model%hf_u(:, j); ud = model%hf_ud(:, j); wl = model%hf_wl(j) END IF - IF (q_cfg(base + 3) > wl) THEN + CALL CD_HermiteCable_Point_Immersion(wl - q_cfg(base + 3), model%att_r(k), wf, dwf) + IF (.NOT. (wf > CD_ZERO)) THEN ! above the free surface: weight only, no buoyancy or fluid load rk(3) = model%att_w(k) + model%att_b(k) RETURN END IF - rk(3) = model%att_w(k) - rk = rk - model%att_fk(k)*ud + IF (wf < CD_ONE) THEN + rk(3) = model%att_w(k) + (CD_ONE - wf)*model%att_b(k) + rk = rk - wf*model%att_fk(k)*ud + IF (PRESENT(jz)) THEN + jz(3) = -dwf*model%att_b(k) + jz = jz - dwf*model%att_fk(k)*ud + END IF + ELSE + rk(3) = model%att_w(k) + rk = rk - model%att_fk(k)*ud + END IF IF (.NOT. (model%att_cda(k) > CD_ZERO .OR. model%att_cdax(k) > CD_ZERO)) RETURN wrel = u - v_cfg(base + 1:base + 3) IF (want_jac) THEN @@ -2475,6 +2506,12 @@ SUBROUTINE attachment_residual(model, k, q_cfg, v_cfg, want_jac, rk, has_jac, jr model%att_cdax(k), f, ErrStat, ErrMsg, isotropic=model%att_iso(k)) END IF IF (ErrStat /= CD_HCDYN_OK) RETURN + IF (wf < CD_ONE) THEN + IF (PRESENT(jz)) jz = jz - dwf*f + f = wf*f + jrel = wf*jrel + jtan = wf*jtan + END IF rk = rk - f IF (PRESENT(f_drag)) f_drag = f END SUBROUTINE attachment_residual @@ -9302,6 +9339,7 @@ SUBROUTINE CD_HermiteCable_Dyn_End(model) TYPE(CD_HermiteCableDynType), INTENT(INOUT) :: model IF (ALLOCATED(model%att_node)) DEALLOCATE (model%att_node, model%att_w, model%att_b, model%att_fk, & model%att_cda, model%att_cdax) + IF (ALLOCATED(model%att_r)) DEALLOCATE (model%att_r) IF (ALLOCATED(model%att_mass)) DEALLOCATE (model%att_mass, model%att_madd) IF (ALLOCATED(model%att_iso)) DEALLOCATE (model%att_iso) IF (ALLOCATED(model%att_point)) DEALLOCATE (model%att_point) @@ -11697,6 +11735,63 @@ PURE SUBROUTINE CD_HermiteCable_Immersion(depth, diam, wf, dwf) END IF END SUBROUTINE CD_HermiteCable_Immersion + PURE REAL(wp) FUNCTION CD_HermiteCable_Point_Radius(volume, cda) RESULT(r) + !! Radius of the sphere whose immersion wets a point attachment at the free surface: the + !! sphere of its volume, r = (3 V/(4 pi))^(1/3), or without a volume that of its projected + !! drag area, CdA = pi r^2 (as rigid6_wet_fraction sizes a Rigid6 body); 0 for neither. + REAL(wp), INTENT(IN) :: volume, cda + REAL(wp), PARAMETER :: PI_ = 3.14159265358979323846_wp + IF (volume > CD_ZERO) THEN + r = (3.0_wp*volume/(4.0_wp*PI_))**(CD_ONE/3.0_wp) + ELSE IF (cda > CD_ZERO) THEN + r = SQRT(cda/PI_) + ELSE + r = CD_ZERO + END IF + END FUNCTION CD_HermiteCable_Point_Radius + + PURE SUBROUTINE CD_HermiteCable_Point_Immersion(depth, radius, wf, dwf, psi) + !! Immersed fraction wf of a sphere of radius r whose centre lies depth below the free + !! surface (negative above it), the formula of a Rigid6 body (rigid6_wet_fraction): with the + !! immersed height h = clamp(depth + r, 0, 2 r), wf = h^2 (3 r - h)/(4 r^3), 0 from r above + !! the surface, 1 from r below, 1/2 at the surface, continuous with its slope (C1). dwf = + !! d wf/d z, the derivative with respect to the height of the centre: -3 h (2 r - h)/(4 r^3) + !! in the band, 0 outside. psi (optional) = the integral of wf over the height, zero above + !! the band and -depth below it (in the band -(r h^3 - h^4/4)/(4 r^3)): the buoyancy + !! rho g V wf is the force of the potential -rho g V psi. A point (r = 0) is wet at and below + !! the surface (the old switch, dwf 0). + REAL(wp), INTENT(IN) :: depth, radius + REAL(wp), INTENT(OUT) :: wf, dwf + REAL(wp), INTENT(OUT), OPTIONAL :: psi + REAL(wp) :: h, r3 + IF (.NOT. (radius > CD_ZERO)) THEN + IF (depth >= CD_ZERO) THEN + wf = CD_ONE + IF (PRESENT(psi)) psi = -depth + ELSE + wf = CD_ZERO + IF (PRESENT(psi)) psi = CD_ZERO + END IF + dwf = CD_ZERO + RETURN + END IF + IF (depth >= radius) THEN + wf = CD_ONE + dwf = CD_ZERO + IF (PRESENT(psi)) psi = -depth + ELSE IF (depth <= -radius) THEN + wf = CD_ZERO + dwf = CD_ZERO + IF (PRESENT(psi)) psi = CD_ZERO + ELSE + h = depth + radius + r3 = 4.0_wp*radius**3 + wf = h*h*(3.0_wp*radius - h)/r3 + dwf = -3.0_wp*h*(2.0_wp*radius - h)/r3 + IF (PRESENT(psi)) psi = -(radius*h**3 - 0.25_wp*h**4)/r3 + END IF + END SUBROUTINE CD_HermiteCable_Point_Immersion + SUBROUTINE CD_HermiteCable_Drag_Element(qe, ve, l0, fluid, waterline_z, rho, diam, cdn, cdt, & fdrag, djq, djv, ErrStat, ErrMsg, & wv_h, wv_om, wv_k, wv_depth, wv_dir, wv_t, & diff --git a/src/CableDyn_HermiteCableStatic.f90 b/src/CableDyn_HermiteCableStatic.f90 index 6451254..778a84c 100644 --- a/src/CableDyn_HermiteCableStatic.f90 +++ b/src/CableDyn_HermiteCableStatic.f90 @@ -47,7 +47,7 @@ MODULE CableDyn_HermiteCableStatic USE CableDyn_Bathymetry, ONLY: CD_BathymetryType, CD_Bathymetry_Is_Initialized, & CD_Bathymetry_Floor, CD_Bathymetry_Floor_Gradient, CD_BATHY_OK, & CD_Bathymetry_Rotate_Curvature - USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Drag_Element, CD_HCDYN_OK, CD_HermiteCable_Point_Immersion 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_Current_Profile_Gradient, CD_Current_Grid_Gradient, CD_HYDRO_OK @@ -309,7 +309,8 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ waterline_z, dry_buoyancy, merit_line_search, pseudo_transient, & energy_minimization, stable, water_weight, current, residual_out, & tangent_out, friction, residual_unmet, torsion, energy_out, & - end_share_hold, f_nodal_twist, stall_limit) + end_share_hold, f_nodal_twist, stall_limit, att_node, att_buoyancy, & + att_radius) !! Solve the finite-EI static equilibrium of a Hermite bending-cable line. !! !! l0(ne), EA(ne), EI(ne), w(ne) : per-element rest length, axial/bending stiffness, @@ -460,6 +461,18 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ !! fixed count; the norm, unlike the largest component !! that decides convergence, does not change when the !! line is turned. + !! att_node, att_buoyancy, att_radius (optional, together, one entry per attachment): + !! point attachments whose buoyancy rho g V [N] + !! (att_buoyancy) at node att_node f_nodal carries in full + !! (their net weight (m - rho V) g). The buoyancy they + !! lose at the free surface (waterline_z, 0 without it), + !! rho g V (1 - wf(z)) downward, is added at the node + !! height of each iterate with its stiffness and + !! potential, wf the immersed fraction of the sphere of + !! radius att_radius (CD_HermiteCable_Point_Immersion), + !! ramped with the load-continuation factor as f_nodal. A + !! buoy floating at the surface then has an equilibrium; + !! a node deeper than its radius adds nothing. REAL(wp), INTENT(IN) :: l0(:), EA(:), EI(:), w(:), seed(:) INTEGER, INTENT(IN) :: fixed_dofs(:) REAL(wp), INTENT(IN) :: seabed_z, kn, tol, damping @@ -499,6 +512,8 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ TYPE(CD_HermiteTorsionType), INTENT(INOUT), OPTIONAL :: torsion REAL(wp), INTENT(IN), OPTIONAL :: f_nodal_twist(:) INTEGER, INTENT(IN), OPTIONAL :: stall_limit + INTEGER, INTENT(IN), OPTIONAL :: att_node(:) + REAL(wp), INTENT(IN), OPTIONAL :: att_buoyancy(:), att_radius(:) INTEGER :: ne, nn, ndof, c, it, es, i, b, nci, n_buoy, omp_threads, axial_order, bending_order ! stall_limit: the residual merit at the start of an update, its value at the last halving @@ -680,6 +695,23 @@ SUBROUTINE CD_HermiteCable_Static_Solve(l0, EA, EI, w, seed, fixed_dofs, seabed_ CALL fail('contact_kn must be finite, positive, and have length n_nodes'); RETURN END IF END IF + IF (PRESENT(att_node) .OR. PRESENT(att_buoyancy) .OR. PRESENT(att_radius)) THEN + IF (.NOT. (PRESENT(att_node) .AND. PRESENT(att_buoyancy) .AND. PRESENT(att_radius))) THEN + CALL fail('att_node, att_buoyancy and att_radius must be supplied together'); RETURN + END IF + IF (SIZE(att_buoyancy) /= SIZE(att_node) .OR. SIZE(att_radius) /= SIZE(att_node)) THEN + CALL fail('att_node, att_buoyancy and att_radius must share one length'); RETURN + END IF + IF (ANY(att_node < 1) .OR. ANY(att_node > nn)) THEN + CALL fail('att_node out of range'); RETURN + END IF + IF (.NOT. (CD_All_Finite(att_buoyancy) .AND. CD_All_Finite(att_radius))) THEN + CALL fail('att_buoyancy and att_radius must be finite'); RETURN + END IF + IF (ANY(att_buoyancy < CD_ZERO) .OR. ANY(att_radius < CD_ZERO)) THEN + CALL fail('att_buoyancy and att_radius must be >= 0'); RETURN + END IF + END IF IF (use_bathymetry) THEN IF (.NOT. CD_Bathymetry_Is_Initialized(bathymetry)) THEN CALL fail('bathymetry must be initialized'); RETURN @@ -1209,6 +1241,8 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) LOGICAL, INTENT(IN) :: do_update REAL(wp) :: qe(12) REAL(wp) :: pen, dqnorm, z_floor, gxg, gyg, gx, gy, xg, yg, normal, normal_gap, kn_eff + ! an attachment's surface waterline, immersed fraction, its height derivative and potential + REAL(wp) :: z_wl_att, wf_att, dwf_att, psi_att REAL(wp) :: curv_g(3), curv_l(3) REAL(wp) :: step_scale, trial_norm, row_scale, column_scale, merit, trial_merit, merit_base, diag_floor REAL(wp) :: gradient_component, column_norm2, fdry(4), kdry(4, 4), e_term @@ -1351,6 +1385,25 @@ RECURSIVE SUBROUTINE newton_step(rnorm, es, em, do_update) END IF END IF + ! ---- buoyancy the point attachments lose at the free surface ---- + ! downward rho g V (1 - wf(z)) on top of f_nodal's net weight, with its stiffness + ! -rho g V dwf/dz >= 0 and potential rho g V (z - psi(z) - z_w), zero below the band + IF (PRESENT(att_node)) THEN + DO a = 1, SIZE(att_node) + IF (.NOT. (att_buoyancy(a) > CD_ZERO)) CYCLE + gi = 6*(att_node(a) - 1) + 3 + z_wl_att = CD_ZERO + IF (PRESENT(waterline_z)) z_wl_att = waterline_z + CALL CD_HermiteCable_Point_Immersion(z_wl_att - q(gi), att_radius(a), wf_att, dwf_att, psi_att) + IF (.NOT. (wf_att < CD_ONE)) CYCLE + R(gi) = R(gi) + eifac*att_buoyancy(a)*(CD_ONE - wf_att) + ab(KL_H + KU_H + 1, gi) = ab(KL_H + KU_H + 1, gi) - eifac*att_buoyancy(a)*dwf_att + e_term = eifac*att_buoyancy(a)*(q(gi) - psi_att - z_wl_att) + pi_total = pi_total + e_term + pi_abs = pi_abs + ABS(e_term) + END DO + END IF + ! ---- optional rotational line-end connections ---- ! Ramped with the same factor as EI: a stiff connection introduced at full strength ! against a cold seed would fight the bending continuation it is meant to ride along. diff --git a/tests/test_attachment_surface.f90 b/tests/test_attachment_surface.f90 new file mode 100644 index 0000000..b70d521 --- /dev/null +++ b/tests/test_attachment_surface.f90 @@ -0,0 +1,167 @@ +! File: tests/test_attachment_surface.f90 +! SPDX-License-Identifier: Apache-2.0 +! Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +PROGRAM test_attachment_surface + !! The immersed fraction of a point attachment at the free surface (the sphere of its volume, + !! CD_HermiteCable_Point_Immersion) and the buoyancy it loses there in the finite-EI static solve. + !! Gates: + !! K1 the fraction: 1 from r below the surface, 0 from r above, 1/2 at it; its height + !! derivative matches central FD in the band; the potential psi has the derivative wf; wf + !! and dwf are continuous at the band edges; r = 0 is the wet/dry switch; the sphere radius + !! of a volume and of a drag area. + !! K2 the static solve (CD_HermiteCable_Static_Solve, att_node/att_buoyancy/att_radius): with + !! the attachment node in the band the residual changes by rho g V (1 - wf) at its height + !! and the tangent's column matches central FD; deeper than r the residual and tangent are + !! those without the attachment term, bit for bit; above the band the residual carries + !! rho g V in full. + USE CableDyn_Precision, ONLY: wp + USE CableDyn_HermiteCableDynamic, ONLY: CD_HermiteCable_Point_Immersion, CD_HermiteCable_Point_Radius + USE CableDyn_HermiteCableStatic, ONLY: CD_HermiteCable_Static_Solve, CD_HCSTAT_OK + IMPLICIT NONE + REAL(wp), PARAMETER :: PI = 3.14159265358979323846_wp + INTEGER, PARAMETER :: NE = 10, NN = NE + 1, NDOF = 6*NN, LDAB = 2*11 + 11 + 1 + INTEGER :: nfail = 0 + + CALL gate_k1() + CALL gate_k2() + IF (nfail > 0) THEN + WRITE (*, '(A,I0,A)') 'FAILED: ', nfail, ' check(s)' + ERROR STOP 1 + END IF + WRITE (*, '(A)') 'PASS: attachment immersion at the free surface' + +CONTAINS + + SUBROUTINE gate_k1() + REAL(wp), PARAMETER :: R = 0.4_wp, H = 1.0e-6_wp + REAL(wp) :: wf, dwf, psi, wp_, wm, dum, pp, pm, err_d, err_p, d + INTEGER :: k + CALL CD_HermiteCable_Point_Immersion(1.0_wp, R, wf, dwf, psi) + CALL check(wf == 1.0_wp .AND. dwf == 0.0_wp .AND. psi == -1.0_wp, 'K1: fully submerged below r') + CALL CD_HermiteCable_Point_Immersion(-1.0_wp, R, wf, dwf, psi) + CALL check(wf == 0.0_wp .AND. dwf == 0.0_wp .AND. psi == 0.0_wp, 'K1: dry above r') + CALL CD_HermiteCable_Point_Immersion(0.0_wp, R, wf, dwf, psi) + CALL check(ABS(wf - 0.5_wp) < 1.0e-15_wp .AND. ABS(dwf + 3.0_wp/(4.0_wp*R)) < 1.0e-14_wp, & + 'K1: half immersed at the surface, slope -3/(4 r)') + err_d = 0.0_wp + err_p = 0.0_wp + DO k = -19, 19 + d = R*REAL(k, wp)/20.0_wp + CALL CD_HermiteCable_Point_Immersion(d, R, wf, dwf, psi) + ! z = -depth: d wf/d z = -(d wf/d depth) + CALL CD_HermiteCable_Point_Immersion(d - H, R, wp_, dum, pp) + CALL CD_HermiteCable_Point_Immersion(d + H, R, wm, dum, pm) + err_d = MAX(err_d, ABS((wp_ - wm)/(2.0_wp*H) - dwf)) + err_p = MAX(err_p, ABS((pp - pm)/(2.0_wp*H) - wf)) + END DO + WRITE (*, '(A,2ES10.2)') ' K1 FD error of dwf/dz and dpsi/dz in the band: ', err_d, err_p + CALL check(err_d < 1.0e-8_wp, 'K1: dwf/dz matches central FD') + CALL check(err_p < 1.0e-8_wp, 'K1: dpsi/dz = wf') + CALL CD_HermiteCable_Point_Immersion(R*(1.0_wp - 1.0e-9_wp), R, wf, dwf, psi) + CALL check(ABS(wf - 1.0_wp) < 1.0e-12_wp .AND. ABS(dwf) < 1.0e-8_wp .AND. ABS(psi + R) < 1.0e-9_wp, & + 'K1: continuous with its slope and potential at the lower band edge') + CALL CD_HermiteCable_Point_Immersion(-R*(1.0_wp - 1.0e-9_wp), R, wf, dwf, psi) + CALL check(ABS(wf) < 1.0e-12_wp .AND. ABS(dwf) < 1.0e-8_wp .AND. ABS(psi) < 1.0e-12_wp, & + 'K1: continuous with its slope and potential at the upper band edge') + CALL CD_HermiteCable_Point_Immersion(0.0_wp, 0.0_wp, wf, dwf, psi) + CALL check(wf == 1.0_wp .AND. dwf == 0.0_wp, 'K1: a point (r = 0) is wet at the surface') + CALL CD_HermiteCable_Point_Immersion(-1.0e-12_wp, 0.0_wp, wf, dwf, psi) + CALL check(wf == 0.0_wp, 'K1: a point (r = 0) is dry above the surface') + CALL check(ABS(CD_HermiteCable_Point_Radius(4.0_wp*PI/3.0_wp, 0.5_wp) - 1.0_wp) < 1.0e-14_wp, & + 'K1: the sphere of the volume') + CALL check(ABS(CD_HermiteCable_Point_Radius(0.0_wp, PI) - 1.0_wp) < 1.0e-14_wp, & + 'K1: without a volume, the sphere of the drag area') + CALL check(CD_HermiteCable_Point_Radius(0.0_wp, 0.0_wp) == 0.0_wp, 'K1: neither: a point') + END SUBROUTINE gate_k1 + + SUBROUTINE gate_k2() + !! A 10 m line of ten elements along x at z0, attachment at node 6 (rho g V 2000 N, r 0.3 m). + REAL(wp), PARAMETER :: B = 2000.0_wp, R = 0.3_wp, HH = 1.0e-6_wp + REAL(wp) :: q(NDOF), r0(NDOF), r1(NDOF), ab0(LDAB, NDOF), ab1(LDAB, NDOF), rp(NDOF), rm(NDOF), dum(LDAB, NDOF) + REAL(wp) :: wf, dwf, col_fd(NDOF), col_an(NDOF), err, z0 + INTEGER :: jz, i + jz = 6*5 + 3 + ! in the band + z0 = 0.1_wp + CALL line_state(z0, q) + CALL evaluate(q, .FALSE., r0, ab0) + CALL evaluate(q, .TRUE., r1, ab1) + CALL CD_HermiteCable_Point_Immersion(-z0, R, wf, dwf) + CALL check(ABS(r1(jz) - r0(jz) - B*(1.0_wp - wf)) < 1.0e-9_wp*B, & + 'K2: the residual carries the lost buoyancy rho g V (1 - wf) at the node height') + CALL check(MAXVAL(ABS(r1(1:jz - 1) - r0(1:jz - 1))) == 0.0_wp .AND. & + MAXVAL(ABS(r1(jz + 1:NDOF) - r0(jz + 1:NDOF))) == 0.0_wp, 'K2: only the node''s vertical DOF changes') + q(jz) = z0 + HH + CALL evaluate(q, .TRUE., rp, dum) + q(jz) = z0 - HH + CALL evaluate(q, .TRUE., rm, dum) + col_fd = (rp - rm)/(2.0_wp*HH) + col_an = 0.0_wp + DO i = MAX(1, jz - 11), MIN(NDOF, jz + 11) + col_an(i) = ab1(2*11 + 1 + i - jz, jz) + END DO + err = MAXVAL(ABS(col_fd - col_an))/MAX(1.0_wp, MAXVAL(ABS(col_an))) + WRITE (*, '(A,ES10.2)') ' K2 static tangent column vs central FD (node in the band): ', err + CALL check(err < 1.0e-6_wp, 'K2: the static tangent column of the node matches central FD') + CALL check(ABS((ab1(2*11 + 1, jz) - ab0(2*11 + 1, jz)) + B*dwf) < 1.0e-9_wp*B, & + 'K2: the tangent adds the buoyancy stiffness -rho g V dwf/dz') + ! deeper than r: unchanged, bit for bit + CALL line_state(-0.31_wp, q) + CALL evaluate(q, .FALSE., r0, ab0) + CALL evaluate(q, .TRUE., r1, ab1) + CALL check(ALL(r1 == r0) .AND. ALL(ab1 == ab0), 'K2: an attachment deeper than r leaves the solve bit-identical') + ! above the band: the whole buoyancy is lost + CALL line_state(0.31_wp, q) + CALL evaluate(q, .FALSE., r0, ab0) + CALL evaluate(q, .TRUE., r1, ab1) + CALL check(ABS(r1(jz) - r0(jz) - B) < 1.0e-12_wp*B .AND. ALL(ab1 == ab0), & + 'K2: above the band the attachment loses its whole buoyancy, with no stiffness') + END SUBROUTINE gate_k2 + + SUBROUTINE line_state(z0, q) + !! A straight line along x at height z0, stretched 1e-4 (a non-trivial elastic residual). + REAL(wp), INTENT(IN) :: z0 + REAL(wp), INTENT(OUT) :: q(NDOF) + INTEGER :: i + q = 0.0_wp + DO i = 1, NN + q(6*(i - 1) + 1) = 1.0001_wp*REAL(i - 1, wp) + q(6*(i - 1) + 3) = z0 + 0.002_wp*SIN(REAL(i, wp)) + q(6*(i - 1) + 4) = 1.0001_wp + END DO + q(6*5 + 3) = z0 + END SUBROUTINE line_state + + SUBROUTINE evaluate(qx, with_att, 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_att + REAL(wp), INTENT(OUT) :: r(NDOF), ab(LDAB, NDOF) + REAL(wp) :: l0(NE), ea(NE), ei(NE), w(NE), qd(NDOF), cd(NN), rr + INTEGER :: itx, esx + CHARACTER(512) :: emx + l0 = 1.0_wp; ea = 1.0e6_wp; ei = 50.0_wp; w = 40.0_wp + IF (with_att) THEN + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w, qx, [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], -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, att_node=[6], att_buoyancy=[2000.0_wp], & + att_radius=[0.3_wp]) + ELSE + CALL CD_HermiteCable_Static_Solve(l0, ea, ei, w, qx, [1, 2, 3, NDOF - 5, NDOF - 4, NDOF - 3], -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(ok, msg) + LOGICAL, INTENT(IN) :: ok + CHARACTER(*), INTENT(IN) :: msg + IF (ok) THEN + WRITE (*, '(2A)') 'ok ', msg + ELSE + WRITE (*, '(2A)') 'FAIL ', msg + nfail = nfail + 1 + END IF + END SUBROUTINE check +END PROGRAM test_attachment_surface diff --git a/tests/test_static_dry_weight.f90 b/tests/test_static_dry_weight.f90 index 178e9c9..445a008 100644 --- a/tests/test_static_dry_weight.f90 +++ b/tests/test_static_dry_weight.f90 @@ -51,12 +51,14 @@ PROGRAM test_static_dry_weight !! 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). + !! the surface: in water it would lift its node 4.5 m above the surface, so it floats. Its + !! buoyancy fades over the sphere of its volume (r 0.78 m), and the static start finds it + !! inside that band, at the height where the immersed share balances its load; the march + !! holds it there over 3 s to 1e-3 m (the dynamics wets the module with the same fraction). + !! In 1.5 m, 6 s Airy waves the module rides the surface through its band for 18 s: every + !! step converges and it stays within its radius of the instantaneous surface's range. + !! Before, a wet/dry switch at the node gave it no static position and the static start + !! failed, naming the attachment that crossed the still-water level. !! 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, & @@ -140,7 +142,7 @@ PROGRAM test_static_dry_weight 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 + ! 9. a module that floats: a static position in the surface band, held by the march CALL floating_module() IF (nfail > 0) THEN @@ -479,10 +481,14 @@ 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 + !! Fixed one at (100, 0, -50) m on a 50 m seabed, a 200 kg, 2 m^3 module 50 m along it (node + !! 26), 3 s of the march. + REAL(wp), PARAMETER :: R_SPHERE = 0.7816_wp ! (3 V/(4 pi))^(1/3), V = 2 m^3 + INTEGER :: u, es, ios + LOGICAL :: conv, first + REAL(wp) :: row(2), z0, dz_max, z_lo, z_hi CHARACTER(1024) :: em + CHARACTER(4096) :: line 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 ---' @@ -505,7 +511,7 @@ SUBROUTINE floating_module() 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)') '1 50.0 200.0 2.0 1.0 0.5 0.0' WRITE (u, '(A)') '--- OPTIONS ---' WRITE (u, '(A)') '9.80665 g' WRITE (u, '(A)') '1025.0 rhoW' @@ -513,18 +519,78 @@ SUBROUTINE floating_module() 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)') '3.0 TMax' WRITE (u, '(A)') '--- OUTPUTS ---' - WRITE (u, '(A)') 'Point1Fz' + WRITE (u, '(A)') 'L1N26pz' 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') + CALL check(es == CD_DECKDRV_OK .AND. conv, 'module that floats: the static start and the march run: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_float.out', STATUS='old', ACTION='read') + first = .TRUE. + z0 = 0.0_wp + dz_max = 0.0_wp + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + READ (line, *, IOSTAT=ios) row + IF (ios /= 0) CYCLE + IF (first) THEN + z0 = row(2) + first = .FALSE. + END IF + dz_max = MAX(dz_max, ABS(row(2) - z0)) + END DO + CLOSE (u) + WRITE (*, '(A,F9.4,A,ES10.2,A)') ' module that floats: static height ', z0, ' m, largest drift ', dz_max, ' m' + CALL check(.NOT. first .AND. ABS(z0) < R_SPHERE, 'module that floats: its static height lies in the surface '// & + 'band of its sphere') + CALL check(dz_max <= 1.0e-3_wp, 'module that floats: the march holds its static height') + ! the same in waves: the module heaves through its band + CALL copy_with_waves('dry_float.dat', 'dry_float_wave.dat') + CALL CD_Run_Deck_Driver('dry_float_wave.dat', 'dry_float_wave', conv, es, em) + CALL check(es == CD_DECKDRV_OK .AND. conv, 'module that floats, in waves: the march runs: '//TRIM(em)) + IF (es /= CD_DECKDRV_OK) RETURN + OPEN (NEWUNIT=u, FILE='dry_float_wave.out', STATUS='old', ACTION='read') + z_lo = HUGE(1.0_wp) + z_hi = -HUGE(1.0_wp) + DO + READ (u, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + READ (line, *, IOSTAT=ios) row + IF (ios /= 0) CYCLE + z_lo = MIN(z_lo, row(2)) + z_hi = MAX(z_hi, row(2)) + END DO + CLOSE (u) + WRITE (*, '(A,2F9.4,A)') ' module that floats, in waves: height range ', z_lo, z_hi, ' m' + CALL check(z_hi - z_lo > 0.5_wp .AND. z_lo > -0.75_wp - R_SPHERE .AND. z_hi < 0.75_wp + R_SPHERE, & + 'module that floats, in waves: it heaves with the surface, within its radius of the wave crest '// & + 'and trough') END SUBROUTINE floating_module + SUBROUTINE copy_with_waves(src, dst) + !! The deck src with 1.5 m, 6 s Airy waves (head-on) and TMax 18 s, written to dst. + CHARACTER(*), INTENT(IN) :: src, dst + INTEGER :: ui, uo, ios + CHARACTER(4096) :: line + OPEN (NEWUNIT=ui, FILE=src, STATUS='old', ACTION='read') + OPEN (NEWUNIT=uo, FILE=dst, STATUS='replace', ACTION='write') + DO + READ (ui, '(A)', IOSTAT=ios) line + IF (ios /= 0) EXIT + IF (TRIM(line) == '3.0 TMax') THEN + WRITE (uo, '(A)') '18.0 TMax' + WRITE (uo, '(A)') 'airy 1.5 6.0 0.0 waves' + ELSE + WRITE (uo, '(A)') TRIM(line) + END IF + END DO + CLOSE (ui) + CLOSE (uo) + END SUBROUTINE copy_with_waves + 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