diff --git a/CHANGELOG.md b/CHANGELOG.md index fb90fd13..4b4018d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -559,6 +559,15 @@ All notable changes to CableDyn are recorded in this file. The format follows seabed holds its heave to 7e-6 m over 3 s (before it moved 2.8e-3 m), and an `EI = 0` chain between that body 5 m above the surface and a `Connect` clump holds both to the output's 8 digits (before 5.5e-3 m). Lines below the surface are unchanged. +- An `EI = 0` line above the still-water level on a deck without a seabed (no `WtrDpth` or + bathymetry) carries its dry weight, and its drag and added mass act on the wetted part only, as + with a seabed and as on a finite-EI line. It was modelled fully submerged up to an end above + the surface, with a warning: a 42 m chain hung wholly above the surface carried 13 % less than + its weight in air, a chain sagging through the surface differed by 7.7 % from the same deck + with a seabed, and a 50 t `Connect` clump hung above the surface started 2 cm off. The march, + the static start and the force balance of points and objects now take the dry weight; the + three agree with the seabed deck exactly and hold their start (`no_seabed_surface`). The + warning is gone. Lines wholly below the surface are unchanged. - `ATTACHMENTS` above the still-water level kept their buoyancy in the static start of a finite-EI line, while the march loads them with their weight alone. A 500 kg, 0.2 m^3 module 3 m above the surface on a cable hung from 5 m above it moved the fairlead load by up to diff --git a/CMakeLists.txt b/CMakeLists.txt index 27306b1d..9a4b65dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1815,6 +1815,17 @@ if(Python3_Interpreter_FOUND) TIMEOUT 900 ENVIRONMENT "${_cabledyn_python_test_environment}") + # An EI = 0 line above the still-water level on a deck without a seabed carries its dry weight + # (it was modelled fully submerged), as with a seabed and as a finite-EI line. + add_test(NAME no_seabed_surface + COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_no_seabed_surface.py + --exe $ + --output ${CMAKE_BINARY_DIR}/no_seabed_surface) + set_tests_properties(no_seabed_surface PROPERTIES + LABELS "python;driver;integration;dynamic" + TIMEOUT 300 + ENVIRONMENT "${_cabledyn_python_test_environment}") + add_test(NAME body_rod_numbering COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_body_rod_numbering.py --exe $ diff --git a/doc/theory.rst b/doc/theory.rst index 12380951..b1be3d2e 100644 --- a/doc/theory.rst +++ b/doc/theory.rst @@ -1548,21 +1548,19 @@ beyond a :math:`10^{-6}` relative round-off band; a slack element reports zero t A line with no admissible equilibrium fails closed, naming the line, the seeds and stages tried, and the reason. -With a seabed (``WtrDpth`` or a bathymetry) the march gives the part of a line above the -still-water level its dry weight, through the recovery load of *Buoyancy and wetting* above, and -the static start does the same. The recovery depends on the wetted lengths, so the line is +The march gives the part of a line above the still-water level its dry weight, through the +recovery load of *Buoyancy and wetting* above, with or without a seabed, and the static start +does the same; drag and added mass act on the wetted part only. The recovery depends on the wetted lengths, so the line is solved again with the recovery of the last solution as a constant load until its nodes move by less than :math:`10^{-9}` m. This fixed point contracts at the ratio of the recovery's stiffness :math:`\rho g A/\sin\theta` (:math:`\theta` the inclination at the surface) to the line's own, a few :math:`10^{-3}` for a hanging chain. A chain hung from 5 m above the surface then starts in the equilibrium its march holds, and the coupled and standalone starts agree; with its buoyancy kept above the surface it moved by :math:`10^{-3}` of its fairlead load in the first step. A line -wholly below the surface has no recovery and is solved once. Without a seabed the march, and so -the static start, keeps the buoyancy everywhere (the driver warns about a line end above the -surface then). The force balance of ``Connect`` and ``Free`` points and of free bodies and rods +wholly below the surface has no recovery and is solved once. The force balance of ``Connect`` and ``Free`` points and of free bodies and rods below takes its lines with the same dry weight, so these objects start balanced against the march too; a finite-EI line, which enters it without its bending stiffness, takes its dry weight there -with or without a seabed, as its cubic-Hermite cable does. +as its cubic-Hermite cable does. A steady current (uniform, or a depth profile sampled at each node's own elevation as in the march) enters the static equilibrium as Morison drag on the line at rest, so the out-of-plane diff --git a/src/CableDyn_DeckDriver.f90 b/src/CableDyn_DeckDriver.f90 index af3746b7..7290b004 100644 --- a/src/CableDyn_DeckDriver.f90 +++ b/src/CableDyn_DeckDriver.f90 @@ -9290,7 +9290,7 @@ SUBROUTINE run_deck_driver(deck_path, out_root, converged, ErrStat, ErrMsg) IF (ErrStat /= 0) RETURN CALL CD_Profile_Enter(CD_PROF_INIT) END IF - CALL print_static_input_warnings(types, points, lines, sections, opts) + CALL print_static_input_warnings(types, lines, sections, opts) CALL warn_coarse_sections(lines, sections) ! free Rigid6 bodies and rods (jointly with Free/Connect points) start at their static ! equilibrium on every route: static-only, TMax = 0 and the dynamic march (pinned rods turn @@ -9867,20 +9867,21 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er CALL fail(ErrStat, ErrMsg, 'host-driven ambient fluid (external_fluid) requires a seabed '// & '(WtrDpth or bathymetryFile) -- the coupled host always supplies one'); RETURN END IF - IF (opts%has_current .OR. want_wave_cfg .OR. opts%has_wtrdpth .OR. PRESENT(bathymetry)) THEN - ALLOCATE (fluid_velocity(3, SIZE(l0) + 1), drag_waterline(SIZE(l0) + 1)) - DO i = 1, SIZE(l0) + 1 - IF (opts%has_current) THEN - fluid_velocity(:, i) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, l0, i), CD_ZERO, es, em) - IF (es /= CD_HYDRO_OK) THEN - CALL fail(ErrStat, ErrMsg, 'current profile for model init: '//TRIM(em)); RETURN - END IF - ELSE - fluid_velocity(:, i) = CD_ZERO + ! Every line has the still-water level: its drag, added mass and buoyancy act on the wetted + ! part only, with or without a seabed (a line hung above the surface on a deck without a + ! seabed was modelled fully submerged). + ALLOCATE (fluid_velocity(3, SIZE(l0) + 1), drag_waterline(SIZE(l0) + 1)) + DO i = 1, SIZE(l0) + 1 + IF (opts%has_current) THEN + fluid_velocity(:, i) = deck_current_velocity(opts, line_node_pos(anchor, fairlead, l0, i), CD_ZERO, es, em) + IF (es /= CD_HYDRO_OK) THEN + CALL fail(ErrStat, ErrMsg, 'current profile for model init: '//TRIM(em)); RETURN END IF - END DO - drag_waterline = CD_ZERO - END IF + ELSE + fluid_velocity(:, i) = CD_ZERO + END IF + END DO + drag_waterline = CD_ZERO IF (want_wave_cfg) THEN ALLOCATE (fluid_acceleration(3, SIZE(l0) + 1)) fluid_acceleration = CD_ZERO @@ -10066,7 +10067,11 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er added_mass_diameter_elem=hydro_diam, added_mass_can_elem=hydro_can, & added_mass_cat_elem=hydro_cat, buoyancy_waterline_z=waterline, & buoyancy_rho=opts%rhoW, buoyancy_diameter_elem=hydro_diam, buoyancy_gravity=opts%g) - ELSE IF (opts%has_current) THEN + ELSE + ! no seabed (deck waves and a host fluid field need one): the still-water level as on the + ! WtrDpth route above, without the seabed contact + ALLOCATE (waterline(SIZE(l0) + 1)) + waterline = CD_ZERO CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & @@ -10075,13 +10080,11 @@ RECURSIVE SUBROUTINE init_one_model(ln, sections, types, points, opts, model, Er current_profile_z=opts%current_profile_z, & current_profile_velocity=opts%current_profile_velocity, current_grid=opts%current_grid, & fluid_velocity=fluid_velocity, drag_waterline_z=drag_waterline, drag_rho=opts%rhoW, & - drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt) - ELSE - CALL CD_Init_Line_Model(model, anchor, fairlead, lts, secs, opts%g, opts%rhoW, .FALSE., & - static_cfg, dynamic_cfg, factors, ErrStat, ErrMsg, & - syrope_is=syrope_is, syrope_type=syrope_type, syrope_slow0=syrope_slow0, & - syrope_tmax0=syrope_tmax0, dynamic_tension_only=.TRUE., anchor_is_end_b=.TRUE., ba=ba, & - ve_ea_d=ve_ead, ve_ba=ve_bas, ve_ba_d=ve_bad, ve_alpha_mbl=ve_ambl, ve_vbeta=ve_vbet) + drag_diameter_elem=hydro_diam, drag_cdn_elem=hydro_cdn, drag_cdt_elem=hydro_cdt, & + added_mass_waterline_z=waterline, added_mass_rho=opts%rhoW, & + added_mass_diameter_elem=hydro_diam, added_mass_can_elem=hydro_can, & + added_mass_cat_elem=hydro_cat, buoyancy_waterline_z=waterline, & + buoyancy_rho=opts%rhoW, buoyancy_diameter_elem=hydro_diam, buoyancy_gravity=opts%g) END IF IF (ErrStat /= CD_MODEL_OK) THEN ErrMsg = 'CableDyn_DeckDriver: model init failed: '//TRIM(ErrMsg) @@ -11679,46 +11682,22 @@ LOGICAL FUNCTION point_moves(ip) RESULT(mv) END FUNCTION point_moves END SUBROUTINE solve_point_equilibrium - SUBROUTINE print_static_input_warnings(types, points, lines, sections, opts) + SUBROUTINE print_static_input_warnings(types, lines, sections, opts) !! Standard-output WARNINGS (never failures) for admissible but non-physical or - !! questionable inputs: an EI = 0 line end above the still-water level on a deck without a - !! seabed (the line is then modelled fully submerged; with WtrDpth or a bathymetry, and on - !! a finite-EI line, the part above the surface carries its dry weight), a line type that - !! sinks into the penalty seabed by more than its + !! questionable inputs: a line type that sinks into the penalty seabed by more than its !! diameter (kBot too soft for its submerged weight), a slack anchored line that hangs !! below its anchor on a deck with no seabed (reported after the static solve by !! warn_line_below_anchor), and a line with fewer than three segments (a straight !! chord: a slack coarse line carries no tension). TYPE(DeckLineType), INTENT(IN) :: types(:) - TYPE(DeckPoint), INTENT(IN) :: points(:) TYPE(DeckLine), INTENT(IN) :: lines(:) TYPE(DeckSection), INTENT(IN) :: sections(:) TYPE(DeckOptions), INTENT(IN) :: opts INTEGER :: i, j, k, nseg REAL(wp) :: w, pen - LOGICAL :: dry_weight CHARACTER(32) :: b1, b2 DO i = 1, SIZE(lines) - ! the line's model carries the dry weight above the surface: a finite-EI line always, an - ! EI = 0 line with a seabed (its buoyancy recovery) - dry_weight = opts%has_wtrdpth .OR. opts%has_bathymetry_file - DO j = 1, SIZE(sections) - IF (sections(j)%line_id /= lines(i)%id) CYCLE - IF (sections(j)%ltype < 1 .OR. sections(j)%ltype > SIZE(types)) CYCLE - IF (types(sections(j)%ltype)%ei > CD_ZERO) dry_weight = .TRUE. - END DO - DO k = 1, 2 - IF (k == 1) j = find_point(points, lines(i)%nodeA) - IF (k == 2) j = find_point(points, lines(i)%nodeB) - IF (j < 1) CYCLE - IF (points(j)%pos(3) > CD_ZERO .AND. .NOT. dry_weight) THEN - WRITE (b1, '(ES10.3)') points(j)%pos(3) - WRITE (output_unit, '(A)') ' WARNING: LINE '//TRIM(int_to_str(lines(i)%id))//' end POINT '// & - TRIM(int_to_str(points(j)%id))//' is above the still-water level (z = '//TRIM(ADJUSTL(b1))// & - ' m); the line is modelled fully submerged (submerged weight, drag) up to it' - END IF - END DO nseg = 0 DO j = 1, SIZE(sections) IF (sections(j)%line_id == lines(i)%id) nseg = nseg + sections(j)%nsegs @@ -12441,12 +12420,12 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg IF (es /= CD_LINE_OK) THEN CALL fail(ErrStat, ErrMsg, 'seabed stiffness: '//TRIM(em)); RETURN END IF - ! the line's model has a seabed and so the buoyancy recovery of its dry part - ! (init_deck_models_from_parsed): the part above the still-water level takes its dry - ! weight here too, so that the static-only start is the dynamic route's - ALLOCATE (dry_wl(ne + 1)) - dry_wl = CD_ZERO END IF + ! the line's model has the buoyancy recovery of its dry part, with or without a seabed + ! (init_one_model): the part above the still-water level takes its dry weight here too, so + ! that the static-only start is the dynamic route's + ALLOCATE (dry_wl(ne + 1)) + dry_wl = CD_ZERO IF (PRESENT(bathymetry)) THEN IF (opts%has_current) THEN @@ -12474,10 +12453,14 @@ SUBROUTINE solve_one_line(ln, sections, types, points, opts, q, tension, converg END IF ELSE IF (opts%has_current) THEN CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em, current=cur) + report, es, em, current=cur, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) ELSE CALL CD_Static_Line_Equilibrium(anchor, fairlead, conn, l0, ea, w, f_ext, cfg, .TRUE., q, converged, & - report, es, em) + report, es, em, & + dry_waterline_z=dry_wl, dry_rho=opts%rhoW, dry_gravity=opts%g, & + dry_diameter=diam, dry_load=f_dry) END IF IF (es /= CD_STATIC_OK) THEN CALL fail(ErrStat, ErrMsg, 'static solve rejected the input: '//TRIM(em)) @@ -27715,15 +27698,12 @@ SUBROUTINE prepare_line(jl, es_out, em_out) END IF ! The part above the still-water level takes its dry weight here, as in solve_one_line, ! where the line's own model gives it that weight, so that the objects start balanced - ! against the loads the march applies: an EI = 0 line with a seabed (its model's buoyancy - ! recovery, init_deck_models_from_parsed) and a finite-EI line always (its cubic-Hermite - ! cable's dry buoyancy, with or without a seabed). Without a seabed this surrogate of a - ! finite-EI line kept its buoyancy above the surface, while its cable did not. - IF (PRESENT(bathymetry) .OR. opts%has_wtrdpth .OR. line_is_finite_ei(lines(jl), types, sections)) THEN - lc(jl)%dry_d = diam - ALLOCATE (lc(jl)%dry_wl(ne + 1)) - lc(jl)%dry_wl = CD_ZERO - END IF + ! against the loads the march applies: an EI = 0 line through its model's buoyancy + ! recovery (init_one_model) and a finite-EI line through its cubic-Hermite cable's dry + ! buoyancy, both with or without a seabed. + lc(jl)%dry_d = diam + ALLOCATE (lc(jl)%dry_wl(ne + 1)) + lc(jl)%dry_wl = CD_ZERO lc(jl)%ready = .TRUE. END SUBROUTINE prepare_line diff --git a/tests/test_no_seabed_surface.py b/tests/test_no_seabed_surface.py new file mode 100644 index 00000000..57df9f45 --- /dev/null +++ b/tests/test_no_seabed_surface.py @@ -0,0 +1,183 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2026 Jae Hoon Seo, SMI Lab, Inha University +"""An EI = 0 line above the still-water level on a deck without a seabed carries its dry weight. + +Without ``WtrDpth`` or a bathymetry an ``EI = 0`` line was modelled fully submerged (submerged +weight, drag and added mass up to an end above the surface, with a warning), while the same line +on a deck with a seabed, and a finite-EI line with or without one, took its dry weight above the +surface: a 50 m chain hung 10 m above the surface was 13 % light. + +Gates, on the driver's own output (``Point

Fz``, ``Point

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

+""" + +from __future__ import annotations + +import argparse +import math +import subprocess +import sys +from pathlib import Path + +G = 9.80665 +RHO = 1025.0 +DIAM = 0.2791 +MASS = 480.93 + +HEAD = """--------------------- CableDyn Input File ------------------------------------ +{title} +--------------------- LINE TYPES --------------------------------------- +TypeName Diam MassDenInAir EA BA/-zeta EI Cd_n Cd_t Ca_n Ca_t +(-) (m) (kg/m) (N) (N-s/-) (N-m^2) (-) (-) (-) (-) +chain 0.2791 480.93 2.058e9 -1.0 0.0 1.37 0.64 1.0 0.0 +--------------------- POINTS ------------------------------------------- +ID Type X Y Z Mass Vol CdA Ca +(-) (-) (m) (m) (m) (kg) (m^3) (m^2) (-) +{points} +--------------------- LINES -------------------------------------------- +ID NodeA NodeB Outputs +(-) (-) (-) (-) +{lines} +--------------------- SECTIONS ----------------------------------------- +LineID LineType Length NumSegs +(-) (-) (m) (-) +{sections} +--------------------- OPTIONS ------------------------------------------ +9.80665 g +1025.0 rhoW +{seabed}0.01 dtM +2.0 TMax +--------------------- OUTPUTS ------------------------------------------ +{outputs} +--------------------- need this line ----------------------------------- +""" + + +def deck(title: str, points: str, lines: str, sections: str, outputs: list[str], seabed: bool) -> str: + return HEAD.format( + title=title, + points=points, + lines=lines, + sections=sections, + seabed="300.0 WtrDpth\n" if seabed else "", + outputs="\n".join(f'"{c}"' for c in outputs), + ) + + +def run(exe: str, out: Path, name: str, text: str) -> tuple[dict[str, list[float]], str]: + path = out / f"{name}.dat" + path.write_text(text, encoding="utf-8", newline="\n") + root = out / name + p = subprocess.run([exe, str(path), str(root)], capture_output=True, text=True, check=False) + log = p.stdout + p.stderr + if p.returncode != 0: + raise RuntimeError(f"{name}: exit {p.returncode}: {log[-600:]}") + rows = [] + header: list[str] = [] + for line in Path(f"{root}.out").read_text(encoding="utf-8").splitlines(): + fields = line.split() + if not fields: + continue + if fields[0].startswith("Time"): + header = fields + continue + try: + rows.append([float(v) for v in fields]) + except ValueError: + continue + cols = {h: [r[i] for r in rows] for i, h in enumerate(header)} + return cols, log + + +def main() -> int: + ap = argparse.ArgumentParser() + ap.add_argument("--exe", required=True) + ap.add_argument("--output", required=True) + args = ap.parse_args() + out = Path(args.output) + out.mkdir(parents=True, exist_ok=True) + failures = [] + logs = [] + + two_points = "1 Coupled 0.0 0.0 10.0 0 0 0 0\n" \ + "2 Fixed 40.0 0.0 10.0 0 0 0 0" + one_line = "1 1 2 -" + + # 1. wholly above the surface: the end forces carry the weight in air + cols, log = run(args.exe, out, "above", deck( + "EI = 0 chain wholly above the still-water level, no seabed", two_points, one_line, + "1 chain 42.0 20", ["Point1Fz", "Point2Fz"], seabed=False)) + logs.append(log) + dry = 42.0 * MASS * G + for k in (0, -1): + total = -(cols["Point1Fz"][k] + cols["Point2Fz"][k]) + rel = abs(total - dry) / dry + print(f"gate 1: t = {cols['Time(s)'][k]:.2f} s: end forces {total:.3f} N, weight in air {dry:.3f} N, " + f"relative {rel:.2e}") + if rel > 1.0e-6: + failures.append(f"gate 1: the end forces {total} N are not the weight in air {dry} N") + + # 2. through the surface: no seabed and a seabed far below agree + res = {} + for sb in (False, True): + cols, log = run(args.exe, out, f"pierce_{'seabed' if sb else 'none'}", deck( + "EI = 0 chain sagging through the still-water level", two_points, one_line, + "1 chain 50.0 20", ["Point1Fz", "Point2Fz"], seabed=sb)) + logs.append(log) + res[sb] = cols + wet = 50.0 * (MASS - RHO * math.pi / 4.0 * DIAM**2) * G + for k in (0, -1): + a = res[False]["Point1Fz"][k] + res[False]["Point2Fz"][k] + b = res[True]["Point1Fz"][k] + res[True]["Point2Fz"][k] + rel = abs(a - b) / abs(b) + print(f"gate 2: t = {res[True]['Time(s)'][k]:.2f} s: no seabed {-a:.3f} N, seabed {-b:.3f} N " + f"(weight in water {wet:.0f} N), relative {rel:.2e}") + if rel > 1.0e-9: + failures.append(f"gate 2: no seabed {-a} N against seabed {-b} N") + + # 3. a Connect clump hung above the surface + clump = "1 Fixed -25.0 0.0 15.0 0 0 0 0\n" \ + "2 Connect 0.0 0.0 5.0 50000.0 2.0 0 0\n" \ + "3 Fixed 25.0 0.0 15.0 0 0 0 0" + two_lines = "1 1 2 -\n2 3 2 -" + two_secs = "1 chain 30.0 15\n2 chain 30.0 15" + res = {} + for sb in (False, True): + cols, log = run(args.exe, out, f"clump_{'seabed' if sb else 'none'}", deck( + "50 t Connect clump hung by two chains above the still-water level", clump, two_lines, two_secs, + ["Point2pz"], seabed=sb)) + logs.append(log) + res[sb] = cols["Point2pz"] + d0 = abs(res[False][0] - res[True][0]) + drift = max(abs(z - res[False][0]) for z in res[False]) + print(f"gate 3: clump start z {res[False][0]:.9f} m (seabed deck {res[True][0]:.9f} m, {d0:.1e} m apart), " + f"largest move over 2 s {drift:.1e} m") + if d0 > 1.0e-9: + failures.append(f"gate 3: the clump starts {d0} m from the seabed deck's start") + if drift > 1.0e-6: + failures.append(f"gate 3: the clump moves {drift} m from its static start") + + # 4. the warning of the old model + if any("modelled fully submerged" in log for log in logs): + failures.append("gate 4: a 'modelled fully submerged' warning is printed") + + for f in failures: + print("FAIL: " + f) + if not failures: + print("PASS: an EI = 0 line above the surface carries its dry weight without a seabed") + return 1 if failures else 0 + + +if __name__ == "__main__": + sys.exit(main())